-// Copyright (C) 2003 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// Copyright (C) 2007-2008 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
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
-
-
+//
+// SMESH SMESHGUI : GUI for SMESH component
+// File : SMESHGUI_VTKUtils.cxx
+// Author : Open CASCADE S.A.S.
+// SMESH includes
+//
#include "SMESHGUI_VTKUtils.h"
+
+#include "SMESHGUI.h"
#include "SMESHGUI_Utils.h"
#include "SMESHGUI_Filter.h"
-#include "SMESHGUI.h"
-#include "SMESH_Actor.h"
-#include "SMESH_ActorUtils.h"
-#include "SMESH_ObjectDef.h"
+#include <SMESH_Actor.h>
+#include <SMESH_ActorUtils.h>
+#include <SMESH_ObjectDef.h>
#include <SMDS_Mesh.hxx>
+// SALOME GUI includes
#include <SUIT_Desktop.h>
#include <SUIT_Session.h>
-#include <SUIT_Study.h>
#include <SUIT_MessageBox.h>
+#include <SUIT_ViewManager.h>
+#include <SUIT_ResourceMgr.h>
#include <SALOME_ListIO.hxx>
#include <SALOME_ListIteratorOfListIO.hxx>
#include <SVTK_ViewModel.h>
#include <SVTK_ViewWindow.h>
+#include <VTKViewer_Algorithm.h>
+
#include <LightApp_SelectionMgr.h>
#include <SalomeApp_Application.h>
#include <SalomeApp_Study.h>
+// SALOME KERNEL includes
#include <utilities.h>
+// IDL includes
#include <SALOMEconfig.h>
-#include CORBA_CLIENT_HEADER(SMESH_Gen)
#include CORBA_CLIENT_HEADER(SMESH_Mesh)
#include CORBA_CLIENT_HEADER(SMESH_Group)
-#include CORBA_CLIENT_HEADER(SMESH_Hypothesis)
-#include <SALOMEDSClient_Study.hxx>
-#include <SALOMEDSClient_SObject.hxx>
-
-// VTK
+// VTK includes
#include <vtkRenderer.h>
#include <vtkActorCollection.h>
#include <vtkUnstructuredGrid.h>
-// OCCT
+// OCCT includes
#include <TColStd_IndexedMapOfInteger.hxx>
#include <Standard_ErrorHandler.hxx>
-// STL
-#include <set>
-using namespace std;
-
-
-namespace SMESH {
-
- typedef map<TKeyOfVisualObj,TVisualObjPtr> TVisualObjCont;
+namespace SMESH
+{
+ typedef std::map<TKeyOfVisualObj,TVisualObjPtr> TVisualObjCont;
static TVisualObjCont VISUAL_OBJ_CONT;
//=============================================================================
SUIT_ViewManager* aViewManager =
app ? app->getViewManager(SVTK_Viewer::Type(), true) : 0;
if ( aViewManager ) {
- QPtrVector<SUIT_ViewWindow> views = aViewManager->getViews();
+ QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
for ( int iV = 0; iV < views.count(); ++iV ) {
if ( SMESH_Actor* actor = FindActorByEntry( views[iV], theEntry)) {
if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV]))
for ( int iM = 0; iM < viewMgrs.count(); ++iM ) {
SUIT_ViewManager* aViewManager = viewMgrs.at( iM );
if ( aViewManager && aViewManager->getType() == SVTK_Viewer::Type()) {
- QPtrVector<SUIT_ViewWindow> views = aViewManager->getViews();
+ QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
for ( int iV = 0; iV < views.count(); ++iV ) {
if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
vtkRenderer *aRenderer = vtkWnd->getRenderer();
- vtkActorCollection *actors = aRenderer->GetActors();
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection *actors = aCopy.GetActors();
for (int i = 0; i < actors->GetNumberOfItems(); ++i ) {
// size of actors changes inside the loop
- while (SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i)))
+ if (SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i)))
{
vtkWnd->RemoveActor(actor);
actor->Delete();
SUIT_ViewManager* aViewManager = viewMgrs.at( iM );
if ( aViewManager && aViewManager->getType() == SVTK_Viewer::Type() &&
aViewManager->study()->id() == studyID ) {
- QPtrVector<SUIT_ViewWindow> views = aViewManager->getViews();
+ QVector<SUIT_ViewWindow*> views = aViewManager->getViews();
for ( int iV = 0; iV < views.count(); ++iV ) {
if(SVTK_ViewWindow* vtkWnd = GetVtkViewWindow(views[iV])) {
vtkRenderer *aRenderer = vtkWnd->getRenderer();
- vtkActorCollection *actors = aRenderer->GetActors();
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection *actors = aCopy.GetActors();
for (int i = 0; i < actors->GetNumberOfItems(); ++i ) {
// size of actors changes inside the loop
- while(SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i)))
+ if(SMESH_Actor *actor = dynamic_cast<SMESH_Actor*>(actors->GetItemAsObject(i)))
{
vtkWnd->RemoveActor(actor);
actor->Delete();
// after or at showing this message, so we do an additional check of available memory
// char* buf = new char[100*1024];
// delete [] buf;
- SUIT_MessageBox::warn1 (SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_VISU_PROBLEM"),
- QObject::tr("SMESH_BUT_OK"));
+ SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_VISU_PROBLEM"));
} catch (...) {
// no more memory at all: last resort
- cout<< "SMESHGUI_VTKUtils::OnVisuException(), exception even at showing a message!!!" <<endl;
- cout<< "Try to remove all visual data..." <<endl;
+ MESSAGE_BEGIN ( "SMESHGUI_VTKUtils::OnVisuException(), exception even at showing a message!!!" <<
+ std::endl << "Try to remove all visual data..." );
if (theVISU_MemoryReserve) {
delete theVISU_MemoryReserve;
theVISU_MemoryReserve = 0;
}
RemoveAllObjectsWithActors();
- SUIT_MessageBox::warn1 (SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_VISU_PROBLEM_CLEAR"),
- QObject::tr("SMESH_BUT_OK"));
- cout<< "...done" << endl;
+ SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_VISU_PROBLEM_CLEAR"));
+ MESSAGE_END ( "...done" );
}
}
//================================================================================
}
catch (...) {
#ifdef _DEBUG_
- cout << "Exception in SMESHGUI_VTKUtils::GetVisualObj()" << endl;
+ MESSAGE ( "Exception in SMESHGUI_VTKUtils::GetVisualObj()" );
#endif
RemoveVisualObjectWithActors( theEntry ); // remove this object
OnVisuException();
int usedMB = aVisualObj->GetUnstructuredGrid()->GetActualMemorySize() / 1024;
if ( freeMB > 0 && usedMB * 30 > freeMB ) {
#ifdef _DEBUG_
- cout << "SMESHGUI_VTKUtils::GetVisualObj(), freeMB=" << freeMB
- << ", usedMB=" << usedMB<< endl;
+ MESSAGE ( "SMESHGUI_VTKUtils::GetVisualObj(), freeMB=" << freeMB
+ << ", usedMB=" << usedMB );
#endif
- int continu = 0;
+ bool continu = false;
if ( usedMB * 10 > freeMB )
// even dont try to show
- SUIT_MessageBox::warn1 (SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
- QObject::tr("SMESH_NO_MESH_VISUALIZATION"),
- QObject::tr("SMESH_BUT_OK"));
+ SUIT_MessageBox::warning(SMESHGUI::desktop(), QObject::tr("SMESH_WRN_WARNING"),
+ QObject::tr("SMESH_NO_MESH_VISUALIZATION"));
else
// there is a chance to succeed
- continu = SUIT_MessageBox::warn2
+ continu = SUIT_MessageBox::warning
(SMESHGUI::desktop(),
QObject::tr("SMESH_WRN_WARNING"),
QObject::tr("SMESH_CONTINUE_MESH_VISUALIZATION"),
- QObject::tr("SMESH_BUT_YES"), QObject::tr("SMESH_BUT_NO"),
- 1, 0, 1);
+ SUIT_MessageBox::Yes | SUIT_MessageBox::No,
+ SUIT_MessageBox::Yes ) == SUIT_MessageBox::Yes;
if ( !continu ) {
// remove the corresponding actors from all views
RemoveVisualObjectWithActors( theEntry );
if( !theMgr )
return NULL;
- QPtrVector<SUIT_ViewWindow> views = theMgr->getViews();
- if( views.containsRef( theWindow ) )
+ QVector<SUIT_ViewWindow*> views = theMgr->getViews();
+ if( views.contains( theWindow ) )
return GetVtkViewWindow( theWindow );
else
return NULL;
}
catch (...) {
#ifdef _DEBUG_
- cout << "Exception in SMESHGUI_VTKUtils::RepaintCurrentView()" << endl;
+ MESSAGE ( "Exception in SMESHGUI_VTKUtils::RepaintCurrentView()" );
#endif
OnVisuException();
}
}
catch (...) {
#ifdef _DEBUG_
- cout << "Exception in SMESHGUI_VTKUtils::RepaintViewWindow(SVTK_ViewWindow)" << endl;
+ MESSAGE ( "Exception in SMESHGUI_VTKUtils::RepaintViewWindow(SVTK_ViewWindow*)" );
#endif
OnVisuException();
}
}
catch (...) {
#ifdef _DEBUG_
- cout << "Exception in SMESHGUI_VTKUtils::RenderViewWindow(SVTK_ViewWindow)" << endl;
+ MESSAGE ( "Exception in SMESHGUI_VTKUtils::RenderViewWindow(SVTK_ViewWindow*)" );
#endif
OnVisuException();
}
}
catch (...) {
#ifdef _DEBUG_
- cout << "Exception in SMESHGUI_VTKUtils::FitAll()" << endl;
+ MESSAGE ( "Exception in SMESHGUI_VTKUtils::FitAll()" );
#endif
OnVisuException();
}
{
if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWindow)){
vtkRenderer *aRenderer = aViewWindow->getRenderer();
- vtkActorCollection *aCollection = aRenderer->GetActors();
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){
if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
}
catch (...) {
#ifdef _DEBUG_
- cout << "Exception in SMESHGUI_VTKUtils::DisplayActor()" << endl;
+ MESSAGE ( "Exception in SMESHGUI_VTKUtils::DisplayActor()" );
#endif
OnVisuException();
}
{
if(SVTK_ViewWindow* aViewWindow = GetVtkViewWindow(theWnd)) {
vtkRenderer *aRenderer = aViewWindow->getRenderer();
- vtkActorCollection *aCollection = aRenderer->GetActors();
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor())
- if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct))
+ if(dynamic_cast<SMESH_Actor*>(anAct))
return false;
}
return true;
{
OK = true;
vtkRenderer *aRenderer = aViewWnd->getRenderer();
- vtkActorCollection *aCollection = aRenderer->GetActors();
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal();
switch (theAction) {
if( selected.Extent() == 0){
vtkRenderer* aRenderer = aWnd->getRenderer();
- vtkActorCollection *aCollection = aRenderer->GetActors();
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){
if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
}
}else{
SALOME_ListIteratorOfListIO anIter( selected );
- for(; anIter.More(); anIter.Next()){
+ for( ; anIter.More(); anIter.Next()){
Handle(SALOME_InteractiveObject) anIO = anIter.Value();
if ( !Update(anIO,true) )
break; // avoid multiple warinings if visu failed
return;
}
- QPtrVector<SUIT_ViewWindow> views = vm->getViews();
+ QVector<SUIT_ViewWindow*> views = vm->getViews();
SUIT_ResourceMgr* mgr = SMESH::GetResourceMgr( theModule );
if( !mgr )
int SW = mgr->integerValue( "SMESH", "selection_width", 5 ),
PW = mgr->integerValue( "SMESH", "highlight_width", 5 );
+ // adjust highlight_width to the width of mesh entities
+ int aPointSize = mgr->integerValue("SMESH", "node_size", 3);
+ int aElem0DSize = mgr->integerValue("SMESH", "elem0d_size", 5);
+ int aLineWidth = mgr->integerValue("SMESH", "element_width", 1);
+ int maxSize = aPointSize;
+ if (aElem0DSize > maxSize) maxSize = aElem0DSize;
+ if (aLineWidth > maxSize) maxSize = aLineWidth;
+ if (PW < maxSize + 2) PW = maxSize + 2;
+
double SP1 = mgr->doubleValue( "SMESH", "selection_precision_node", 0.025 ),
SP2 = mgr->doubleValue( "SMESH", "selection_precision_element", 0.001 ),
SP3 = mgr->doubleValue( "SMESH", "selection_precision_object", 0.025 );
PW);
// update actors
vtkRenderer* aRenderer = aVtkView->getRenderer();
- vtkActorCollection *aCollection = aRenderer->GetActors();
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){
if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
void RemoveFilters(SVTK_Selector* theSelector)
{
- for ( int id = SMESHGUI_NodeFilter; theSelector && id < SMESHGUI_LastFilter; id++ )
+ for ( int id = SMESH::NodeFilter; theSelector && id < SMESH::LastFilter; id++ )
theSelector->RemoveFilter( id );
}
void SetPointRepresentation(bool theIsVisible){
if(SVTK_ViewWindow* aViewWindow = GetCurrentVtkView()){
vtkRenderer *aRenderer = aViewWindow->getRenderer();
- vtkActorCollection *aCollection = aRenderer->GetActors();
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){
if(SMESH_Actor *anActor = dynamic_cast<SMESH_Actor*>(anAct)){
if(SVTK_ViewWindow* aWnd = GetCurrentVtkView()){
int anIsAllPickable = (theActor == NULL);
vtkRenderer *aRenderer = aWnd->getRenderer();
- vtkActorCollection *aCollection = aRenderer->GetActors();
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal();
while(vtkActor *anAct = aCollection->GetNextActor()){
if(SALOME_Actor *anActor = dynamic_cast<SALOME_Actor*>(anAct)){
anIdContainer.insert(aMapIndex(i));
TIdContainer::const_iterator anIter = anIdContainer.begin();
- for(; anIter != anIdContainer.end(); anIter++)
+ for( ; anIter != anIdContainer.end(); anIter++)
theName += QString(" %1").arg(*anIter);
return aMapIndex.Extent();
if(FindActorByEntry(theIO->getEntry())){
TColStd_IndexedMapOfInteger aMapIndex;
theMgr->GetIndexes(theIO,aMapIndex);
- typedef set<int> TIdContainer;
+ typedef std::set<int> TIdContainer;
TIdContainer anIdContainer;
for( int i = 1; i <= aMapIndex.Extent(); i++)
anIdContainer.insert(aMapIndex(i));
TIdContainer::const_iterator anIter = anIdContainer.begin();
- for(; anIter != anIdContainer.end(); anIter++){
+ for( ; anIter != anIdContainer.end(); anIter++){
theName += QString(" %1").arg(*anIter);
}
return aMapIndex.Extent();
if( SVTK_ViewWindow* aWnd = SMESH::GetCurrentVtkView() )
{
vtkRenderer *aRenderer = aWnd->getRenderer();
- vtkActorCollection *aCollection = aRenderer->GetActors();
+ VTK::ActorCollectionCopy aCopy(aRenderer->GetActors());
+ vtkActorCollection *aCollection = aCopy.GetActors();
aCollection->InitTraversal();
while ( vtkActor *anAct = aCollection->GetNextActor())
}
}
-}
+} // end of namespace SMESH