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>
29 #include "HYDRO_trace.hxx"
31 HYDROGUI_AbstractDisplayer::HYDROGUI_AbstractDisplayer( HYDROGUI_Module* theModule )
32 : myModule( theModule )
36 HYDROGUI_AbstractDisplayer::~HYDROGUI_AbstractDisplayer()
40 bool HYDROGUI_AbstractDisplayer::IsApplicable( const size_t theViewerId ) const
42 return IsApplicable( myModule->getViewManager( theViewerId ) );
45 bool HYDROGUI_AbstractDisplayer::IsApplicable( const SUIT_ViewManager* theViewMgr ) const
47 return ( theViewMgr && ( theViewMgr->getType() == GetType() ) );
50 void HYDROGUI_AbstractDisplayer::UpdateAll( const size_t theViewerId,
52 const bool theIsForced,
53 const bool theDoFitAll )
55 DEBTRACE("UpdateAll");
57 EraseAll( theViewerId );
59 DisplayAll( theViewerId, theIsForced, theDoFitAll );
62 void HYDROGUI_AbstractDisplayer::DisplayAll( const size_t theViewerId,
63 const bool theIsForced,
64 const bool theDoFitAll )
66 DEBTRACE("DisplayAll");
67 HYDROData_SequenceOfObjects aSeq;
68 HYDROGUI_Tool::GetPrsSubObjects( myModule, aSeq );
69 Update( aSeq, theViewerId, theIsForced, theDoFitAll );
72 void HYDROGUI_AbstractDisplayer::Update( const HYDROData_SequenceOfObjects& theObjs,
73 const size_t theViewerId,
74 const bool theIsForced,
75 const bool theDoFitAll )
78 // First of all, kill all bad presentations
79 purgeObjects( theViewerId );
81 // Now dig in the data model
82 HYDROData_SequenceOfObjects anObjectsToErase, anObjectsToDisplay;
83 SUIT_ViewModel* aViewer = module()->getViewManager( theViewerId )->getViewModel();
85 for( int i = 1, n = theObjs.Length(); i <= n; i++ )
87 const Handle(HYDROData_Entity)& anObj = theObjs.Value( i );
89 if( module()->isObjectVisible( (size_t)aViewer, anObj ) )
91 anObjectsToDisplay.Append( anObj );
95 anObjectsToErase.Append( anObj );
99 if( anObjectsToErase.Length() )
100 Erase( anObjectsToErase, theViewerId );
101 if( anObjectsToDisplay.Length() )
102 Display( anObjectsToDisplay, theViewerId, theIsForced, theDoFitAll );