1 // Copyright (C) 2014-2015 EDF-R&D
2 // This library is free software; you can redistribute it and/or
3 // modify it under the terms of the GNU Lesser General Public
4 // License as published by the Free Software Foundation; either
5 // version 2.1 of the License, or (at your option) any later version.
7 // This library is distributed in the hope that it will be useful,
8 // but WITHOUT ANY WARRANTY; without even the implied warranty of
9 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 // Lesser General Public License for more details.
12 // You should have received a copy of the GNU Lesser General Public
13 // License along with this library; if not, write to the Free Software
14 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
16 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
19 #include "HYDROGUI_AbstractDisplayer.h"
21 #include "HYDROGUI_DataModel.h"
22 #include "HYDROGUI_Module.h"
23 #include "HYDROGUI_Tool2.h"
25 #include <SUIT_ViewManager.h>
26 #include <SUIT_ViewModel.h>
28 HYDROGUI_AbstractDisplayer::HYDROGUI_AbstractDisplayer( HYDROGUI_Module* theModule )
29 : myModule( theModule )
33 HYDROGUI_AbstractDisplayer::~HYDROGUI_AbstractDisplayer()
37 bool HYDROGUI_AbstractDisplayer::IsApplicable( const int theViewerId ) const
39 return IsApplicable( myModule->getViewManager( theViewerId ) );
42 bool HYDROGUI_AbstractDisplayer::IsApplicable( const SUIT_ViewManager* theViewMgr ) const
44 return ( theViewMgr && ( theViewMgr->getType() == GetType() ) );
47 void HYDROGUI_AbstractDisplayer::UpdateAll( const int theViewerId,
49 const bool theIsForced,
50 const bool theDoFitAll )
53 EraseAll( theViewerId );
55 DisplayAll( theViewerId, theIsForced, theDoFitAll );
58 void HYDROGUI_AbstractDisplayer::DisplayAll( const int theViewerId,
59 const bool theIsForced,
60 const bool theDoFitAll )
62 HYDROData_SequenceOfObjects aSeq;
63 HYDROGUI_Tool::GetPrsSubObjects( myModule, aSeq );
64 Update( aSeq, theViewerId, theIsForced, theDoFitAll );
67 void HYDROGUI_AbstractDisplayer::Update( const HYDROData_SequenceOfObjects& theObjs,
68 const int theViewerId,
69 const bool theIsForced,
70 const bool theDoFitAll )
72 // First of all, kill all bad presentations
73 purgeObjects( theViewerId );
75 // Now dig in the data model
76 HYDROData_SequenceOfObjects anObjectsToErase, anObjectsToDisplay;
77 SUIT_ViewModel* aViewer = module()->getViewManager( theViewerId )->getViewModel();
79 for( int i = 1, n = theObjs.Length(); i <= n; i++ )
81 const Handle(HYDROData_Entity)& anObj = theObjs.Value( i );
83 if( module()->isObjectVisible( (size_t)aViewer, anObj ) )
85 anObjectsToDisplay.Append( anObj );
89 anObjectsToErase.Append( anObj );
93 if( anObjectsToErase.Length() )
94 Erase( anObjectsToErase, theViewerId );
95 if( anObjectsToDisplay.Length() )
96 Display( anObjectsToDisplay, theViewerId, theIsForced, theDoFitAll );