]> SALOME platform Git repositories - modules/visu.git/commitdiff
Salome HOME
To implement update outside presentation fcuntionality
authorapo <apo@opencascade.com>
Mon, 3 Oct 2005 06:26:20 +0000 (06:26 +0000)
committerapo <apo@opencascade.com>
Mon, 3 Oct 2005 06:26:20 +0000 (06:26 +0000)
src/OBJECT/VISU_GaussPtsAct.cxx
src/OBJECT/VISU_GaussPtsAct.h

index ed2dcd92757c812430ebe06b89431362c98e6c27..b70b8ec5357f92b96254560ec31492812a4c9a77 100644 (file)
@@ -355,22 +355,6 @@ VISU_GaussPtsAct
   return myChangeMagnification;
 }
 
-//----------------------------------------------------------------
-void
-VISU_GaussPtsAct
-::SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings)
-{
-  myOutsideCursorSettings = theOutsideCursorSettings;
-}
-
-//----------------------------------------------------------------
-void
-VISU_GaussPtsAct
-::UpdateOutsideCursorSettings()
-{
-  // update actor from myOutsideCursorSettings
-}
-
 //----------------------------------------------------------------------------
 namespace
 {
@@ -572,7 +556,7 @@ VISU_GaussPtsAct
            aStr<<"\nScalar: "<<aVal;
 
            mySphereSource->SetCenter(aNodeCoord);
-           float aRadius = myGaussPointsPL->GetPointSize(anObjId,aScalarArray);
+           float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray);
            mySphereSource->SetRadius(aRadius);
 
            float aColor[3];
@@ -689,7 +673,7 @@ VISU_GaussPtsAct
        vtkDataSet* aDataSet = GetInput();
        vtkCellData* aCellData = aDataSet->GetCellData();
        if(vtkDataArray* aScalarArray = aCellData->GetScalars()){
-         float aRadius = myGaussPointsPL->GetPointSize(anObjId, aScalarArray);
+         float aRadius = myGaussPointsPL->GetPointSize(aVtkId, aScalarArray);
          mySphereSourceSelected->SetRadius(aRadius);
          if(theSelector->HasIndex(myIO)){
            mySphereActorSelected->SetVisibility(1);
@@ -713,7 +697,7 @@ VISU_GaussPtsAct
            vtkIdType aCellID = aGaussPointID.first;
            vtkCell* aCell = aParent->GetElemCell(aCellID);
            myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
-
+           myCellActor->GetProperty()->SetRepresentationToWireframe(); // VTK bug
            myCellActor->SetVisibility(1);
          }
        }
@@ -803,7 +787,7 @@ VISU_GaussPtsAct
                          aStr<<"\nScalar: "<<aVal;
                          
                          mySphereSource->SetCenter(aNodeCoord);
-                         float aRadius = myGaussPointsPL->GetPointSize(anObjId,aScalarArray);
+                         float aRadius = myGaussPointsPL->GetPointSize(aVtkId,aScalarArray);
                          mySphereSource->SetRadius(aRadius);
                        }
                        
@@ -845,15 +829,18 @@ vtkStandardNewMacro(VISU_GaussPtsAct1);
 VISU_GaussPtsAct1
 ::VISU_GaussPtsAct1():
   myInsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
-  myOutsideDeviceActor(VISU_GaussPtsDeviceActor::New())
+  myOutsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
+  myOutsideCursorSettings(NULL)
 {
   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::VISU_GaussPtsAct1 - this = "<<this);
+
+  myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents);
+
   myInsideDeviceActor->SetProperty(GetProperty());
   myInsideDeviceActor->SetVisibility(false);
   myInsideDeviceActor->SetPickable(false);
   myInsideDeviceActor->Delete();
 
-  myOutsideDeviceActor->SetProperty(GetProperty());
   myOutsideDeviceActor->SetVisibility(false);
   myOutsideDeviceActor->SetPickable(false);
   myOutsideDeviceActor->Delete();
@@ -863,6 +850,8 @@ VISU_GaussPtsAct1
 ::~VISU_GaussPtsAct1()
 {
   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::~VISU_GaussPtsAct1 - this = "<<this);
+
+  SetOutsideCursorSettings(NULL);
 }
 
 
@@ -977,6 +966,8 @@ VISU_GaussPtsAct1
   }
 }
 
+
+//----------------------------------------------------------------
 void 
 VISU_GaussPtsAct1
 ::Connect(VISU_GaussPtsAct2* theActor)
@@ -1000,6 +991,57 @@ VISU_GaussPtsAct1
   mySetVisibilitySignal(GetVisibility());
 }
 
