#include <qmap.h>
#include <qpainter.h>
#include <qpaintdevicemetrics.h>
+#include <qevent.h>
#include <qwt_math.h>
#include <qwt_plot_canvas.h>
#define DEFAULT_MARKER_SIZE 9 // default marker size
#define MIN_RECT_SIZE 11 // min sensibility area size
+#define FITALL_EVENT ( QEvent::User + 9999 )
+
const char* imageZoomCursor[] = {
"32 32 3 1",
". c None",
*/
void Plot2d_ViewFrame::fitAll()
{
+ // Postpone fitAll operation until QwtPlot geometry
+ // has been fully defined
+ if ( !myPlot->polished() ){
+ QApplication::postEvent( this, new QCustomEvent( FITALL_EVENT ) );
+ return;
+ }
+
QwtDiMap xMap1 = myPlot->canvasMap( QwtPlot::xBottom );
myPlot->setAxisAutoScale( QwtPlot::yLeft );
Constructor
*/
Plot2d_Plot2d::Plot2d_Plot2d( QWidget* parent )
- : QwtPlot( parent )
+ : QwtPlot( parent ),
+ myIsPolished( false )
{
// outline
enableOutline( true );
return false;
}
+/*!
+ Sets the flag saying that QwtPlot geometry has been fully defined.
+*/
+void Plot2d_Plot2d::polish()
+{
+ QwtPlot::polish();
+ myIsPolished = true;
+}
+
+
/*!
Creates presentation of object
Default implementation is empty
{
this->incrementalZoom( -INCREMENT_FOR_OP, -INCREMENT_FOR_OP );
}
+
+/*!
+ Schedules a FitAll operation by putting it to the application's
+ event queue. This ensures that other important events (show, resize, etc.)
+ are processed first.
+*/
+void Plot2d_ViewFrame::customEvent( QCustomEvent* ce )
+{
+ if ( ce->type() == FITALL_EVENT )
+ fitAll();
+}
class Plot2d_Plot2d;
class Plot2d_Prs;
+class QCustomEvent;
typedef QIntDict<Plot2d_Curve> CurveDict;
void onZoomIn();
void onZoomOut();
+protected:
+ virtual void customEvent( QCustomEvent* );
+
protected slots:
void plotMousePressed( const QMouseEvent& );
void plotMouseMoved( const QMouseEvent& );
class Plot2d_Plot2d : public QwtPlot
{
+ Q_OBJECT
public:
Plot2d_Plot2d( QWidget* parent );
virtual QSizePolicy sizePolicy() const;
virtual QSize minimumSizeHint() const;
+ bool polished() const { return myIsPolished; }
+
+public slots:
+ virtual void polish();
+
protected:
bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine );
protected:
QValueList<QColor> myColors;
+ bool myIsPolished;
};
#endif