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 <SALOME_ExtractPolyDataGeometry.h>
43 #include <vtkCamera.h>
44 #include <vtkRenderer.h>
45 #include <vtkPointPicker.h>
46 #include <vtkMatrix4x4.h>
47 #include <vtkScalarBarWidget.h>
48 #include <vtkTextMapper.h>
49 #include <vtkTextProperty.h>
50 #include <vtkImplicitBoolean.h>
51 #include <vtkImplicitFunctionCollection.h>
54 #include <vtkPointData.h>
55 #include <vtkCellData.h>
56 #include <vtkDataArray.h>
58 #include <vtkSphereSource.h>
59 #include <vtkPolyDataMapper.h>
60 #include <vtkPolyData.h>
62 #include <vtkTransform.h>
64 #include <vtkObjectFactory.h>
65 #include <vtkCallbackCommand.h>
66 #include <vtkInteractorStyle.h>
67 #include <vtkRenderWindowInteractor.h>
68 #include <vtkOutlineSource.h>
71 #include <boost/bind.hpp>
73 #include <vtkUnstructuredGrid.h>
74 #include <vtkPolyDataMapper.h>
75 #include <vtkRenderWindow.h>
76 #include <vtkCellArray.h>
77 #include <vtkWarpVector.h>
78 #include <vtkCellDataToPointData.h>
82 #include <vtkViewport.h>
84 #include "utilities.h"
87 static int MYDEBUG = 0;
88 static int MYDEBUG1 = 0;
89 static int MYDEBUG2 = 0;
91 static int MYDEBUG = 0;
92 static int MYDEBUG1 = 0;
93 static int MYDEBUG2 = 0;
100 CheckIsSameValue(vtkFloatingPointType theTarget,
101 vtkFloatingPointType theSource)
103 static vtkFloatingPointType TOL = 10.0 / VTK_LARGE_FLOAT;
104 return fabs(theTarget - theSource) < TOL;
108 CheckIsSameVector(vtkFloatingPointType* theTarget,
109 vtkFloatingPointType* theSource,
112 for ( size_t anId = 0; anId < theLength; anId++ ) {
113 if ( !CheckIsSameValue( theTarget[ anId ], theSource[ anId ] ) )
122 //============================================================================
123 vtkStandardNewMacro(VISU_GaussPtsAct);
125 //----------------------------------------------------------------------------
127 ::VISU_GaussPtsAct():
128 myEventCallbackCommand(vtkCallbackCommand::New()),
130 myDeviceActor(VISU_GaussPtsDeviceActor::New()),
132 myGaussPointsPL(NULL),
133 myLastPreHighlightObjID(-1),
134 myCursorPyramid(VISU_CursorPyramid::New()),
135 myCursorPyramidSelected(VISU_CursorPyramid::New()),
136 myCellSource(vtkUnstructuredGrid::New()),
137 myCellActor(SVTK_Actor::New()),
138 myScalarBarCtrl(VISU_ScalarBarCtrl::New()),
139 myBarVisibility(true),
140 myInsideCursorSettings(NULL),
142 myMapper(vtkPolyDataMapper::New()),
143 myPolyDataExtractor(SALOME_ExtractPolyDataGeometry::New()),
144 myFunction(vtkImplicitBoolean::New()),
145 myWarpVector(vtkWarpVector::New()),
146 myCellDataToPointData(vtkCellDataToPointData::New())
148 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::VISU_GaussPtsAct - this = "<<this);
150 myEventCallbackCommand->Delete();
151 myDeviceActor->Delete();
153 myCursorPyramid->Delete();
154 myCursorPyramid->SetPickable(0);
155 myCursorPyramid->SetVisibility(0);
157 myCursorPyramidSelected->Delete();
158 myCursorPyramidSelected->SetPickable(0);
159 myCursorPyramidSelected->SetVisibility(0);
161 myCellSource->Delete();
162 myCellActor->Delete();
164 myEventCallbackCommand->SetClientData(this);
165 myEventCallbackCommand->SetCallback(VISU_GaussPtsAct::ProcessEvents);
167 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
169 myDeviceActor->SetProperty(GetProperty());
170 myDeviceActor->SetUserMatrix(aMatrix);
171 myDeviceActor->SetVisibility(true);
172 myDeviceActor->SetPickable(false);
174 myCellSource->Allocate();
175 myCellActor->Initialize();
176 myCellActor->SetRepresentation(VTK_WIREFRAME);
177 myCellActor->SetSource(myCellSource.GetPointer());
179 myCellActor->SetVisibility(0);
180 myCellActor->SetPickable(0);
181 myCellActor->GetProperty()->SetAmbient(1.0);
182 myCellActor->GetProperty()->SetDiffuse(0.0);
184 myScalarBarCtrl->Delete();
189 myWarpVector->Delete();
190 myCellDataToPointData->Delete();
192 myPolyDataExtractor->SetImplicitFunction(myFunction);
193 //myPolyDataExtractor->ExtractBoundaryCellsOn();
195 myFunction->SetOperationTypeToIntersection();
196 myPolyDataExtractor->Delete();
197 myFunction->Delete();
199 if( VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get() )
200 aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent,
201 myEventCallbackCommand.GetPointer(),
206 ::~VISU_GaussPtsAct()
208 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::~VISU_GaussPtsAct - this = "<<this);
211 SetInsideCursorSettings(NULL);
215 //----------------------------------------------------------------------------
218 ::SetPipeLine(VISU_PipeLine* thePipeLine)
220 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::SetPipeLine - this = "<<this);
222 myGaussPointsPL = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine);
224 Superclass::SetPipeLine(thePipeLine);
231 return myGaussPointsPL.GetPointer();
234 //----------------------------------------------------------------------------
237 ::DeepCopy(VISU_Actor *theActor)
239 if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
240 Superclass::DeepCopy(theActor);
241 SetBarVisibility(anActor->GetBarVisibility());
245 //----------------------------------------------------------------------------
248 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
250 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::ShallowCopyPL - this = "<<this);
252 Superclass::ShallowCopyPL(thePipeLine);
254 UpdateInsideCursorSettings();
256 Highlight(isHighlighted());
260 //----------------------------------------------------------------------------
266 //vtkMapper* aMapper = myCurrentPL->GetPointSpriteMapper();
270 return myMapper.GetPointer();
273 vtkFloatingPointType*
277 return GetMapper()->GetBounds();
284 return GetMapper()->GetInput();
295 //----------------------------------------------------------------------------
300 vtkDataSet* aDataSet = myDeviceActor->GetMapper()->GetInput();
301 unsigned long int aSize = aDataSet->GetActualMemorySize() * 1024;
303 aSize += Superclass::GetMemorySize();
308 //----------------------------------------------------------------------------
311 ::AddToRender(vtkRenderer* theRenderer)
313 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::AddToRender - this = "<<this);
315 Superclass::AddToRender(theRenderer);
317 myDeviceActor->AddToRender(theRenderer);
319 theRenderer->AddActor(myCellActor.GetPointer());
321 myCursorPyramid->AddToRender(theRenderer);
322 myCursorPyramidSelected->AddToRender(theRenderer);
323 myScalarBarCtrl->AddToRender(theRenderer);
328 ::RemoveFromRender(vtkRenderer* theRenderer)
330 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::RemoveFromRender - this = "<<this);
332 myDeviceActor->RemoveFromRender(theRenderer);
334 theRenderer->RemoveActor(myCellActor.GetPointer());
336 myCursorPyramid->RemoveFromRender(theRenderer);
337 myCursorPyramidSelected->RemoveFromRender(theRenderer);
338 myScalarBarCtrl->RemoveFromRender(theRenderer);
340 Superclass::RemoveFromRender(theRenderer);
345 ::SetTransform(VTKViewer_Transform* theTransform)
347 Superclass::SetTransform(theTransform);
349 myDeviceActor->SetTransform(theTransform);
354 ::RenderOpaqueGeometry(vtkViewport *viewport)
356 GetMatrix(myDeviceActor->GetUserMatrix());
362 ::RenderTranslucentGeometry(vtkViewport *viewport)
364 GetMatrix(myDeviceActor->GetUserMatrix());
369 //----------------------------------------------------------------------------
372 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
374 if(myWidgetCtrl == theWidgetCtrl)
378 MESSAGE("VISU_GaussPtsAct::SetWidgetCtrl - this = "<<this<<"; theWidget = "<<theWidgetCtrl);
381 myWidgetCtrl->RemoveObserver(myEventCallbackCommand.GetPointer());
384 theWidgetCtrl->AddObserver(vtkCommand::EnableEvent,
385 myEventCallbackCommand.GetPointer(),
387 theWidgetCtrl->AddObserver(vtkCommand::DisableEvent,
388 myEventCallbackCommand.GetPointer(),
390 theWidgetCtrl->AddObserver(vtkCommand::StartInteractionEvent,
391 myEventCallbackCommand.GetPointer(),
393 theWidgetCtrl->AddObserver(vtkCommand::EndInteractionEvent,
394 myEventCallbackCommand.GetPointer(),
398 myWidgetCtrl = theWidgetCtrl;
403 ::GetChangeMagnification()
405 return myChangeMagnification;
410 ::ChangeMagnification( bool up )
412 myEventCallbackCommand->SetAbortFlag(1);
414 vtkFloatingPointType aMagnification = myInsideCursorSettings->GetMagnification();
415 vtkFloatingPointType anIncrement = myInsideCursorSettings->GetIncrement();
416 vtkFloatingPointType coefficient = up ? anIncrement : 1 / anIncrement;
418 myInsideCursorSettings->SetMagnification( aMagnification * coefficient );
419 myInsideCursorSettings->InvokeEvent(VISU::UpdateFromSettingsEvent,NULL);
424 //----------------------------------------------------------------------------
428 CreatePipeLine(VISU_GaussPointsPL* thePipeLine)
430 VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New();
431 aPipeLine->ShallowCopy(thePipeLine, true);
439 ::SetMapperInput(vtkDataSet* theDataSet)
441 if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::SetMapperInput - this = "<<this);
443 myDeviceActor->SetExtractor(myPolyDataExtractor);
444 myDeviceActor->SetPipeLine(GetGaussPointsPL());
445 myCurrentPL = myDeviceActor->GetPipeLine();
447 //SetMapper(myCurrentPL->GetPointSpriteMapper());
449 // myPolyDataExtractor->SetInput(myCurrentPL->GetPickableDataSet());
450 //myMapper->SetInput(myPolyDataExtractor->GetOutput());
451 myMapper->SetInput(myCurrentPL->GetPickableDataSet());
452 SetMapper(myMapper.GetPointer());
456 //----------------------------------------------------------------------------
461 GetRadius(vtkIdType theVTKID,
462 vtkDataArray *theScalarArray,
463 VISU_GaussPointsPL* theGaussPointsPL)
465 vtkFloatingPointType aRadius = 0.5;
466 if(theGaussPointsPL->GetPointSpriteMapper()->GetPointSpriteMode() == 1) // Geometry mode
467 aRadius *= theGaussPointsPL->GetSize() * theGaussPointsPL->GetAverageCellSize();
468 else if(theGaussPointsPL->GetBicolor()){
469 vtkFloatingPointType aVal = theScalarArray->GetTuple1(theVTKID);
471 aRadius *= theGaussPointsPL->GetMaxSize();
473 aRadius *= theGaussPointsPL->GetMinSize();
474 aRadius *= theGaussPointsPL->GetAverageCellSize();
476 aRadius *= theGaussPointsPL->GetPointSize(theVTKID,theScalarArray);
484 ::GetRadius(vtkIdType theObjID,
486 vtkDataArray *theScalarArray)
488 return ::GetRadius(theVTKID,theScalarArray,myDeviceActor->GetPipeLine());
491 //----------------------------------------------------------------------------
494 ::GetMagnification(vtkIdType theObjID)
496 return myDeviceActor->GetPipeLine()->GetMagnification();
500 //----------------------------------------------------------------------------
505 GetClamp(VISU_GaussPointsPL* theGaussPointsPL)
507 vtkFloatingPointType aClamp = theGaussPointsPL->GetClamp();
508 if(theGaussPointsPL->GetPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere)
516 ::GetClamp(vtkIdType theObjID)
518 return ::GetClamp(myDeviceActor->GetPipeLine());
522 //----------------------------------------------------------------------------
525 ::SetFactory(VISU::TActorFactory* theActorFactory)
527 using namespace VISU;
528 myGaussPtsActorFactory = dynamic_cast<TGaussPtsActorFactory*>(theActorFactory);
529 myUpdatePrs3dSignal.connect(boost::bind(&TGaussPtsActorFactory::UpdateFromActor,
530 myGaussPtsActorFactory,
532 Superclass::SetFactory(theActorFactory);
535 VISU::TGaussPtsActorFactory*
537 ::GetGaussPtsFactory()
539 return myGaussPtsActorFactory;
543 //----------------------------------------------------------------------------
546 ::SetVisibility(int theMode)
548 Superclass::SetVisibility(theMode);
549 myDeviceActor->SetVisibility(GetVisibility()); // VSV
550 myScalarBarCtrl->SetVisibility(theMode);
551 Highlight(isHighlighted());
556 ::IsSegmentationEnabled()
558 return myWidgetCtrl && myWidgetCtrl->GetEnabled();
562 //----------------------------------------------------------------------------
565 ::SetBarVisibility(bool theMode)
567 myBarVisibility = theMode;
568 myScalarBarCtrl->SetCtrlVisibility(theMode);
569 myScalarBarCtrl->SetVisibility(GetVisibility());
576 return myBarVisibility;
583 return myScalarBarCtrl.GetPointer();
586 //----------------------------------------------------------------------------
589 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
591 if(theInteractor == myInteractor)
595 myInteractor->RemoveObserver(myEventCallbackCommand.GetPointer());
598 theInteractor->AddObserver(vtkCommand::CharEvent,
599 myEventCallbackCommand.GetPointer(),
601 theInteractor->AddObserver(VISU::SetSMDecreaseMagnificationEvent,
602 myEventCallbackCommand.GetPointer(),
604 theInteractor->AddObserver(VISU::SetSMIncreaseMagnificationEvent,
605 myEventCallbackCommand.GetPointer(),
608 Superclass::SetInteractor(theInteractor);
612 //-------------------------------------------------------------------------
615 ::ProcessEvents(vtkObject* vtkNotUsed(theObject),
616 unsigned long theEvent,
618 void* vtkNotUsed(theCallData))
620 if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
621 if(VISU_GaussPtsAct* self = dynamic_cast<VISU_GaussPtsAct*>(anObject)) {
622 if(theEvent == VISU::UpdateInsideSettingsEvent)
623 self->UpdateInsideCursorSettings();
625 self->OnInteractorEvent(theEvent);
629 //-------------------------------------------------------------------------
632 ::OnInteractorEvent(unsigned long theEvent)
635 case vtkCommand::CharEvent: {
636 switch(myInteractor->GetKeyCode()) {
640 if( IsSegmentationEnabled() )
642 this->ChangeMagnification( myInteractor->GetShiftKey() );
646 myChangeMagnification = myInteractor->GetShiftKey();
652 if( IsSegmentationEnabled() && myWidgetCtrl->IsSphereActive() )
654 VISU_SphereWidget* aSphereWidget = myWidgetCtrl->GetSphereWidget();
655 aSphereWidget->ChangeRadius( myInteractor->GetShiftKey() );
656 myWidgetCtrl->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
657 myWidgetCtrl->GetInteractor()->Render();
664 myUpdatePrs3dSignal(this);
667 case VISU::SetSMDecreaseMagnificationEvent:
668 case VISU::SetSMIncreaseMagnificationEvent:
669 myChangeMagnification = theEvent == VISU::SetSMIncreaseMagnificationEvent;
670 myUpdatePrs3dSignal(this);
672 case VISU::UpdatePickingSettingsEvent:
673 UpdatePickingSettings();
675 case vtkCommand::EndInteractionEvent:
676 case vtkCommand::EnableEvent:
677 case vtkCommand::DisableEvent:
678 myCurrentPL->GetMapper()->Update();
679 Highlight(isHighlighted());
686 //----------------------------------------------------------------------------
691 if(vtkMapper* aMapper = myDeviceActor->GetMapper()){
692 if(vtkDataSet* aDataSet= aMapper->GetInput()){
694 myIsInfinite = aDataSet->GetNumberOfCells() < 2;
700 //----------------------------------------------------------------------------
705 if(Superclass::GetPickable()){
706 if(vtkMapper* aMapper = GetMapper()){
707 if(vtkDataSet* aDataSet= aMapper->GetInput()){
709 return aDataSet->GetNumberOfCells() > 0;
717 //----------------------------------------------------------------------------
720 ::PreHighlight(vtkInteractorStyle* theInteractorStyle,
721 SVTK_SelectionEvent* theSelectionEvent,
724 if ( !GetPickable() )
727 myPreHighlightActor->SetVisibility(false);
728 myCursorPyramid->SetVisibility(false);
730 if (!myBarVisibility)
735 myLastPreHighlightObjID = -1;
737 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
739 if(aSelectionMode == ActorSelection || !theIsHighlight)
740 return Superclass::PreHighlight(theInteractorStyle,
744 bool anIsChanged = (mySelectionMode != aSelectionMode);
745 bool anIsPreselected = myIsPreselected;
746 myIsPreselected = false;
748 VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
750 if(aSelectionMode == GaussPointSelection && theIsHighlight){
751 myPointPicker->Pick(theSelectionEvent->myX,
752 theSelectionEvent->myY,
754 theInteractorStyle->GetCurrentRenderer());
756 if(myPointPicker->GetActor() != this)
757 return (anIsPreselected != myIsPreselected);
759 vtkIdType aVtkId = myPointPicker->GetPointId();
761 if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){
762 vtkIdType anObjId = GetNodeObjId( aVtkId );
763 myIsPreselected = (anObjId >= 0);
765 anIsChanged = (myLastPreHighlightObjID != anObjId);
767 vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
768 //Take into account translation
769 vtkFloatingPointType aLocalNodeCoord[3];
770 this->Transform->Push();
771 this->Transform->PostMultiply();
772 this->Transform->Identity();
774 this->Transform->Translate(this->Position[0],
778 this->Transform->GetPosition(aPosition);
780 aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0];
781 aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
782 aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
784 vtkDataSet* aDataSet = GetInput();
785 vtkPointData* aPointData = aDataSet->GetPointData();
786 if(vtkDataArray *aScalarArray = aPointData->GetScalars()){
787 vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight();
788 aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
789 //vtkFloatingPointType aColor[3] = myPreHighlightActor->GetProperty()->GetColor();
790 vtkFloatingPointType aColor[3];
791 theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor );
792 aColor[0] = 1. - aColor[0];
793 aColor[1] = 1. - aColor[1];
794 aColor[2] = 1. - aColor[2];
796 myCursorPyramid->Init(aPyramidHeight,
797 aPickingSettings->GetCursorSize(),
798 GetRadius(anObjId,aVtkId,aScalarArray),
799 GetMagnification(anObjId),
804 this->Transform->Pop();
805 myLastPreHighlightObjID = anObjId;
807 myCursorPyramid->SetVisibility(true);
812 mySelectionMode = aSelectionMode;
813 anIsChanged |= (anIsPreselected != myIsPreselected);
819 //----------------------------------------------------------------------------
822 ChangeZoom(VISU_PickingSettings *thePickingSettings,
823 vtkRenderer* theRenderer,
824 vtkIdType theInitialHasIndex,
825 vtkIdType theCurrentHasIndex)
827 if( (theInitialHasIndex + theCurrentHasIndex == 1) && thePickingSettings){
828 vtkCamera *aCamera = theRenderer->GetActiveCamera();
830 vtkFloatingPointType aZoomFactor = thePickingSettings->GetZoomFactor();
831 double aScale = aCamera->GetParallelScale();
832 if ( !theInitialHasIndex && theCurrentHasIndex ) {
833 aCamera->SetParallelScale( aScale/aZoomFactor );
836 aCamera->SetParallelScale( aScale*aZoomFactor );
844 ::Highlight(vtkInteractorStyle* theInteractorStyle,
845 SVTK_SelectionEvent* theSelectionEvent,
848 if ( !GetPickable() )
851 // int anInitialHasIndex = myIsSubElementsHighlighted && mySelectionMode == GaussPointSelection;
852 Handle(SALOME_InteractiveObject) anIO = getIO();
853 // myIsSubElementsHighlighted = false;
855 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
857 if(!theIsHighlight && aSelectionMode == GaussPointSelection){
858 mySelector->RemoveIObject(anIO);
860 /* ChangeZoom(myPickingSettings,
869 if (!myBarVisibility)
873 if(aSelectionMode == ActorSelection)
874 return Superclass::Highlight(theInteractorStyle,
878 if(aSelectionMode == GaussPointSelection && !theSelectionEvent->myIsRectangle){
880 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
881 myPointPicker->Pick(theSelectionEvent->myX,
882 theSelectionEvent->myY,
886 if(myPointPicker->GetActor() != this) {
887 mySelector->ClearIObjects();
889 /* ChangeZoom(myPickingSettings,
898 vtkIdType aVtkId = myPointPicker->GetPointId();
899 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO()) {
900 vtkIdType anObjId = GetNodeObjId( aVtkId );
902 // myIsHighlighted = true;
903 // Update the Selector
904 if(mySelector->IsSelected(myIO))
905 mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
907 if(!theSelectionEvent->myIsShift){
908 mySelector->ClearIObjects();
910 mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
911 mySelector->AddIObject(this);
914 vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
917 vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor();
918 vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
919 int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
921 anInteractor->SetDolly(0.);
922 anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber());
923 anInteractor->FlyTo(aRenderer,aNodeCoord);
924 aRenderer->ResetCameraClippingRange();
925 anInteractor->SetDolly(aDollyWas);
926 anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
928 anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);*/
930 mySelectionMode = aSelectionMode;
932 /* ChangeZoom(myPickingSettings,
939 }// if( anObjId >= 0 ) {
940 }//if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO())
941 }//if(!theSelectionEvent->myIsRectangle){
943 /* ChangeZoom(myPickingSettings,
954 void VISU_GaussPtsAct::SetPosition(double _arg[3]){
955 Superclass::SetPosition(_arg);
956 Highlight(isHighlighted());
959 //==================================================================
960 // function : Highlight
962 //==================================================================
965 ::Highlight(bool theIsHighlight)
967 if(!mySelector.GetPointer())
970 VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
972 Selection_Mode aSelectionMode = mySelector->SelectionMode();
974 bool anInitialHasIndex = isSubElementsHighlighted() && mySelectionMode == GaussPointSelection;
976 TColStd_IndexedMapOfInteger aMapIndex;
977 mySelector->GetIndex( getIO(), aMapIndex );
978 bool aCurrentHasIndex = aMapIndex.Extent() == 1;
979 bool anIsVisible = GetVisibility() && aCurrentHasIndex && theIsHighlight;
980 bool aShowTextActor = aPickingSettings->GetInfoWindowEnabled();
981 bool aShowCellActor = aPickingSettings->GetDisplayParentMesh();
983 myOutlineActor->SetVisibility(false);
984 myCursorPyramid->SetVisibility(false);
985 myTextActor->SetVisibility(anIsVisible && aShowTextActor);
986 myCellActor->SetVisibility(anIsVisible && aShowCellActor);
987 GetScalarBarCtrl()->SetIsMarked(anIsVisible);
988 myCursorPyramidSelected->SetVisibility(anIsVisible);
989 //GetScalarBarCtrl()->Update();
991 myIsSubElementsHighlighted = aCurrentHasIndex;
994 if( GetVisibility() && aPickingSettings->GetCameraMovementEnabled() )
996 ChangeZoom(aPickingSettings,
1002 if( aSelectionMode == ActorSelection ) {
1003 Superclass::Highlight(theIsHighlight);
1010 if( aSelectionMode != GaussPointSelection )
1013 if ( !aCurrentHasIndex || !myBarVisibility )
1016 // myTextActor->SetVisibility(anIsVisible);
1017 // myCellActor->SetVisibility(anIsVisible && myPickingSettings->GetDisplayParentMesh());
1018 // GetScalarBarCtrl()->SetIsMarked(anIsVisible);
1019 // myCursorPyramidSelected->SetVisibility(anIsVisible);
1020 //GetScalarBarCtrl()->Update();
1022 // myIsHighlighted = aCurrentHasIndex;
1024 // Zoom if necessary
1025 // ChangeZoom(myPickingSettings,
1027 // anInitialHasIndex,
1028 // aCurrentHasIndex);
1030 // TColStd_IndexedMapOfInteger aMapIndex;
1031 mySelector->GetIndex( getIO(), aMapIndex );
1032 if(aMapIndex.Extent() != 1 || !myBarVisibility) {
1036 vtkRenderer *aRenderer = GetRenderer();
1037 vtkCamera* aCamera = aRenderer->GetActiveCamera();
1039 int anObjId = aMapIndex(1);
1040 vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
1043 //Take into account translation
1044 vtkFloatingPointType aLocalNodeCoord[3];
1045 this->Transform->Push();
1046 this->Transform->PostMultiply();
1047 this->Transform->Identity();
1048 this->Transform->Translate(this->Position[0],
1051 double aPosition[3];
1052 this->Transform->GetPosition(aPosition);
1053 aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0];
1054 aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
1055 aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
1056 this->Transform->Pop();
1058 vtkFloatingPointType aFocalPnt[3];
1059 aCamera->GetFocalPoint(aFocalPnt);
1061 if ( CheckIsSameVector(aLocalNodeCoord, aFocalPnt, 3 ) )
1065 if( anIsVisible && aPickingSettings->GetCameraMovementEnabled() )
1067 vtkRenderWindowInteractor* anInteractor = myInteractor;
1068 vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
1069 int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
1071 anInteractor->SetDolly(0.0);
1072 anInteractor->SetNumberOfFlyFrames(aPickingSettings->GetStepNumber());
1073 anInteractor->FlyTo(aRenderer, aNodeCoord);
1074 aRenderer->ResetCameraClippingRange();
1075 anInteractor->SetDolly(aDollyWas);
1076 anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
1077 anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);
1080 std::ostringstream aStr;
1081 // int anObjId = aMapIndex(1);
1082 aStr<<"Global ID: "<<anObjId;
1084 vtkIdType aVtkId = GetNodeVTKID(anObjId);
1086 vtkFloatingPointType aWorldCoord[4] = {aLocalNodeCoord[0], aLocalNodeCoord[1], aLocalNodeCoord[2], 1.};
1088 vtkDataSet* aDataSet = GetInput();
1089 vtkPointData* aDataSetAttributes = aDataSet->GetPointData();
1091 if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){
1092 vtkFloatingPointType aVal = aScalarArray->GetTuple1(aVtkId);
1094 // GetScalarBarCtrl()->SetIsMarked(true);
1095 GetScalarBarCtrl()->SetMarkValue(aVal);
1096 GetScalarBarCtrl()->Update();
1098 vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight();
1099 aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
1100 myCursorPyramidSelected->Init(aPyramidHeight,
1101 aPickingSettings->GetCursorSize(),
1102 GetRadius(anObjId,aVtkId,aScalarArray),
1103 GetMagnification(anObjId),
1106 myHighlightActor->GetProperty()->GetColor());
1107 myCursorPyramidSelected->SetVisibility(anIsVisible && theIsHighlight);
1109 const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper =
1110 myGaussPointsPL->GetGaussPtsIDMapper();
1111 VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
1113 VISU::TGaussPointID aGaussPointID = myGaussPointsPL->GetObjID(anObjId);
1114 VISU::TCellID aCellID = aGaussPointID.first;
1115 VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
1116 aStr<<"\nParentCellID: "<<aCellID;
1117 std::string aParentName = aParent->GetElemName(aCellID);
1118 if(aParentName != "") {
1119 aStr<<"\nParentCellName: '"<<aParentName<<"'";
1121 aStr<<"\nLocalPntID: "<<aLocalPntID;
1122 aStr<<"\nScalar: "<<aVal;
1125 if(vtkDataArray* aFieldArray = aDataSetAttributes->GetArray("VISU_FIELD")){
1126 int aNbComp = aFieldArray->GetNumberOfComponents();
1127 std::vector<vtkFloatingPointType> aTuple(aNbComp);
1128 aFieldArray->GetTuple(aVtkId, &aTuple[0]);
1132 while(anId < aNbComp){
1133 vtkFloatingPointType aComp = aTuple[anId++];
1142 std::string aString = aStr.str();
1143 myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
1144 myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
1145 myTextActor->SetWorldPoint(aWorldCoord);
1146 myTextActor->SetText(aString.c_str());
1147 myTextActor->SetVisibility(anIsVisible && theIsHighlight && aShowTextActor);
1150 const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = myGaussPointsPL->GetGaussPtsIDMapper();
1151 VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
1153 myCellSource->Reset();
1154 myCellSource->Modified(); // a VTK bug
1155 vtkUnstructuredGrid* aCellDataSet = aParent->GetUnstructuredGridOutput();
1157 // get parent cell and insert it to myCellSource
1158 VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId);
1159 vtkIdType aCellID = aGaussPointID.first;
1160 vtkCell* aCell = aParent->GetElemCell(aCellID);
1161 myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
1163 if (myGaussPointsPL->GetIsDeformed()) {
1164 // find neighbour cells ids
1165 vtkIdList* aNeighbourCells = vtkIdList::New();
1166 aNeighbourCells->Allocate(VTK_CELL_SIZE);
1168 vtkIdList* aCellPoints = aCell->GetPointIds();
1170 vtkIdList *aPointCells = vtkIdList::New();
1171 aPointCells->Allocate(VTK_CELL_SIZE);
1173 vtkIdType aNbPoints = aCellPoints->GetNumberOfIds();
1174 for (vtkIdType i = 0; i < aNbPoints; i++) {
1175 aCellDataSet->GetPointCells(aCellPoints->GetId(i), aPointCells);
1178 vtkIdType aNbCells = aPointCells->GetNumberOfIds();
1179 for (vtkIdType j = 0; j < aNbCells; j++)
1180 aNeighbourCells->InsertUniqueId(aPointCells->GetId(j));
1183 aPointCells->Delete();
1186 vtkDataArray* anInputVectors = aDataSetAttributes->GetVectors();
1187 if (!anInputVectors)
1190 // insert neighbour cells to the special dataset
1191 vtkUnstructuredGrid *aCellsToWarp = vtkUnstructuredGrid::New();
1192 aCellsToWarp->SetPoints(aCellDataSet->GetPoints());
1194 vtkIdType aNbNeighbourCells = aNeighbourCells->GetNumberOfIds();
1196 vtkDataArray *aVectorsToSet = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
1197 aVectorsToSet->SetNumberOfComponents(3);
1198 aVectorsToSet->SetNumberOfTuples(aNbNeighbourCells);
1200 vtkDataArray *aCellVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
1201 aCellVectors->SetNumberOfComponents(3);
1203 int aNbComp = anInputVectors->GetNumberOfComponents();
1204 std::vector<vtkFloatingPointType> aTuple(aNbComp);
1206 for (vtkIdType i = 0; i < aNbNeighbourCells; i++) {
1207 vtkIdType aVTKCellId = aNeighbourCells->GetId(i);
1208 vtkIdType anObjCellId = aParent->GetElemObjID(aVTKCellId);
1210 vtkCell* aCurCell = aParent->GetElemCell(anObjCellId);
1212 vtkIdType aNewCellId = aCellsToWarp->InsertNextCell(aCurCell->GetCellType(), aCurCell->GetPointIds());
1214 // get gauss points corresponding to the current cell
1215 vtkIdType aPointVtkId = -1;
1216 vtkIdType aLocalPntId = 0;
1217 aPointVtkId = aGaussPtsIDMapper->GetVTKID(VISU::TGaussPointID(anObjCellId, aLocalPntId));
1219 if (aPointVtkId >= 0) {
1220 // Compute average vector
1221 aCellVectors->Reset();
1222 while (aPointVtkId >= 0) {
1223 anInputVectors->GetTuple(aPointVtkId, &aTuple[0]);
1226 aCellVectors->InsertNextTuple3(aTuple[0], aTuple[1], aTuple[2]);
1227 else if (aNbComp == 2)
1228 aCellVectors->InsertNextTuple3(aTuple[0], aTuple[1], 0);
1229 else if (aNbComp == 1)
1230 aCellVectors->InsertNextTuple3(aTuple[0], 0, 0);
1232 aPointVtkId = aGaussPtsIDMapper->GetVTKID(VISU::TGaussPointID(anObjCellId, ++aLocalPntId));
1235 double aXCoord = 0, anYCoord = 0, aZCoord = 0;
1237 vtkIdType aNbVectors = aCellVectors->GetNumberOfTuples();
1239 for (vtkIdType aVecId = 0; aVecId < aNbVectors; aVecId++) {
1240 aXCoord += aCellVectors->GetComponent(aVecId, 0);
1241 anYCoord += aCellVectors->GetComponent(aVecId, 1);
1242 aZCoord += aCellVectors->GetComponent(aVecId, 2);
1245 aXCoord = aXCoord / aNbVectors;
1246 anYCoord = anYCoord / aNbVectors;
1247 aZCoord = aZCoord / aNbVectors;
1249 // set vector data for the cell
1250 aVectorsToSet->SetTuple3(aNewCellId, aXCoord, anYCoord, aZCoord);
1253 aVectorsToSet->SetTuple3(aNewCellId, 0, 0, 0);
1256 aCellsToWarp->GetCellData()->SetVectors(aVectorsToSet);
1258 aVectorsToSet->Delete();
1259 aCellVectors->Delete();
1260 aNeighbourCells->Delete();
1263 myWarpVector->SetScaleFactor(myGaussPointsPL->GetScale());
1265 myCellDataToPointData->SetInput(aCellsToWarp);
1266 myCellDataToPointData->PassCellDataOn();
1267 aCellsToWarp->Delete();
1269 myWarpVector->SetInput(myCellDataToPointData->GetUnstructuredGridOutput());
1270 vtkUnstructuredGrid* aWarpedDataSet = myWarpVector->GetUnstructuredGridOutput();
1271 aWarpedDataSet->Update();
1272 myCellSource->SetPoints(aWarpedDataSet->GetPoints());
1275 myCellSource->SetPoints(aCellDataSet->GetPoints());
1277 myCellActor->SetVisibility(anIsVisible && theIsHighlight && aShowCellActor);
1283 ::UpdatePickingSettings()
1285 //printf( "VISU_GaussPtsAct::UpdatePickingSettings()\n" );
1286 VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
1287 if(!aPickingSettings)
1290 myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
1291 myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
1293 vtkFloatingPointType aHeight = myGaussPointsPL->GetMaxPointSize()*aPickingSettings->GetPyramidHeight();
1294 vtkFloatingPointType aCursorSize = aPickingSettings->GetCursorSize();
1295 myCursorPyramid->SetPreferences(aHeight,aCursorSize);
1296 myCursorPyramidSelected->SetPreferences(aHeight,aCursorSize);
1298 myHighlightActor->GetProperty()->SetColor( aPickingSettings->GetColor() );
1299 myPointPicker->SetTolerance( aPickingSettings->GetPointTolerance() );
1301 Highlight(isHighlighted());
1306 //----------------------------------------------------------------
1309 ::SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings)
1311 if(myInsideCursorSettings == theInsideCursorSettings)
1314 if(myInsideCursorSettings)
1315 myInsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1317 myInsideCursorSettings = theInsideCursorSettings;
1319 if(theInsideCursorSettings){
1320 theInsideCursorSettings->AddObserver(VISU::UpdateInsideSettingsEvent,
1321 myEventCallbackCommand.GetPointer(),
1323 UpdateInsideCursorSettings();
1329 ::UpdateInsideCursorSettings()
1331 UpdateInsideCursorSettings( myDeviceActor );
1336 ::UpdateInsideCursorSettings( PDeviceActor theActor )
1338 if(!myInsideCursorSettings || myInsideCursorSettings->GetInitial())
1341 VISU_GaussPointsPL* aPipeline = theActor->GetPipeLine();
1343 vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
1345 aPipeline->ShallowCopy(GetGaussPointsPL(), true);
1347 aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1349 aPipeline->SetPrimitiveType( myInsideCursorSettings->GetPrimitiveType() );
1350 aPipeline->SetClamp( myInsideCursorSettings->GetClamp() );
1351 aPipeline->SetImageData( myInsideCursorSettings->GetTexture() );
1352 aPipeline->SetAlphaThreshold( myInsideCursorSettings->GetAlphaThreshold() );
1353 aPipeline->SetResolution( myInsideCursorSettings->GetResolution() );
1354 aPipeline->SetMinSize( myInsideCursorSettings->GetMinSize() );
1355 aPipeline->SetMaxSize( myInsideCursorSettings->GetMaxSize() );
1356 aPipeline->SetMagnification( myInsideCursorSettings->GetMagnification() );
1357 aPipeline->SetMagnificationIncrement( myInsideCursorSettings->GetIncrement() );
1359 if( myInsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1360 theActor->GetProperty()->SetRepresentation( VTK_POINTS );
1362 theActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1364 aPipeline->Update();
1366 Highlight(isHighlighted());
1371 //----------------------------------------------------------------------------
1376 unsigned long int aTime = Superclass::GetMTime();
1377 aTime = std::max(aTime, myGaussPointsPL->GetPointSpriteMapper()->GetMTime() );
1381 void VISU_GaussPtsAct::RemoveAllClippingPlanes()
1383 myFunction->GetFunction()->RemoveAllItems();
1384 myFunction->Modified();
1387 vtkIdType VISU_GaussPtsAct::GetNumberOfClippingPlanes()
1389 return myFunction->GetFunction()->GetNumberOfItems();
1392 bool VISU_GaussPtsAct::AddClippingPlane(vtkPlane* thePlane)
1394 vtkImplicitFunctionCollection* aFunctions = GetClippingPlanes();
1395 aFunctions->InitTraversal();
1396 vtkImplicitFunction* aItem;
1397 while ((aItem = aFunctions->GetNextItem())) {
1398 if (thePlane == aItem)
1401 myFunction->AddFunction(thePlane);
1405 vtkPlane* VISU_GaussPtsAct::GetClippingPlane(vtkIdType theID)
1407 vtkPlane* aPlane = NULL;
1408 if ((theID >= 0) && (theID < GetNumberOfClippingPlanes())) {
1409 vtkImplicitFunctionCollection* aFunction = myFunction->GetFunction();
1410 vtkImplicitFunction* aFun = NULL;
1411 aFunction->InitTraversal();
1412 for (vtkIdType i = 0; i <= theID; i++)
1413 aFun = aFunction->GetNextItem();
1414 aPlane = dynamic_cast<vtkPlane*>(aFun);
1419 vtkImplicitFunctionCollection* VISU_GaussPtsAct::GetClippingPlanes()
1421 return myFunction->GetFunction();
1426 //==============================================================================
1427 vtkStandardNewMacro(VISU_GaussPtsAct1);
1430 //----------------------------------------------------------------------------
1432 ::VISU_GaussPtsAct1():
1433 myInsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1434 myOutsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1435 myOutsideCursorSettings(NULL)
1437 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::VISU_GaussPtsAct1 - this = "<<this);
1439 myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents);
1441 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
1443 myInsideDeviceActor->SetVisibility(false);
1444 myInsideDeviceActor->SetPickable(false);
1445 myInsideDeviceActor->SetUserMatrix(aMatrix);
1446 myInsideDeviceActor->Delete();
1448 myOutsideDeviceActor->SetVisibility(false);
1449 myOutsideDeviceActor->SetPickable(false);
1450 myOutsideDeviceActor->SetUserMatrix(aMatrix);
1451 myOutsideDeviceActor->Delete();
1456 ::~VISU_GaussPtsAct1()
1458 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::~VISU_GaussPtsAct1 - this = "<<this);
1460 SetOutsideCursorSettings(NULL);
1464 //----------------------------------------------------------------------------
1467 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1469 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::ShallowCopyPL - this = "<<this);
1471 Superclass::ShallowCopyPL(thePipeLine);
1473 UpdateOutsideCursorSettings();
1477 //----------------------------------------------------------------------------
1480 ::AddToRender(vtkRenderer* theRenderer)
1482 Superclass::AddToRender(theRenderer);
1484 //myInsideDeviceActor->AddToRender(theRenderer);
1485 //myOutsideDeviceActor->AddToRender(theRenderer);
1490 ::RemoveFromRender(vtkRenderer* theRenderer)
1492 //myInsideDeviceActor->RemoveFromRender(theRenderer);
1493 //myOutsideDeviceActor->RemoveFromRender(theRenderer);
1495 Superclass::RemoveFromRender(theRenderer);
1500 ::SetTransform(VTKViewer_Transform* theTransform)
1502 Superclass::SetTransform(theTransform);
1504 myInsideDeviceActor->SetTransform(theTransform);
1505 myOutsideDeviceActor->SetTransform(theTransform);
1511 ::RenderOpaqueGeometry(vtkViewport *viewport)
1514 Superclass::RenderOpaqueGeometry(viewport);
1515 GetMatrix(myInsideDeviceActor->GetUserMatrix());
1516 GetMatrix(myOutsideDeviceActor->GetUserMatrix());
1522 ::RenderTranslucentGeometry(vtkViewport *viewport)
1524 Superclass::RenderTranslucentGeometry(viewport);
1525 GetMatrix(myInsideDeviceActor->GetUserMatrix());
1526 GetMatrix(myOutsideDeviceActor->GetUserMatrix());
1531 //----------------------------------------------------------------------------
1534 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1536 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetWidgetCtrl - this = "<<this);
1538 if(myWidgetCtrl == theWidgetCtrl){
1543 myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1544 myInsideDeviceActor->SetVisibility(false);
1546 myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1547 myOutsideDeviceActor->SetVisibility(false);
1550 Superclass::SetWidgetCtrl(theWidgetCtrl);
1553 myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1554 myInsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1556 myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1557 myOutsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1562 //----------------------------------------------------------------------------
1565 ::SetMapperInput(vtkDataSet* theDataSet)
1567 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetMapperInput - this = "<<this);
1569 Superclass::SetMapperInput(theDataSet);
1571 // if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1572 // myInsideDeviceActor->SetPipeLine(aPipeLine);
1573 // aPipeLine->Delete();
1576 // if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1577 // myOutsideDeviceActor->SetPipeLine(aPipeLine);
1578 // aPipeLine->Delete();
1580 // aPipeLine->SetExtractBoundaryCells(true);
1581 // aPipeLine->SetExtractInside(true);
1586 //----------------------------------------------------------------------------
1587 vtkFloatingPointType
1589 ::GetRadius(vtkIdType theObjID,
1591 vtkDataArray *theScalarArray)
1593 VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1594 if(IsSegmentationEnabled()){
1595 if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1596 aPipeLine = myOutsideDeviceActor->GetPipeLine();
1598 aPipeLine = myInsideDeviceActor->GetPipeLine();
1600 return ::GetRadius(theVTKID,theScalarArray,aPipeLine);
1604 //----------------------------------------------------------------------------
1605 vtkFloatingPointType
1607 ::GetMagnification(vtkIdType theObjID)
1609 VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1610 if(IsSegmentationEnabled()){
1611 if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1612 aPipeLine = myOutsideDeviceActor->GetPipeLine();
1614 aPipeLine = myInsideDeviceActor->GetPipeLine();
1616 return aPipeLine->GetMagnification();
1620 //----------------------------------------------------------------------------
1621 vtkFloatingPointType
1623 ::GetClamp(vtkIdType theObjID)
1625 if(IsSegmentationEnabled()){
1626 if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1627 return ::GetClamp(myOutsideDeviceActor->GetPipeLine());
1629 return ::GetClamp(myInsideDeviceActor->GetPipeLine());
1631 return Superclass::GetClamp(theObjID);
1635 //----------------------------------------------------------------
1638 VISU_GaussPtsAct1::SetPosition(double _arg[3]){
1639 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetPosition - this = "<<this);
1640 Superclass::SetPosition(_arg);
1641 myUpdatePositionSignal(_arg);
1646 ::Connect(VISU_GaussPtsAct2* theActor)
1648 mySetVisibilitySignal.connect(boost::bind(&VISU_GaussPtsAct2::SetVisibility,theActor,_1));
1649 myUpdatePositionSignal.connect(boost::bind(&VISU_GaussPtsAct2::SetPosition, theActor,_1));
1654 ::SetVisibility(int theMode)
1656 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetVisibility - this = "<<this);
1658 Superclass::SetVisibility(theMode);
1660 bool aVisisbility = GetVisibility();
1661 bool anIsSegementation = IsSegmentationEnabled();
1662 myDeviceActor->SetVisibility(aVisisbility/* && !anIsSegementation*/);
1663 myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1664 myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1666 mySetVisibilitySignal(GetVisibility());
1669 //----------------------------------------------------------------
1672 ::UpdateInsideCursorSettings()
1674 Superclass::UpdateInsideCursorSettings( myInsideDeviceActor );
1677 //----------------------------------------------------------------
1680 ::SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings)
1682 if(myOutsideCursorSettings == theOutsideCursorSettings)
1685 if(myOutsideCursorSettings)
1686 myOutsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1688 myOutsideCursorSettings = theOutsideCursorSettings;
1690 if(theOutsideCursorSettings)
1692 theOutsideCursorSettings->AddObserver(VISU::UpdateOutsideSettingsEvent,
1693 myEventCallbackCommand.GetPointer(),
1695 UpdateOutsideCursorSettings();
1701 ::UpdateOutsideCursorSettings()
1703 if(!myOutsideCursorSettings || myOutsideCursorSettings->GetInitial())
1706 VISU_GaussPointsPL* aPipeline = myOutsideDeviceActor->GetPipeLine();
1708 vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
1709 vtkFloatingPointType aMagnification = aPipeline->GetMagnification();
1711 aPipeline->ShallowCopy(GetGaussPointsPL(), true);
1713 aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1714 aPipeline->SetExtractBoundaryCells(true);
1715 //aPipeline->SetExtractInside(true);
1716 aPipeline->SetMagnification( aMagnification );
1718 aPipeline->SetPrimitiveType( myOutsideCursorSettings->GetPrimitiveType() );
1720 if( myOutsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1721 myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_POINTS );
1723 myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1725 aPipeline->SetClamp( myOutsideCursorSettings->GetClamp() );
1726 aPipeline->SetImageData( myOutsideCursorSettings->GetTexture() );
1727 aPipeline->SetAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() );
1728 aPipeline->SetResolution( myOutsideCursorSettings->GetResolution() );
1729 aPipeline->SetSize( myOutsideCursorSettings->GetSize() );
1730 aPipeline->SetMagnification( myOutsideCursorSettings->GetMagnification() );
1731 aPipeline->SetMagnificationIncrement( myOutsideCursorSettings->GetIncrement() );
1733 if( myOutsideCursorSettings->GetUniform() )
1735 myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOff();
1736 myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 1 ); // Geometry mode
1737 myOutsideDeviceActor->GetProperty()->SetColor( myOutsideCursorSettings->GetColor() );
1741 myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 2 ); // Outside cursor mode
1742 myOutsideDeviceActor->GetPointSpriteMapper()->SetColorModeToMapScalars();
1743 myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOn();
1746 aPipeline->Update();
1748 Highlight(isHighlighted());
1754 //----------------------------------------------------------------
1757 ::ProcessEvents(vtkObject* theObject,
1758 unsigned long theEvent,
1759 void* theClientData,
1762 if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
1763 if(VISU_GaussPtsAct1* self = dynamic_cast<VISU_GaussPtsAct1*>(anObject))
1764 if(theEvent == VISU::UpdateOutsideSettingsEvent)
1765 self->UpdateOutsideCursorSettings();
1767 Superclass::ProcessEvents(theObject,theEvent,theClientData,theCallData);
1772 ::OnInteractorEvent(unsigned long theEvent)
1775 case vtkCommand::StartInteractionEvent:
1776 myDeviceActor->SetVisibility(GetVisibility());
1777 myInsideDeviceActor->SetVisibility(false);
1778 myOutsideDeviceActor->SetVisibility(false);
1780 case vtkCommand::EnableEvent:
1781 case vtkCommand::DisableEvent:
1782 case vtkCommand::EndInteractionEvent: {
1783 bool aVisisbility = GetVisibility();
1784 bool anIsSegementation = IsSegmentationEnabled();
1785 myDeviceActor->SetVisibility(aVisisbility/* && !anIsSegementation*/);
1786 myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1787 myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1794 Superclass::OnInteractorEvent(theEvent);
1797 //----------------------------------------------------------------------------
1802 unsigned long int aSize = Superclass::GetMemorySize();
1803 if(IsSegmentationEnabled()){
1804 aSize += myInsideDeviceActor->GetMemorySize();
1805 aSize += myOutsideDeviceActor->GetMemorySize();
1812 //==============================================================================
1813 vtkStandardNewMacro(VISU_GaussPtsAct2);
1816 //----------------------------------------------------------------------------
1818 ::VISU_GaussPtsAct2()
1820 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::VISU_GaussPtsAct2 - this = "<<this);
1821 myDeviceActor->SetVisibility(false);
1825 ::~VISU_GaussPtsAct2()
1827 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::~VISU_GaussPtsAct2 - this = "<<this);
1831 //----------------------------------------------------------------------------
1834 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1836 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::ShallowCopyPL - this = "<<this);
1838 Superclass::ShallowCopyPL(thePipeLine);
1841 //----------------------------------------------------------------------------
1843 VISU_GaussPtsAct2::SetPosition(double _arg[3]){
1844 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct2::SetPosition - this = "<<this);
1845 Superclass::SetPosition(_arg);
1848 //----------------------------------------------------------------------------
1851 ::SetMapperInput(vtkDataSet* theDataSet)
1853 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetMapperInput - this = "<<this);
1854 Superclass::SetMapperInput(theDataSet);
1855 // if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1856 // myDeviceActor->SetPipeLine(aPipeLine);
1857 // myCurrentPL = aPipeLine;
1858 // aPipeLine->Delete();
1860 // myMapper->SetInput(myCurrentPL->GetPickableDataSet());
1861 // SetMapper(myMapper.GetPointer());
1865 //----------------------------------------------------------------------------
1868 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1870 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetWidgetCtrl - this = "<<this);
1872 if(myWidgetCtrl == theWidgetCtrl)
1876 theWidgetCtrl->RemoveObserver(myEventCallbackCommand.GetPointer());
1877 myDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1878 myDeviceActor->SetVisibility(false);
1881 Superclass::SetWidgetCtrl(theWidgetCtrl);
1884 myDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1885 myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1890 //----------------------------------------------------------------------------
1895 if(IsSegmentationEnabled())
1896 return Superclass::GetMemorySize();
1901 //----------------------------------------------------------------------------
1904 ::SetVisibility(int theMode)
1906 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetVisibility - this = "<<this);
1908 Superclass::SetVisibility(theMode);
1910 myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1915 ::OnInteractorEvent(unsigned long theEvent)
1918 case vtkCommand::EnableEvent:
1919 case vtkCommand::DisableEvent:
1920 myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1921 if(theEvent == vtkCommand::EnableEvent)
1924 case vtkCommand::EndInteractionEvent:
1930 Superclass::OnInteractorEvent(theEvent);