+//----------------------------------------------------------------
+void
+VISU_GaussPtsAct1
+::SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings)
+{
+  if(myOutsideCursorSettings == theOutsideCursorSettings)
+    return;
+
+  if(myOutsideCursorSettings)
+    myOutsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
+
+  myOutsideCursorSettings = theOutsideCursorSettings;
+
+  if(theOutsideCursorSettings)
+    theOutsideCursorSettings->AddObserver(vtkCommand::ModifiedEvent, 
+                                         myEventCallbackCommand.GetPointer(), 
+                                         myPriority);
+}
+
+void
+VISU_GaussPtsAct1
+::UpdateOutsideCursorSettings()
+{
+  // update actor from myOutsideCursorSettings
+  VISU_OpenGLPointSpriteMapper* aMapper = myOutsideDeviceActor->GetPSMapper();
+  aMapper->SetPointSpriteClamp(myOutsideCursorSettings->GetClamp());
+  aMapper->SetImageData(myOutsideCursorSettings->GetTexture());
+  aMapper->SetPointSpriteAlphaThreshold(myOutsideCursorSettings->GetAlphaThreshold());
+  aMapper->SetPointSpriteSize(myOutsideCursorSettings->GetSize());
+  aMapper->SetPointSpriteClamp(myOutsideCursorSettings->GetClamp());
+  myOutsideDeviceActor->GetProperty()->SetColor(myOutsideCursorSettings->GetColor());
+  
+  Update();
+}
+
+
+//----------------------------------------------------------------
+void 
+VISU_GaussPtsAct1
+::ProcessEvents(vtkObject* theObject, 
+               unsigned long theEvent,
+               void* theClientData, 
+               void* theCallData)
+{
+  if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
+    if(VISU_GaussPtsAct1* self = dynamic_cast<VISU_GaussPtsAct1*>(anObject))
+      if(theEvent == vtkCommand::ModifiedEvent)
+       self->UpdateOutsideCursorSettings();
+
+  Superclass::ProcessEvents(theObject,theEvent,theClientData,theCallData);
+}
 
 void
 VISU_GaussPtsAct1
@@ -1028,6 +1070,7 @@ VISU_GaussPtsAct2
 ::VISU_GaussPtsAct2()
 {
   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::VISU_GaussPtsAct2 - this = "<<this);
+  myDeviceActor->SetVisibility(false);
 }
 
 VISU_GaussPtsAct2
@@ -1089,7 +1132,7 @@ VISU_GaussPtsAct2
                           myEventCallbackCommand.GetPointer(), 
                           myPriority);
     myDeviceActor->GetPipeLine()->SetImplicitFunction(theWidget->ImplicitFunction());
-    myDeviceActor->SetVisibility(GetVisibility() && theWidget->IsEnabled());
+    myDeviceActor->SetVisibility(Superclass::GetVisibility() && theWidget->IsEnabled());
   }
 
   Superclass::SetImplicitFunctionWidget(theWidget);
@@ -1105,7 +1148,14 @@ VISU_GaussPtsAct2
 
   Superclass::SetVisibility(theMode);
 
-  myDeviceActor->SetVisibility(GetVisibility() && myWidget->IsEnabled());
+  myDeviceActor->SetVisibility(Superclass::GetVisibility() && myWidget->IsEnabled());
+}
+
+int
+VISU_GaussPtsAct2
+::GetVisibility()
+{
+  return Superclass::GetVisibility() && myWidget->IsEnabled();
 }
 
 void
@@ -1115,7 +1165,8 @@ VISU_GaussPtsAct2
   switch(theEvent){
   case vtkCommand::EnableEvent: 
   case vtkCommand::DisableEvent:
-    myDeviceActor->SetVisibility(GetVisibility() && myWidget->IsEnabled());
+    myDeviceActor->SetVisibility(Superclass::GetVisibility() && myWidget->IsEnabled());
+    Update();
     break;
   case vtkCommand::EndInteractionEvent:
     //vtkLODActor::SetMapper(GetMapper());
index 095447f3c1fbfeef2d325adc86a603fa12a10192..207f2ba0a38c7d4cfe9fea6cbf4b2668d0dc739c 100644 (file)
@@ -191,12 +191,6 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor
   void
   SetImplicitFunctionWidget(VISU_ImplicitFunctionWidget* theWidget);
 
-  void
-  SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
-
-  void
-  UpdateOutsideCursorSettings();
-
   bool
   ChangeMagnification();
 
@@ -269,8 +263,6 @@ class VTKOCC_EXPORT VISU_GaussPtsAct : public VISU_Actor
 
   bool myBarVisibility;
   vtkSmartPointer<VISU_ScalarBarCtrl> myScalarBarCtrl;
-
-  vtkSmartPointer<VISU_OutsideCursorSettings> myOutsideCursorSettings;
 };
 
 
@@ -299,6 +291,13 @@ class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct
   void
   Connect(VISU_GaussPtsAct2* theActor);
 
+  //----------------------------------------------------------------------------
+  void
+  SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings);
+
+  void
+  UpdateOutsideCursorSettings();
+
   //----------------------------------------------------------------------------
   virtual
   void
@@ -328,12 +327,21 @@ class VTKOCC_EXPORT VISU_GaussPtsAct1 : public VISU_GaussPtsAct
   SetMapperInput(vtkDataSet* theDataSet);
 
   //----------------------------------------------------------------------------
+  // Main process VTK event method
+  static
+  void
+  ProcessEvents(vtkObject* theObject, 
+               unsigned long theEvent,
+               void* theClientData, 
+               void* theCallData);
+
   // To process VTK event method
   virtual 
   void
   OnInteractorEvent(unsigned long theEvent);
 
   boost::signal1<void,int> mySetVisibilitySignal;
+  VISU_OutsideCursorSettings* myOutsideCursorSettings;
 
   //----------------------------------------------------------------------------
   PDeviceActor myInsideDeviceActor;
@@ -364,6 +372,10 @@ class VTKOCC_EXPORT VISU_GaussPtsAct2 : public VISU_GaussPtsAct
   void
   SetVisibility(int theMode);
 
+  virtual
+  int
+  GetVisibility();
+
   virtual
   void
   SetImplicitFunctionWidget(VISU_ImplicitFunctionWidget* theWidget);