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 );
82 bool eventFilter( QObject* o, QEvent* e );
85 void setTitle( const QString& title );
86 QString getTitle() const { return myTitle; }
87 void displayCurve( Plot2d_Curve* curve, bool update = false );
88 void displayCurves( Plot2d_CurveContainer& curves, bool update = false );
89 void eraseCurve( Plot2d_Curve* curve, bool update = false );
90 void eraseCurves( Plot2d_CurveContainer& curves, bool update = false );
91 int getCurves( QList<Plot2d_Curve>& clist );
92 int hasCurve( Plot2d_Curve* curve );
93 Plot2d_Curve* getCurveByIO( const Handle(SALOME_InteractiveObject)& theIObject );
94 void updateCurve( Plot2d_Curve* curve, bool update = false );
96 void fitArea( const QRect& area );
99 void setCurveType( int curveType, bool update = true );
100 int getCurveType() const { return myCurveType; }
101 void showLegend( bool show, bool update = true );
102 void setLegendPos( int pos );
103 int getLegendPos() const { return myLegendPos; }
104 void setMarkerSize( const int size, bool update = true );
105 int getMarkerSize() const { return myMarkerSize; }
106 void setBackgroundColor( const QColor& color );
107 QColor backgroundColor() const;
108 void setXGrid( bool xMajorEnabled, const int xMajorMax, bool xMinorEnabled, const int xMinorMax, bool update = true );
109 void setYGrid( bool yMajorEnabled, const int yMajorMax, bool yMinorEnabled, const int yMinorMax, bool update = true );
110 void setMainTitle( bool enabled, const QString& title, bool update = true);
111 void setXTitle( bool enabled, const QString& title, bool update = true );
112 QString getXTitle() const { return myXTitle; }
113 void setYTitle( bool enabled, const QString& title, bool update = true );
114 QString getYTitle() const { return myYTitle; }
115 void setHorScaleMode( const int mode, bool update = true );
116 int getHorScaleMode() const { return myXMode; }
117 void setVerScaleMode( const int mode, bool update = true );
118 int getVerScaleMode() const { return myYMode; }
121 void createActions();
122 int testOperation( const QMouseEvent& );
123 void readPreferences();
124 void writePreferences();
125 QString getInfo( const QPoint& pnt );
132 void onViewFitArea();
133 void onViewGlobalPan();
142 void onViewTrihedron();
149 void onChangeBackground();
152 void onLegendClicked( long key );
153 void plotMousePressed( const QMouseEvent& );
154 void plotMouseMoved( const QMouseEvent& );
155 void plotMouseReleased( const QMouseEvent& );
158 Plot2d_Plot2d* myPlot;
169 QString myTitle, myXTitle, myYTitle;
170 bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled;
171 bool myXGridMajorEnabled, myYGridMajorEnabled;
172 bool myXGridMinorEnabled, myYGridMinorEnabled;
173 int myXGridMaxMajor, myYGridMaxMajor;
174 int myXGridMaxMinor, myYGridMaxMinor;
175 int myXMode, myYMode;
178 //=================================================================================
179 // class : Plot2d_Plot2d
180 // purpose : Plot2d View
181 //=================================================================================
182 class Plot2d_Plot2d : public QwtPlot
185 Plot2d_Plot2d( QWidget* parent );
188 void getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine );
189 QwtLegend* getLegend() { return d_legend; }
192 bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine );
195 QValueList<QColor> myColors;
198 #endif // Plot2d_ViewFrame_H