{
public:
{
setTrackerMode(AlwaysOn);
}
virtual QwtText trackerText
(const QwtDoublePoint
&pos
) const {
#if QT_VERSION >= 0x040300
bg.setAlpha(200);
#endif
text.
setBackgroundBrush( QBrush( bg
));
return text;
}
};
class MyZoomer: public QwtPlotZoomer
{
public:
MyZoomer(QwtPlotCanvas *canvas):
QwtPlotZoomer(canvas)
{
setTrackerMode(AlwaysOn);
}
virtual QwtText trackerText(const QwtDoublePoint &pos) const
{
QColor bg(Qt::white);
#if QT_VERSION >= 0x040300
bg.setAlpha(200);
#endif
QwtText text = QwtPlotZoomer::trackerText(pos);
text.setBackgroundBrush( QBrush( bg ));
return text;
}
};
To copy to clipboard, switch view to plain text mode
ui->PlotInitial->detachItems();
//** [Setup grid scheme]!
ui
->PlotInitial
->setCanvasBackground
(QColor(Qt
::white));
grid->enableXMin(true);
grid->enableYMin(true);
grid
->setMajPen
(QPen(Qt
::black,
0, Qt
::DotLine));
grid
->setMinPen
(QPen(Qt
::gray,
0 , Qt
::DotLine));
grid->attach(ui->PlotInitial);
//** [Setup grid scheme]!
QString ColorMapFile
= appPath
+ "/crp/topo.crp";
vector< vector<double> > ColorMatrix = make_2DimVector <double>(256, 4);
LoadFileIntoMatrix(ColorMapFile, ColorMatrix, 4, 256);
QwtArray< double > xVal, yVal;
double xmax = 0, ymax = 0, zmax = 0;
double xmin = 10000000000, ymin = 10000000000, zmin = 10000000000;
for (int i = 0; i < Rows;i ++) {
if (BigMatrix[i][0] < xmin) xmin = BigMatrix[i][0];
if (BigMatrix[i][0] > xmax) xmax = BigMatrix[i][0];
if (BigMatrix[i][1] < ymin) ymin = BigMatrix[i][1];
if (BigMatrix[i][1] > ymax) ymax = BigMatrix[i][1];
if (BigMatrix[i][2] > zmax) zmax = BigMatrix[i][2];
if (BigMatrix[i][2] < zmin) zmin = BigMatrix[i][2];
}
double zKorrektur = 0;
if (zmin < 0) {
zmax = zmax + abs(zmin);
zKorrektur = abs(zmin);
}
for (int i = 0; i < Rows;i ++) {
xVal.push_back(BigMatrix[i][0]);
yVal.push_back(BigMatrix[i][1]);
double zVal = BigMatrix[i][2] + zKorrektur;
int ColorIndex = (zVal * 255) / zmax;
// Insert new curves
QColor Color2Set
= QColor::fromRgb(ColorMatrix
[ColorIndex
][1],ColorMatrix
[ColorIndex
][2],ColorMatrix
[ColorIndex
][3]);
symb.setBrush(Color2Set);
symb.setPen(Color2Set);
symb.setSize(5);
cScatter->setSymbol(symb);
cScatter->setData(xVal,yVal);
cScatter->attach(ui->PlotInitial);
xVal.clear();
yVal.clear();
}
//ui->PlotInitial->setAxisScale(QwtPlot::yLeft, ymin, ymax);
//ui->PlotInitial->setAxisScale(QwtPlot::xBottom, xmin, xmax);
//ui->PlotInitial->replot();
ui
->PlotInitial
->setAxisAutoScale
(QwtPlot::yLeft);
ui
->PlotInitial
->setAxisAutoScale
(QwtPlot::xBottom);
//** [Zoomfunctions!]
zoomerI = new MyZoomer(ui->PlotInitial->canvas());
zoomerI->setZoomBase();
#if QT_VERSION < 0x040000
Qt::RightButton, Qt::ControlButton);
#else
Qt::RightButton, Qt::ControlModifier);
#endif
Qt::RightButton);
//** [Zoomfunctions!]
ui->PlotInitial->detachItems();
//** [Setup grid scheme]!
ui->PlotInitial->setCanvasBackground(QColor(Qt::white));
QwtPlotGrid *grid = new QwtPlotGrid;
grid->enableXMin(true);
grid->enableYMin(true);
grid->setMajPen(QPen(Qt::black, 0, Qt::DotLine));
grid->setMinPen(QPen(Qt::gray, 0 , Qt::DotLine));
grid->attach(ui->PlotInitial);
//** [Setup grid scheme]!
QString appPath = QApplication::applicationDirPath();
QString ColorMapFile = appPath + "/crp/topo.crp";
vector< vector<double> > ColorMatrix = make_2DimVector <double>(256, 4);
LoadFileIntoMatrix(ColorMapFile, ColorMatrix, 4, 256);
QwtArray< double > xVal, yVal;
double xmax = 0, ymax = 0, zmax = 0;
double xmin = 10000000000, ymin = 10000000000, zmin = 10000000000;
for (int i = 0; i < Rows;i ++) {
if (BigMatrix[i][0] < xmin) xmin = BigMatrix[i][0];
if (BigMatrix[i][0] > xmax) xmax = BigMatrix[i][0];
if (BigMatrix[i][1] < ymin) ymin = BigMatrix[i][1];
if (BigMatrix[i][1] > ymax) ymax = BigMatrix[i][1];
if (BigMatrix[i][2] > zmax) zmax = BigMatrix[i][2];
if (BigMatrix[i][2] < zmin) zmin = BigMatrix[i][2];
}
double zKorrektur = 0;
if (zmin < 0) {
zmax = zmax + abs(zmin);
zKorrektur = abs(zmin);
}
for (int i = 0; i < Rows;i ++) {
xVal.push_back(BigMatrix[i][0]);
yVal.push_back(BigMatrix[i][1]);
double zVal = BigMatrix[i][2] + zKorrektur;
int ColorIndex = (zVal * 255) / zmax;
// Insert new curves
QwtSymbol symb;
symb.setStyle(QwtSymbol::Ellipse);
QColor Color2Set = QColor::fromRgb(ColorMatrix[ColorIndex][1],ColorMatrix[ColorIndex][2],ColorMatrix[ColorIndex][3]);
symb.setBrush(Color2Set);
symb.setPen(Color2Set);
symb.setSize(5);
QwtPlotCurve *cScatter = new QwtPlotCurve();
cScatter->setStyle(QwtPlotCurve::NoCurve);
cScatter->setSymbol(symb);
cScatter->setData(xVal,yVal);
cScatter->attach(ui->PlotInitial);
xVal.clear();
yVal.clear();
}
//ui->PlotInitial->setAxisScale(QwtPlot::yLeft, ymin, ymax);
//ui->PlotInitial->setAxisScale(QwtPlot::xBottom, xmin, xmax);
//ui->PlotInitial->replot();
ui->PlotInitial->setAxisAutoScale(QwtPlot::yLeft);
ui->PlotInitial->setAxisAutoScale(QwtPlot::xBottom);
//** [Zoomfunctions!]
zoomerI = new MyZoomer(ui->PlotInitial->canvas());
zoomerI->setZoomBase();
#if QT_VERSION < 0x040000
zoomerI->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlButton);
#else
zoomerI->setMousePattern(QwtEventPattern::MouseSelect2,
Qt::RightButton, Qt::ControlModifier);
#endif
zoomerI->setMousePattern(QwtEventPattern::MouseSelect3,
Qt::RightButton);
//** [Zoomfunctions!]
To copy to clipboard, switch view to plain text mode
Bookmarks