Commit 004fea51 authored by Jan Möbius's avatar Jan Möbius
Browse files

Cleaned up a bit, draw min and max markers



git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@14052 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 2ae6c68c
...@@ -90,11 +90,10 @@ QwtFunctionPlot::QwtFunctionPlot(QWidget* _parent) : ...@@ -90,11 +90,10 @@ QwtFunctionPlot::QwtFunctionPlot(QWidget* _parent) :
{ {
setupUi( this ); setupUi( this );
qwtPlot->setAxisTitle(QwtPlot::yLeft, "count" );
plot_zoomer_ = new QwtPlotZoomer( qwtPlot->canvas()); plot_zoomer_ = new QwtPlotZoomer( qwtPlot->canvas());
plot_zoomer_->initKeyPattern(); plot_zoomer_->initKeyPattern();
connect(zoomInButton, SIGNAL( clicked() ), this,SLOT( zoomIn() ) );
connect(zoomOutButton,SIGNAL( clicked() ), this,SLOT( zoomOut() ) );
connect(clampButton, SIGNAL( clicked() ), this,SLOT( clamp() ) );
QwtPlotPanner *panner = new QwtPlotPanner( qwtPlot->canvas() ); QwtPlotPanner *panner = new QwtPlotPanner( qwtPlot->canvas() );
panner->setMouseButton( Qt::MidButton ); panner->setMouseButton( Qt::MidButton );
...@@ -114,30 +113,6 @@ void QwtFunctionPlot::setFunction( std::vector<double>& _values) ...@@ -114,30 +113,6 @@ void QwtFunctionPlot::setFunction( std::vector<double>& _values)
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
void QwtFunctionPlot::zoomIn()
{
emit plot_zoomer_->zoom(1);
}
//------------------------------------------------------------------------------
void QwtFunctionPlot::zoomOut()
{
emit plot_zoomer_->zoom(-1);
}
//------------------------------------------------------------------------------
void QwtFunctionPlot::clamp()
{
QRectF clamped = plot_zoomer_->zoomRect();
clamped.setLeft( min_ );
clamped.setRight( max_ );
emit plot_zoomer_->zoom(clamped);
}
//------------------------------------------------------------------------------
void QwtFunctionPlot::replot() void QwtFunctionPlot::replot()
{ {
//create intervals //create intervals
...@@ -198,63 +173,60 @@ void QwtFunctionPlot::replot() ...@@ -198,63 +173,60 @@ void QwtFunctionPlot::replot()
qwtPlot->setAxisScale(QwtPlot::yLeft, 0.0, maxCount); qwtPlot->setAxisScale(QwtPlot::yLeft, 0.0, maxCount);
qwtPlot->setAxisScale(QwtPlot::xBottom, realMin, realMax); qwtPlot->setAxisScale(QwtPlot::xBottom, realMin, realMax);
qwtPlot->setAxisTitle(QwtPlot::yLeft, "count" );
qwtPlot->setAxisTitle(QwtPlot::xBottom, "values" );
//define this scaling as the zoomBase //define this scaling as the zoomBase
plot_zoomer_->setZoomBase(); plot_zoomer_->setZoomBase();
// // Mark the clamp values in the histogramm //Mark the clamp values in the histogram.
// if ( parameters_.clamp ) { if ( min_ > realMin ) {
// if ( ! clampMinMarker_ ) { if ( ! clampMinMarker_ ) {
// clampMinMarker_ = new QwtPlotMarker(); clampMinMarker_ = new QwtPlotMarker();
// minSymbol_ = new QwtSymbol(QwtSymbol::VLine); minSymbol_ = new QwtSymbol(QwtSymbol::VLine);
// minSymbol_->setColor(QColor(255,0,0)); minSymbol_->setColor(cCoder.color_qcolor(std::max(min_,realMin)));
// minSymbol_->setSize(200,1000); minSymbol_->setSize(200,1000);
// QPen pen = minSymbol_->pen(); QPen pen = minSymbol_->pen();
// pen.setWidth(3); pen.setWidth(3);
// minSymbol_->setPen(pen); minSymbol_->setPen(pen);
// clampMinMarker_->setSymbol(minSymbol_); clampMinMarker_->setSymbol(minSymbol_);
// clampMinMarker_->attach(qwtPlot); clampMinMarker_->attach(qwtPlot);
// } clampMinMarker_->show();
// }
// // Draw at left boundary if less than the minimal value we get from the function
// if ( parameters_.clampMin < min_ ) // Draw at right boundary if greater than the maximal value we get from the function
// clampMinMarker_->setXValue(min_); clampMinMarker_->setXValue(std::max(min_,realMin));
// else
// clampMinMarker_->setXValue(parameters_.clampMin); } else {
// if ( clampMinMarker_ ) {
// clampMinMarker_->detach();
// delete clampMinMarker_;
// clampMinMarker_->show(); clampMinMarker_ = 0;
// }
// if ( ! clampMaxMarker_ ) { }
// clampMaxMarker_ = new QwtPlotMarker();
// maxSymbol_ = new QwtSymbol(QwtSymbol::VLine);
// maxSymbol_->setColor(QColor(0,255,0));
// maxSymbol_->setSize(200,1000);
// QPen pen = maxSymbol_->pen();
// pen.setWidth(3);
// maxSymbol_->setPen(pen);
// clampMaxMarker_->setSymbol(maxSymbol_);
// clampMaxMarker_->attach(qwtPlot);
// }
// // Draw at right boundary if greater than the maximal value we get from the function
// if ( parameters_.clampMax < max_ )
// clampMaxMarker_->setXValue(parameters_.clampMax);
// else
// clampMaxMarker_->setXValue(max_);
//
// clampMaxMarker_->show();
// } else { //Mark the clamp values in the histogram.
// if ( clampMinMarker_ ) if ( max_ < realMax ) {
// clampMinMarker_->hide(); if ( ! clampMaxMarker_ ) {
// clampMaxMarker_ = new QwtPlotMarker();
// if ( clampMaxMarker_ ) maxSymbol_ = new QwtSymbol(QwtSymbol::VLine);
// clampMaxMarker_->hide(); maxSymbol_->setColor(cCoder.color_qcolor(std::min(max_,realMax)));
// } maxSymbol_->setSize(200,1000);
QPen pen = maxSymbol_->pen();
pen.setWidth(3);
maxSymbol_->setPen(pen);
clampMaxMarker_->setSymbol(maxSymbol_);
clampMaxMarker_->attach(qwtPlot);
clampMaxMarker_->show();
}
// Draw at right boundary if greater than the maximal value we get from the function
clampMaxMarker_->setXValue(std::min(max_,realMax));
} else {
if ( clampMaxMarker_ ) {
clampMaxMarker_->detach();
delete clampMaxMarker_;
clampMaxMarker_ = 0;
}
}
// an plot it // an plot it
qwtPlot->replot(); qwtPlot->replot();
......
...@@ -97,9 +97,6 @@ public: ...@@ -97,9 +97,6 @@ public:
void setMinMax(double _min, double _max); void setMinMax(double _min, double _max);
public slots: public slots:
void zoomIn();
void zoomOut();
void clamp();
void replot(); void replot();
...@@ -114,7 +111,7 @@ private: ...@@ -114,7 +111,7 @@ private:
QwtSymbol* maxSymbol_; QwtSymbol* maxSymbol_;
/// Histogram Plot /// Histogram Plot
Histogram* histogram_; Histogram* histogram_;
/// Values that will define the function to plot /// Values that will define the function to plot
std::vector<double> values_; std::vector<double> values_;
......
...@@ -20,44 +20,6 @@ ...@@ -20,44 +20,6 @@
<item> <item>
<widget class="QwtPlot" name="qwtPlot"/> <widget class="QwtPlot" name="qwtPlot"/>
</item> </item>
<item>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QPushButton" name="zoomInButton">
<property name="text">
<string>+</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="zoomOutButton">
<property name="text">
<string>-</string>
</property>
</widget>
</item>
<item>
<widget class="QPushButton" name="clampButton">
<property name="text">
<string>C</string>
</property>
</widget>
</item>
<item>
<spacer name="verticalSpacer">
<property name="orientation">
<enum>Qt::Vertical</enum>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>20</width>
<height>40</height>
</size>
</property>
</spacer>
</item>
</layout>
</item>
</layout> </layout>
</widget> </widget>
<layoutdefault spacing="6" margin="11"/> <layoutdefault spacing="6" margin="11"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment