1 // Copyright (C) 2007-2008 CEA/DEN, EDF R&D, OPEN CASCADE
3 // Copyright (C) 2003-2007 OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
6 // This library is free software; you can redistribute it and/or
7 // modify it under the terms of the GNU Lesser General Public
8 // License as published by the Free Software Foundation; either
9 // version 2.1 of the License.
11 // This library is distributed in the hope that it will be useful,
12 // but WITHOUT ANY WARRANTY; without even the implied warranty of
13 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 // Lesser General Public License for more details.
16 // You should have received a copy of the GNU Lesser General Public
17 // License along with this library; if not, write to the Free Software
18 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
22 // VISU OBJECT : interactive object for VISU entities implementation
23 // File : VISU_MeshAct.hxx
24 // Author : Laurent CORNABE with the help of Nicolas REJNERI
28 #include "VISU_GaussPtsAct.h"
29 #include "VISU_GaussPointsPL.hxx"
30 #include "VISU_GaussPtsSettings.h"
31 #include "VISU_GaussPtsDeviceActor.h"
32 #include "VISU_PickingSettings.h"
33 #include "VISU_WidgetCtrl.hxx"
34 #include "VISU_SphereWidget.hxx"
35 #include "VISU_OpenGLPointSpriteMapper.hxx"
36 #include "VISU_ScalarBarCtrl.hxx"
37 #include "VISU_ScalarBarActor.hxx"
39 #include "VISU_Event.h"
40 #include "SVTK_Actor.h"
41 #include "VTKViewer_FramedTextActor.h"
42 #include <SALOME_ExtractPolyDataGeometry.h>
44 #include <vtkCamera.h>
45 #include <vtkRenderer.h>
46 #include <vtkPointPicker.h>
47 #include <vtkMatrix4x4.h>
48 #include <vtkScalarBarWidget.h>
49 #include <vtkTextMapper.h>
50 #include <vtkTextProperty.h>
51 #include <vtkImplicitBoolean.h>
52 #include <vtkImplicitFunctionCollection.h>
55 #include <vtkPointData.h>
56 #include <vtkCellData.h>
57 #include <vtkDataArray.h>
59 #include <vtkSphereSource.h>
60 #include <vtkPolyDataMapper.h>
61 #include <vtkPolyData.h>
63 #include <vtkTransform.h>
65 #include <vtkObjectFactory.h>
66 #include <vtkCallbackCommand.h>
67 #include <vtkInteractorStyle.h>
68 #include <vtkRenderWindowInteractor.h>
69 #include <vtkOutlineSource.h>
72 #include <boost/bind.hpp>
74 #include <vtkUnstructuredGrid.h>
75 #include <vtkPolyDataMapper.h>
76 #include <vtkRenderWindow.h>
77 #include <vtkCellArray.h>
78 #include <vtkWarpVector.h>
79 #include <vtkCellDataToPointData.h>
83 #include <vtkViewport.h>
85 #include "utilities.h"
88 static int MYDEBUG = 0;
89 static int MYDEBUG1 = 0;
90 static int MYDEBUG2 = 0;
92 static int MYDEBUG = 0;
93 static int MYDEBUG1 = 0;
94 static int MYDEBUG2 = 0;
101 CheckIsSameValue(vtkFloatingPointType theTarget,
102 vtkFloatingPointType theSource)
104 static vtkFloatingPointType TOL = 10.0 / VTK_LARGE_FLOAT;
105 return fabs(theTarget - theSource) < TOL;
109 CheckIsSameVector(vtkFloatingPointType* theTarget,
110 vtkFloatingPointType* theSource,
113 for ( size_t anId = 0; anId < theLength; anId++ ) {
114 if ( !CheckIsSameValue( theTarget[ anId ], theSource[ anId ] ) )
123 //============================================================================
124 vtkStandardNewMacro(VISU_GaussPtsAct);
126 //----------------------------------------------------------------------------
128 ::VISU_GaussPtsAct():
129 myEventCallbackCommand(vtkCallbackCommand::New()),
131 myDeviceActor(VISU_GaussPtsDeviceActor::New()),
133 myGaussPointsPL(NULL),
134 myLastPreHighlightObjID(-1),
135 myCursorPyramid(VISU_CursorPyramid::New()),
136 myCursorPyramidSelected(VISU_CursorPyramid::New()),
137 myCellSource(vtkUnstructuredGrid::New()),
138 myCellActor(SVTK_Actor::New()),
139 myScalarBarCtrl(VISU_ScalarBarCtrl::New()),
140 myBarVisibility(true),
141 myInsideCursorSettings(NULL),
143 myMapper(vtkPolyDataMapper::New()),
144 myPolyDataExtractor(SALOME_ExtractPolyDataGeometry::New()),
145 myFunction(vtkImplicitBoolean::New()),
146 myWarpVector(vtkWarpVector::New()),
147 myCellDataToPointData(vtkCellDataToPointData::New())
149 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::VISU_GaussPtsAct - this = "<<this);
151 myEventCallbackCommand->Delete();
152 myDeviceActor->Delete();
154 myCursorPyramid->Delete();
155 myCursorPyramid->SetPickable(0);
156 myCursorPyramid->SetVisibility(0);
158 myCursorPyramidSelected->Delete();
159 myCursorPyramidSelected->SetPickable(0);
160 myCursorPyramidSelected->SetVisibility(0);
162 myCellSource->Delete();
163 myCellActor->Delete();
165 myEventCallbackCommand->SetClientData(this);
166 myEventCallbackCommand->SetCallback(VISU_GaussPtsAct::ProcessEvents);
168 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
170 myDeviceActor->SetProperty(GetProperty());
171 myDeviceActor->SetUserMatrix(aMatrix);
172 myDeviceActor->SetVisibility(true);
173 myDeviceActor->SetPickable(false);
175 myCellSource->Allocate();
176 myCellActor->Initialize();
177 myCellActor->SetRepresentation(VTK_WIREFRAME);
178 myCellActor->SetSource(myCellSource.GetPointer());
180 myCellActor->SetVisibility(0);
181 myCellActor->SetPickable(0);
182 myCellActor->GetProperty()->SetAmbient(1.0);
183 myCellActor->GetProperty()->SetDiffuse(0.0);
185 myScalarBarCtrl->Delete();
190 myWarpVector->Delete();
191 myCellDataToPointData->Delete();
193 myPolyDataExtractor->SetImplicitFunction(myFunction);
194 //myPolyDataExtractor->ExtractBoundaryCellsOn();
196 myFunction->SetOperationTypeToIntersection();
197 myPolyDataExtractor->Delete();
198 myFunction->Delete();
200 if( VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get() )
201 aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent,
202 myEventCallbackCommand.GetPointer(),
207 ::~VISU_GaussPtsAct()
209 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::~VISU_GaussPtsAct - this = "<<this);
212 SetInsideCursorSettings(NULL);
216 //----------------------------------------------------------------------------
219 ::SetPipeLine(VISU_PipeLine* thePipeLine)
221 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::SetPipeLine - this = "<<this);
223 myGaussPointsPL = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine);
225 Superclass::SetPipeLine(thePipeLine);
232 return myGaussPointsPL.GetPointer();
235 //----------------------------------------------------------------------------
238 ::DeepCopy(VISU_Actor *theActor)
240 if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
241 Superclass::DeepCopy(theActor);
242 SetBarVisibility(anActor->GetBarVisibility());
246 //----------------------------------------------------------------------------
249 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
251 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::ShallowCopyPL - this = "<<this);
253 Superclass::ShallowCopyPL(thePipeLine);
255 UpdateInsideCursorSettings();
257 Highlight(isHighlighted());
261 //----------------------------------------------------------------------------
267 //vtkMapper* aMapper = myCurrentPL->GetPointSpriteMapper();
271 return myMapper.GetPointer();
274 vtkFloatingPointType*
278 return GetMapper()->GetBounds();
285 return GetMapper()->GetInput();
296 //----------------------------------------------------------------------------
301 vtkDataSet* aDataSet = myDeviceActor->GetMapper()->GetInput();
302 unsigned long int aSize = aDataSet->GetActualMemorySize() * 1024;
304 aSize += Superclass::GetMemorySize();
309 //----------------------------------------------------------------------------
312 ::AddToRender(vtkRenderer* theRenderer)
314 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::AddToRender - this = "<<this);
316 Superclass::AddToRender(theRenderer);
318 myDeviceActor->AddToRender(theRenderer);
320 theRenderer->AddActor(myCellActor.GetPointer());
322 myCursorPyramid->AddToRender(theRenderer);
323 myCursorPyramidSelected->AddToRender(theRenderer);
324 myScalarBarCtrl->AddToRender(theRenderer);
329 ::RemoveFromRender(vtkRenderer* theRenderer)
331 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::RemoveFromRender - this = "<<this);
333 myDeviceActor->RemoveFromRender(theRenderer);
335 theRenderer->RemoveActor(myCellActor.GetPointer());
337 myCursorPyramid->RemoveFromRender(theRenderer);
338 myCursorPyramidSelected->RemoveFromRender(theRenderer);
339 myScalarBarCtrl->RemoveFromRender(theRenderer);
341 Superclass::RemoveFromRender(theRenderer);
346 ::SetTransform(VTKViewer_Transform* theTransform)
348 Superclass::SetTransform(theTransform);
350 myDeviceActor->SetTransform(theTransform);
355 ::RenderOpaqueGeometry(vtkViewport *viewport)
357 GetMatrix(myDeviceActor->GetUserMatrix());
363 ::RenderTranslucentGeometry(vtkViewport *viewport)
365 GetMatrix(myDeviceActor->GetUserMatrix());
370 //----------------------------------------------------------------------------
373 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
375 if(myWidgetCtrl == theWidgetCtrl)
379 MESSAGE("VISU_GaussPtsAct::SetWidgetCtrl - this = "<<this<<"; theWidget = "<<theWidgetCtrl);
382 myWidgetCtrl->RemoveObserver(myEventCallbackCommand.GetPointer());
385 theWidgetCtrl->AddObserver(vtkCommand::EnableEvent,
386 myEventCallbackCommand.GetPointer(),
388 theWidgetCtrl->AddObserver(vtkCommand::DisableEvent,
389 myEventCallbackCommand.GetPointer(),
391 theWidgetCtrl->AddObserver(vtkCommand::StartInteractionEvent,
392 myEventCallbackCommand.GetPointer(),
394 theWidgetCtrl->AddObserver(vtkCommand::EndInteractionEvent,
395 myEventCallbackCommand.GetPointer(),
399 myWidgetCtrl = theWidgetCtrl;
404 ::GetChangeMagnification()
406 return myChangeMagnification;
411 ::ChangeMagnification( bool up )
413 myEventCallbackCommand->SetAbortFlag(1);
415 vtkFloatingPointType aMagnification = myInsideCursorSettings->GetMagnification();
416 vtkFloatingPointType anIncrement = myInsideCursorSettings->GetIncrement();
417 vtkFloatingPointType coefficient = up ? anIncrement : 1 / anIncrement;
419 myInsideCursorSettings->SetMagnification( aMagnification * coefficient );
420 myInsideCursorSettings->InvokeEvent(VISU::UpdateFromSettingsEvent,NULL);
425 //----------------------------------------------------------------------------
429 CreatePipeLine(VISU_GaussPointsPL* thePipeLine)
431 VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New();
432 aPipeLine->ShallowCopy(thePipeLine, true);
440 ::SetMapperInput(vtkDataSet* theDataSet)
442 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::SetMapperInput - this = "<<this);
444 myDeviceActor->SetExtractor(myPolyDataExtractor);
445 myDeviceActor->SetPipeLine(GetGaussPointsPL());
446 myCurrentPL = myDeviceActor->GetPipeLine();
448 //SetMapper(myCurrentPL->GetPointSpriteMapper());
450 // myPolyDataExtractor->SetInput(myCurrentPL->GetPickableDataSet());
451 //myMapper->SetInput(myPolyDataExtractor->GetOutput());
452 myMapper->SetInput(myCurrentPL->GetPickableDataSet());
453 SetMapper(myMapper.GetPointer());
457 //----------------------------------------------------------------------------
462 GetRadius(vtkIdType theVTKID,
463 vtkDataArray *theScalarArray,
464 VISU_GaussPointsPL* theGaussPointsPL)
466 vtkFloatingPointType aRadius = 0.5;
467 if(theGaussPointsPL->GetPointSpriteMapper()->GetPointSpriteMode() == 1) // Geometry mode
468 aRadius *= theGaussPointsPL->GetSize() * theGaussPointsPL->GetAverageCellSize();
469 else if(theGaussPointsPL->GetBicolor()){
470 vtkFloatingPointType aVal = theScalarArray->GetTuple1(theVTKID);
472 aRadius *= theGaussPointsPL->GetMaxSize();
474 aRadius *= theGaussPointsPL->GetMinSize();
475 aRadius *= theGaussPointsPL->GetAverageCellSize();
477 aRadius *= theGaussPointsPL->GetPointSize(theVTKID,theScalarArray);
485 ::GetRadius(vtkIdType theObjID,
487 vtkDataArray *theScalarArray)
489 return ::GetRadius(theVTKID,theScalarArray,myDeviceActor->GetPipeLine());
492 //----------------------------------------------------------------------------
495 ::GetMagnification(vtkIdType theObjID)
497 return myDeviceActor->GetPipeLine()->GetMagnification();
501 //----------------------------------------------------------------------------
506 GetClamp(VISU_GaussPointsPL* theGaussPointsPL)
508 vtkFloatingPointType aClamp = theGaussPointsPL->GetClamp();
509 if(theGaussPointsPL->GetPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere)
517 ::GetClamp(vtkIdType theObjID)
519 return ::GetClamp(myDeviceActor->GetPipeLine());
523 //----------------------------------------------------------------------------
526 ::SetFactory(VISU::TActorFactory* theActorFactory)
528 using namespace VISU;
529 myGaussPtsActorFactory = dynamic_cast<TGaussPtsActorFactory*>(theActorFactory);
530 myUpdatePrs3dSignal.connect(boost::bind(&TGaussPtsActorFactory::UpdateFromActor,
531 myGaussPtsActorFactory,
533 Superclass::SetFactory(theActorFactory);
536 VISU::TGaussPtsActorFactory*
538 ::GetGaussPtsFactory()
540 return myGaussPtsActorFactory;
544 //----------------------------------------------------------------------------
547 ::SetVisibility(int theMode)
549 Superclass::SetVisibility(theMode);
550 myDeviceActor->SetVisibility(GetVisibility()); // VSV
551 myScalarBarCtrl->SetVisibility(theMode);
552 Highlight(isHighlighted());
557 ::IsSegmentationEnabled()
559 return myWidgetCtrl && myWidgetCtrl->GetEnabled();
563 //----------------------------------------------------------------------------
566 ::SetBarVisibility(bool theMode)
568 myBarVisibility = theMode;
569 myScalarBarCtrl->SetCtrlVisibility(theMode);
570 myScalarBarCtrl->SetVisibility(GetVisibility());
577 return myBarVisibility;
584 return myScalarBarCtrl.GetPointer();
587 //----------------------------------------------------------------------------
590 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
592 if(theInteractor == myInteractor)
596 myInteractor->RemoveObserver(myEventCallbackCommand.GetPointer());
599 theInteractor->AddObserver(vtkCommand::CharEvent,
600 myEventCallbackCommand.GetPointer(),
602 theInteractor->AddObserver(VISU::SetSMDecreaseMagnificationEvent,
603 myEventCallbackCommand.GetPointer(),
605 theInteractor->AddObserver(VISU::SetSMIncreaseMagnificationEvent,
606 myEventCallbackCommand.GetPointer(),
609 Superclass::SetInteractor(theInteractor);
613 //-------------------------------------------------------------------------
616 ::ProcessEvents(vtkObject* vtkNotUsed(theObject),
617 unsigned long theEvent,
619 void* vtkNotUsed(theCallData))
621 if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
622 if(VISU_GaussPtsAct* self = dynamic_cast<VISU_GaussPtsAct*>(anObject)) {
623 if(theEvent == VISU::UpdateInsideSettingsEvent)
624 self->UpdateInsideCursorSettings();
626 self->OnInteractorEvent(theEvent);
630 //-------------------------------------------------------------------------
633 ::OnInteractorEvent(unsigned long theEvent)
636 case vtkCommand::CharEvent: {
637 switch(myInteractor->GetKeyCode()) {
641 if( IsSegmentationEnabled() )
643 this->ChangeMagnification( myInteractor->GetShiftKey() );
647 myChangeMagnification = myInteractor->GetShiftKey();
653 if( IsSegmentationEnabled() && myWidgetCtrl->IsSphereActive() )
655 VISU_SphereWidget* aSphereWidget = myWidgetCtrl->GetSphereWidget();
656 aSphereWidget->ChangeRadius( myInteractor->GetShiftKey() );
657 myWidgetCtrl->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
658 myWidgetCtrl->GetInteractor()->Render();
665 myUpdatePrs3dSignal(this);
668 case VISU::SetSMDecreaseMagnificationEvent:
669 case VISU::SetSMIncreaseMagnificationEvent:
670 myChangeMagnification = theEvent == VISU::SetSMIncreaseMagnificationEvent;
671 myUpdatePrs3dSignal(this);
673 case VISU::UpdatePickingSettingsEvent:
674 UpdatePickingSettings();
676 case vtkCommand::EndInteractionEvent:
677 case vtkCommand::EnableEvent:
678 case vtkCommand::DisableEvent:
679 myCurrentPL->GetMapper()->Update();
680 Highlight(isHighlighted());
687 //----------------------------------------------------------------------------
692 if(vtkMapper* aMapper = myDeviceActor->GetMapper()){
693 if(vtkDataSet* aDataSet= aMapper->GetInput()){
695 myIsInfinite = aDataSet->GetNumberOfCells() < 2;
701 //----------------------------------------------------------------------------
706 if(Superclass::GetPickable()){
707 if(vtkMapper* aMapper = GetMapper()){
708 if(vtkDataSet* aDataSet= aMapper->GetInput()){
710 return aDataSet->GetNumberOfCells() > 0;
718 //----------------------------------------------------------------------------
721 ::PreHighlight(vtkInteractorStyle* theInteractorStyle,
722 SVTK_SelectionEvent* theSelectionEvent,
725 if ( !GetPickable() )
728 myPreHighlightActor->SetVisibility(false);
729 myCursorPyramid->SetVisibility(false);
731 /* if (!myBarVisibility)
736 myLastPreHighlightObjID = -1;
738 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
740 if(aSelectionMode == ActorSelection || !theIsHighlight)
741 return Superclass::PreHighlight(theInteractorStyle,
745 bool anIsChanged = (mySelectionMode != aSelectionMode);
746 bool anIsPreselected = myIsPreselected;
747 myIsPreselected = false;
749 VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
751 if(aSelectionMode == GaussPointSelection && theIsHighlight){
752 myPointPicker->Pick(theSelectionEvent->myX,
753 theSelectionEvent->myY,
755 theInteractorStyle->GetCurrentRenderer());
757 if(myPointPicker->GetActor() != this)
758 return (anIsPreselected != myIsPreselected);
760 vtkIdType aVtkId = myPointPicker->GetPointId();
762 if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){
763 vtkIdType anObjId = GetNodeObjId( aVtkId );
764 myIsPreselected = (anObjId >= 0);
766 anIsChanged = (myLastPreHighlightObjID != anObjId);
768 vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
769 //Take into account translation
770 vtkFloatingPointType aLocalNodeCoord[3];
771 this->Transform->Push();
772 this->Transform->PostMultiply();
773 this->Transform->Identity();
775 this->Transform->Translate(this->Position[0],
779 this->Transform->GetPosition(aPosition);
781 aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0];
782 aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
783 aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
785 vtkDataSet* aDataSet = GetInput();
786 vtkPointData* aPointData = aDataSet->GetPointData();
787 if(vtkDataArray *aScalarArray = aPointData->GetScalars()){
788 vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight();
789 aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
790 //vtkFloatingPointType aColor[3] = myPreHighlightActor->GetProperty()->GetColor();
791 vtkFloatingPointType aColor[3];
792 theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor );
793 aColor[0] = 1. - aColor[0];
794 aColor[1] = 1. - aColor[1];
795 aColor[2] = 1. - aColor[2];
797 myCursorPyramid->Init(aPyramidHeight,
798 aPickingSettings->GetCursorSize(),
799 GetRadius(anObjId,aVtkId,aScalarArray),
800 GetMagnification(anObjId),
805 this->Transform->Pop();
806 myLastPreHighlightObjID = anObjId;
808 myCursorPyramid->SetVisibility(true);
813 mySelectionMode = aSelectionMode;
814 anIsChanged |= (anIsPreselected != myIsPreselected);
820 //----------------------------------------------------------------------------
823 ChangeZoom(VISU_PickingSettings *thePickingSettings,
824 vtkRenderer* theRenderer,
825 vtkIdType theInitialHasIndex,
826 vtkIdType theCurrentHasIndex)
828 if( (theInitialHasIndex + theCurrentHasIndex == 1) && thePickingSettings){
829 vtkCamera *aCamera = theRenderer->GetActiveCamera();
831 vtkFloatingPointType aZoomFactor = thePickingSettings->GetZoomFactor();
832 double aScale = aCamera->GetParallelScale();
833 if ( !theInitialHasIndex && theCurrentHasIndex ) {
834 aCamera->SetParallelScale( aScale/aZoomFactor );
837 aCamera->SetParallelScale( aScale*aZoomFactor );
845 ::Highlight(vtkInteractorStyle* theInteractorStyle,
846 SVTK_SelectionEvent* theSelectionEvent,
849 if ( !GetPickable() )
852 // int anInitialHasIndex = myIsSubElementsHighlighted && mySelectionMode == GaussPointSelection;
853 Handle(SALOME_InteractiveObject) anIO = getIO();
854 // myIsSubElementsHighlighted = false;
856 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
858 if(!theIsHighlight && aSelectionMode == GaussPointSelection){
859 mySelector->RemoveIObject(anIO);
861 /* ChangeZoom(myPickingSettings,
870 /* if (!myBarVisibility)
874 if(aSelectionMode == ActorSelection)
875 return Superclass::Highlight(theInteractorStyle,
879 if(aSelectionMode == GaussPointSelection && !theSelectionEvent->myIsRectangle){
881 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
882 myPointPicker->Pick(theSelectionEvent->myX,
883 theSelectionEvent->myY,
887 if(myPointPicker->GetActor() != this) {
888 mySelector->ClearIObjects();
890 /* ChangeZoom(myPickingSettings,
899 vtkIdType aVtkId = myPointPicker->GetPointId();
900 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO()) {
901 vtkIdType anObjId = GetNodeObjId( aVtkId );
903 // myIsHighlighted = true;
904 // Update the Selector
905 if(mySelector->IsSelected(myIO))
906 mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
908 if(!theSelectionEvent->myIsShift){
909 mySelector->ClearIObjects();
911 mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
912 mySelector->AddIObject(this);
915 vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
918 vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor();
919 vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
920 int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
922 anInteractor->SetDolly(0.);
923 anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber());
924 anInteractor->FlyTo(aRenderer,aNodeCoord);
925 aRenderer->ResetCameraClippingRange();
926 anInteractor->SetDolly(aDollyWas);
927 anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
929 anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);*/
931 mySelectionMode = aSelectionMode;
933 /* ChangeZoom(myPickingSettings,
940 }// if( anObjId >= 0 ) {
941 }//if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO())
942 }//if(!theSelectionEvent->myIsRectangle){
944 /* ChangeZoom(myPickingSettings,
955 void VISU_GaussPtsAct::SetPosition(double _arg[3]){
956 Superclass::SetPosition(_arg);
957 Highlight(isHighlighted());
960 //==================================================================
961 // function : Highlight
963 //==================================================================
966 ::Highlight(bool theIsHighlight)
968 if(!mySelector.GetPointer())
971 VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
973 Selection_Mode aSelectionMode = mySelector->SelectionMode();
975 bool anInitialHasIndex = isSubElementsHighlighted() && mySelectionMode == GaussPointSelection;
977 TColStd_IndexedMapOfInteger aMapIndex;
978 mySelector->GetIndex( getIO(), aMapIndex );
979 bool aCurrentHasIndex = aMapIndex.Extent() == 1;
980 bool anIsVisible = GetVisibility() && aCurrentHasIndex && theIsHighlight;
981 bool aShowTextActor = aPickingSettings->GetInfoWindowEnabled();
982 bool aShowCellActor = aPickingSettings->GetDisplayParentMesh();
984 myOutlineActor->SetVisibility(false);
985 myCursorPyramid->SetVisibility(false);
986 myTextActor->SetVisibility(anIsVisible && aShowTextActor);
987 myCellActor->SetVisibility(anIsVisible && aShowCellActor);
988 GetScalarBarCtrl()->SetIsMarked(anIsVisible);
989 myCursorPyramidSelected->SetVisibility(anIsVisible);
990 //GetScalarBarCtrl()->Update();
992 myIsSubElementsHighlighted = aCurrentHasIndex;
995 if( GetVisibility() && aPickingSettings->GetCameraMovementEnabled() )
997 ChangeZoom(aPickingSettings,
1003 if( aSelectionMode == ActorSelection ) {
1004 Superclass::Highlight(theIsHighlight);
1011 if( aSelectionMode != GaussPointSelection )
1014 if ( !aCurrentHasIndex || !myBarVisibility )
1017 // myTextActor->SetVisibility(anIsVisible);
1018 // myCellActor->SetVisibility(anIsVisible && myPickingSettings->GetDisplayParentMesh());
1019 // GetScalarBarCtrl()->SetIsMarked(anIsVisible);
1020 // myCursorPyramidSelected->SetVisibility(anIsVisible);
1021 //GetScalarBarCtrl()->Update();
1023 // myIsHighlighted = aCurrentHasIndex;
1025 // Zoom if necessary
1026 // ChangeZoom(myPickingSettings,
1028 // anInitialHasIndex,
1029 // aCurrentHasIndex);
1031 // TColStd_IndexedMapOfInteger aMapIndex;
1032 mySelector->GetIndex( getIO(), aMapIndex );
1033 if(aMapIndex.Extent() != 1 || !myBarVisibility) {
1037 vtkRenderer *aRenderer = GetRenderer();
1038 vtkCamera* aCamera = aRenderer->GetActiveCamera();
1040 int anObjId = aMapIndex(1);
1041 vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
1044 //Take into account translation
1045 vtkFloatingPointType aLocalNodeCoord[3];
1046 this->Transform->Push();
1047 this->Transform->PostMultiply();
1048 this->Transform->Identity();
1049 this->Transform->Translate(this->Position[0],
1052 double aPosition[3];
1053 this->Transform->GetPosition(aPosition);
1054 aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0];
1055 aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
1056 aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
1057 this->Transform->Pop();
1059 vtkFloatingPointType aFocalPnt[3];
1060 aCamera->GetFocalPoint(aFocalPnt);
1062 if ( CheckIsSameVector(aLocalNodeCoord, aFocalPnt, 3 ) )
1066 if( anIsVisible && aPickingSettings->GetCameraMovementEnabled() )
1068 vtkRenderWindowInteractor* anInteractor = myInteractor;
1069 vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
1070 int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
1072 anInteractor->SetDolly(0.0);
1073 anInteractor->SetNumberOfFlyFrames(aPickingSettings->GetStepNumber());
1074 anInteractor->FlyTo(aRenderer, aNodeCoord);
1075 aRenderer->ResetCameraClippingRange();
1076 anInteractor->SetDolly(aDollyWas);
1077 anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
1078 anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);
1081 std::ostringstream aStr;
1082 // int anObjId = aMapIndex(1);
1083 aStr<<"Global ID: "<<anObjId;
1085 vtkIdType aVtkId = GetNodeVTKID(anObjId);
1087 vtkFloatingPointType aWorldCoord[4] = {aLocalNodeCoord[0], aLocalNodeCoord[1], aLocalNodeCoord[2], 1.};
1089 vtkDataSet* aDataSet = GetInput();
1090 vtkPointData* aDataSetAttributes = aDataSet->GetPointData();
1092 if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){
1093 vtkFloatingPointType aVal = aScalarArray->GetTuple1(aVtkId);
1095 // GetScalarBarCtrl()->SetIsMarked(true);
1096 GetScalarBarCtrl()->SetMarkValue(aVal);
1097 GetScalarBarCtrl()->Update();
1099 vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight();
1100 aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
1101 myCursorPyramidSelected->Init(aPyramidHeight,
1102 aPickingSettings->GetCursorSize(),
1103 GetRadius(anObjId,aVtkId,aScalarArray),
1104 GetMagnification(anObjId),
1107 myHighlightActor->GetProperty()->GetColor());
1108 myCursorPyramidSelected->SetVisibility(anIsVisible && theIsHighlight);
1110 const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper =
1111 myGaussPointsPL->GetGaussPtsIDMapper();
1112 VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
1114 VISU::TGaussPointID aGaussPointID = myGaussPointsPL->GetObjID(anObjId);
1115 VISU::TCellID aCellID = aGaussPointID.first;
1116 VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
1117 aStr<<"\nParentCellID: "<<aCellID;
1118 std::string aParentName = aParent->GetElemName(aCellID);
1119 if(aParentName != "") {
1120 aStr<<"\nParentCellName: '"<<aParentName<<"'";
1122 aStr<<"\nLocalPntID: "<<aLocalPntID;
1123 aStr<<"\nScalar: "<<aVal;
1126 if(vtkDataArray* aFieldArray = aDataSetAttributes->GetArray("VISU_FIELD")){
1127 int aNbComp = aFieldArray->GetNumberOfComponents();
1128 std::vector<vtkFloatingPointType> aTuple(aNbComp);
1129 aFieldArray->GetTuple(aVtkId, &aTuple[0]);
1133 while(anId < aNbComp){
1134 vtkFloatingPointType aComp = aTuple[anId++];
1143 std::string aString = aStr.str();
1144 myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
1145 myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
1146 myTextActor->SetWorldPoint(aWorldCoord);
1147 myTextActor->SetText(aString.c_str());
1148 myTextActor->SetVisibility(anIsVisible && theIsHighlight && aShowTextActor);
1151 const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = myGaussPointsPL->GetGaussPtsIDMapper();
1152 VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
1154 myCellSource->Reset();
1155 myCellSource->Modified(); // a VTK bug
1156 vtkUnstructuredGrid* aCellDataSet = aParent->GetUnstructuredGridOutput();
1158 // get parent cell and insert it to myCellSource
1159 VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId);
1160 vtkIdType aCellID = aGaussPointID.first;
1161 vtkCell* aCell = aParent->GetElemCell(aCellID);
1162 myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
1164 if (myGaussPointsPL->GetIsDeformed()) {
1165 // find neighbour cells ids
1166 vtkIdList* aNeighbourCells = vtkIdList::New();
1167 aNeighbourCells->Allocate(VTK_CELL_SIZE);
1169 vtkIdList* aCellPoints = aCell->GetPointIds();
1171 vtkIdList *aPointCells = vtkIdList::New();
1172 aPointCells->Allocate(VTK_CELL_SIZE);
1174 vtkIdType aNbPoints = aCellPoints->GetNumberOfIds();
1175 for (vtkIdType i = 0; i < aNbPoints; i++) {
1176 aCellDataSet->GetPointCells(aCellPoints->GetId(i), aPointCells);
1179 vtkIdType aNbCells = aPointCells->GetNumberOfIds();
1180 for (vtkIdType j = 0; j < aNbCells; j++)
1181 aNeighbourCells->InsertUniqueId(aPointCells->GetId(j));
1184 aPointCells->Delete();
1187 vtkDataArray* anInputVectors = aDataSetAttributes->GetVectors();
1188 if (!anInputVectors)
1191 // insert neighbour cells to the special dataset
1192 vtkUnstructuredGrid *aCellsToWarp = vtkUnstructuredGrid::New();
1193 aCellsToWarp->SetPoints(aCellDataSet->GetPoints());
1195 vtkIdType aNbNeighbourCells = aNeighbourCells->GetNumberOfIds();
1197 vtkDataArray *aVectorsToSet = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
1198 aVectorsToSet->SetNumberOfComponents(3);
1199 aVectorsToSet->SetNumberOfTuples(aNbNeighbourCells);
1201 vtkDataArray *aCellVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
1202 aCellVectors->SetNumberOfComponents(3);
1204 int aNbComp = anInputVectors->GetNumberOfComponents();
1205 std::vector<vtkFloatingPointType> aTuple(aNbComp);
1207 for (vtkIdType i = 0; i < aNbNeighbourCells; i++) {
1208 vtkIdType aVTKCellId = aNeighbourCells->GetId(i);
1209 vtkIdType anObjCellId = aParent->GetElemObjID(aVTKCellId);
1211 vtkCell* aCurCell = aParent->GetElemCell(anObjCellId);
1213 vtkIdType aNewCellId = aCellsToWarp->InsertNextCell(aCurCell->GetCellType(), aCurCell->GetPointIds());
1215 // get gauss points corresponding to the current cell
1216 vtkIdType aPointVtkId = -1;
1217 vtkIdType aLocalPntId = 0;
1218 aPointVtkId = aGaussPtsIDMapper->GetVTKID(VISU::TGaussPointID(anObjCellId, aLocalPntId));
1220 if (aPointVtkId >= 0) {
1221 // Compute average vector
1222 aCellVectors->Reset();
1223 while (aPointVtkId >= 0) {
1224 anInputVectors->GetTuple(aPointVtkId, &aTuple[0]);
1227 aCellVectors->InsertNextTuple3(aTuple[0], aTuple[1], aTuple[2]);
1228 else if (aNbComp == 2)
1229 aCellVectors->InsertNextTuple3(aTuple[0], aTuple[1], 0);
1230 else if (aNbComp == 1)
1231 aCellVectors->InsertNextTuple3(aTuple[0], 0, 0);
1233 aPointVtkId = aGaussPtsIDMapper->GetVTKID(VISU::TGaussPointID(anObjCellId, ++aLocalPntId));
1236 double aXCoord = 0, anYCoord = 0, aZCoord = 0;
1238 vtkIdType aNbVectors = aCellVectors->GetNumberOfTuples();
1240 for (vtkIdType aVecId = 0; aVecId < aNbVectors; aVecId++) {
1241 aXCoord += aCellVectors->GetComponent(aVecId, 0);
1242 anYCoord += aCellVectors->GetComponent(aVecId, 1);
1243 aZCoord += aCellVectors->GetComponent(aVecId, 2);
1246 aXCoord = aXCoord / aNbVectors;
1247 anYCoord = anYCoord / aNbVectors;
1248 aZCoord = aZCoord / aNbVectors;
1250 // set vector data for the cell
1251 aVectorsToSet->SetTuple3(aNewCellId, aXCoord, anYCoord, aZCoord);
1254 aVectorsToSet->SetTuple3(aNewCellId, 0, 0, 0);
1257 aCellsToWarp->GetCellData()->SetVectors(aVectorsToSet);
1259 aVectorsToSet->Delete();
1260 aCellVectors->Delete();
1261 aNeighbourCells->Delete();
1264 myWarpVector->SetScaleFactor(myGaussPointsPL->GetScale());
1266 myCellDataToPointData->SetInput(aCellsToWarp);
1267 myCellDataToPointData->PassCellDataOn();
1268 aCellsToWarp->Delete();
1270 myWarpVector->SetInput(myCellDataToPointData->GetUnstructuredGridOutput());
1271 vtkUnstructuredGrid* aWarpedDataSet = myWarpVector->GetUnstructuredGridOutput();
1272 aWarpedDataSet->Update();
1273 myCellSource->SetPoints(aWarpedDataSet->GetPoints());
1276 myCellSource->SetPoints(aCellDataSet->GetPoints());
1278 myCellActor->SetVisibility(anIsVisible && theIsHighlight && aShowCellActor);
1284 ::UpdatePickingSettings()
1286 //printf( "VISU_GaussPtsAct::UpdatePickingSettings()\n" );
1287 VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
1288 if(!aPickingSettings)
1291 myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
1292 myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
1294 vtkFloatingPointType aHeight = myGaussPointsPL->GetMaxPointSize()*aPickingSettings->GetPyramidHeight();
1295 vtkFloatingPointType aCursorSize = aPickingSettings->GetCursorSize();
1296 myCursorPyramid->SetPreferences(aHeight,aCursorSize);
1297 myCursorPyramidSelected->SetPreferences(aHeight,aCursorSize);
1299 myHighlightActor->GetProperty()->SetColor( aPickingSettings->GetColor() );
1300 myPointPicker->SetTolerance( aPickingSettings->GetPointTolerance() );
1302 Highlight(isHighlighted());
1307 //----------------------------------------------------------------
1310 ::SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings)
1312 if(myInsideCursorSettings == theInsideCursorSettings)
1315 if(myInsideCursorSettings)
1316 myInsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1318 myInsideCursorSettings = theInsideCursorSettings;
1320 if(theInsideCursorSettings){
1321 theInsideCursorSettings->AddObserver(VISU::UpdateInsideSettingsEvent,
1322 myEventCallbackCommand.GetPointer(),
1324 UpdateInsideCursorSettings();
1330 ::UpdateInsideCursorSettings()
1332 UpdateInsideCursorSettings( myDeviceActor );
1337 ::UpdateInsideCursorSettings( PDeviceActor theActor )
1339 if(!myInsideCursorSettings || myInsideCursorSettings->GetInitial())
1342 VISU_GaussPointsPL* aPipeline = theActor->GetPipeLine();
1344 vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
1346 aPipeline->ShallowCopy(GetGaussPointsPL(), true);
1348 aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1350 aPipeline->SetPrimitiveType( myInsideCursorSettings->GetPrimitiveType() );
1351 aPipeline->SetClamp( myInsideCursorSettings->GetClamp() );
1352 aPipeline->SetImageData( myInsideCursorSettings->GetTexture() );
1353 aPipeline->SetAlphaThreshold( myInsideCursorSettings->GetAlphaThreshold() );
1354 aPipeline->SetResolution( myInsideCursorSettings->GetResolution() );
1355 aPipeline->SetMinSize( myInsideCursorSettings->GetMinSize() );
1356 aPipeline->SetMaxSize( myInsideCursorSettings->GetMaxSize() );
1357 aPipeline->SetMagnification( myInsideCursorSettings->GetMagnification() );
1358 aPipeline->SetMagnificationIncrement( myInsideCursorSettings->GetIncrement() );
1360 if( myInsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1361 theActor->GetProperty()->SetRepresentation( VTK_POINTS );
1363 theActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1365 aPipeline->Update();
1367 Highlight(isHighlighted());
1372 //----------------------------------------------------------------------------
1377 unsigned long int aTime = Superclass::GetMTime();
1378 aTime = std::max(aTime, myGaussPointsPL->GetPointSpriteMapper()->GetMTime() );
1382 void VISU_GaussPtsAct::RemoveAllClippingPlanes()
1384 myFunction->GetFunction()->RemoveAllItems();
1385 myFunction->Modified();
1388 vtkIdType VISU_GaussPtsAct::GetNumberOfClippingPlanes()
1390 return myFunction->GetFunction()->GetNumberOfItems();
1393 bool VISU_GaussPtsAct::AddClippingPlane(vtkPlane* thePlane)
1395 vtkImplicitFunctionCollection* aFunctions = GetClippingPlanes();
1396 aFunctions->InitTraversal();
1397 vtkImplicitFunction* aItem;
1398 while ((aItem = aFunctions->GetNextItem())) {
1399 if (thePlane == aItem)
1402 myFunction->AddFunction(thePlane);
1406 vtkPlane* VISU_GaussPtsAct::GetClippingPlane(vtkIdType theID)
1408 vtkPlane* aPlane = NULL;
1409 if ((theID >= 0) && (theID < GetNumberOfClippingPlanes())) {
1410 vtkImplicitFunctionCollection* aFunction = myFunction->GetFunction();
1411 vtkImplicitFunction* aFun = NULL;
1412 aFunction->InitTraversal();
1413 for (vtkIdType i = 0; i <= theID; i++)
1414 aFun = aFunction->GetNextItem();
1415 aPlane = dynamic_cast<vtkPlane*>(aFun);
1420 vtkImplicitFunctionCollection* VISU_GaussPtsAct::GetClippingPlanes()
1422 return myFunction->GetFunction();
1427 //==============================================================================
1428 vtkStandardNewMacro(VISU_GaussPtsAct1);
1431 //----------------------------------------------------------------------------
1433 ::VISU_GaussPtsAct1():
1434 myInsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1435 myOutsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1436 myOutsideCursorSettings(NULL)
1438 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::VISU_GaussPtsAct1 - this = "<<this);
1440 myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents);
1442 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
1444 myInsideDeviceActor->SetVisibility(false);
1445 myInsideDeviceActor->SetPickable(false);
1446 myInsideDeviceActor->SetUserMatrix(aMatrix);
1447 myInsideDeviceActor->Delete();
1449 myOutsideDeviceActor->SetVisibility(false);
1450 myOutsideDeviceActor->SetPickable(false);
1451 myOutsideDeviceActor->SetUserMatrix(aMatrix);
1452 myOutsideDeviceActor->Delete();
1457 ::~VISU_GaussPtsAct1()
1459 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::~VISU_GaussPtsAct1 - this = "<<this);
1461 SetOutsideCursorSettings(NULL);
1465 //----------------------------------------------------------------------------
1468 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1470 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::ShallowCopyPL - this = "<<this);
1472 Superclass::ShallowCopyPL(thePipeLine);
1474 UpdateOutsideCursorSettings();
1478 //----------------------------------------------------------------------------
1481 ::AddToRender(vtkRenderer* theRenderer)
1483 Superclass::AddToRender(theRenderer);
1485 //myInsideDeviceActor->AddToRender(theRenderer);
1486 //myOutsideDeviceActor->AddToRender(theRenderer);
1491 ::RemoveFromRender(vtkRenderer* theRenderer)
1493 //myInsideDeviceActor->RemoveFromRender(theRenderer);
1494 //myOutsideDeviceActor->RemoveFromRender(theRenderer);
1496 Superclass::RemoveFromRender(theRenderer);
1501 ::SetTransform(VTKViewer_Transform* theTransform)
1503 Superclass::SetTransform(theTransform);
1505 myInsideDeviceActor->SetTransform(theTransform);
1506 myOutsideDeviceActor->SetTransform(theTransform);
1512 ::RenderOpaqueGeometry(vtkViewport *viewport)
1515 Superclass::RenderOpaqueGeometry(viewport);
1516 GetMatrix(myInsideDeviceActor->GetUserMatrix());
1517 GetMatrix(myOutsideDeviceActor->GetUserMatrix());
1523 ::RenderTranslucentGeometry(vtkViewport *viewport)
1525 Superclass::RenderTranslucentGeometry(viewport);
1526 GetMatrix(myInsideDeviceActor->GetUserMatrix());
1527 GetMatrix(myOutsideDeviceActor->GetUserMatrix());
1532 //----------------------------------------------------------------------------
1535 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1537 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetWidgetCtrl - this = "<<this);
1539 if(myWidgetCtrl == theWidgetCtrl){
1544 myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1545 myInsideDeviceActor->SetVisibility(false);
1547 myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1548 myOutsideDeviceActor->SetVisibility(false);
1551 Superclass::SetWidgetCtrl(theWidgetCtrl);
1554 myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1555 myInsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1557 myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1558 myOutsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1563 //----------------------------------------------------------------------------
1566 ::SetMapperInput(vtkDataSet* theDataSet)
1568 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetMapperInput - this = "<<this);
1570 Superclass::SetMapperInput(theDataSet);
1572 // if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1573 // myInsideDeviceActor->SetPipeLine(aPipeLine);
1574 // aPipeLine->Delete();
1577 // if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1578 // myOutsideDeviceActor->SetPipeLine(aPipeLine);
1579 // aPipeLine->Delete();
1581 // aPipeLine->SetExtractBoundaryCells(true);
1582 // aPipeLine->SetExtractInside(true);
1587 //----------------------------------------------------------------------------
1588 vtkFloatingPointType
1590 ::GetRadius(vtkIdType theObjID,
1592 vtkDataArray *theScalarArray)
1594 VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1595 if(IsSegmentationEnabled()){
1596 if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1597 aPipeLine = myOutsideDeviceActor->GetPipeLine();
1599 aPipeLine = myInsideDeviceActor->GetPipeLine();
1601 return ::GetRadius(theVTKID,theScalarArray,aPipeLine);
1605 //----------------------------------------------------------------------------
1606 vtkFloatingPointType
1608 ::GetMagnification(vtkIdType theObjID)
1610 VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1611 if(IsSegmentationEnabled()){
1612 if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1613 aPipeLine = myOutsideDeviceActor->GetPipeLine();
1615 aPipeLine = myInsideDeviceActor->GetPipeLine();
1617 return aPipeLine->GetMagnification();
1621 //----------------------------------------------------------------------------
1622 vtkFloatingPointType
1624 ::GetClamp(vtkIdType theObjID)
1626 if(IsSegmentationEnabled()){
1627 if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1628 return ::GetClamp(myOutsideDeviceActor->GetPipeLine());
1630 return ::GetClamp(myInsideDeviceActor->GetPipeLine());
1632 return Superclass::GetClamp(theObjID);
1636 //----------------------------------------------------------------
1639 VISU_GaussPtsAct1::SetPosition(double _arg[3]){
1640 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetPosition - this = "<<this);
1641 Superclass::SetPosition(_arg);
1642 myUpdatePositionSignal(_arg);
1647 ::Connect(VISU_GaussPtsAct2* theActor)
1649 mySetVisibilitySignal.connect(boost::bind(&VISU_GaussPtsAct2::SetVisibility,theActor,_1));
1650 myUpdatePositionSignal.connect(boost::bind(&VISU_GaussPtsAct2::SetPosition, theActor,_1));
1655 ::SetVisibility(int theMode)
1657 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetVisibility - this = "<<this);
1659 Superclass::SetVisibility(theMode);
1661 bool aVisisbility = GetVisibility();
1662 bool anIsSegementation = IsSegmentationEnabled();
1663 myDeviceActor->SetVisibility(aVisisbility/* && !anIsSegementation*/);
1664 myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1665 myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1667 mySetVisibilitySignal(GetVisibility());
1670 //----------------------------------------------------------------
1673 ::UpdateInsideCursorSettings()
1675 Superclass::UpdateInsideCursorSettings( myInsideDeviceActor );
1678 //----------------------------------------------------------------
1681 ::SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings)
1683 if(myOutsideCursorSettings == theOutsideCursorSettings)
1686 if(myOutsideCursorSettings)
1687 myOutsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1689 myOutsideCursorSettings = theOutsideCursorSettings;
1691 if(theOutsideCursorSettings)
1693 theOutsideCursorSettings->AddObserver(VISU::UpdateOutsideSettingsEvent,
1694 myEventCallbackCommand.GetPointer(),
1696 UpdateOutsideCursorSettings();
1702 ::UpdateOutsideCursorSettings()
1704 if(!myOutsideCursorSettings || myOutsideCursorSettings->GetInitial())
1707 VISU_GaussPointsPL* aPipeline = myOutsideDeviceActor->GetPipeLine();
1709 vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
1710 vtkFloatingPointType aMagnification = aPipeline->GetMagnification();
1712 aPipeline->ShallowCopy(GetGaussPointsPL(), true);
1714 aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1715 aPipeline->SetExtractBoundaryCells(true);
1716 //aPipeline->SetExtractInside(true);
1717 aPipeline->SetMagnification( aMagnification );
1719 aPipeline->SetPrimitiveType( myOutsideCursorSettings->GetPrimitiveType() );
1721 if( myOutsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1722 myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_POINTS );
1724 myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1726 aPipeline->SetClamp( myOutsideCursorSettings->GetClamp() );
1727 aPipeline->SetImageData( myOutsideCursorSettings->GetTexture() );
1728 aPipeline->SetAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() );
1729 aPipeline->SetResolution( myOutsideCursorSettings->GetResolution() );
1730 aPipeline->SetSize( myOutsideCursorSettings->GetSize() );
1731 aPipeline->SetMagnification( myOutsideCursorSettings->GetMagnification() );
1732 aPipeline->SetMagnificationIncrement( myOutsideCursorSettings->GetIncrement() );
1734 if( myOutsideCursorSettings->GetUniform() )
1736 myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOff();
1737 myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 1 ); // Geometry mode
1738 myOutsideDeviceActor->GetProperty()->SetColor( myOutsideCursorSettings->GetColor() );
1742 myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 2 ); // Outside cursor mode
1743 myOutsideDeviceActor->GetPointSpriteMapper()->SetColorModeToMapScalars();
1744 myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOn();
1747 aPipeline->Update();
1749 Highlight(isHighlighted());
1755 //----------------------------------------------------------------
1758 ::ProcessEvents(vtkObject* theObject,
1759 unsigned long theEvent,
1760 void* theClientData,
1763 if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
1764 if(VISU_GaussPtsAct1* self = dynamic_cast<VISU_GaussPtsAct1*>(anObject))
1765 if(theEvent == VISU::UpdateOutsideSettingsEvent)
1766 self->UpdateOutsideCursorSettings();
1768 Superclass::ProcessEvents(theObject,theEvent,theClientData,theCallData);
1773 ::OnInteractorEvent(unsigned long theEvent)
1776 case vtkCommand::StartInteractionEvent:
1777 myDeviceActor->SetVisibility(GetVisibility());
1778 myInsideDeviceActor->SetVisibility(false);
1779 myOutsideDeviceActor->SetVisibility(false);
1781 case vtkCommand::EnableEvent:
1782 case vtkCommand::DisableEvent:
1783 case vtkCommand::EndInteractionEvent: {
1784 bool aVisisbility = GetVisibility();
1785 bool anIsSegementation = IsSegmentationEnabled();
1786 myDeviceActor->SetVisibility(aVisisbility/* && !anIsSegementation*/);
1787 myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1788 myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1795 Superclass::OnInteractorEvent(theEvent);
1798 //----------------------------------------------------------------------------
1803 unsigned long int aSize = Superclass::GetMemorySize();
1804 if(IsSegmentationEnabled()){
1805 aSize += myInsideDeviceActor->GetMemorySize();
1806 aSize += myOutsideDeviceActor->GetMemorySize();
1813 //==============================================================================
1814 vtkStandardNewMacro(VISU_GaussPtsAct2);
1817 //----------------------------------------------------------------------------
1819 ::VISU_GaussPtsAct2()
1821 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::VISU_GaussPtsAct2 - this = "<<this);
1822 myDeviceActor->SetVisibility(false);
1826 ::~VISU_GaussPtsAct2()
1828 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::~VISU_GaussPtsAct2 - this = "<<this);
1832 //----------------------------------------------------------------------------
1835 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1837 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::ShallowCopyPL - this = "<<this);
1839 Superclass::ShallowCopyPL(thePipeLine);
1842 //----------------------------------------------------------------------------
1844 VISU_GaussPtsAct2::SetPosition(double _arg[3]){
1845 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct2::SetPosition - this = "<<this);
1846 Superclass::SetPosition(_arg);
1849 //----------------------------------------------------------------------------
1852 ::SetMapperInput(vtkDataSet* theDataSet)
1854 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetMapperInput - this = "<<this);
1855 Superclass::SetMapperInput(theDataSet);
1856 // if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1857 // myDeviceActor->SetPipeLine(aPipeLine);
1858 // myCurrentPL = aPipeLine;
1859 // aPipeLine->Delete();
1861 // myMapper->SetInput(myCurrentPL->GetPickableDataSet());
1862 // SetMapper(myMapper.GetPointer());
1866 //----------------------------------------------------------------------------
1869 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1871 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetWidgetCtrl - this = "<<this);
1873 if(myWidgetCtrl == theWidgetCtrl)
1877 theWidgetCtrl->RemoveObserver(myEventCallbackCommand.GetPointer());
1878 myDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1879 myDeviceActor->SetVisibility(false);
1882 Superclass::SetWidgetCtrl(theWidgetCtrl);
1885 myDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1886 myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1891 //----------------------------------------------------------------------------
1896 if(IsSegmentationEnabled())
1897 return Superclass::GetMemorySize();
1902 //----------------------------------------------------------------------------
1905 ::SetVisibility(int theMode)
1907 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetVisibility - this = "<<this);
1909 Superclass::SetVisibility(theMode);
1911 myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1916 ::OnInteractorEvent(unsigned long theEvent)
1919 case vtkCommand::EnableEvent:
1920 case vtkCommand::DisableEvent:
1921 myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1922 if(theEvent == vtkCommand::EnableEvent)
1925 case vtkCommand::EndInteractionEvent:
1931 Superclass::OnInteractorEvent(theEvent);