Salome HOME
IPAL21797: Shrink factor is disabled for Point Map 3D Definition
authorvsr <vsr@opencascade.com>
Wed, 23 Jun 2010 12:31:05 +0000 (12:31 +0000)
committervsr <vsr@opencascade.com>
Wed, 23 Jun 2010 12:31:05 +0000 (12:31 +0000)
src/OBJECT/VISU_ActorBase.cxx
src/OBJECT/VISU_ActorBase.h
src/VISUGUI/VisuGUI_ShrinkFactorDlg.cxx

index ae6c8e9db2a1b46e03be91599a26d59408d85812..fbb889e389d8489a7cbd5f5d9fd3b43f693ed097 100644 (file)
@@ -161,6 +161,22 @@ bool VISU_ActorBase::IsShrunkable()
   return myIsShrinkable;
 }
 
+void
+VISU_ActorBase
+::SetShrinkFactor(vtkFloatingPointType theValue)
+{
+  myShrinkFilter->SetShrinkFactor(theValue);
+  Modified();
+}
+
+vtkFloatingPointType
+VISU_ActorBase
+::GetShrinkFactor()
+{
+  return myShrinkFilter->GetShrinkFactor();
+}
+
+
 //--------------------------------------------------------------------------------------
 
 void VISU_ActorBase::RemoveFromRender(vtkRenderer* theRenderer)
index 10645c4027a84fc9876826da14b7b3b4d986dce6..b4e2da399c49945cd149844d4a1762f897249fe8 100644 (file)
@@ -64,6 +64,9 @@ class VISU_OBJECT_EXPORT VISU_ActorBase: public SALOME_Actor,
   virtual bool IsShrunkable();
   virtual bool IsShrunk();
   virtual void SetShrinkable(bool theIsShrinkable);
+
+  virtual void SetShrinkFactor(vtkFloatingPointType theFactor = 0.8); 
+  virtual vtkFloatingPointType GetShrinkFactor();
   
   virtual void SetRepresentation(int theMode);
 
index 0d755a9ab063f4081d1bfb8968bdc19e9cdc7132..fc6d6b63a203d4719d25d2d075ba79efafd569f1 100644 (file)
@@ -53,6 +53,7 @@
 #include <QKeyEvent>
 
 const int DEFAULT_SHRINK = 80;
+const int UNDEF_SHRINK   = -1;
 
 //=================================================================================
 // class    : VisuGUI_ShrinkFactorDlg()
@@ -174,10 +175,19 @@ void VisuGUI_ShrinkFactorDlg::setShrinkFactor()
     for ( ; anIter.More(); anIter.Next() ) {
       Handle(SALOME_InteractiveObject) anIO = anIter.Value();
       VISU_Actor* anActor = VISU::FindActor( VISU::GetAppStudy( myModule ), myViewWindow, anIO->getEntry() );
-      if ( anActor && anActor->IsShrunkable() )
-        anActor->SetShrinkFactor( shrink );
+      if ( anActor ) {
+       if ( anActor->IsShrunkable() )
+         anActor->SetShrinkFactor( shrink );
+      }
+      else {
+       VISU_ActorBase* anActor = VISU::FindActorBase(VISU::GetAppStudy(myModule), myViewWindow, anIO->getEntry());
+       if ( anActor ) {
+         if ( anActor->IsShrunkable() )
+           anActor->SetShrinkFactor( shrink );
+       }
+      }
     }
-  myViewWindow->Repaint();
+    myViewWindow->Repaint();
   }
 }
 
@@ -189,49 +199,42 @@ void VisuGUI_ShrinkFactorDlg::onSelectionChanged()
 {
   bool shrinkable = false;
   if ( myViewWindow ) {
-    int shrink = DEFAULT_SHRINK;
+    int shrinkFactor = UNDEF_SHRINK;
 
     SALOME_ListIO aList;
     mySelectionMgr->selectedObjects( aList );
 
-    if ( aList.Extent() == 1 ) {
-      Handle(SALOME_InteractiveObject) FirstIOS = aList.First();
-      if ( !FirstIOS.IsNull() ) {
-        VISU_Actor* anActor = VISU::FindActor( VISU::GetAppStudy( myModule ), myViewWindow, FirstIOS->getEntry() );
-        if ( anActor ) {
-          shrinkable = anActor->IsShrunkable();
-          if ( shrinkable )
-            shrink = int( anActor->GetShrinkFactor() * 100. + 0.5 );
-        }
-      }
-    } 
-    else if ( aList.Extent() > 1 ) {
-      SALOME_ListIteratorOfListIO It( aList );
-      int setShr = -1;
-      for ( ; It.More(); It.Next() ) {
-        Handle(SALOME_InteractiveObject) IO = It.Value();
-        if (!IO.IsNull()) {
-          VISU_Actor* anActor = VISU::FindActor( VISU::GetAppStudy( myModule ), myViewWindow, IO->getEntry() );
-          if ( anActor ) {
-            bool lshrinkable = anActor->IsShrunkable();
-            shrinkable = shrinkable || lshrinkable;
-            if ( lshrinkable ) {
-              int shr = int( anActor->GetShrinkFactor() * 100. + 0.5 );
-              if ( setShr < 0 )
-                setShr = shr;
-              else if ( setShr != shr ) {
-                setShr = DEFAULT_SHRINK;
-                break;
-              }
-            }
-          }
-        }
+    SALOME_ListIteratorOfListIO It( aList );
+    for ( ; It.More(); It.Next() ) {
+      Handle(SALOME_InteractiveObject) IO = It.Value();
+      if (!IO.IsNull()) {
+       bool ashrinkable = false;
+       int shr = UNDEF_SHRINK;
+       VISU_Actor* anActor = VISU::FindActor( VISU::GetAppStudy( myModule ), myViewWindow, IO->getEntry() );
+       if ( anActor ) {
+         ashrinkable = anActor->IsShrunkable();
+         if ( ashrinkable ) shr = int( anActor->GetShrinkFactor() * 100. + 0.5 );
+       } 
+       else {
+         VISU_ActorBase* anActor = VISU::FindActorBase(VISU::GetAppStudy(myModule), myViewWindow, IO->getEntry());
+         if ( anActor ) {
+           ashrinkable = anActor->IsShrunkable();
+           if ( ashrinkable ) shr = int( anActor->GetShrinkFactor() * 100. + 0.5 );
+         }
+       }
+       shrinkable = shrinkable || ashrinkable;
+       if ( shr != UNDEF_SHRINK ) {
+         if ( shrinkFactor == UNDEF_SHRINK )
+           shrinkFactor = shr;
+         else if ( shrinkFactor != shr ) {
+           shrinkFactor = DEFAULT_SHRINK;
+           break;
+         }
+       }
       }
-      if ( setShr >= 0 )
-        shrink = setShr;
     }
     ValueSpin->blockSignals( true );
-    ValueSpin->setValue( shrink );
+    ValueSpin->setValue( shrinkFactor == UNDEF_SHRINK ? DEFAULT_SHRINK : shrinkFactor );
     ValueSpin->blockSignals( false );
   }
   GroupC1->setEnabled( shrinkable );