+
+//=================================================================================
+// function : initializePlaneData()
+// purpose :
+//=================================================================================
+void SMESHGUI_ClippingDlg::initializePlaneData()
+{
+ const SMESHGUI_ClippingPlaneInfoMap& aClippingPlaneInfoMap = mySMESHGUI->getClippingPlaneInfoMap();
+ SMESHGUI_ClippingPlaneInfoMap::const_iterator anIter1 = aClippingPlaneInfoMap.find( myViewWindow->getViewManager() );
+ if( anIter1 != aClippingPlaneInfoMap.end() ) {
+ const SMESHGUI_ClippingPlaneInfoList& aClippingPlaneInfoList = anIter1->second;
+ SMESHGUI_ClippingPlaneInfoList::const_iterator anIter2 = aClippingPlaneInfoList.begin();
+ for( ; anIter2 != aClippingPlaneInfoList.end(); anIter2++ ) {
+ const SMESH::ClippingPlaneInfo& aClippingPlaneInfo = *anIter2;
+ SMESH::TPlane aTPlane( aClippingPlaneInfo.Plane );
+ SMESH::TPlaneData aPlaneData( aTPlane, aClippingPlaneInfo.ActorList );
+ myPlanes.push_back( aPlaneData );
+ }
+ }
+ std::for_each( myPlanes.begin(),myPlanes.end(), TSetVisibility( PreviewCheckBox->isChecked() ) );
+}
+
+//=================================================================================
+// function : updateActorList()
+// purpose :
+//=================================================================================
+void SMESHGUI_ClippingDlg::updateActorList()
+{
+ ActorList->clear();
+
+ SalomeApp_Study* anAppStudy = SMESHGUI::activeStudy();
+ if( !anAppStudy )
+ return;
+
+ _PTR(Study) aStudy = anAppStudy->studyDS();
+ if( !aStudy )
+ return;
+
+ if( !myViewWindow )
+ return;
+
+ int aCurPlaneIndex = ComboBoxPlanes->currentIndex();
+ const SMESH::TPlaneData& aPlaneData = myPlanes[ aCurPlaneIndex ];
+ const SMESH::TActorList& anActorList = aPlaneData.ActorList;
+
+ VTK::ActorCollectionCopy aCopy( myViewWindow->getRenderer()->GetActors() );
+ vtkActorCollection* anAllActors = aCopy.GetActors();
+ anAllActors->InitTraversal();
+ while( vtkActor* aVTKActor = anAllActors->GetNextActor() ) {
+ if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) ) {
+ if( anActor->hasIO() ) {
+ Handle(SALOME_InteractiveObject) anIO = anActor->getIO();
+ if( _PTR(SObject) aSObj = aStudy->FindObjectID( anIO->getEntry() ) ) {
+ bool anIsChecked = false;
+ SMESH::TActorList::const_iterator anIter = anActorList.begin();
+ for ( ; anIter != anActorList.end(); anIter++ ) {
+ if( vtkActor* aVTKActorRef = *anIter ) {
+ if( SMESH_Actor* anActorRef = SMESH_Actor::SafeDownCast( aVTKActorRef ) ) {
+ if( anActorRef == anActor ) {
+ anIsChecked = true;
+ break;
+ }
+ }
+ }
+ }
+ QString aName = QString( aSObj->GetName().c_str() );
+ QListWidgetItem* anItem = new ActorItem( anActor, aName, ActorList );
+ anItem->setCheckState( anIsChecked ? Qt::Checked : Qt::Unchecked );
+ updateActorItem( anItem, true, false );
+ }
+ }
+ }
+ }
+}
+
+//=================================================================================
+// function : getCurrentActors()
+// purpose :
+//=================================================================================
+SMESH::TActorList SMESHGUI_ClippingDlg::getCurrentActors()
+{
+ SMESH::TActorList anActorList;
+ for( int i = 0, n = ActorList->count(); i < n; i++ )
+ if( ActorItem* anItem = dynamic_cast<ActorItem*>( ActorList->item( i ) ) )
+ if( anItem->checkState() == Qt::Checked )
+ if( SMESH_Actor* anActor = anItem->getActor() )
+ anActorList.push_back( anActor );
+ return anActorList;
+}
+
+//=================================================================================
+// function : dumpPlaneData()
+// purpose :
+//=================================================================================
+void SMESHGUI_ClippingDlg::dumpPlaneData() const
+{
+ printf( "----------- Plane Data -----------\n" );
+ int anId = 1;
+ SMESH::TPlaneDataVector::const_iterator anIter1 = myPlanes.begin();
+ for ( ; anIter1 != myPlanes.end(); anIter1++, anId++ ) {
+ SMESH::TPlaneData aPlaneData = *anIter1;
+ SMESH::TPlane aPlane = aPlaneData.Plane;
+ vtkFloatingPointType* aNormal = aPlane->GetNormal();
+ vtkFloatingPointType* anOrigin = aPlane->GetOrigin();
+ printf( "Plane N%d:\n", anId );
+ printf( " Normal = ( %f, %f, %f )\n", aNormal[0], aNormal[1], aNormal[2] );
+ printf( " Origin = ( %f, %f, %f )\n", anOrigin[0], anOrigin[1], anOrigin[2] );
+
+ SMESH::TActorList anActorList = aPlaneData.ActorList;
+ SMESH::TActorList::const_iterator anIter2 = anActorList.begin();
+ for ( ; anIter2 != anActorList.end(); anIter2++ ) {
+ if( vtkActor* aVTKActor = *anIter2 ) {
+ if( SMESH_Actor* anActor = SMESH_Actor::SafeDownCast( aVTKActor ) )
+ printf( " - Actor: '%s'\n", anActor->getName() );
+ }
+ else
+ printf( " - Actor: NULL\n");
+ }
+ }
+ printf( "----------------------------------\n" );
+}