1 // Copyright (C) 2003 CEA/DEN, EDF R&D
5 // File : Plot2d_ViewFrame.h
6 // Author : Vadim SANDLER
10 #ifndef Plot2d_ViewFrame_H
11 #define Plot2d_ViewFrame_H
13 #include "QAD_ViewFrame.h"
14 #include "QAD_Popup.h"
15 #include "QAD_Action.h"
16 #include "Plot2d_Curve.h"
17 #include "Plot2d_CurveContainer.h"
18 #include "SALOME_Selection.h"
19 #include <qmainwindow.h>
23 #include <qwt_legend.h>
25 //=================================================================================
26 // class : Plot2d_ViewFrame
27 // purpose : Plot2d view frame
28 //=================================================================================
30 typedef QIntDict<Plot2d_Curve> CurveDict;
32 class QAD_EXPORT Plot2d_ViewFrame : public QAD_ViewFrame, public QAD_PopupClientServer
36 enum { NoOpId, FitAllId, FitAreaId, ZoomId, PanId, DumpId,
37 ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId,
38 LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId, FitDataId, ChangeBackgroundId };
40 /* Construction/destruction */
41 Plot2d_ViewFrame( QWidget* parent, const QString& title = "" );
42 virtual ~Plot2d_ViewFrame();
46 ViewType getTypeView() const { return VIEW_PLOT2D; }
47 QWidget* getViewWidget();
48 void SetSelectionMode( Selection_Mode mode ) {}
49 void onAdjustTrihedron( ) {}
51 /* popup management */
52 void setPopupServer( QAD_Application* );
55 /* interactive object management */
56 void highlight( const Handle(SALOME_InteractiveObject)& IObject,
57 bool highlight, bool update = true ) {}
58 void unHighlightAll() {}
59 void rename( const Handle(SALOME_InteractiveObject)& IObject,
61 bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
62 bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
64 /* undo/redo management */
65 void undo( SALOMEDS::Study_var aStudy,
66 const char* StudyFrameEntry ) {}
67 void redo( SALOMEDS::Study_var aStudy,
68 const char* StudyFrameEntry ) {}
70 /* interactive objects handling */
71 Handle(SALOME_InteractiveObject) FindIObject( const char* Entry );
74 void Display( const Handle(SALOME_InteractiveObject)& IObject, bool update = true );
75 void DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject );
76 void Erase( const Handle(SALOME_InteractiveObject)& IObject, bool update = true );
81 /* Reimplemented from SALOME_View */
82 void Display( const SALOME_Prs2d* );
83 void Erase( const SALOME_Prs2d*, const bool = false );
84 SALOME_Prs* CreatePrs( const char* entry = 0 );
85 virtual void BeforeDisplay( SALOME_Displayer* d );
86 virtual void AfterDisplay ( SALOME_Displayer* d );
89 bool eventFilter( QObject* o, QEvent* e );
92 void setTitle( const QString& title );
93 QString getTitle() const { return myTitle; }
94 void displayCurve( Plot2d_Curve* curve, bool update = false );
95 void displayCurves( Plot2d_CurveContainer& curves, bool update = false );
96 void eraseCurve( Plot2d_Curve* curve, bool update = false );
97 void eraseCurves( Plot2d_CurveContainer& curves, bool update = false );
98 int getCurves( QList<Plot2d_Curve>& clist );
99 int hasCurve( Plot2d_Curve* curve );
100 Plot2d_Curve* getCurveByIO( const Handle(SALOME_InteractiveObject)& theIObject );
101 void updateCurve( Plot2d_Curve* curve, bool update = false );
103 void fitArea( const QRect& area );
105 /* view parameters */
106 void setCurveType( int curveType, bool update = true );
107 int getCurveType() const { return myCurveType; }
108 void showLegend( bool show, bool update = true );
109 void setLegendPos( int pos );
110 int getLegendPos() const { return myLegendPos; }
111 void setMarkerSize( const int size, bool update = true );
112 int getMarkerSize() const { return myMarkerSize; }
113 void setBackgroundColor( const QColor& color );
114 QColor backgroundColor() const;
115 void setXGrid( bool xMajorEnabled, const int xMajorMax, bool xMinorEnabled, const int xMinorMax, bool update = true );
116 void setYGrid( bool yMajorEnabled, const int yMajorMax, bool yMinorEnabled, const int yMinorMax, bool update = true );
117 void setMainTitle( bool enabled, const QString& title, bool update = true);
118 void setXTitle( bool enabled, const QString& title, bool update = true );
119 QString getXTitle() const { return myXTitle; }
120 void setYTitle( bool enabled, const QString& title, bool update = true );
121 QString getYTitle() const { return myYTitle; }
122 void setHorScaleMode( const int mode, bool update = true );
123 int getHorScaleMode() const { return myXMode; }
124 void setVerScaleMode( const int mode, bool update = true );
125 int getVerScaleMode() const { return myYMode; }
127 void incrementalPan ( const int incrX, const int incrY );
128 void incrementalZoom( const int incrX, const int incrY );
131 void createActions();
132 int testOperation( const QMouseEvent& );
133 void readPreferences();
134 void writePreferences();
135 QString getInfo( const QPoint& pnt );
142 void onViewFitArea();
143 void onViewGlobalPan();
152 void onViewTrihedron();
159 void onChangeBackground();
169 void onLegendClicked( long key );
170 void plotMousePressed( const QMouseEvent& );
171 void plotMouseMoved( const QMouseEvent& );
172 void plotMouseReleased( const QMouseEvent& );
175 Plot2d_Plot2d* myPlot;
186 QString myTitle, myXTitle, myYTitle;
187 bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled;
188 bool myXGridMajorEnabled, myYGridMajorEnabled;
189 bool myXGridMinorEnabled, myYGridMinorEnabled;
190 int myXGridMaxMajor, myYGridMaxMajor;
191 int myXGridMaxMinor, myYGridMaxMinor;
192 int myXMode, myYMode;
195 //=================================================================================
196 // class : Plot2d_Plot2d
197 // purpose : Plot2d View
198 //=================================================================================
199 class Plot2d_Plot2d : public QwtPlot
202 Plot2d_Plot2d( QWidget* parent );
205 void getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine );
206 QwtLegend* getLegend() { return d_legend; }
209 bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine );
212 QValueList<QColor> myColors;
215 #endif // Plot2d_ViewFrame_H