1 // File : Plot2d_ViewFrame.h
2 // Created : Wed Jun 27 16:38:42 2001
3 // Author : Vadim SANDLER
6 // Copyright : Open CASCADE
9 #ifndef Plot2d_ViewFrame_H
10 #define Plot2d_ViewFrame_H
12 #include "QAD_ViewFrame.h"
13 #include "QAD_Popup.h"
14 #include "Plot2d_Curve.h"
15 #include "Plot2d_CurveContainer.h"
16 #include <qmainwindow.h>
21 #include <qwt_legend.h>
23 //=================================================================================
24 // class : Plot2d_ViewFrame
25 // purpose : Plot2d view frame
26 //=================================================================================
28 typedef QIntDict<Plot2d_Curve> CurveDict;
30 class QAD_EXPORT Plot2d_ViewFrame : public QAD_ViewFrame, public QAD_PopupClientServer
34 enum { NoOpId, FitAllId, FitAreaId, ZoomId, PanId, DumpId,
35 ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId,
36 LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId };
38 /* Construction/destruction */
39 Plot2d_ViewFrame( QWidget* parent, const QString& title = "" );
40 virtual ~Plot2d_ViewFrame();
44 ViewType getTypeView() const { return VIEW_PLOT2D; }
45 QWidget* getViewWidget();
46 void SetSelectionMode( int mode ) {}
47 void SetTrihedronSize( int dim ) {}
49 /* popup management */
50 void setPopupServer( QAD_Application* );
53 /* interactive object management */
54 void highlight( const Handle(SALOME_InteractiveObject)& IObject,
55 bool highlight, bool update = true ) {}
56 void unHighlightAll() {}
57 void rename( const Handle(SALOME_InteractiveObject)& IObject,
59 bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
60 bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
62 /* undo/redo management */
63 void undo( SALOMEDS::Study_var aStudy,
64 const char* StudyFrameEntry ) {}
65 void redo( SALOMEDS::Study_var aStudy,
66 const char* StudyFrameEntry ) {}
68 /* interactive objects handling */
69 Handle(SALOME_InteractiveObject) FindIObject( const char* Entry );
72 void Display( const Handle(SALOME_InteractiveObject)& IObject, bool update = true );
73 void DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject );
74 void Erase( const Handle(SALOME_InteractiveObject)& IObject, bool update = true );
80 bool eventFilter( QObject* o, QEvent* e );
83 void setTitle( const QString& title );
84 QString getTitle() const { return myTitle; }
85 void displayCurve( Plot2d_Curve* curve, bool update = false );
86 void displayCurves( Plot2d_CurveContainer& curves, bool update = false );
87 void eraseCurve( Plot2d_Curve* curve, bool update = false );
88 void eraseCurves( Plot2d_CurveContainer& curves, bool update = false );
89 int getCurves( QList<Plot2d_Curve>& clist );
90 int hasCurve( Plot2d_Curve* curve );
91 Plot2d_Curve* getCurveByIO( const Handle(SALOME_InteractiveObject)& theIObject );
92 void updateCurve( Plot2d_Curve* curve, bool update = false );
94 void fitArea( const QRect& area );
97 void setCurveType( int curveType, bool update = true );
98 int getCurveType() const { return myCurveType; }
99 void showLegend( bool show, bool update = true );
100 void setLegendPos( int pos );
101 int getLegendPos() const { return myLegendPos; }
102 void setMarkerSize( const int size, bool update = true );
103 int getMarkerSize() const { return myMarkerSize; }
104 void setBackgroundColor( const QColor& color );
105 QColor backgroundColor() const;
106 void setXGrid( bool xMajorEnabled, const int xMajorMax, bool xMinorEnabled, const int xMinorMax, bool update = true );
107 void setYGrid( bool yMajorEnabled, const int yMajorMax, bool yMinorEnabled, const int yMinorMax, bool update = true );
108 void setMainTitle( bool enabled, const QString& title, bool update = true);
109 void setXTitle( bool enabled, const QString& title, bool update = true );
110 QString getXTitle() const { return myXTitle; }
111 void setYTitle( bool enabled, const QString& title, bool update = true );
112 QString getYTitle() const { return myYTitle; }
113 void setHorScaleMode( const int mode, bool update = true );
114 int getHorScaleMode() const { return myXMode; }
115 void setVerScaleMode( const int mode, bool update = true );
116 int getVerScaleMode() const { return myYMode; }
119 void createActions();
120 int testOperation( const QMouseEvent& );
121 void readPreferences();
122 void writePreferences();
123 QString getInfo( const QPoint& pnt );
130 void onViewFitArea();
131 void onViewGlobalPan();
140 void onViewTrihedron();
148 void onLegendClicked( long key );
149 void plotMousePressed( const QMouseEvent& );
150 void plotMouseMoved( const QMouseEvent& );
151 void plotMouseReleased( const QMouseEvent& );
154 Plot2d_Plot2d* myPlot;
155 QMap<int, QAction*> myActions;
165 QString myTitle, myXTitle, myYTitle;
166 bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled;
167 bool myXGridMajorEnabled, myYGridMajorEnabled;
168 bool myXGridMinorEnabled, myYGridMinorEnabled;
169 int myXGridMaxMajor, myYGridMaxMajor;
170 int myXGridMaxMinor, myYGridMaxMinor;
171 int myXMode, myYMode;
174 //=================================================================================
175 // class : Plot2d_Plot2d
176 // purpose : Plot2d View
177 //=================================================================================
178 class Plot2d_Plot2d : public QwtPlot
181 Plot2d_Plot2d( QWidget* parent );
184 void getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine );
185 QwtLegend* getLegend() { return d_legend; }
188 bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine );
191 QValueList<QColor> myColors;
194 #endif // Plot2d_ViewFrame_H