From e38b29b4fe34161b09ff9812086483a7c809593c Mon Sep 17 00:00:00 2001 From: apo Date: Mon, 3 Oct 2005 06:26:20 +0000 Subject: [PATCH] To implement update outside presentation fcuntionality --- src/OBJECT/VISU_GaussPtsAct.cxx | 101 ++++++++++++++++++++++++-------- src/OBJECT/VISU_GaussPtsAct.h | 28 ++++++--- 2 files changed, 96 insertions(+), 33 deletions(-) diff --git a/src/OBJECT/VISU_GaussPtsAct.cxx b/src/OBJECT/VISU_GaussPtsAct.cxx index ed2dcd92..b70b8ec5 100644 --- a/src/OBJECT/VISU_GaussPtsAct.cxx +++ b/src/OBJECT/VISU_GaussPtsAct.cxx @@ -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: "<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: "<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 = "<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 = "<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(theClientData)) + if(VISU_GaussPtsAct1* self = dynamic_cast(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 = "<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()); diff --git a/src/OBJECT/VISU_GaussPtsAct.h b/src/OBJECT/VISU_GaussPtsAct.h index 095447f3..207f2ba0 100644 --- a/src/OBJECT/VISU_GaussPtsAct.h +++ b/src/OBJECT/VISU_GaussPtsAct.h @@ -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 myScalarBarCtrl; - - vtkSmartPointer 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 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); -- 2.39.2