From 7c72b644e9ca932d6dd4a60d023c7ccb2cc81030 Mon Sep 17 00:00:00 2001 From: vsr Date: Mon, 17 Jan 2011 09:14:25 +0000 Subject: [PATCH] Add histogram items to the Plot2d viewer --- src/SPlot2d/Makefile.am | 2 + src/SPlot2d/SPlot2d_Curve.cxx | 36 +++---------- src/SPlot2d/SPlot2d_Curve.h | 12 +---- src/SPlot2d/SPlot2d_Histogram.cxx | 84 +++++++++++++++++++++++++++++++ src/SPlot2d/SPlot2d_Histogram.h | 54 ++++++++++++++++++++ src/SPlot2d/SPlot2d_Prs.cxx | 29 +++++++---- src/SPlot2d/SPlot2d_Prs.h | 16 +++--- 7 files changed, 174 insertions(+), 59 deletions(-) create mode 100644 src/SPlot2d/SPlot2d_Histogram.cxx create mode 100644 src/SPlot2d/SPlot2d_Histogram.h diff --git a/src/SPlot2d/Makefile.am b/src/SPlot2d/Makefile.am index 8f9c0ebc5..1bdf874cd 100644 --- a/src/SPlot2d/Makefile.am +++ b/src/SPlot2d/Makefile.am @@ -27,12 +27,14 @@ lib_LTLIBRARIES = libSPlot2d.la salomeinclude_HEADERS = \ SPlot2d.h \ SPlot2d_Curve.h \ + SPlot2d_Histogram.h \ SPlot2d_Prs.h \ SPlot2d_ViewModel.h \ SPlot2d_ViewWindow.h dist_libSPlot2d_la_SOURCES = \ SPlot2d_Curve.cxx \ + SPlot2d_Histogram.cxx \ SPlot2d_Prs.cxx \ SPlot2d_ViewModel.cxx \ SPlot2d_ViewWindow.cxx diff --git a/src/SPlot2d/SPlot2d_Curve.cxx b/src/SPlot2d/SPlot2d_Curve.cxx index 2dba5829f..ebc35f408 100644 --- a/src/SPlot2d/SPlot2d_Curve.cxx +++ b/src/SPlot2d/SPlot2d_Curve.cxx @@ -19,16 +19,10 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - // File : SPlot2d_Curve.cxx -// Author : Sergey RUIN -// Module : SUIT -// -#include "SPlot2d_Curve.h" -#include -#include +// Author : Sergey RUIN, Open CASCADE S.A.S. (sergey.ruin@opencascade.com) -using namespace std; +#include "SPlot2d_Curve.h" /*! Constructor @@ -49,19 +43,10 @@ SPlot2d_Curve::~SPlot2d_Curve() Copy constructor. Makes deep copy of data. */ SPlot2d_Curve::SPlot2d_Curve( const SPlot2d_Curve& curve ) +: Plot2d_Curve( curve ) { - myAutoAssign = curve.isAutoAssign(); - myHorTitle = curve.getHorTitle(); - myVerTitle = curve.getVerTitle(); - myHorUnits = curve.getHorUnits(); - myVerUnits = curve.getVerUnits(); - myColor = curve.getColor(); - myMarker = curve.getMarker(); - myLine = curve.getLine(); - myLineWidth = curve.getLineWidth(); - myPoints = curve.getPointList(); - myIO = curve.getIO(); - myTableIO = curve.getTableIO(); + myIO = curve.getIO(); + myTableIO = curve.getTableIO(); } /*! @@ -69,16 +54,7 @@ SPlot2d_Curve::SPlot2d_Curve( const SPlot2d_Curve& curve ) */ SPlot2d_Curve& SPlot2d_Curve::operator=( const SPlot2d_Curve& curve ) { - myAutoAssign = curve.isAutoAssign(); - myHorTitle = curve.getHorTitle(); - myVerTitle = curve.getVerTitle(); - myHorUnits = curve.getHorUnits(); - myVerUnits = curve.getVerUnits(); - myColor = curve.getColor(); - myMarker = curve.getMarker(); - myLine = curve.getLine(); - myLineWidth = curve.getLineWidth(); - myPoints = curve.getPointList(); + Plot2d_Curve::operator=(curve); myIO = curve.getIO(); myTableIO = curve.getTableIO(); return *this; diff --git a/src/SPlot2d/SPlot2d_Curve.h b/src/SPlot2d/SPlot2d_Curve.h index 6fbe16f1a..7ef107a3a 100644 --- a/src/SPlot2d/SPlot2d_Curve.h +++ b/src/SPlot2d/SPlot2d_Curve.h @@ -19,16 +19,13 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - // File : SPlot2d_Curve.h -// Author : Sergey RUIN -// Module : SUIT -// +// Author : Sergey RUIN, Open CASCADE S.A.S. (sergey.ruin@opencascade.com) + #ifndef SPlot2d_Curve_h #define SPlot2d_Curve_h #include "SPlot2d.h" - #include "Plot2d_Curve.h" #ifndef _Handle_SALOME_InteractiveObject_HeaderFile @@ -36,9 +33,6 @@ #endif #include "SALOME_InteractiveObject.hxx" -class QString; -class QColor; - class SPLOT2D_EXPORT SPlot2d_Curve : public Plot2d_Curve { public: @@ -64,5 +58,3 @@ private: }; #endif // SPlot2d_Curve_h - - diff --git a/src/SPlot2d/SPlot2d_Histogram.cxx b/src/SPlot2d/SPlot2d_Histogram.cxx new file mode 100644 index 000000000..5ca6bc443 --- /dev/null +++ b/src/SPlot2d/SPlot2d_Histogram.cxx @@ -0,0 +1,84 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : SPlot2d_Histogram.cxx +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#include "SPlot2d_Histogram.h" + +/*! + Constructor +*/ +SPlot2d_Histogram::SPlot2d_Histogram() +:Plot2d_Histogram() +{ +} + +/*! + Destructor +*/ +SPlot2d_Histogram::~SPlot2d_Histogram() +{ +} + +/*! + Copy constructor. Makes deep copy of data. +*/ +SPlot2d_Histogram::SPlot2d_Histogram( const SPlot2d_Histogram& hist ) +: Plot2d_Histogram( hist ) +{ + myIO = hist.getIO(); +} + +/*! + operator=. Makes deep copy of data. +*/ +SPlot2d_Histogram& SPlot2d_Histogram::operator=( const SPlot2d_Histogram& hist ) +{ + Plot2d_Histogram::operator=(hist); + myIO = hist.getIO(); + return *this; +} + +/*! + \return corresponding SALOME_InteractiveObject +*/ +Handle(SALOME_InteractiveObject) SPlot2d_Histogram::getIO() const +{ + return myIO; +} + +/*! + Sets corresponding SALOME_InteractiveObject + \param io - SALOME_InteractiveObject +*/ +void SPlot2d_Histogram::setIO( const Handle(SALOME_InteractiveObject)& io ) +{ + myIO = io; +} + +/*! + \return SALOME_InteractiveObject +*/ +bool SPlot2d_Histogram::hasIO() const +{ + return !myIO.IsNull(); +} diff --git a/src/SPlot2d/SPlot2d_Histogram.h b/src/SPlot2d/SPlot2d_Histogram.h new file mode 100644 index 000000000..b9fcdb2f1 --- /dev/null +++ b/src/SPlot2d/SPlot2d_Histogram.h @@ -0,0 +1,54 @@ +// Copyright (C) 2007-2010 CEA/DEN, EDF R&D, OPEN CASCADE +// +// Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN, +// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS +// +// This library is free software; you can redistribute it and/or +// modify it under the terms of the GNU Lesser General Public +// License as published by the Free Software Foundation; either +// version 2.1 of the License. +// +// This library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +// Lesser General Public License for more details. +// +// You should have received a copy of the GNU Lesser General Public +// License along with this library; if not, write to the Free Software +// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +// +// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com +// +// File : SPlot2d_Histogram.h +// Author : Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com) + +#ifndef SPlot2d_Histogram_h +#define SPlot2d_Histogram_h + +#include "SPlot2d.h" + +#include "Plot2d_Histogram.h" + +#ifndef _Handle_SALOME_InteractiveObject_HeaderFile +#include +#endif +#include "SALOME_InteractiveObject.hxx" + +class SPLOT2D_EXPORT SPlot2d_Histogram : public Plot2d_Histogram +{ +public: + + SPlot2d_Histogram(); + virtual ~SPlot2d_Histogram(); + SPlot2d_Histogram( const SPlot2d_Histogram& hist ); + SPlot2d_Histogram& operator= ( const SPlot2d_Histogram& hist ); + + virtual bool hasIO() const; + virtual Handle(SALOME_InteractiveObject) getIO() const; + virtual void setIO( const Handle(SALOME_InteractiveObject)& ); + +private: + Handle(SALOME_InteractiveObject) myIO; +}; + +#endif // SPlot2d_Histogram_h diff --git a/src/SPlot2d/SPlot2d_Prs.cxx b/src/SPlot2d/SPlot2d_Prs.cxx index c7ef2d7b5..9c0e6d0c4 100644 --- a/src/SPlot2d/SPlot2d_Prs.cxx +++ b/src/SPlot2d/SPlot2d_Prs.cxx @@ -19,15 +19,10 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - // File : SPlot2d_Prs.cxx -// Author : Sergey RUIN -// Module : SUIT -// +// Author : Sergey RUIN, Open CASCADE S.A.S. (sergey.ruin@opencascade.com) + #include "SPlot2d_Prs.h" -#ifndef WIN32 -using namespace std; -#endif /*! Default constructor @@ -40,7 +35,7 @@ SPlot2d_Prs::SPlot2d_Prs() /*! Standard constructor */ -SPlot2d_Prs::SPlot2d_Prs( const Plot2d_Curve* obj ) +SPlot2d_Prs::SPlot2d_Prs( const Plot2d_Object* obj ) :Plot2d_Prs(obj) { } @@ -51,7 +46,8 @@ SPlot2d_Prs::SPlot2d_Prs( const Plot2d_Curve* obj ) SPlot2d_Prs::SPlot2d_Prs( const Plot2d_Prs* prs ) { mySecondY = prs->isSecondY(); - myCurves = prs->getCurves(); + myObjects = prs->getObjects(); + myIsAutoDel = false; // VSR: error? should auto-delete flag be removed } /*! @@ -62,3 +58,18 @@ SPlot2d_Prs::~SPlot2d_Prs() } +/*! + Check if the presentation is empty +*/ +bool SPlot2d_Prs::IsNull() const +{ + return Plot2d_Prs::IsNull(); +} + +/*! + Get contained objects +*/ +objectList SPlot2d_Prs::GetObjects() const +{ + return getObjects(); +} diff --git a/src/SPlot2d/SPlot2d_Prs.h b/src/SPlot2d/SPlot2d_Prs.h index 3bf047570..9210d9064 100644 --- a/src/SPlot2d/SPlot2d_Prs.h +++ b/src/SPlot2d/SPlot2d_Prs.h @@ -19,11 +19,9 @@ // // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com // - // File : SPlot2d_Prs.h -// Author : Sergey RUIN -// Module : SUIT -// +// Author : Sergey RUIN, Open CASCADE S.A.S. (sergey.ruin@opencascade.com) + #ifndef SPLOT2D_PRS_H #define SPLOT2D_PRS_H @@ -36,24 +34,22 @@ class Plot2d_Curve; class SPLOT2D_EXPORT SPlot2d_Prs : public SALOME_Prs2d, public Plot2d_Prs { public: - // Default constructor SPlot2d_Prs(); // Standard constructor - SPlot2d_Prs( const Plot2d_Curve* obj ); + SPlot2d_Prs( const Plot2d_Object* obj ); SPlot2d_Prs( const Plot2d_Prs* prs ); // Destructor ~SPlot2d_Prs(); - virtual bool IsNull() const { return Plot2d_Prs::IsNull(); } + virtual bool IsNull() const; // Get curves list - // Note: Depricated method, use method getCurves - curveList GetObjects() const { return getCurves(); } - + // Note: Deprecated method, use method getCurves + objectList GetObjects() const; }; #endif -- 2.39.2