From 38bc57c0b3d85c0f277f9cf2ddefddf028440c8c Mon Sep 17 00:00:00 2001 From: asl Date: Thu, 13 Oct 2005 11:53:07 +0000 Subject: [PATCH] PAL10190 - clone of plot2d --- src/Plot2d/Plot2d_Curve.cxx | 3 ++- src/Plot2d/Plot2d_Curve.h | 11 +++++---- src/Plot2d/Plot2d_FitDataDlg.cxx | 4 +++ src/Plot2d/Plot2d_FitDataDlg.h | 10 ++++---- src/Plot2d/Plot2d_Prs.h | 5 +--- src/Plot2d/Plot2d_SetupViewDlg.h | 1 - src/Plot2d/Plot2d_ViewFrame.cxx | 41 +++++++++++++++++++++++++++++-- src/Plot2d/Plot2d_ViewFrame.h | 13 ++++------ src/Plot2d/Plot2d_ViewManager.cxx | 25 +++++++++++++++++-- src/Plot2d/Plot2d_ViewManager.h | 14 ++++++----- src/Plot2d/Plot2d_ViewModel.cxx | 20 +++++++++++++++ src/Plot2d/Plot2d_ViewModel.h | 13 +++++----- src/Plot2d/Plot2d_ViewWindow.cxx | 5 ++++ src/Plot2d/Plot2d_ViewWindow.h | 19 +++++--------- src/SPlot2d/SPlot2d_ViewModel.cxx | 20 +++++++++++++++ src/SPlot2d/SPlot2d_ViewModel.h | 2 ++ 16 files changed, 152 insertions(+), 54 deletions(-) diff --git a/src/Plot2d/Plot2d_Curve.cxx b/src/Plot2d/Plot2d_Curve.cxx index 399e6be20..25ed5ac6d 100755 --- a/src/Plot2d/Plot2d_Curve.cxx +++ b/src/Plot2d/Plot2d_Curve.cxx @@ -1,4 +1,5 @@ #include "Plot2d_Curve.h" +#include /*! Constructor @@ -251,7 +252,7 @@ bool Plot2d_Curve::isAutoAssign() const /*! Sets curve's color ( and resets AutoAssign flag ) */ -void Plot2d_Curve::setColor( const QColor color ) +void Plot2d_Curve::setColor( const QColor& color ) { myColor = color; myAutoAssign = false; diff --git a/src/Plot2d/Plot2d_Curve.h b/src/Plot2d/Plot2d_Curve.h index bbb969679..703a9cdf0 100755 --- a/src/Plot2d/Plot2d_Curve.h +++ b/src/Plot2d/Plot2d_Curve.h @@ -2,12 +2,11 @@ #define PLOT2D_CURVE_H #include "Plot2d.h" - +#include +#include #include -#include -#include -#include +class QColor; typedef struct { @@ -53,7 +52,7 @@ public: void setAutoAssign( bool on ); bool isAutoAssign() const; - void setColor( const QColor color ); + void setColor( const QColor& color ); QColor getColor() const; void setMarker( MarkerType marker ); MarkerType getMarker() const; @@ -78,4 +77,6 @@ protected: pointList myPoints; }; +typedef QPtrList curveList; + #endif diff --git a/src/Plot2d/Plot2d_FitDataDlg.cxx b/src/Plot2d/Plot2d_FitDataDlg.cxx index 91a63af30..1b9256c27 100755 --- a/src/Plot2d/Plot2d_FitDataDlg.cxx +++ b/src/Plot2d/Plot2d_FitDataDlg.cxx @@ -11,6 +11,10 @@ #include #include #include +#include +#include +#include +#include #define SPACING_SIZE 6 #define MARGIN_SIZE 11 diff --git a/src/Plot2d/Plot2d_FitDataDlg.h b/src/Plot2d/Plot2d_FitDataDlg.h index 2b717b9c9..c3083b6c4 100755 --- a/src/Plot2d/Plot2d_FitDataDlg.h +++ b/src/Plot2d/Plot2d_FitDataDlg.h @@ -2,12 +2,12 @@ #define PLOT2D_FITDATADLG_H #include "Plot2d.h" - #include -#include -#include -#include -#include + +class QButtonGroup; +class QRadioButton; +class QLineEdit; +class QPushButton; class PLOT2D_EXPORT Plot2d_FitDataDlg : public QDialog { diff --git a/src/Plot2d/Plot2d_Prs.h b/src/Plot2d/Plot2d_Prs.h index de50ec9bf..b96e08747 100755 --- a/src/Plot2d/Plot2d_Prs.h +++ b/src/Plot2d/Plot2d_Prs.h @@ -1,12 +1,9 @@ #ifndef PLOT2D_PRS_H #define PLOT2D_PRS_H +#include "Plot2d.h" #include "Plot2d_Curve.h" -#include - -typedef QPtrList curveList; - class PLOT2D_EXPORT Plot2d_Prs { public: diff --git a/src/Plot2d/Plot2d_SetupViewDlg.h b/src/Plot2d/Plot2d_SetupViewDlg.h index d53d1aa36..ab93a4cb1 100755 --- a/src/Plot2d/Plot2d_SetupViewDlg.h +++ b/src/Plot2d/Plot2d_SetupViewDlg.h @@ -2,7 +2,6 @@ #define PLOT2D_SETUPVIEWDLG_H #include "Plot2d.h" - #include class QSpinBox; diff --git a/src/Plot2d/Plot2d_ViewFrame.cxx b/src/Plot2d/Plot2d_ViewFrame.cxx index 03540eabd..59e3637a9 100755 --- a/src/Plot2d/Plot2d_ViewFrame.cxx +++ b/src/Plot2d/Plot2d_ViewFrame.cxx @@ -28,6 +28,8 @@ #include #include +#include + //#include "utilities.h" #define DEFAULT_LINE_WIDTH 0 // (default) line width @@ -629,7 +631,7 @@ void Plot2d_ViewFrame::displayCurve( Plot2d_Curve* curve, bool update ) /*! Adds curves into view */ -void Plot2d_ViewFrame::displayCurves( curveList curves, bool update ) +void Plot2d_ViewFrame::displayCurves( const curveList& curves, bool update ) { myPlot->setUpdatesEnabled( false ); QPtrListIterator it(curves); @@ -664,7 +666,7 @@ void Plot2d_ViewFrame::eraseCurve( Plot2d_Curve* curve, bool update ) /*! Erases curves */ -void Plot2d_ViewFrame::eraseCurves( curveList& curves, bool update ) +void Plot2d_ViewFrame::eraseCurves( const curveList& curves, bool update ) { QPtrListIterator it(curves); Plot2d_Curve* aCurve; @@ -1709,3 +1711,38 @@ Plot2d_Prs* Plot2d_ViewFrame::CreatePrs( const char* /*entry*/ ) { return 0; } + +void Plot2d_ViewFrame::copyPreferences( Plot2d_ViewFrame* vf ) +{ + if( !vf ) + return; + + myCurveType = vf->myCurveType; + myShowLegend = vf->myShowLegend; + myLegendPos = vf->myLegendPos; + myMarkerSize = vf->myMarkerSize; + myBackground = vf->myBackground; + myTitle = vf->myTitle; + myXTitle = vf->myXTitle; + myYTitle = vf->myYTitle; + myY2Title = vf->myY2Title; + myTitleEnabled = vf->myTitleEnabled; + myXTitleEnabled = vf->myXTitleEnabled; + myYTitleEnabled = vf->myYTitleEnabled; + myY2TitleEnabled = vf->myY2TitleEnabled; + myXGridMajorEnabled = vf->myXGridMajorEnabled; + myYGridMajorEnabled = vf->myYGridMajorEnabled; + myY2GridMajorEnabled = vf->myY2GridMajorEnabled; + myXGridMinorEnabled = vf->myXGridMinorEnabled; + myYGridMinorEnabled = vf->myYGridMinorEnabled; + myY2GridMinorEnabled = vf->myY2GridMinorEnabled; + myXGridMaxMajor = vf->myXGridMaxMajor; + myYGridMaxMajor = vf->myYGridMaxMajor; + myY2GridMaxMajor = vf->myY2GridMaxMajor; + myXGridMaxMinor = vf->myXGridMaxMinor; + myYGridMaxMinor = vf->myYGridMaxMinor; + myY2GridMaxMinor = vf->myY2GridMaxMinor; + myXMode = vf->myXMode; + myYMode = vf->myYMode; + mySecondY = vf->mySecondY; +} diff --git a/src/Plot2d/Plot2d_ViewFrame.h b/src/Plot2d/Plot2d_ViewFrame.h index 565f8d04e..bd5d988f8 100755 --- a/src/Plot2d/Plot2d_ViewFrame.h +++ b/src/Plot2d/Plot2d_ViewFrame.h @@ -1,16 +1,12 @@ #ifndef PLOT2D_VIEWFRAME_H #define PLOT2D_VIEWFRAME_H -#include "Plot2d_Prs.h" #include "Plot2d_Curve.h" - #include #include -#include -#include - class Plot2d_Plot2d; +class Plot2d_Prs; typedef QIntDict CurveDict; @@ -44,10 +40,10 @@ public: void setTitle( const QString& title ); QString getTitle() const { return myTitle; } void displayCurve( Plot2d_Curve* curve, bool update = false ); - void displayCurves( curveList curves, bool update = false ); + void displayCurves( const curveList& curves, bool update = false ); void eraseCurve( Plot2d_Curve* curve, bool update = false ); - void eraseCurves( curveList& curves, bool update = false ); - int getCurves( QList& clist ); + void eraseCurves( const curveList& curves, bool update = false ); + int getCurves( curveList& clist ); const CurveDict& getCurves() { return myCurves; } int hasCurve( Plot2d_Curve* curve ); bool isVisible( Plot2d_Curve* curve ); @@ -57,6 +53,7 @@ public: void fitArea( const QRect& area ); /* view parameters */ + void copyPreferences( Plot2d_ViewFrame* ); void setCurveType( int curveType, bool update = true ); int getCurveType() const { return myCurveType; } void setCurveTitle( int curveKey, const QString& title ); diff --git a/src/Plot2d/Plot2d_ViewManager.cxx b/src/Plot2d/Plot2d_ViewManager.cxx index a739f25d9..c94fe7f66 100755 --- a/src/Plot2d/Plot2d_ViewManager.cxx +++ b/src/Plot2d/Plot2d_ViewManager.cxx @@ -1,5 +1,6 @@ #include "Plot2d_ViewManager.h" #include "Plot2d_ViewModel.h" +#include "Plot2d_ViewWindow.h" int Plot2d_ViewManager::myMaxId = 0; @@ -7,13 +8,19 @@ Plot2d_ViewManager::Plot2d_ViewManager( SUIT_Study* study, SUIT_Desktop* desk ) : SUIT_ViewManager( study, desk ) { myId = ++myMaxId; - setViewModel( new Plot2d_Viewer() ); + Plot2d_Viewer* v = new Plot2d_Viewer(); + setViewModel( v ); } Plot2d_ViewManager::~Plot2d_ViewManager() { } +Plot2d_Viewer* Plot2d_ViewManager::getPlot2dModel() const +{ + return (Plot2d_Viewer*)myViewModel; +} + void Plot2d_ViewManager::setViewName( SUIT_ViewWindow* theView ) { int aPos = myViews.find(theView); @@ -26,7 +33,7 @@ bool Plot2d_ViewManager::insertView( SUIT_ViewWindow* theView ) if ( res ) { Plot2d_ViewWindow* view = (Plot2d_ViewWindow*)theView; - connect( view, SIGNAL( cloneView() ), this, SLOT( createView() ) ); + connect( view, SIGNAL( cloneView() ), this, SLOT( onCloneView() ) ); } return res; } @@ -35,3 +42,17 @@ void Plot2d_ViewManager::createView() { createViewWindow(); } + +void Plot2d_ViewManager::onCloneView() +{ + SUIT_ViewWindow* vw = createViewWindow(); + + Plot2d_ViewWindow *newWnd = 0, *clonedWnd = 0; + if( vw && vw->inherits( "Plot2d_ViewWindow" ) ) + newWnd = ( Plot2d_ViewWindow* )vw; + if( sender() && sender()->inherits( "Plot2d_ViewWindow" ) ) + clonedWnd = ( Plot2d_ViewWindow* )sender(); + + if( newWnd && clonedWnd ) + emit cloneView( clonedWnd->getViewFrame(), newWnd->getViewFrame() ); +} diff --git a/src/Plot2d/Plot2d_ViewManager.h b/src/Plot2d/Plot2d_ViewManager.h index d2089fddd..8a626bc30 100755 --- a/src/Plot2d/Plot2d_ViewManager.h +++ b/src/Plot2d/Plot2d_ViewManager.h @@ -2,14 +2,11 @@ #define PLOT2D_VIEWMANAGER_H #include "Plot2d.h" - -#include "Plot2d_ViewWindow.h" - -#include "SUIT_Desktop.h" -#include "SUIT_ViewWindow.h" #include "SUIT_ViewManager.h" class SUIT_Desktop; +class Plot2d_Viewer; +class Plot2d_ViewFrame; class PLOT2D_EXPORT Plot2d_ViewManager : public SUIT_ViewManager { @@ -19,7 +16,7 @@ public: Plot2d_ViewManager( SUIT_Study*, SUIT_Desktop* ); ~Plot2d_ViewManager(); - Plot2d_Viewer* getPlot2dModel() { return (Plot2d_Viewer*)myViewModel; }; + Plot2d_Viewer* getPlot2dModel() const; protected: void setViewName(SUIT_ViewWindow* theView); @@ -28,6 +25,11 @@ protected: public slots: void createView(); +protected slots: + void onCloneView(); + +signals: + void cloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ); protected: static int myMaxId; diff --git a/src/Plot2d/Plot2d_ViewModel.cxx b/src/Plot2d/Plot2d_ViewModel.cxx index e5f1bf967..950c311f0 100755 --- a/src/Plot2d/Plot2d_ViewModel.cxx +++ b/src/Plot2d/Plot2d_ViewModel.cxx @@ -4,7 +4,11 @@ #include "Plot2d_ViewModel.h" #include "Plot2d_ViewWindow.h" +#include "Plot2d_ViewManager.h" +#include "Plot2d_ViewFrame.h" +#include "Plot2d_Prs.h" +#include Plot2d_Viewer::Plot2d_Viewer(bool theAutoDel) :SUIT_ViewModel() @@ -119,3 +123,19 @@ void Plot2d_Viewer::onDumpView() if ( aView ) aView->onDumpView(); } + +//********************************************************************* +void Plot2d_Viewer::onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ) +{ +} +//********************************************************************* +void Plot2d_Viewer::setViewManager( SUIT_ViewManager* mgr ) +{ + SUIT_ViewModel::setViewManager( mgr ); + if( mgr && mgr->inherits( "Plot2d_ViewManager" ) ) + { + Plot2d_ViewManager* pmgr = ( Plot2d_ViewManager* )mgr; + connect( pmgr, SIGNAL( cloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ) ), + this, SLOT( onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ) ) ); + } +} diff --git a/src/Plot2d/Plot2d_ViewModel.h b/src/Plot2d/Plot2d_ViewModel.h index 4189f3138..1f52c8933 100755 --- a/src/Plot2d/Plot2d_ViewModel.h +++ b/src/Plot2d/Plot2d_ViewModel.h @@ -3,16 +3,13 @@ #include "Plot2d.h" #include "SUIT_ViewModel.h" -#include "SUIT_ViewWindow.h" -#include "SUIT_Desktop.h" -#include "SUIT_ViewManager.h" -#include "Plot2d_Prs.h" - -#include -#include class SUIT_ViewWindow; class SUIT_Desktop; +class Plot2d_ViewFrame; +class Plot2d_Prs; +class QString; +class QPopupMenu; class PLOT2D_EXPORT Plot2d_Viewer: public SUIT_ViewModel { @@ -24,6 +21,7 @@ public: Plot2d_Viewer(bool theAutoDel = false); ~Plot2d_Viewer(); + virtual void setViewManager( SUIT_ViewManager* ); virtual SUIT_ViewWindow* createView(SUIT_Desktop* theDesktop); virtual QString getType() const { return Type(); } virtual void contextMenuPopup(QPopupMenu*); @@ -37,6 +35,7 @@ protected slots: void onChangeBgColor(); void onDumpView(); void onShowToolbar(); + virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ); private: Plot2d_Prs* myPrs; diff --git a/src/Plot2d/Plot2d_ViewWindow.cxx b/src/Plot2d/Plot2d_ViewWindow.cxx index 5d9f36aa4..21646900d 100755 --- a/src/Plot2d/Plot2d_ViewWindow.cxx +++ b/src/Plot2d/Plot2d_ViewWindow.cxx @@ -2,15 +2,20 @@ // ////////////////////////////////////////////////////////////////////// #include "Plot2d_ViewWindow.h" +#include "Plot2d_ViewFrame.h" #include "SUIT_ViewManager.h" #include "SUIT_ResourceMgr.h" #include "SUIT_Session.h" #include "SUIT_ToolButton.h" +#include "SUIT_Desktop.h" + +#include "QtxAction.h" #include #include #include +#include ////////////////////////////////////////////////////////////////////// // Construction/Destruction diff --git a/src/Plot2d/Plot2d_ViewWindow.h b/src/Plot2d/Plot2d_ViewWindow.h index 6ac6970b6..dfc9b4888 100755 --- a/src/Plot2d/Plot2d_ViewWindow.h +++ b/src/Plot2d/Plot2d_ViewWindow.h @@ -2,25 +2,18 @@ #define PLOT2D_VIEWWINDOW_H #include "Plot2d.h" - -#include "Plot2d_ViewModel.h" -#include "Plot2d_ViewFrame.h" - -#include #include -#include - -#include - -#include -#include -#include -#include #ifdef WIN32 #pragma warning( disable:4251 ) #endif +class SUIT_Desktop; +class Plot2d_Viewer; +class Plot2d_ViewFrame; +class QtxAction; +class SUIT_ToolButton; + class PLOT2D_EXPORT Plot2d_ViewWindow : public SUIT_ViewWindow { Q_OBJECT diff --git a/src/SPlot2d/SPlot2d_ViewModel.cxx b/src/SPlot2d/SPlot2d_ViewModel.cxx index 9bd393771..1e84a8d91 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.cxx +++ b/src/SPlot2d/SPlot2d_ViewModel.cxx @@ -323,3 +323,23 @@ SPlot2d_Curve* SPlot2d_Viewer::getCurveByIO( const Handle(SALOME_InteractiveObje return NULL; } +void SPlot2d_Viewer::onCloneView( Plot2d_ViewFrame* clonedVF, Plot2d_ViewFrame* newVF ) +{ + if( !clonedVF || !newVF ) + return; + + // 1) Copy all properties of view + + newVF->copyPreferences( clonedVF ); + + // 2) Display all curves displayed in cloned view + + QList aCurves; + clonedVF->getCurves( aCurves ); + QList::const_iterator anIt = aCurves.begin(), aLast = aCurves.end(); + + for( ; anIt!=aLast; anIt++ ) + if( clonedVF->isVisible( *anIt ) ) + newVF->displayCurve( *anIt, false ); + newVF->Repaint(); +} diff --git a/src/SPlot2d/SPlot2d_ViewModel.h b/src/SPlot2d/SPlot2d_ViewModel.h index 7003990aa..f325b032f 100644 --- a/src/SPlot2d/SPlot2d_ViewModel.h +++ b/src/SPlot2d/SPlot2d_ViewModel.h @@ -55,6 +55,8 @@ public: Plot2d_ViewFrame* getActiveViewFrame(); Handle(SALOME_InteractiveObject) FindIObject( const char* Entry ); +protected slots: + virtual void onCloneView( Plot2d_ViewFrame*, Plot2d_ViewFrame* ); }; -- 2.39.2