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 <qmainwindow.h>
22 #include <qwt_legend.h>
24 //=================================================================================
25 // class : Plot2d_ViewFrame
26 // purpose : Plot2d view frame
27 //=================================================================================
29 typedef QIntDict<Plot2d_Curve> CurveDict;
31 class QAD_EXPORT Plot2d_ViewFrame : public QAD_ViewFrame, public QAD_PopupClientServer
35 enum { NoOpId, FitAllId, FitAreaId, ZoomId, PanId, DumpId,
36 ModeXLinearId, ModeXLogarithmicId, ModeYLinearId, ModeYLogarithmicId,
37 LegendId, CurvePointsId, CurveLinesId, CurveSplinesId, SettingsId, FitDataId };
39 /* Construction/destruction */
40 Plot2d_ViewFrame( QWidget* parent, const QString& title = "" );
41 virtual ~Plot2d_ViewFrame();
45 ViewType getTypeView() const { return VIEW_PLOT2D; }
46 QWidget* getViewWidget();
47 void SetSelectionMode( int mode ) {}
48 void onAdjustTrihedron( ) {}
50 /* popup management */
51 void setPopupServer( QAD_Application* );
54 /* interactive object management */
55 void highlight( const Handle(SALOME_InteractiveObject)& IObject,
56 bool highlight, bool update = true ) {}
57 void unHighlightAll() {}
58 void rename( const Handle(SALOME_InteractiveObject)& IObject,
60 bool isInViewer( const Handle(SALOME_InteractiveObject)& IObject );
61 bool isVisible( const Handle(SALOME_InteractiveObject)& IObject );
63 /* undo/redo management */
64 void undo( SALOMEDS::Study_var aStudy,
65 const char* StudyFrameEntry ) {}
66 void redo( SALOMEDS::Study_var aStudy,
67 const char* StudyFrameEntry ) {}
69 /* interactive objects handling */
70 Handle(SALOME_InteractiveObject) FindIObject( const char* Entry );
73 void Display( const Handle(SALOME_InteractiveObject)& IObject, bool update = true );
74 void DisplayOnly( const Handle(SALOME_InteractiveObject)& IObject );
75 void Erase( const Handle(SALOME_InteractiveObject)& IObject, bool update = true );
81 bool eventFilter( QObject* o, QEvent* e );
84 void setTitle( const QString& title );
85 QString getTitle() const { return myTitle; }
86 void displayCurve( Plot2d_Curve* curve, bool update = false );
87 void displayCurves( Plot2d_CurveContainer& curves, bool update = false );
88 void eraseCurve( Plot2d_Curve* curve, bool update = false );
89 void eraseCurves( Plot2d_CurveContainer& curves, bool update = false );
90 int getCurves( QList<Plot2d_Curve>& clist );
91 int hasCurve( Plot2d_Curve* curve );
92 Plot2d_Curve* getCurveByIO( const Handle(SALOME_InteractiveObject)& theIObject );
93 void updateCurve( Plot2d_Curve* curve, bool update = false );
95 void fitArea( const QRect& area );
98 void setCurveType( int curveType, bool update = true );
99 int getCurveType() const { return myCurveType; }
100 void showLegend( bool show, bool update = true );
101 void setLegendPos( int pos );
102 int getLegendPos() const { return myLegendPos; }
103 void setMarkerSize( const int size, bool update = true );
104 int getMarkerSize() const { return myMarkerSize; }
105 void setBackgroundColor( const QColor& color );
106 QColor backgroundColor() const;
107 void setXGrid( bool xMajorEnabled, const int xMajorMax, bool xMinorEnabled, const int xMinorMax, bool update = true );
108 void setYGrid( bool yMajorEnabled, const int yMajorMax, bool yMinorEnabled, const int yMinorMax, bool update = true );
109 void setMainTitle( bool enabled, const QString& title, bool update = true);
110 void setXTitle( bool enabled, const QString& title, bool update = true );
111 QString getXTitle() const { return myXTitle; }
112 void setYTitle( bool enabled, const QString& title, bool update = true );
113 QString getYTitle() const { return myYTitle; }
114 void setHorScaleMode( const int mode, bool update = true );
115 int getHorScaleMode() const { return myXMode; }
116 void setVerScaleMode( const int mode, bool update = true );
117 int getVerScaleMode() const { return myYMode; }
120 void createActions();
121 int testOperation( const QMouseEvent& );
122 void readPreferences();
123 void writePreferences();
124 QString getInfo( const QPoint& pnt );
131 void onViewFitArea();
132 void onViewGlobalPan();
141 void onViewTrihedron();
150 void onLegendClicked( long key );
151 void plotMousePressed( const QMouseEvent& );
152 void plotMouseMoved( const QMouseEvent& );
153 void plotMouseReleased( const QMouseEvent& );
156 Plot2d_Plot2d* myPlot;
167 QString myTitle, myXTitle, myYTitle;
168 bool myTitleEnabled, myXTitleEnabled, myYTitleEnabled;
169 bool myXGridMajorEnabled, myYGridMajorEnabled;
170 bool myXGridMinorEnabled, myYGridMinorEnabled;
171 int myXGridMaxMajor, myYGridMaxMajor;
172 int myXGridMaxMinor, myYGridMaxMinor;
173 int myXMode, myYMode;
176 //=================================================================================
177 // class : Plot2d_Plot2d
178 // purpose : Plot2d View
179 //=================================================================================
180 class Plot2d_Plot2d : public QwtPlot
183 Plot2d_Plot2d( QWidget* parent );
186 void getNextMarker( QwtSymbol::Style& typeMarker, QColor& color, Qt::PenStyle& typeLine );
187 QwtLegend* getLegend() { return d_legend; }
190 bool existMarker( const QwtSymbol::Style typeMarker, const QColor& color, const Qt::PenStyle typeLine );
193 QValueList<QColor> myColors;
196 #endif // Plot2d_ViewFrame_H