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; }
128 void createActions();
129 int testOperation( const QMouseEvent& );
130 void readPreferences();
131 void writePreferences();
132 QString getInfo( const QPoint& pnt );
139 void onViewFitArea();
140 void onViewGlobalPan();
149 void onViewTrihedron();
156 void onChangeBackground();
159 void onLegendClicked( long key );
160 void plotMousePressed( const QMouseEvent& );
161 void plotMouseMoved( const QMouseEvent& );
162 void plotMouseReleased( const QMouseEvent& );
165 Plot2d_Plot2d* myPlot;
176 QString myTitle, myXTitle, myYTitle;
177 bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled;
178 bool myXGridMajorEnabled, myYGridMajorEnabled;
179 bool myXGridMinorEnabled, myYGridMinorEnabled;
180 int myXGridMaxMajor, myYGridMaxMajor;
181 int myXGridMaxMinor, myYGridMaxMinor;
182 int myXMode, myYMode;
185 //=================================================================================
186 // class : Plot2d_Plot2d
187 // purpose : Plot2d View
188 //=================================================================================
189 class Plot2d_Plot2d : public QwtPlot
192 Plot2d_Plot2d( QWidget* parent );
195 void getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine );
196 QwtLegend* getLegend() { return d_legend; }
199 bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine );
202 QValueList<QColor> myColors;
205 #endif // Plot2d_ViewFrame_H