From 8c3bb27be497dd3fea078b26d8b801ed77579a47 Mon Sep 17 00:00:00 2001 From: rkv Date: Mon, 18 Nov 2013 06:08:47 +0000 Subject: [PATCH] Fix for the bug #56: Show, Show only, Hide for Region and Zone under Region. --- src/HYDROGUI/HYDROGUI_AbstractDisplayer.cxx | 82 +++++++++++++ src/HYDROGUI/HYDROGUI_AbstractDisplayer.h | 128 ++++++++++++++++++++ 2 files changed, 210 insertions(+) create mode 100644 src/HYDROGUI/HYDROGUI_AbstractDisplayer.cxx create mode 100644 src/HYDROGUI/HYDROGUI_AbstractDisplayer.h diff --git a/src/HYDROGUI/HYDROGUI_AbstractDisplayer.cxx b/src/HYDROGUI/HYDROGUI_AbstractDisplayer.cxx new file mode 100644 index 00000000..7817f3cc --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_AbstractDisplayer.cxx @@ -0,0 +1,82 @@ +// Copyright (C) 2007-2013 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 +// + +#include "HYDROGUI_AbstractDisplayer.h" + +#include "HYDROGUI_DataModel.h" +#include "HYDROGUI_Module.h" +#include "HYDROGUI_Tool.h" + +HYDROGUI_AbstractDisplayer::HYDROGUI_AbstractDisplayer( HYDROGUI_Module* theModule ) +: myModule( theModule ) +{ +} + +HYDROGUI_AbstractDisplayer::~HYDROGUI_AbstractDisplayer() +{ +} + +void HYDROGUI_AbstractDisplayer::UpdateAll( const int theViewerId, + const bool theIsInit, + const bool theIsForced, + const bool theDoFitAll ) +{ + if ( theIsInit ) + EraseAll( theViewerId ); + + DisplayAll( theViewerId, theIsForced, theDoFitAll ); +} + +void HYDROGUI_AbstractDisplayer::DisplayAll( const int theViewerId, + const bool theIsForced, + const bool theDoFitAll ) +{ + HYDROData_SequenceOfObjects aSeq; + HYDROGUI_Tool::GetPrsSubObjects( myModule, aSeq ); + Update( aSeq, theViewerId, theIsForced, theDoFitAll ); +} + +void HYDROGUI_AbstractDisplayer::Update( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId, + const bool theIsForced, + const bool theDoFitAll ) +{ + // First of all, kill all bad presentations + purgeObjects( theViewerId ); + + // Now dig in the data model + HYDROData_SequenceOfObjects anObjectsToErase, anObjectsToDisplay; + + for( int i = 1, n = theObjs.Length(); i <= n; i++ ) + { + const Handle(HYDROData_Entity)& anObj = theObjs.Value( i ); + if( anObj.IsNull() ) + anObjectsToErase.Append( anObj ); + else + anObjectsToDisplay.Append( anObj ); + } + + if( anObjectsToErase.Length() ) + Erase( anObjectsToErase, theViewerId ); + if( anObjectsToDisplay.Length() ) + Display( anObjectsToDisplay, theViewerId, theIsForced, theDoFitAll ); +} diff --git a/src/HYDROGUI/HYDROGUI_AbstractDisplayer.h b/src/HYDROGUI/HYDROGUI_AbstractDisplayer.h new file mode 100644 index 00000000..ec3f9ed4 --- /dev/null +++ b/src/HYDROGUI/HYDROGUI_AbstractDisplayer.h @@ -0,0 +1,128 @@ +// Copyright (C) 2007-2013 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 +// + +#ifndef HYDROGUI_ABSTRACT_DISPLAYER_H +#define HYDROGUI_ABSTRACT_DISPLAYER_H + +#include + +class HYDROGUI_Module; + +/** + * \class HYDROGUI_DataModel + * \brief Class intended to create, display and update the presentations. + */ +class HYDROGUI_AbstractDisplayer +{ +public: + /** + * \brief Constructor. + * \param theModule module object + */ + HYDROGUI_AbstractDisplayer( HYDROGUI_Module* theModule ); + + /** + * \brief Destructor. + */ + virtual ~HYDROGUI_AbstractDisplayer(); + +public: + /** + * \brief Update all objects in the viewer. + * \param theViewerId viewer identifier + * \param theIsInit flag used for initial update + * \param theIsForced flag used to update all objects, including the unchanged ones + */ + virtual void UpdateAll( const int theViewerId, + const bool theIsInit, + const bool theIsForced, + const bool theDoFitAll ); + + /** + * \brief Force the specified objects to be updated. + * \param theObjs sequence of objects to update + * \param theViewerId viewer identifier + */ + virtual void SetToUpdate( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId ) = 0; + +protected: + /** + * \brief Update and display all objects in the viewer. + * \param theViewerId viewer identifier + * \param theIsForced flag used to update all objects, including the unchanged ones + */ + virtual void DisplayAll( const int theViewerId, + const bool theIsForced, + const bool theDoFitAll ); + + /** + * \brief Update the specified viewer objects. + * \param theObjs sequence of objects to update + * \param theViewerId viewer identifier + * \param theIsForced flag used to update all objects, including the unchanged ones + * \param theDoFitAll flag used to fit the view to all visible objects; do not fit by default + */ + virtual void Update( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId, + const bool theIsForced, + const bool theDoFitAll ); + + /** + * \brief Erase all viewer objects. + * \param theViewerId viewer identifier + */ + virtual void EraseAll( const int theViewerId ) = 0; + + /** + * \brief Erase the specified viewer objects. + * \param theObjs sequence of objects to erase + * \param theViewerId viewer identifier + */ + virtual void Erase( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId ) = 0; + + /** + * \brief Display the specified viewer objects. + * \param theObjs sequence of objects to display + * \param theViewerId viewer identifier + * \param theIsForced flag used to update all objects, including the unchanged ones + * \param theDoFitAll flag used to fit the view to all visible objects; do not fit by default + */ + virtual void Display( const HYDROData_SequenceOfObjects& theObjs, + const int theViewerId, + const bool theIsForced, + const bool theDoFitAll ) = 0; + + /** + * \brief Purge all invalid objects in the viewer. + * \param theViewerId viewer identifier + */ + virtual void purgeObjects( const int theViewerId ) = 0; + + HYDROGUI_Module* module() const {return myModule;} + +private: + HYDROGUI_Module* myModule; +}; + +#endif -- 2.39.2