1 // Copyright (C) 2007-2016 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License, or (at your option) any later version.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
23 // SMESH SMESHGUI : GUI for SMESH component
24 // File : SMESHGUI_VTKUtils.cxx
25 // Author : Open CASCADE S.A.S.
28 #include "SMESHGUI_VTKUtils.h"
31 #include "SMESHGUI_Filter.h"
32 #include "SMESHGUI_Utils.h"
33 #include "SMDS_Mesh.hxx"
34 #include "SMESH_Actor.h"
35 #include "SMESH_ActorUtils.h"
36 #include "SMESH_CellLabelActor.h"
37 #include "SMESH_ControlsDef.hxx"
38 #include "SMESH_NodeLabelActor.h"
39 #include "SMESH_ObjectDef.h"
41 // SALOME GUI includes
42 #include <SUIT_Desktop.h>
43 #include <SUIT_Session.h>
44 #include <SUIT_MessageBox.h>
45 #include <SUIT_ViewManager.h>
46 #include <SUIT_ResourceMgr.h>
48 #include <SALOME_ListIO.hxx>
50 #include <SVTK_Selector.h>
51 #include <SVTK_ViewModel.h>
52 #include <SVTK_ViewWindow.h>
54 #include <VTKViewer_Algorithm.h>
56 #include <LightApp_SelectionMgr.h>
57 #include <SalomeApp_Application.h>
58 #include <SalomeApp_Study.h>
60 // SALOME KERNEL includes
61 #include <utilities.h>
64 #include <SALOMEconfig.h>
65 #include CORBA_CLIENT_HEADER(SMESH_Mesh)
66 #include CORBA_CLIENT_HEADER(SMESH_Group)
70 #include <vtkRenderer.h>
71 #include <vtkActorCollection.h>
72 #include <vtkUnstructuredGrid.h>
75 #include <Standard_ErrorHandler.hxx>
79 typedef std::map<std::string,TVisualObjPtr> TVisualObjCont;
80 static TVisualObjCont VISUAL_OBJ_CONT;
82 //=============================================================================
84 * \brief Allocate some memory at construction and release it at destruction.
85 * Is used to be able to continue working after mesh generation or visualization
86 * break due to lack of memory
88 //=============================================================================
93 MemoryReserve(): myBuf( new char[1024*1024*1] ){} // 1M
94 void Free() { if (myBuf) { delete [] myBuf; myBuf = 0; }}
95 ~MemoryReserve() { Free(); }
97 static MemoryReserve* theVISU_MemoryReserve = new MemoryReserve;
99 //================================================================================
101 * \brief Remove VisualObj and its actor from all views
103 //================================================================================
105 void RemoveVisualObjectWithActors( const char* theEntry, bool fromAllViews )
107 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>(SUIT_Session::session()->activeApplication());
110 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(app->activeStudy());
113 ViewManagerList aList;
116 app->viewManagers(SVTK_Viewer::Type() , aList);
118 SUIT_ViewManager* aVM = app->getViewManager(SVTK_Viewer::Type(), true);
122 bool actorRemoved = false;
123 ViewManagerList::ConstIterator it = aList.begin();
124 SUIT_ViewManager* aViewManager = 0;
125 for( ; it!=aList.end();it++) {
127 QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
128 for ( int iV = 0; iV < views.count(); ++iV ) {
129 if ( SMESH_Actor* actor = FindActorByEntry( views[iV], theEntry)) {
130 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
131 vtkWnd->RemoveActor(actor);
139 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(theEntry);
140 if(anIter != VISUAL_OBJ_CONT.end()) {
141 // for unknown reason, object destructor is not called, so clear object manually
142 anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
143 anIter->second->GetUnstructuredGrid()->SetPoints(0);
145 VISUAL_OBJ_CONT.erase(theEntry);
148 aStudy->setVisibilityState(theEntry, Qtx::HiddenState);
150 //================================================================================
152 * \brief Remove all VisualObjs and their actors from all views
154 //================================================================================
156 void RemoveAllObjectsWithActors()
158 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
159 ( SUIT_Session::session()->activeApplication() );
161 ViewManagerList viewMgrs = app->viewManagers();
162 for ( int iM = 0; iM < viewMgrs.count(); ++iM ) {
163 SUIT_ViewManager* aViewManager = viewMgrs.at( iM );
164 if ( aViewManager && aViewManager->getType() == SVTK_Viewer::Type()) {
165 QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
166 for ( int iV = 0; iV < views.count(); ++iV ) {
167 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
168 vtkRenderer *aRenderer = vtkWnd->getRenderer();
169 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
170 vtkActorCollection *actors = aCopy.GetActors();
171 for (int i = 0; i < actors->GetNumberOfItems(); ++i ) {
172 // size of actors changes inside the loop
173 if (SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i)))
175 vtkWnd->RemoveActor(actor);
183 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.begin();
184 for ( ; anIter != VISUAL_OBJ_CONT.end(); ++anIter ) {
185 // for unknown reason, object destructor is not called, so clear object manually
186 anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
187 anIter->second->GetUnstructuredGrid()->SetPoints(0);
189 VISUAL_OBJ_CONT.clear();
192 //================================================================================
194 * \brief Remove all VisualObjs of a study
196 //================================================================================
198 void RemoveVisuData()
200 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>
201 ( SUIT_Session::session()->activeApplication() );
203 ViewManagerList viewMgrs = app->viewManagers();
204 for ( int iM = 0; iM < viewMgrs.count(); ++iM ) {
205 SUIT_ViewManager* aViewManager = viewMgrs.at( iM );
206 if ( aViewManager && aViewManager->getType() == SVTK_Viewer::Type() ) {
207 QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
208 for ( int iV = 0; iV < views.count(); ++iV ) {
209 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
210 vtkRenderer *aRenderer = vtkWnd->getRenderer();
211 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
212 vtkActorCollection *actors = aCopy.GetActors();
213 for (int i = 0; i < actors->GetNumberOfItems(); ++i ) {
214 // size of actors changes inside the loop
215 if(SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i)))
217 vtkWnd->RemoveActor(actor);
225 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.begin();
226 for ( ; anIter != VISUAL_OBJ_CONT.end(); ) {
227 // for unknown reason, object destructor is not called, so clear object manually
228 anIter->second->GetUnstructuredGrid()->SetCells(0,0,0,0,0);
229 anIter->second->GetUnstructuredGrid()->SetPoints(0);
230 VISUAL_OBJ_CONT.erase( anIter++ ); // anIter++ returns a copy of self before incrementing
234 //================================================================================
236 * \brief Notify the user on problems during visualization
238 //================================================================================
240 void OnVisuException()
244 // PAL16774 (Crash after display of many groups). Salome sometimes crashes just
245 // after or at showing this message, so we do an additional check of available memory
246 // char* buf = new char[100*1024];
248 SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
249 QObject::tr("SMESH_VISU_PROBLEM"));
251 // no more memory at all: last resort
252 MESSAGE_BEGIN ( "SMESHGUI_VTKUtils::OnVisuException(), exception even at showing a message!!!" <<
253 std::endl << "Try to remove all visual data..." );
254 if (theVISU_MemoryReserve) {
255 delete theVISU_MemoryReserve;
256 theVISU_MemoryReserve = 0;
258 RemoveAllObjectsWithActors();
259 SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
260 QObject::tr("SMESH_VISU_PROBLEM_CLEAR"));
261 MESSAGE_END ( "...done" );
264 //================================================================================
266 * \brief Returns an updated visual object
268 //================================================================================
270 TVisualObjPtr GetVisualObj(const char* theEntry, bool nulData){
271 TVisualObjPtr aVisualObj;
274 TVisualObjCont::iterator anIter = VISUAL_OBJ_CONT.find(theEntry);
275 if(anIter != VISUAL_OBJ_CONT.end()){
276 aVisualObj = anIter->second;
278 SalomeApp_Application* app =
279 dynamic_cast<SalomeApp_Application*>( SMESHGUI::activeStudy()->application() );
280 _PTR(Study) aStudy = SMESH::getStudy();
281 _PTR(SObject) aSObj = aStudy->FindObjectID(theEntry);
283 _PTR(GenericAttribute) anAttr;
284 if(aSObj->FindAttribute(anAttr,"AttributeIOR")){
285 _PTR(AttributeIOR) anIOR = anAttr;
286 CORBA::String_var aVal = anIOR->Value().c_str();
287 CORBA::Object_var anObj = app->orb()->string_to_object( aVal.in() );
288 if(!CORBA::is_nil(anObj)){
289 //Try narrow to SMESH_Mesh interface
290 SMESH::SMESH_Mesh_var aMesh = SMESH::SMESH_Mesh::_narrow(anObj);
291 if(!aMesh->_is_nil()){
292 aVisualObj.reset(new SMESH_MeshObj(aMesh));
293 TVisualObjCont::value_type aValue(theEntry,aVisualObj);
294 VISUAL_OBJ_CONT.insert(aValue);
296 //Try narrow to SMESH_Group interface
297 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow(anObj);
298 if(!aGroup->_is_nil()){
299 _PTR(SObject) aFatherSObj = aSObj->GetFather();
300 if(!aFatherSObj) return aVisualObj;
301 aFatherSObj = aFatherSObj->GetFather();
302 if(!aFatherSObj) return aVisualObj;
303 CORBA::String_var anEntry = aFatherSObj->GetID().c_str();
304 TVisualObjPtr aVisObj = GetVisualObj(anEntry.in());
305 if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
306 aVisualObj.reset(new SMESH_GroupObj(aGroup,aMeshObj));
307 TVisualObjCont::value_type aValue(theEntry,aVisualObj);
308 VISUAL_OBJ_CONT.insert(aValue);
311 //Try narrow to SMESH_subMesh interface
312 SMESH::SMESH_subMesh_var aSubMesh = SMESH::SMESH_subMesh::_narrow(anObj);
313 if(!aSubMesh->_is_nil()){
314 _PTR(SObject) aFatherSObj = aSObj->GetFather();
315 if(!aFatherSObj) return aVisualObj;
316 aFatherSObj = aFatherSObj->GetFather();
317 if(!aFatherSObj) return aVisualObj;
318 CORBA::String_var anEntry = aFatherSObj->GetID().c_str();
319 TVisualObjPtr aVisObj = GetVisualObj(anEntry.in());
320 if(SMESH_MeshObj* aMeshObj = dynamic_cast<SMESH_MeshObj*>(aVisObj.get())){
321 aVisualObj.reset(new SMESH_subMeshObj(aSubMesh,aMeshObj));
322 TVisualObjCont::value_type aValue(theEntry,aVisualObj);
323 VISUAL_OBJ_CONT.insert(aValue);
331 INFOS("GetMeshObj - There is no SMESH_Mesh object for the SALOMEDS::Strudy and Entry!!!");
332 return TVisualObjPtr();
335 bool objModified = false;
340 objModified = aVisualObj->NulData();
342 objModified = aVisualObj->Update();
345 MESSAGE ( "Exception in SMESHGUI_VTKUtils::GetVisualObj()" );
346 RemoveVisualObjectWithActors( theEntry ); // remove this object
353 // PAL16631. Measurements showed that to show aVisualObj in SHADING(default) mode,
354 // ~5 times more memory is used than it occupies.
355 // Warn the user if there is less free memory than 30 sizes of a grid
356 // TODO: estimate memory usage in other modes and take current mode into account
357 int freeMB = SMDS_Mesh::CheckMemory(true);
358 int usedMB = aVisualObj->GetUnstructuredGrid()->GetActualMemorySize() / 1024;
359 //MESSAGE("SMESHGUI_VTKUtils::GetVisualObj(), freeMB=" << freeMB << ", usedMB=" <<usedMB);
360 if ( freeMB > 0 && usedMB * 5 > freeMB ) {
361 bool continu = false;
362 if ( usedMB * 3 > freeMB )
363 // don't even try to show
364 SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
365 QObject::tr("SMESH_NO_MESH_VISUALIZATION"));
367 // there is a chance to succeed
368 continu = SUIT_MessageBox::warning
369 (SMESHGUI::desktop(),
370 QObject::tr("SMESH_WRN_WARNING"),
371 QObject::tr("SMESH_CONTINUE_MESH_VISUALIZATION"),
372 SUIT_MessageBox::Yes | SUIT_MessageBox::No,
373 SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes;
375 // remove the corresponding actors from all views
376 RemoveVisualObjectWithActors( theEntry );
386 /*! Return active view window, if it instantiates SVTK_ViewWindow class,
387 * otherwise find or create corresponding view window, make it active and return it.
388 * \note Active VVTK_ViewWindow can be returned, because it inherits SVTK_ViewWindow.
390 SVTK_ViewWindow* GetViewWindow (const SalomeApp_Module* theModule,
391 bool createIfNotFound)
393 SalomeApp_Application* anApp;
395 anApp = theModule->getApp();
397 anApp = dynamic_cast<SalomeApp_Application*>
398 (SUIT_Session::session()->activeApplication());
401 if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(anApp->desktop()->activeWindow()))
404 SUIT_ViewManager* aViewManager =
405 anApp->getViewManager(SVTK_Viewer::Type(), createIfNotFound);
407 if (SUIT_ViewWindow* aViewWindow = aViewManager->getActiveView()) {
408 if (SVTK_ViewWindow* aView = dynamic_cast<SVTK_ViewWindow*>(aViewWindow)) {
409 aViewWindow->raise();
410 aViewWindow->setFocus();
419 SVTK_ViewWindow* FindVtkViewWindow (SUIT_ViewManager* theMgr,
420 SUIT_ViewWindow * theWindow)
425 QVector<SUIT_ViewWindow*> views = theMgr->getViews();
426 if( views.contains( theWindow ) )
427 return GetVtkViewWindow( theWindow );
432 SVTK_ViewWindow* GetVtkViewWindow(SUIT_ViewWindow* theWindow){
433 return dynamic_cast<SVTK_ViewWindow*>(theWindow);
436 /* SUIT_ViewWindow* GetActiveWindow()
438 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
441 SUIT_ViewManager* mgr = app->activeViewManager();
443 return mgr->getActiveView();
448 SVTK_ViewWindow* GetCurrentVtkView(){
449 return GetVtkViewWindow( GetActiveWindow() );
453 void RepaintCurrentView()
455 if (SVTK_ViewWindow* wnd = GetCurrentVtkView())
459 wnd->getRenderer()->Render();
463 MESSAGE ( "Exception in SMESHGUI_VTKUtils::RepaintCurrentView()" );
469 void RepaintViewWindow(SVTK_ViewWindow* theWindow)
473 theWindow->getRenderer()->Render();
474 theWindow->Repaint();
477 MESSAGE ( "Exception in SMESHGUI_VTKUtils::RepaintViewWindow(SVTK_ViewWindow*)" );
482 void RenderViewWindow(SVTK_ViewWindow* theWindow)
486 theWindow->getRenderer()->Render();
487 theWindow->Repaint();
490 MESSAGE ( "Exception in SMESHGUI_VTKUtils::RenderViewWindow(SVTK_ViewWindow*)" );
496 if(SVTK_ViewWindow* wnd = GetCurrentVtkView() ){
503 MESSAGE ( "Exception in SMESHGUI_VTKUtils::FitAll()" );
510 SMESH_Actor* FindActorByEntry(SUIT_ViewWindow *theWindow,
511 const char* theEntry)
513 if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow)){
514 vtkRenderer *aRenderer = aViewWindow->getRenderer();
515 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
516 vtkActorCollection *aCollection = aCopy.GetActors();
517 aCollection->InitTraversal();
518 while(vtkActor *anAct = aCollection->GetNextActor()){
519 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
520 if(anActor->hasIO()){
521 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
522 if(anIO->hasEntry() && strcmp(anIO->getEntry(),theEntry) == 0){
533 SMESH_Actor* FindActorByEntry(const char* theEntry){
534 return FindActorByEntry(GetActiveWindow(),theEntry);
538 SMESH_Actor* FindActorByObject(CORBA::Object_ptr theObject){
539 SalomeApp_Application* app = dynamic_cast<SalomeApp_Application*>( SUIT_Session::session()->activeApplication() );
543 if(!CORBA::is_nil(theObject)){
544 _PTR(Study) aStudy = getStudy();
545 CORBA::String_var anIOR = app->orb()->object_to_string( theObject );
546 _PTR(SObject) aSObject = aStudy->FindObjectIOR(anIOR.in());
548 CORBA::String_var anEntry = aSObject->GetID().c_str();
549 return FindActorByEntry(anEntry.in());
556 SMESH_Actor* CreateActor(const char* theEntry,
559 SMESH_Actor *anActor = NULL;
560 if(TVisualObjPtr aVisualObj = GetVisualObj(theEntry)){
561 _PTR(SObject) aSObj = getStudy()->FindObjectID(theEntry);
563 _PTR(GenericAttribute) anAttr;
564 if(aSObj->FindAttribute(anAttr,"AttributeName")){
565 _PTR(AttributeName) aName = anAttr;
566 std::string aNameVal = aName->Value();
567 anActor = SMESH_Actor::New(aVisualObj,theEntry,aNameVal.c_str(),theIsClear);
570 SMESH::SMESH_GroupBase_var aGroup = SMESH::SMESH_GroupBase::_narrow( SMESH::SObjectToObject( aSObj ));
571 if(!CORBA::is_nil(aGroup) && anActor)
575 SMESH::GetColor( "SMESH", "fill_color", c, deltaF, "0,170,255|-100" );
576 SMESH::GetColor( "SMESH", "volume_color", c, deltaV, "255,0,170|-100" );
577 c = SMESH::GetColor( "SMESH", "default_grp_color", c );
578 SALOMEDS::Color aColor = aGroup->GetColor();
579 if( !( aColor.R > 0 || aColor.G > 0 || aColor.B > 0 ))
582 aColor.G = c.greenF();
583 aColor.B = c.blueF();
584 aGroup->SetColor( aColor );
586 if( aGroup->GetType() == SMESH::NODE )
587 anActor->SetNodeColor( aColor.R, aColor.G, aColor.B );
588 else if( aGroup->GetType() == SMESH::EDGE )
589 anActor->SetEdgeColor( aColor.R, aColor.G, aColor.B );
590 else if( aGroup->GetType() == SMESH::ELEM0D )
591 anActor->Set0DColor( aColor.R, aColor.G, aColor.B );
592 else if( aGroup->GetType() == SMESH::BALL )
593 anActor->SetBallColor( aColor.R, aColor.G, aColor.B );
594 else if( aGroup->GetType() == SMESH::VOLUME )
595 anActor->SetVolumeColor( aColor.R, aColor.G, aColor.B, deltaV );
597 anActor->SetSufaceColor( aColor.R, aColor.G, aColor.B, deltaF );
601 //MESSAGE("CreateActor " << anActor);
603 if( SMESHGUI* aSMESHGUI = SMESHGUI::GetSMESHGUI() )
604 aSMESHGUI->addActorAsObserver( anActor );
609 void DisplayActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor){
610 if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)){
613 //MESSAGE("DisplayActor " << theActor);
614 vtkWnd->AddActor(theActor);
618 MESSAGE ( "Exception in SMESHGUI_VTKUtils::DisplayActor()" );
625 void RemoveActor( SUIT_ViewWindow *theWnd, SMESH_Actor* theActor)
627 if ( SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd)) {
628 //MESSAGE("RemoveActor " << theActor);
629 vtkWnd->RemoveActor(theActor);
630 if(theActor->hasIO()){
631 Handle(SALOME_InteractiveObject) anIO = theActor->getIO();
632 if(anIO->hasEntry()){
633 std::string anEntry = anIO->getEntry();
634 VISUAL_OBJ_CONT.erase(anEntry);
642 //================================================================================
644 * \brief Return true if there are no SMESH actors in a view
646 //================================================================================
648 bool noSmeshActors(SUIT_ViewWindow *theWnd)
650 if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWnd)) {
651 vtkRenderer *aRenderer = aViewWindow->getRenderer();
652 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
653 vtkActorCollection *aCollection = aCopy.GetActors();
654 aCollection->InitTraversal();
655 while(vtkActor *anAct = aCollection->GetNextActor())
656 if(dynamic_cast<SMESH_Actor*>(anAct))
662 bool UpdateView(SUIT_ViewWindow *theWnd, EDisplaing theAction, const char* theEntry)
664 //MESSAGE("UpdateView");
666 SVTK_ViewWindow* aViewWnd = GetVtkViewWindow(theWnd);
670 SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(theWnd);
674 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>( vtkWnd->getViewManager()->study() );
681 vtkRenderer *aRenderer = aViewWnd->getRenderer();
682 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
683 vtkActorCollection *aCollection = aCopy.GetActors();
684 aCollection->InitTraversal();
688 while (vtkActor *anAct = aCollection->GetNextActor()) {
689 if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
690 //MESSAGE("--- display " << anActor);
691 anActor->SetVisibility(true);
693 if(anActor->hasIO()){
694 Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
695 if(anIO->hasEntry()){
696 aStudy->setVisibilityState(anIO->getEntry(), Qtx::ShownState);
705 //MESSAGE("---case eDisplayOnly");
706 while (vtkActor *anAct = aCollection->GetNextActor()) {
707 if (SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)) {
708 //MESSAGE("--- erase " << anActor);
709 anActor->SetVisibility(false);
712 aStudy->setVisibilityStateForAll(Qtx::HiddenState);
715 if (SMESH_Actor *anActor = FindActorByEntry(theWnd,theEntry)) {
719 //MESSAGE("--- display " << anActor);
721 anActor->SetVisibility(true);
722 if (theAction == eDisplayOnly) aRenderer->ResetCameraClippingRange();
723 aStudy->setVisibilityState(theEntry, Qtx::ShownState);
726 //MESSAGE("--- erase " << anActor);
727 anActor->SetVisibility(false);
728 aStudy->setVisibilityState(theEntry, Qtx::HiddenState);
738 SalomeApp_Study* aStudy = dynamic_cast<SalomeApp_Study*>(theWnd->getViewManager()->study());
739 TVisualObjPtr aVisualObj;
740 if ( (aVisualObj = GetVisualObj(theEntry)) && aVisualObj->IsValid())
742 if ((anActor = CreateActor(theEntry,true))) {
743 bool needFitAll = noSmeshActors(theWnd); // fit for the first object only
744 DisplayActor(theWnd,anActor);
745 anActor->SetVisibility(true);
746 aStudy->setVisibilityState(theEntry, Qtx::ShownState);
747 // FitAll(); - PAL16770(Display of a group performs an automatic fit all)
748 if (needFitAll) FitAll();
765 bool UpdateView(EDisplaing theAction, const char* theEntry) {
766 //MESSAGE("UpdateView");
767 SalomeApp_Study* aStudy = dynamic_cast< SalomeApp_Study* >( GetActiveStudy() );
768 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( aStudy->application() );
769 if ( SUIT_ViewManager* vm = app->activeViewManager() )
771 SUIT_ViewWindow *aWnd = vm->getActiveView();
772 return UpdateView(aWnd,theAction,theEntry);
778 if ( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView()) {
779 LightApp_SelectionMgr* mgr = SMESHGUI::selectionMgr();
780 SALOME_ListIO selected; mgr->selectedObjects( selected );
782 if( selected.Extent() == 0){
783 vtkRenderer* aRenderer = aWnd->getRenderer();
784 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
785 vtkActorCollection *aCollection = aCopy.GetActors();
786 aCollection->InitTraversal();
787 while(vtkActor *anAct = aCollection->GetNextActor()){
788 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
790 if (!Update(anActor->getIO(),anActor->GetVisibility()))
791 break; // avoid multiple warinings if visu failed
795 SALOME_ListIteratorOfListIO anIter( selected );
796 for( ; anIter.More(); anIter.Next()){
797 Handle(SALOME_InteractiveObject) anIO = anIter.Value();
798 if ( !Update(anIO,true) )
799 break; // avoid multiple warinings if visu failed
802 RepaintCurrentView();
807 bool Update(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay)
810 if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(theIO->getEntry())) {
812 UpdateView(SMESH::eDisplay,theIO->getEntry());
818 bool UpdateNulData(const Handle(SALOME_InteractiveObject)& theIO, bool theDisplay)
820 //MESSAGE("UpdateNulData");
821 if ( TVisualObjPtr aVisualObj = SMESH::GetVisualObj(theIO->getEntry(), true)) {
823 UpdateView(SMESH::eDisplay,theIO->getEntry());
829 void UpdateSelectionProp( SMESHGUI* theModule )
834 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( theModule->application() );
837 MESSAGE( "UpdateSelectionProp: Application is null" );
841 SUIT_ViewManager* vm = app->activeViewManager();
844 MESSAGE( "UpdateSelectionProp: View manager is null" );
848 QVector<SUIT_ViewWindow*> views = vm->getViews();
850 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( theModule );
853 MESSAGE( "UpdateSelectionProp: Resource manager is null" );
858 aHiColor = mgr->colorValue( "SMESH", "selection_object_color", Qt::white ),
859 aSelColor = mgr->colorValue( "SMESH", "selection_element_color", Qt::yellow ),
860 aPreColor = mgr->colorValue( "SMESH", "highlight_color", Qt::cyan );
862 int aElem0DSize = mgr->integerValue("SMESH", "elem0d_size", 5);
863 // int aBallSize = mgr->integerValue("SMESH", "ball_elem_size", 5);
864 int aLineWidth = mgr->integerValue("SMESH", "element_width", 1);
865 int maxSize = aElem0DSize;
866 if (aElem0DSize > maxSize) maxSize = aElem0DSize;
867 if (aLineWidth > maxSize) maxSize = aLineWidth;
868 // if (aBallSize > maxSize) maxSize = aBallSize;
871 SP1 = mgr->doubleValue( "SMESH", "selection_precision_node", 0.025 ),
872 SP2 = mgr->doubleValue( "SMESH", "selection_precision_element", 0.001 ),
873 SP3 = mgr->doubleValue( "SMESH", "selection_precision_object", 0.025 );
875 for ( int i=0, n=views.count(); i<n; i++ )
877 // update VTK viewer properties
878 if ( SVTK_ViewWindow* aVtkView = GetVtkViewWindow( views[i] ))
880 // mesh element selection
881 aVtkView->SetSelectionProp(aSelColor.red()/255.,
882 aSelColor.green()/255.,
883 aSelColor.blue()/255.);
885 aVtkView->SetSelectionTolerance(SP1, SP2, SP3);
888 aVtkView->SetPreselectionProp(aPreColor.red()/255.,
889 aPreColor.green()/255.,
890 aPreColor.blue()/255.);
892 vtkRenderer* aRenderer = aVtkView->getRenderer();
893 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
894 vtkActorCollection *aCollection = aCopy.GetActors();
895 aCollection->InitTraversal();
896 while ( vtkActor *anAct = aCollection->GetNextActor() ) {
897 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct) ) {
898 anActor->SetHighlightColor(aHiColor.red()/255.,
899 aHiColor.green()/255.,
900 aHiColor.blue()/255.);
901 anActor->SetPreHighlightColor(aPreColor.red()/255.,
902 aPreColor.green()/255.,
903 aPreColor.blue()/255.);
911 void UpdateFontProp( SMESHGUI* theModule )
913 if ( !theModule ) return;
915 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( theModule->application() );
918 SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( theModule );
921 double anRGBNd[3] = {1,1,1};
922 SMESH::GetColor( "SMESH", "numbering_node_color", anRGBNd[0], anRGBNd[1], anRGBNd[2], QColor( 255, 255, 255 ) );
924 SMESH::LabelFont aFamilyNd = SMESH::FntTimes;
926 bool anItalicNd = false;
927 bool aShadowNd = false;
929 if ( mgr->hasValue( "SMESH", "numbering_node_font" ) ) {
930 QFont f = mgr->fontValue( "SMESH", "numbering_node_font" );
931 if ( f.family() == "Arial" ) aFamilyNd = SMESH::FntArial;
932 else if ( f.family() == "Courier" ) aFamilyNd = SMESH::FntCourier;
933 else if ( f.family() == "Times" ) aFamilyNd = SMESH::FntTimes;
935 anItalicNd = f.italic();
936 aShadowNd = f.overline();
937 aSizeNd = f.pointSize();
940 double anRGBEl[3] = {0,1,0};
941 SMESH::GetColor( "SMESH", "numbering_elem_color", anRGBEl[0], anRGBEl[1], anRGBEl[2], QColor( 0, 255, 0 ) );
943 SMESH::LabelFont aFamilyEl = SMESH::FntTimes;
945 bool anItalicEl = false;
946 bool aShadowEl = false;
948 if ( mgr->hasValue( "SMESH", "numbering_elem_font" ) ) {
949 QFont f = mgr->fontValue( "SMESH", "numbering_elem_font" );
951 if ( f.family() == "Arial" ) aFamilyEl = SMESH::FntArial;
952 else if ( f.family() == "Courier" ) aFamilyEl = SMESH::FntCourier;
953 else if ( f.family() == "Times" ) aFamilyEl = SMESH::FntTimes;
955 anItalicEl = f.italic();
956 aShadowEl = f.overline();
957 aSizeEl = f.pointSize();
960 ViewManagerList vmList;
961 app->viewManagers( SVTK_Viewer::Type(), vmList );
962 foreach ( SUIT_ViewManager* vm, vmList ) {
963 QVector<SUIT_ViewWindow*> views = vm->getViews();
964 foreach ( SUIT_ViewWindow* vw, views ) {
965 // update VTK viewer properties
966 if ( SVTK_ViewWindow* aVtkView = GetVtkViewWindow( vw ) ) {
968 vtkRenderer* aRenderer = aVtkView->getRenderer();
969 VTK::ActorCollectionCopy aCopy( aRenderer->GetActors() );
970 vtkActorCollection* aCollection = aCopy.GetActors();
971 aCollection->InitTraversal();
972 while ( vtkActor* anAct = aCollection->GetNextActor() ) {
973 if ( SMESH_NodeLabelActor* anActor = dynamic_cast< SMESH_NodeLabelActor* >( anAct ) ) {
974 anActor->SetFontProperties( aFamilyNd, aSizeNd, aBoldNd, anItalicNd, aShadowNd, anRGBNd[0], anRGBNd[1], anRGBNd[2] );
976 else if ( SMESH_CellLabelActor* anActor = dynamic_cast< SMESH_CellLabelActor* >( anAct ) ) {
977 anActor->SetFontProperties( aFamilyEl, aSizeEl, aBoldEl, anItalicEl, aShadowEl, anRGBEl[0], anRGBEl[1], anRGBEl[2] );
980 aVtkView->Repaint( false );
986 //----------------------------------------------------------------------------
988 GetSelector(SUIT_ViewWindow *theWindow)
990 if(SVTK_ViewWindow* aWnd = GetVtkViewWindow(theWindow))
991 return aWnd->GetSelector();
996 void SetFilter(const Handle(VTKViewer_Filter)& theFilter,
997 SVTK_Selector* theSelector)
1000 theSelector->SetFilter(theFilter);
1003 Handle(VTKViewer_Filter) GetFilter(int theId, SVTK_Selector* theSelector)
1005 return theSelector->GetFilter(theId);
1008 bool IsFilterPresent(int theId, SVTK_Selector* theSelector)
1010 return theSelector->IsFilterPresent(theId);
1013 void RemoveFilter(int theId, SVTK_Selector* theSelector)
1015 theSelector->RemoveFilter(theId);
1018 void RemoveFilters(SVTK_Selector* theSelector)
1020 for ( int id = SMESH::NodeFilter; theSelector && id < SMESH::LastFilter; id++ )
1021 theSelector->RemoveFilter( id );
1024 bool IsValid(SALOME_Actor* theActor, int theCellId,
1025 SVTK_Selector* theSelector)
1027 return theSelector->IsValid(theActor,theCellId);
1031 //----------------------------------------------------------------------------
1032 void SetPointRepresentation(bool theIsVisible)
1034 if ( SVTK_ViewWindow* aViewWindow = GetCurrentVtkView() ) {
1035 vtkRenderer *aRenderer = aViewWindow->getRenderer();
1036 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1037 vtkActorCollection *aCollection = aCopy.GetActors();
1038 aCollection->InitTraversal();
1039 while(vtkActor *anAct = aCollection->GetNextActor()){
1040 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1041 if(anActor->GetVisibility()){
1042 anActor->SetPointRepresentation(theIsVisible);
1046 RepaintCurrentView();
1051 void SetPickable(SMESH_Actor* theActor)
1053 if ( SVTK_ViewWindow* aWnd = GetCurrentVtkView() ) {
1054 int anIsAllPickable = (theActor == NULL);
1055 vtkRenderer *aRenderer = aWnd->getRenderer();
1056 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1057 vtkActorCollection *aCollection = aCopy.GetActors();
1058 aCollection->InitTraversal();
1059 while(vtkActor *anAct = aCollection->GetNextActor()){
1060 if(SALOME_Actor *anActor = dynamic_cast<SALOME_Actor*>(anAct)){
1061 if(anActor->GetVisibility()){
1062 anActor->SetPickable(anIsAllPickable);
1067 theActor->SetPickable(!anIsAllPickable);
1068 RepaintCurrentView();
1073 //----------------------------------------------------------------------------
1074 int GetNameOfSelectedNodes(SVTK_Selector* theSelector,
1075 const Handle(SALOME_InteractiveObject)& theIO,
1079 TColStd_IndexedMapOfInteger aMapIndex;
1080 theSelector->GetIndex(theIO,aMapIndex);
1082 for(int i = 1; i <= aMapIndex.Extent(); i++)
1083 theName += QString(" %1").arg(aMapIndex(i));
1085 return aMapIndex.Extent();
1088 int GetNameOfSelectedElements(SVTK_Selector* theSelector,
1089 const Handle(SALOME_InteractiveObject)& theIO,
1093 TColStd_IndexedMapOfInteger aMapIndex;
1094 theSelector->GetIndex(theIO,aMapIndex);
1096 typedef std::set<int> TIdContainer;
1097 TIdContainer anIdContainer;
1098 for( int i = 1; i <= aMapIndex.Extent(); i++)
1099 anIdContainer.insert(aMapIndex(i));
1101 TIdContainer::const_iterator anIter = anIdContainer.begin();
1102 for( ; anIter != anIdContainer.end(); anIter++)
1103 theName += QString(" %1").arg(*anIter);
1105 return aMapIndex.Extent();
1109 int GetEdgeNodes(SVTK_Selector* theSelector,
1110 const TVisualObjPtr& theVisualObject,
1114 const SALOME_ListIO& selected = theSelector->StoredIObjects();
1116 if ( selected.Extent() != 1 )
1119 Handle(SALOME_InteractiveObject) anIO = selected.First();
1120 if ( anIO.IsNull() || !anIO->hasEntry() )
1123 TColStd_IndexedMapOfInteger aMapIndex;
1124 theSelector->GetIndex( anIO, aMapIndex );
1125 if ( aMapIndex.Extent() != 2 )
1128 int anObjId = -1, anEdgeNum = -1;
1129 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
1130 int aVal = aMapIndex( i );
1134 anEdgeNum = abs( aVal ) - 1;
1137 if ( anObjId == -1 || anEdgeNum == -1 )
1140 return theVisualObject->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
1143 //----------------------------------------------------------------------------
1144 int GetNameOfSelectedNodes(LightApp_SelectionMgr *theMgr,
1145 const Handle(SALOME_InteractiveObject)& theIO,
1149 if(theIO->hasEntry()){
1150 if(FindActorByEntry(theIO->getEntry())){
1151 TColStd_IndexedMapOfInteger aMapIndex;
1152 theMgr->GetIndexes(theIO,aMapIndex);
1153 for(int i = 1; i <= aMapIndex.Extent(); i++){
1154 theName += QString(" %1").arg(aMapIndex(i));
1156 return aMapIndex.Extent();
1162 int GetNameOfSelectedNodes(LightApp_SelectionMgr *theMgr, QString& theName)
1165 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1166 if(selected.Extent() == 1){
1167 Handle(SALOME_InteractiveObject) anIO = selected.First();
1168 return GetNameOfSelectedNodes(theMgr,anIO,theName);
1174 int GetNameOfSelectedElements(LightApp_SelectionMgr * theMgr,
1175 const Handle(SALOME_InteractiveObject)& theIO,
1179 if(theIO->hasEntry()){
1180 if(FindActorByEntry(theIO->getEntry())){
1181 TColStd_IndexedMapOfInteger aMapIndex;
1182 theMgr->GetIndexes(theIO,aMapIndex);
1183 typedef std::set<int> TIdContainer;
1184 TIdContainer anIdContainer;
1185 for( int i = 1; i <= aMapIndex.Extent(); i++)
1186 anIdContainer.insert(aMapIndex(i));
1187 TIdContainer::const_iterator anIter = anIdContainer.begin();
1188 for( ; anIter != anIdContainer.end(); anIter++){
1189 theName += QString(" %1").arg(*anIter);
1191 return aMapIndex.Extent();
1198 int GetNameOfSelectedElements(LightApp_SelectionMgr *theMgr, QString& theName)
1201 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1203 if( selected.Extent() == 1){
1204 Handle(SALOME_InteractiveObject) anIO = selected.First();
1205 return GetNameOfSelectedElements(theMgr,anIO,theName);
1210 int GetSelected(LightApp_SelectionMgr* theMgr,
1211 TColStd_IndexedMapOfInteger& theMap,
1212 const bool theIsElement)
1215 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1217 if ( selected.Extent() == 1 )
1219 Handle(SALOME_InteractiveObject) anIO = selected.First();
1220 if ( anIO->hasEntry() ) {
1221 theMgr->GetIndexes( anIO, theMap );
1224 return theMap.Extent();
1228 int GetEdgeNodes( LightApp_SelectionMgr* theMgr, int& theId1, int& theId2 )
1230 SALOME_ListIO selected; theMgr->selectedObjects( selected );
1232 if ( selected.Extent() != 1 )
1235 Handle(SALOME_InteractiveObject) anIO = selected.First();
1236 if ( anIO.IsNull() || !anIO->hasEntry() )
1239 SMESH_Actor *anActor = SMESH::FindActorByEntry( anIO->getEntry() );
1243 TColStd_IndexedMapOfInteger aMapIndex;
1244 theMgr->GetIndexes( anIO, aMapIndex );
1245 if ( aMapIndex.Extent() != 2 )
1248 int anObjId = -1, anEdgeNum = -1;
1249 for ( int i = 1; i <= aMapIndex.Extent(); i++ ) {
1250 int aVal = aMapIndex( i );
1254 anEdgeNum = abs( aVal );
1257 if ( anObjId == -1 || anEdgeNum == -1 )
1260 return anActor->GetObject()->GetEdgeNodes( anObjId, anEdgeNum, theId1, theId2 ) ? 1 : -1;
1263 void SetControlsPrecision( const long theVal )
1265 if( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView() )
1267 vtkRenderer *aRenderer = aWnd->getRenderer();
1268 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1269 vtkActorCollection *aCollection = aCopy.GetActors();
1270 aCollection->InitTraversal();
1272 while ( vtkActor *anAct = aCollection->GetNextActor())
1274 if ( SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>( anAct ) )
1276 anActor->SetControlsPrecision( theVal );
1277 anActor->SetControlMode( anActor->GetControlMode() );
1284 //----------------------------------------------------------------------------
1285 // internal function
1286 void ComputeBoundsParam( double theBounds[6],
1287 double theDirection[3],
1288 double theMinPnt[3],
1289 double& theMaxBoundPrj,
1290 double& theMinBoundPrj )
1292 //Enlarge bounds in order to avoid conflicts of precision
1293 for(int i = 0; i < 6; i += 2){
1294 static double EPS = 1.0E-3;
1295 double aDelta = (theBounds[i+1] - theBounds[i])*EPS;
1296 theBounds[i] -= aDelta;
1297 theBounds[i+1] += aDelta;
1300 double aBoundPoints[8][3] = { {theBounds[0],theBounds[2],theBounds[4]},
1301 {theBounds[1],theBounds[2],theBounds[4]},
1302 {theBounds[0],theBounds[3],theBounds[4]},
1303 {theBounds[1],theBounds[3],theBounds[4]},
1304 {theBounds[0],theBounds[2],theBounds[5]},
1305 {theBounds[1],theBounds[2],theBounds[5]},
1306 {theBounds[0],theBounds[3],theBounds[5]},
1307 {theBounds[1],theBounds[3],theBounds[5]}};
1310 theMaxBoundPrj = vtkMath::Dot(theDirection,aBoundPoints[aMaxId]);
1311 theMinBoundPrj = theMaxBoundPrj;
1312 for(int i = 1; i < 8; i++){
1313 double aTmp = vtkMath::Dot(theDirection,aBoundPoints[i]);
1314 if(theMaxBoundPrj < aTmp){
1315 theMaxBoundPrj = aTmp;
1318 if(theMinBoundPrj > aTmp){
1319 theMinBoundPrj = aTmp;
1322 double *aMinPnt = aBoundPoints[aMaxId];
1323 theMinPnt[0] = aMinPnt[0];
1324 theMinPnt[1] = aMinPnt[1];
1325 theMinPnt[2] = aMinPnt[2];
1328 // internal function
1329 void DistanceToPosition( double theBounds[6],
1330 double theDirection[3],
1334 double aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1335 ComputeBoundsParam(theBounds,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1336 double aLength = (aMaxBoundPrj-aMinBoundPrj)*theDist;
1337 thePos[0] = aMinPnt[0]-theDirection[0]*aLength;
1338 thePos[1] = aMinPnt[1]-theDirection[1]*aLength;
1339 thePos[2] = aMinPnt[2]-theDirection[2]*aLength;
1342 // internal function (currently unused, left just in case)
1343 void PositionToDistance( double theBounds[6],
1344 double theDirection[3],
1348 double aMaxBoundPrj, aMinBoundPrj, aMinPnt[3];
1349 ComputeBoundsParam(theBounds,theDirection,aMinPnt,aMaxBoundPrj,aMinBoundPrj);
1350 double aPrj = vtkMath::Dot(theDirection,thePos);
1351 theDist = (aPrj-aMinBoundPrj)/(aMaxBoundPrj-aMinBoundPrj);
1354 bool ComputeClippingPlaneParameters( std::list<vtkActor*> theActorList,
1355 double theNormal[3],
1357 double theBounds[6],
1358 double theOrigin[3] )
1360 bool anIsOk = false;
1361 anIsOk = ComputeBounds( theActorList, theBounds );
1367 DistanceToPosition( theBounds, theNormal, theDist, theOrigin );
1371 bool ComputeBounds( std::list<vtkActor*> theActorList,
1372 double theBounds[6])
1374 bool anIsOk = false;
1375 theBounds[0] = theBounds[2] = theBounds[4] = VTK_DOUBLE_MAX;
1376 theBounds[1] = theBounds[3] = theBounds[5] = -VTK_DOUBLE_MAX;
1377 std::list<vtkActor*>::iterator anIter = theActorList.begin();
1378 for( ; anIter != theActorList.end(); anIter++ ) {
1379 if( vtkActor* aVTKActor = *anIter ) {
1380 if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) ) {
1382 anActor->GetUnstructuredGrid()->GetBounds( aBounds );
1383 theBounds[0] = std::min( theBounds[0], aBounds[0] );
1384 theBounds[1] = std::max( theBounds[1], aBounds[1] );
1385 theBounds[2] = std::min( theBounds[2], aBounds[2] );
1386 theBounds[3] = std::max( theBounds[3], aBounds[3] );
1387 theBounds[4] = std::min( theBounds[4], aBounds[4] );
1388 theBounds[5] = std::max( theBounds[5], aBounds[5] );
1396 #ifndef DISABLE_PLOT2DVIEWER
1397 //================================================================================
1399 * \brief Find all SMESH_Actor's in the View Window.
1400 * If actor constains Plot2d_Histogram object remove it from each Plot2d Viewer.
1402 //================================================================================
1404 void ClearPlot2Viewers( SUIT_ViewWindow* theWindow )
1406 if ( SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow) ) {
1407 vtkRenderer *aRenderer = aViewWindow->getRenderer();
1408 VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
1409 vtkActorCollection *aCollection = aCopy.GetActors();
1410 aCollection->InitTraversal();
1411 while(vtkActor *anAct = aCollection->GetNextActor()){
1412 if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
1413 if(anActor->hasIO() && anActor->GetPlot2Histogram() ){
1414 ProcessIn2DViewers(anActor,RemoveFrom2dViewer);
1423 } // end of namespace SMESH