From b85a292ce06475d560bfa1195b63a8bfe211f22d Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Wed, 11 Jul 2012 14:15:27 -0500 Subject: Add 0.2.7 release of qwtplot3d for future TQt3 conversion and use --- lib/tqwtplot3d/examples/axes/src/axes.h | 75 ++++++ .../examples/axes/src/axesmainwindow.cpp | 245 +++++++++++++++++ lib/tqwtplot3d/examples/axes/src/axesmainwindow.h | 64 +++++ .../examples/axes/src/axesmainwindowbase.ui | 243 +++++++++++++++++ .../examples/axes/src/axesmainwindowbase4.ui | 295 +++++++++++++++++++++ lib/tqwtplot3d/examples/axes/src/main.cpp | 31 +++ 6 files changed, 953 insertions(+) create mode 100644 lib/tqwtplot3d/examples/axes/src/axes.h create mode 100644 lib/tqwtplot3d/examples/axes/src/axesmainwindow.cpp create mode 100644 lib/tqwtplot3d/examples/axes/src/axesmainwindow.h create mode 100644 lib/tqwtplot3d/examples/axes/src/axesmainwindowbase.ui create mode 100644 lib/tqwtplot3d/examples/axes/src/axesmainwindowbase4.ui create mode 100644 lib/tqwtplot3d/examples/axes/src/main.cpp (limited to 'lib/tqwtplot3d/examples/axes/src') diff --git a/lib/tqwtplot3d/examples/axes/src/axes.h b/lib/tqwtplot3d/examples/axes/src/axes.h new file mode 100644 index 0000000..675ae8b --- /dev/null +++ b/lib/tqwtplot3d/examples/axes/src/axes.h @@ -0,0 +1,75 @@ +#ifndef axes_h__2004_06_07_10_38_begin_guarded_code +#define axes_h__2004_06_07_10_38_begin_guarded_code + +#include "qwt3d_plot.h" +using namespace Qwt3D; + +/***************************** +* +* Examples for user defined +* tic labels +* +******************************/ + +class Letter : public LinearScale +{ +public: + explicit Letter(bool uppercase = true) : uc_(uppercase) {} + Scale* clone() const {return new Letter(*this);} + QString ticLabel(unsigned int idx) const + { + if (idx 59) + { + if (h==23) + h=0; + else + h+=1; + m = (m+idx) % 60; + } + else + m += idx; + + return QTime(h,m).toString("hh:mm")+"h"; + } + return QString(""); + } +}; + + +#endif /* include guarded */ diff --git a/lib/tqwtplot3d/examples/axes/src/axesmainwindow.cpp b/lib/tqwtplot3d/examples/axes/src/axesmainwindow.cpp new file mode 100644 index 0000000..d3086bc --- /dev/null +++ b/lib/tqwtplot3d/examples/axes/src/axesmainwindow.cpp @@ -0,0 +1,245 @@ +#include +#include +#include +#include +#include +#include +#include +#include + +#include "axes.h" +#include "axesmainwindow.h" +#include "../../../include/qwt3d_function.h" + +using namespace std; +using namespace Qwt3D; + + +// Example function +class Rosenbrock : public Function +{ +public: + + Rosenbrock(SurfacePlot& pw) + :Function(pw) + { + } + + double operator()(double x, double y) + { + return log10((1-x)*(1-x) + 1 * (y - x*x)*(y - x*x)); + } +}; + + +// Main widget + +AxesMainWindow::AxesMainWindow( QWidget* parent) + : DummyBase(parent) +{ +#if QT_VERSION < 0x040000 + setCaption("axes"); + QGridLayout *grid = new QGridLayout( frame, 0, 0 ); +#else + setupUi(this); + QGridLayout *grid = new QGridLayout( frame); +#endif + + plot = new SurfacePlot(frame); + grid->addWidget( plot, 0, 0 ); + + plot->setZoom(0.8); + plot->setRotation(30,0,15); + + plot->coordinates()->setGridLines(true,true); + plot->setCoordinateStyle(BOX); + //plot->setCoordinateStyle(NOCOORD); + //plot->setPlotStyle(FILLED); + + + rosenbrock = new Rosenbrock(*plot); + + rosenbrock->setMesh(31,33); + rosenbrock->setDomain(-1.73,1.8,-1.9,1.8); + rosenbrock->setMinZ(-100); + + rosenbrock->create(); + + for (unsigned i=0; i!=plot->coordinates()->axes.size(); ++i) + { + plot->coordinates()->axes[i].setMajors(5); + plot->coordinates()->axes[i].setMinors(4); + plot->coordinates()->axes[i].setLabelColor(RGBA(0,0,0.4)); + } + + //plot->setTitle("Rosenbrock"); + plot->setMeshLineWidth(1); + plot->coordinates()->setGridLinesColor(RGBA(0,0,0.5)); + plot->coordinates()->setLineWidth(1); + plot->coordinates()->setNumberColor(RGBA(0,0.5,0)); + plot->coordinates()->setNumberFont("Courier",10); + plot->setTitleFont("Courier",11); + plot->coordinates()->setLabelFont("Courier",12, QFont::Bold); + plot->coordinates()->axes[X1].setLabelString("X1"); + plot->coordinates()->axes[Y1].setLabelString("Y1"); + plot->coordinates()->axes[Z1].setLabelString("Z1"); + plot->coordinates()->axes[X2].setLabelString("X2"); + plot->coordinates()->axes[Y2].setLabelString("Y2"); + plot->coordinates()->axes[Z2].setLabelString("Z2"); + plot->coordinates()->axes[X3].setLabelString("X3"); + plot->coordinates()->axes[Y3].setLabelString("Y3"); + plot->coordinates()->axes[Z3].setLabelString("Z3"); + plot->coordinates()->axes[X4].setLabelString("X4"); + plot->coordinates()->axes[Y4].setLabelString("Y4"); + plot->coordinates()->axes[Z4].setLabelString("Z4"); + + + plot->coordinates()->setLineSmooth(true); + smoothBox->setDown(true); + +#if QT_VERSION < 0x040000 + Items->insertItem( "&Standard", this, SLOT(standardItems()), ALT+Key_S ); + Items->insertItem( "&Imaginary", this, SLOT(complexItems()), ALT+Key_I ); + Items->insertItem( "&Letter", this, SLOT(letterItems()), ALT+Key_L ); + Items->insertItem( "&Time", this, SLOT(timeItems()), ALT+Key_T ); + Items->insertItem( "&Log", this, SLOT(customScale()), ALT+Key_C ); +#else + QMenu* Items = menuBar()->addMenu("Item"); + Items->addAction( "&Standard", this, SLOT(standardItems()), QKeySequence("ALT+S") ); + Items->addAction( "&Imaginary", this, SLOT(complexItems()), QKeySequence("ALT+I") ); + Items->addAction( "&Letter", this, SLOT(letterItems()), QKeySequence("ALT+L") ); + Items->addAction( "&Time", this, SLOT(timeItems()), QKeySequence("ALT+T") ); + Items->addAction( "&Log", this, SLOT(customScale()), QKeySequence("ALT+C") ); +#endif + + plot->makeCurrent(); + plot->updateData(); + plot->updateGL(); + + connect(smoothBox, SIGNAL(toggled(bool)), this, SLOT(setSmoothLines(bool)) ); + connect(numbergapslider, SIGNAL(valueChanged(int)), this, SLOT(setNumberGap(int)) ); + connect(labelgapslider, SIGNAL(valueChanged(int)), this, SLOT(setLabelGap(int)) ); + connect(ticLengthSlider, SIGNAL(valueChanged(int)), this, SLOT(setTicLength(int)) ); + connect(ticNumberSlider, SIGNAL(valueChanged(int)), this, SLOT(setTicNumber(int)) ); + + tics = plot->coordinates()->axes[X1].majors(); + + //resetTics(); + + customScale(); + + plot->setPolygonOffset(10); +} + +AxesMainWindow::~AxesMainWindow() +{ + delete rosenbrock; +} + +void AxesMainWindow::setNumberGap(int gap) +{ + plot->coordinates()->adjustNumbers(gap); + plot->makeCurrent(); + plot->updateGL(); +} + +void AxesMainWindow::setLabelGap(int gap) +{ + plot->coordinates()->adjustLabels(gap); + plot->makeCurrent(); + plot->updateGL(); +} + +void AxesMainWindow::setSmoothLines(bool val) +{ + plot->coordinates()->setLineSmooth(val); + plot->updateGL(); +} + +void AxesMainWindow::setTicLength(int val) +{ + double majl = (plot->coordinates()->second()-plot->coordinates()->first()).length() / 1000.; + majl = majl * val; + plot->coordinates()->setTicLength(majl,0.6*majl); + plot->updateGL(); +} + +void AxesMainWindow::setTicNumber(int degree) +{ + plot->coordinates()->axes[X1].setMajors(tics + degree); + plot->updateGL(); +} + +void AxesMainWindow::resetTics() +{ + ticNumberSlider->setEnabled(false); + plot->setTitle(""); + plot->coordinates()->axes[X1].setMajors(5); + plot->coordinates()->setAutoScale(true); + plot->coordinates()->setStandardScale(); + plot->coordinates()->axes[Z2].setLabelString("Z4"); + plot->coordinates()->setGridLines(false,false,Qwt3D::BACK); +} + +void AxesMainWindow::standardItems() +{ + resetTics(); + plot->updateGL(); +} + +void AxesMainWindow::letterItems() +{ + resetTics(); + ticNumberSlider->setEnabled(true); + plot->coordinates()->axes[X1].setAutoScale(false); + plot->coordinates()->setStandardScale(); + plot->coordinates()->axes[X1].setScale(new Letter); + plot->coordinates()->axes[X2].setScale(new Letter); + plot->coordinates()->axes[X3].setScale(new Letter); + plot->coordinates()->axes[X4].setScale(new Letter); + plot->coordinates()->axes[Y1].setScale(new Letter(false)); + plot->coordinates()->axes[Y2].setScale(new Letter(false)); + plot->coordinates()->axes[Y3].setScale(new Letter(false)); + plot->coordinates()->axes[Y4].setScale(new Letter(false)); + plot->setTitle("Use the tics slider for this example!"); + plot->updateGL(); +} + +void AxesMainWindow::complexItems() +{ + resetTics(); + plot->coordinates()->axes[Y1].setScale(new Imaginary); + plot->coordinates()->axes[Y2].setScale(new Imaginary); + plot->coordinates()->axes[Y3].setScale(new Imaginary); + plot->coordinates()->axes[Y4].setScale(new Imaginary); + plot->updateGL(); +} + +void AxesMainWindow::timeItems() +{ + resetTics(); + plot->coordinates()->axes[Z1].setScale(new TimeItems); + plot->coordinates()->axes[Z2].setScale(new TimeItems); + plot->coordinates()->axes[Z3].setScale(new TimeItems); + plot->coordinates()->axes[Z4].setScale(new TimeItems); + plot->updateGL(); +} + +void AxesMainWindow::customScale() +{ + resetTics(); + plot->coordinates()->axes[Z1].setScale(LOG10SCALE); + plot->coordinates()->axes[Z3].setScale(LOG10SCALE); + plot->coordinates()->axes[Z4].setScale(LOG10SCALE); + plot->coordinates()->axes[Z2].setLabelString("log10(z)"); +// plot->coordinates()->axes[Z4].setScale(new LogScale); +// plot->coordinates()->axes[Z1].setAutoScale(false); +// plot->coordinates()->axes[Z2].setAutoScale(false); +// plot->coordinates()->axes[Z3].setAutoScale(false); +// plot->coordinates()->axes[Z4].setAutoScale(false); + + plot->coordinates()->setGridLines(true,true,Qwt3D::BACK); + + plot->updateGL(); +} + diff --git a/lib/tqwtplot3d/examples/axes/src/axesmainwindow.h b/lib/tqwtplot3d/examples/axes/src/axesmainwindow.h new file mode 100644 index 0000000..fd99d0d --- /dev/null +++ b/lib/tqwtplot3d/examples/axes/src/axesmainwindow.h @@ -0,0 +1,64 @@ +#include + +#include "qwt3d_surfaceplot.h" +#include "qwt3d_function.h" +#include "qwt3d_plot.h" + +#if QT_VERSION < 0x040000 +#include "axesmainwindowbase.h" +#else +#include "ui_axesmainwindowbase4.h" +#endif + +//MOC_SKIP_BEGIN +#if QT_VERSION < 0x040000 + class DummyBase : public AxesMainWindowBase + { + public: + DummyBase(QWidget* parent = 0) + : AxesMainWindowBase(parent) + { + } + }; +#else + class DummyBase : public QMainWindow, protected Ui::MainWindow + { + public: + DummyBase(QWidget* parent = 0) + : QMainWindow(parent) + { + } + }; +#endif +//MOC_SKIP_END + + +class AxesMainWindow : public DummyBase +{ + Q_OBJECT + +public: + AxesMainWindow( QWidget* parent = 0); + ~AxesMainWindow(); + Qwt3D::SurfacePlot* plot; + Qwt3D::Function *rosenbrock; + void resetTics(); + +public slots: + void setNumberGap(int gap); + void setLabelGap(int gap); + + void setSmoothLines(bool); + void setTicLength(int val); + void setTicNumber(int degree); + + void standardItems(); + void complexItems(); + void letterItems(); + void timeItems(); + void customScale(); + +private: + + int tics; +}; diff --git a/lib/tqwtplot3d/examples/axes/src/axesmainwindowbase.ui b/lib/tqwtplot3d/examples/axes/src/axesmainwindowbase.ui new file mode 100644 index 0000000..92bab56 --- /dev/null +++ b/lib/tqwtplot3d/examples/axes/src/axesmainwindowbase.ui @@ -0,0 +1,243 @@ + +AxesMainWindowBase + + + AxesMainWindowBase + + + + 0 + 0 + 826 + 608 + + + + print + + + + unnamed + + + 11 + + + 6 + + + + frame + + + + 7 + 7 + 0 + 0 + + + + StyledPanel + + + Sunken + + + + + layout11 + + + + unnamed + + + + layout9 + + + + unnamed + + + + TextLabel1_2 + + + Number gap + + + + + numbergapslider + + + + 7 + 0 + 0 + 0 + + + + 10 + + + Horizontal + + + Above + + + 1 + + + + + + + layout10 + + + + unnamed + + + + TextLabel1_2_2 + + + Label gap + + + + + labelgapslider + + + + 7 + 0 + 0 + 0 + + + + 10 + + + Horizontal + + + Above + + + 1 + + + + + + + + + smoothBox + + + Smooth Lines + + + true + + + + + layout11 + + + + unnamed + + + + layout9 + + + + unnamed + + + + ticNumeberLabel + + + true + + + Tics + + + AlignCenter + + + + + ticLengthSlider + + + 100 + + + 10 + + + Vertical + + + Below + + + Tic Length (rel.) + + + + + ticNumberSlider + + + false + + + 25 + + + 0 + + + Vertical + + + Below + + + Change Tic Number (available only for letter example) + + + + + + + + + + + menubar + + + + + + + + diff --git a/lib/tqwtplot3d/examples/axes/src/axesmainwindowbase4.ui b/lib/tqwtplot3d/examples/axes/src/axesmainwindowbase4.ui new file mode 100644 index 0000000..1e4a0b5 --- /dev/null +++ b/lib/tqwtplot3d/examples/axes/src/axesmainwindowbase4.ui @@ -0,0 +1,295 @@ + + + + + MainWindow + + + + 0 + 0 + 694 + 600 + + + + MainWindow + + + + + 8 + + + 6 + + + + + 0 + + + 6 + + + + + + 7 + 7 + 0 + 0 + + + + QFrame::StyledPanel + + + QFrame::Sunken + + + + + + + 0 + + + 6 + + + + + 0 + + + 6 + + + + + + 0 + 0 + 0 + 0 + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Tics</p></body></html> + + + + + + + Qt::Horizontal + + + QSizePolicy::Preferred + + + + 40 + 20 + + + + + + + + + + 0 + + + 6 + + + + + + 0 + 7 + 0 + 0 + + + + 100 + + + 10 + + + Qt::Vertical + + + true + + + QSlider::TicksBelow + + + + + + + + 0 + 7 + 0 + 0 + + + + 25 + + + Qt::Vertical + + + true + + + QSlider::TicksBelow + + + + + + + + + + + + + 0 + + + 6 + + + + + + 0 + + + 6 + + + + + 0 + + + 6 + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Number gap</p></body></html> + + + + + + + + 7 + 5 + 0 + 0 + + + + 10 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + + + + + + + 0 + + + 6 + + + + + <html><head><meta name="qrichtext" content="1" /></head><body style=" white-space: pre-wrap; font-family:MS Shell Dlg; font-weight:400; font-style:normal; text-decoration:none;"><p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Label gap</p></body></html> + + + + + + + + 7 + 5 + 0 + 0 + + + + 10 + + + Qt::Horizontal + + + QSlider::TicksAbove + + + + + + + + + + + + + 1 + 5 + 0 + 0 + + + + Smooth Lines + + + + + + + + + + 590 + 10 + 61 + 421 + + + + + + + + + diff --git a/lib/tqwtplot3d/examples/axes/src/main.cpp b/lib/tqwtplot3d/examples/axes/src/main.cpp new file mode 100644 index 0000000..518faf6 --- /dev/null +++ b/lib/tqwtplot3d/examples/axes/src/main.cpp @@ -0,0 +1,31 @@ +/******************************************************************** + created: 2003/09/10 + filename: main.cpp + + author: Micha Bieber +*********************************************************************/ + +#include +#include "axesmainwindow.h" + + +int main( int argc, char** argv ) +{ + QApplication app( argc, argv ); + + if ( !QGLFormat::hasOpenGL() ) + { + qWarning( "This system has no OpenGL support. Exiting." ); + return -1; + } + + AxesMainWindow mainwindow; + +#if QT_VERSION < 0x040000 + app.setMainWidget(&mainwindow); +#endif + + mainwindow.show(); + + return app.exec(); +} -- cgit v1.2.3