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 ::SetOpacity(vtkFloatingPointType theValue)
528 GetGaussPointsPL()->SetOpacity(theValue);
529 Superclass::SetOpacity(theValue);
533 //----------------------------------------------------------------------------
536 ::SetFactory(VISU::TActorFactory* theActorFactory)
538 using namespace VISU;
539 myGaussPtsActorFactory = dynamic_cast<TGaussPtsActorFactory*>(theActorFactory);
540 myUpdatePrs3dSignal.connect(boost::bind(&TGaussPtsActorFactory::UpdateFromActor,
541 myGaussPtsActorFactory,
543 Superclass::SetFactory(theActorFactory);
546 VISU::TGaussPtsActorFactory*
548 ::GetGaussPtsFactory()
550 return myGaussPtsActorFactory;
554 //----------------------------------------------------------------------------
557 ::SetVisibility(int theMode)
559 Superclass::SetVisibility(theMode);
560 myDeviceActor->SetVisibility(GetVisibility()); // VSV
561 myScalarBarCtrl->SetVisibility(theMode);
566 ::IsSegmentationEnabled()
568 return myWidgetCtrl && myWidgetCtrl->GetEnabled();
572 //----------------------------------------------------------------------------
575 ::SetBarVisibility(bool theMode)
577 myBarVisibility = theMode;
578 myScalarBarCtrl->SetCtrlVisibility(theMode);
579 myScalarBarCtrl->SetVisibility(GetVisibility());
586 return myBarVisibility;
593 return myScalarBarCtrl.GetPointer();
596 //----------------------------------------------------------------------------
599 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
601 if(theInteractor == myInteractor)
605 myInteractor->RemoveObserver(myEventCallbackCommand.GetPointer());
608 theInteractor->AddObserver(vtkCommand::CharEvent,
609 myEventCallbackCommand.GetPointer(),
611 theInteractor->AddObserver(VISU::SetSMDecreaseMagnificationEvent,
612 myEventCallbackCommand.GetPointer(),
614 theInteractor->AddObserver(VISU::SetSMIncreaseMagnificationEvent,
615 myEventCallbackCommand.GetPointer(),
618 Superclass::SetInteractor(theInteractor);
622 //-------------------------------------------------------------------------
625 ::ProcessEvents(vtkObject* vtkNotUsed(theObject),
626 unsigned long theEvent,
628 void* vtkNotUsed(theCallData))
630 if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
631 if(VISU_GaussPtsAct* self = dynamic_cast<VISU_GaussPtsAct*>(anObject)) {
632 if(theEvent == VISU::UpdateInsideSettingsEvent)
633 self->UpdateInsideCursorSettings();
635 self->OnInteractorEvent(theEvent);
639 //-------------------------------------------------------------------------
642 ::OnInteractorEvent(unsigned long theEvent)
645 case vtkCommand::CharEvent: {
646 switch(myInteractor->GetKeyCode()) {
650 if( IsSegmentationEnabled() )
652 this->ChangeMagnification( myInteractor->GetShiftKey() );
656 myChangeMagnification = myInteractor->GetShiftKey();
662 if( IsSegmentationEnabled() && myWidgetCtrl->IsSphereActive() )
664 VISU_SphereWidget* aSphereWidget = myWidgetCtrl->GetSphereWidget();
665 aSphereWidget->ChangeRadius( myInteractor->GetShiftKey() );
666 myWidgetCtrl->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
667 myWidgetCtrl->GetInteractor()->Render();
674 myUpdatePrs3dSignal(this);
677 case VISU::SetSMDecreaseMagnificationEvent:
678 case VISU::SetSMIncreaseMagnificationEvent:
679 myChangeMagnification = theEvent == VISU::SetSMIncreaseMagnificationEvent;
680 myUpdatePrs3dSignal(this);
682 case VISU::UpdatePickingSettingsEvent:
683 UpdatePickingSettings();
685 case vtkCommand::EndInteractionEvent:
686 case vtkCommand::EnableEvent:
687 case vtkCommand::DisableEvent:
688 myCurrentPL->GetMapper()->Update();
689 Highlight(isHighlighted());
696 //----------------------------------------------------------------------------
701 if(vtkMapper* aMapper = myDeviceActor->GetMapper()){
702 if(vtkDataSet* aDataSet= aMapper->GetInput()){
704 myIsInfinite = aDataSet->GetNumberOfCells() < 2;
710 //----------------------------------------------------------------------------
715 if(Superclass::GetPickable()){
716 if(vtkMapper* aMapper = GetMapper()){
717 if(vtkDataSet* aDataSet= aMapper->GetInput()){
719 return aDataSet->GetNumberOfCells() > 0;
727 //----------------------------------------------------------------------------
730 ::PreHighlight(vtkInteractorStyle* theInteractorStyle,
731 SVTK_SelectionEvent* theSelectionEvent,
734 if ( !GetPickable() )
737 myPreHighlightActor->SetVisibility(false);
738 myCursorPyramid->SetVisibility(false);
740 /* if (!myBarVisibility)
745 myLastPreHighlightObjID = -1;
747 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
749 if(aSelectionMode == ActorSelection || !theIsHighlight)
750 return Superclass::PreHighlight(theInteractorStyle,
754 bool anIsChanged = (mySelectionMode != aSelectionMode);
755 bool anIsPreselected = myIsPreselected;
756 myIsPreselected = false;
758 VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
760 if(aSelectionMode == GaussPointSelection && theIsHighlight){
761 myPointPicker->Pick(theSelectionEvent->myX,
762 theSelectionEvent->myY,
764 theInteractorStyle->GetCurrentRenderer());
766 if(myPointPicker->GetActor() != this)
767 return (anIsPreselected != myIsPreselected);
769 vtkIdType aVtkId = myPointPicker->GetPointId();
771 if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){
772 vtkIdType anObjId = GetNodeObjId( aVtkId );
773 myIsPreselected = (anObjId >= 0);
775 anIsChanged = (myLastPreHighlightObjID != anObjId);
777 vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
778 //Take into account translation
779 vtkFloatingPointType aLocalNodeCoord[3];
780 this->Transform->Push();
781 this->Transform->PostMultiply();
782 this->Transform->Identity();
784 this->Transform->Translate(this->Position[0],
788 this->Transform->GetPosition(aPosition);
790 aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0];
791 aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
792 aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
794 vtkDataSet* aDataSet = GetInput();
795 vtkPointData* aPointData = aDataSet->GetPointData();
796 if(vtkDataArray *aScalarArray = aPointData->GetScalars()){
797 vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight();
798 aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
799 //vtkFloatingPointType aColor[3] = myPreHighlightActor->GetProperty()->GetColor();
800 vtkFloatingPointType aColor[3];
801 theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor );
802 aColor[0] = 1. - aColor[0];
803 aColor[1] = 1. - aColor[1];
804 aColor[2] = 1. - aColor[2];
806 myCursorPyramid->Init(aPyramidHeight,
807 aPickingSettings->GetCursorSize(),
808 GetRadius(anObjId,aVtkId,aScalarArray),
809 GetMagnification(anObjId),
814 this->Transform->Pop();
815 myLastPreHighlightObjID = anObjId;
817 myCursorPyramid->SetVisibility(true);
822 mySelectionMode = aSelectionMode;
823 anIsChanged |= (anIsPreselected != myIsPreselected);
829 //----------------------------------------------------------------------------
832 ChangeZoom(VISU_PickingSettings *thePickingSettings,
833 vtkRenderer* theRenderer,
834 vtkIdType theInitialHasIndex,
835 vtkIdType theCurrentHasIndex)
837 if( (theInitialHasIndex + theCurrentHasIndex == 1) && thePickingSettings){
838 vtkCamera *aCamera = theRenderer->GetActiveCamera();
840 vtkFloatingPointType aZoomFactor = thePickingSettings->GetZoomFactor();
841 double aScale = aCamera->GetParallelScale();
842 if ( !theInitialHasIndex && theCurrentHasIndex ) {
843 aCamera->SetParallelScale( aScale/aZoomFactor );
846 aCamera->SetParallelScale( aScale*aZoomFactor );
854 ::Highlight(vtkInteractorStyle* theInteractorStyle,
855 SVTK_SelectionEvent* theSelectionEvent,
858 if ( !GetPickable() )
861 // int anInitialHasIndex = myIsSubElementsHighlighted && mySelectionMode == GaussPointSelection;
862 Handle(SALOME_InteractiveObject) anIO = getIO();
863 // myIsSubElementsHighlighted = false;
865 Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
867 if(!theIsHighlight && aSelectionMode == GaussPointSelection){
868 mySelector->RemoveIObject(anIO);
870 /* ChangeZoom(myPickingSettings,
879 /* if (!myBarVisibility)
883 if(aSelectionMode == ActorSelection)
884 return Superclass::Highlight(theInteractorStyle,
888 if(aSelectionMode == GaussPointSelection && !theSelectionEvent->myIsRectangle){
890 vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
891 myPointPicker->Pick(theSelectionEvent->myX,
892 theSelectionEvent->myY,
896 if(myPointPicker->GetActor() != this) {
897 mySelector->ClearIObjects();
899 /* ChangeZoom(myPickingSettings,
908 vtkIdType aVtkId = myPointPicker->GetPointId();
909 if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO()) {
910 vtkIdType anObjId = GetNodeObjId( aVtkId );
912 // myIsHighlighted = true;
913 // Update the Selector
914 if(mySelector->IsSelected(myIO))
915 mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
917 if(!theSelectionEvent->myIsShift){
918 mySelector->ClearIObjects();
920 mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
921 mySelector->AddIObject(this);
924 vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
927 vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor();
928 vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
929 int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
931 anInteractor->SetDolly(0.);
932 anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber());
933 anInteractor->FlyTo(aRenderer,aNodeCoord);
934 aRenderer->ResetCameraClippingRange();
935 anInteractor->SetDolly(aDollyWas);
936 anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
938 anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);*/
940 mySelectionMode = aSelectionMode;
942 /* ChangeZoom(myPickingSettings,
949 }// if( anObjId >= 0 ) {
950 }//if( aVtkId >= 0 && mySelector->IsValid( this, aVtkId, true ) && hasIO())
951 }//if(!theSelectionEvent->myIsRectangle){
953 /* ChangeZoom(myPickingSettings,
964 void VISU_GaussPtsAct::SetPosition(double _arg[3]){
965 Superclass::SetPosition(_arg);
966 Highlight(isHighlighted());
969 //==================================================================
970 // function : Highlight
972 //==================================================================
975 ::Highlight(bool theIsHighlight)
977 if(!mySelector.GetPointer())
980 VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
982 Selection_Mode aSelectionMode = mySelector->SelectionMode();
984 bool anInitialHasIndex = isSubElementsHighlighted() && mySelectionMode == GaussPointSelection;
986 TColStd_IndexedMapOfInteger aMapIndex;
987 mySelector->GetIndex( getIO(), aMapIndex );
988 bool aCurrentHasIndex = aMapIndex.Extent() == 1;
989 bool anIsVisible = GetVisibility() && aCurrentHasIndex && theIsHighlight;
990 bool aShowTextActor = aPickingSettings->GetInfoWindowEnabled();
991 bool aShowCellActor = aPickingSettings->GetDisplayParentMesh();
993 myOutlineActor->SetVisibility(false);
994 myCursorPyramid->SetVisibility(false);
995 myTextActor->SetVisibility(anIsVisible && aShowTextActor);
996 myCellActor->SetVisibility(anIsVisible && aShowCellActor);
997 GetScalarBarCtrl()->SetIsMarked(anIsVisible);
998 myCursorPyramidSelected->SetVisibility(anIsVisible);
999 //GetScalarBarCtrl()->Update();
1001 myIsSubElementsHighlighted = aCurrentHasIndex;
1003 // Zoom if necessary
1004 if( GetVisibility() && aPickingSettings->GetCameraMovementEnabled() )
1006 ChangeZoom(aPickingSettings,
1012 if( aSelectionMode == ActorSelection ) {
1013 Superclass::Highlight(theIsHighlight);
1020 if( aSelectionMode != GaussPointSelection )
1023 if ( !aCurrentHasIndex || !myBarVisibility )
1026 // myTextActor->SetVisibility(anIsVisible);
1027 // myCellActor->SetVisibility(anIsVisible && myPickingSettings->GetDisplayParentMesh());
1028 // GetScalarBarCtrl()->SetIsMarked(anIsVisible);
1029 // myCursorPyramidSelected->SetVisibility(anIsVisible);
1030 //GetScalarBarCtrl()->Update();
1032 // myIsHighlighted = aCurrentHasIndex;
1034 // Zoom if necessary
1035 // ChangeZoom(myPickingSettings,
1037 // anInitialHasIndex,
1038 // aCurrentHasIndex);
1040 // TColStd_IndexedMapOfInteger aMapIndex;
1041 mySelector->GetIndex( getIO(), aMapIndex );
1042 if(aMapIndex.Extent() != 1 || !myBarVisibility) {
1046 vtkRenderer *aRenderer = GetRenderer();
1047 vtkCamera* aCamera = aRenderer->GetActiveCamera();
1049 int anObjId = aMapIndex(1);
1050 vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
1053 //Take into account translation
1054 vtkFloatingPointType aLocalNodeCoord[3];
1055 this->Transform->Push();
1056 this->Transform->PostMultiply();
1057 this->Transform->Identity();
1058 this->Transform->Translate(this->Position[0],
1061 double aPosition[3];
1062 this->Transform->GetPosition(aPosition);
1063 aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0];
1064 aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
1065 aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
1066 this->Transform->Pop();
1068 vtkFloatingPointType aFocalPnt[3];
1069 aCamera->GetFocalPoint(aFocalPnt);
1071 if ( CheckIsSameVector(aLocalNodeCoord, aFocalPnt, 3 ) )
1075 if( anIsVisible && aPickingSettings->GetCameraMovementEnabled() )
1077 vtkRenderWindowInteractor* anInteractor = myInteractor;
1078 vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
1079 int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
1081 anInteractor->SetDolly(0.0);
1082 anInteractor->SetNumberOfFlyFrames(aPickingSettings->GetStepNumber());
1083 anInteractor->FlyTo(aRenderer, aNodeCoord);
1084 aRenderer->ResetCameraClippingRange();
1085 anInteractor->SetDolly(aDollyWas);
1086 anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
1087 anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);
1090 std::ostringstream aStr;
1091 // int anObjId = aMapIndex(1);
1092 aStr<<"Global ID: "<<anObjId;
1094 vtkIdType aVtkId = GetNodeVTKID(anObjId);
1096 vtkFloatingPointType aWorldCoord[4] = {aLocalNodeCoord[0], aLocalNodeCoord[1], aLocalNodeCoord[2], 1.};
1098 vtkDataSet* aDataSet = GetInput();
1099 vtkPointData* aDataSetAttributes = aDataSet->GetPointData();
1101 if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){
1102 vtkFloatingPointType aVal = aScalarArray->GetTuple1(aVtkId);
1104 // GetScalarBarCtrl()->SetIsMarked(true);
1105 GetScalarBarCtrl()->SetMarkValue(aVal);
1106 GetScalarBarCtrl()->Update();
1108 vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight();
1109 aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
1110 myCursorPyramidSelected->Init(aPyramidHeight,
1111 aPickingSettings->GetCursorSize(),
1112 GetRadius(anObjId,aVtkId,aScalarArray),
1113 GetMagnification(anObjId),
1116 myHighlightActor->GetProperty()->GetColor());
1117 myCursorPyramidSelected->SetVisibility(anIsVisible && theIsHighlight);
1119 const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper =
1120 myGaussPointsPL->GetGaussPtsIDMapper();
1121 VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
1123 VISU::TGaussPointID aGaussPointID = myGaussPointsPL->GetObjID(anObjId);
1124 VISU::TCellID aCellID = aGaussPointID.first;
1125 VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
1126 aStr<<"\nParentCellID: "<<aCellID;
1127 std::string aParentName = aParent->GetElemName(aCellID);
1128 if(aParentName != "") {
1129 aStr<<"\nParentCellName: '"<<aParentName<<"'";
1131 aStr<<"\nLocalPntID: "<<aLocalPntID;
1132 aStr<<"\nScalar: "<<aVal;
1135 if(vtkDataArray* aFieldArray = aDataSetAttributes->GetArray("VISU_FIELD")){
1136 int aNbComp = aFieldArray->GetNumberOfComponents();
1137 std::vector<vtkFloatingPointType> aTuple(aNbComp);
1138 aFieldArray->GetTuple(aVtkId, &aTuple[0]);
1142 while(anId < aNbComp){
1143 vtkFloatingPointType aComp = aTuple[anId++];
1152 std::string aString = aStr.str();
1153 myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
1154 myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
1155 myTextActor->SetWorldPoint(aWorldCoord);
1156 myTextActor->SetText(aString.c_str());
1157 myTextActor->SetVisibility(anIsVisible && theIsHighlight && aShowTextActor);
1160 const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = myGaussPointsPL->GetGaussPtsIDMapper();
1161 VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
1163 myCellSource->Reset();
1164 myCellSource->Modified(); // a VTK bug
1165 vtkUnstructuredGrid* aCellDataSet = aParent->GetUnstructuredGridOutput();
1167 // get parent cell and insert it to myCellSource
1168 VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId);
1169 vtkIdType aCellID = aGaussPointID.first;
1170 vtkCell* aCell = aParent->GetElemCell(aCellID);
1171 myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
1173 if (myGaussPointsPL->GetIsDeformed()) {
1174 // find neighbour cells ids
1175 vtkIdList* aNeighbourCells = vtkIdList::New();
1176 aNeighbourCells->Allocate(VTK_CELL_SIZE);
1178 vtkIdList* aCellPoints = aCell->GetPointIds();
1180 vtkIdList *aPointCells = vtkIdList::New();
1181 aPointCells->Allocate(VTK_CELL_SIZE);
1183 vtkIdType aNbPoints = aCellPoints->GetNumberOfIds();
1184 for (vtkIdType i = 0; i < aNbPoints; i++) {
1185 aCellDataSet->GetPointCells(aCellPoints->GetId(i), aPointCells);
1188 vtkIdType aNbCells = aPointCells->GetNumberOfIds();
1189 for (vtkIdType j = 0; j < aNbCells; j++)
1190 aNeighbourCells->InsertUniqueId(aPointCells->GetId(j));
1193 aPointCells->Delete();
1196 vtkDataArray* anInputVectors = aDataSetAttributes->GetVectors();
1197 if (!anInputVectors)
1200 // insert neighbour cells to the special dataset
1201 vtkUnstructuredGrid *aCellsToWarp = vtkUnstructuredGrid::New();
1202 aCellsToWarp->SetPoints(aCellDataSet->GetPoints());
1204 vtkIdType aNbNeighbourCells = aNeighbourCells->GetNumberOfIds();
1206 vtkDataArray *aVectorsToSet = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
1207 aVectorsToSet->SetNumberOfComponents(3);
1208 aVectorsToSet->SetNumberOfTuples(aNbNeighbourCells);
1210 vtkDataArray *aCellVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
1211 aCellVectors->SetNumberOfComponents(3);
1213 int aNbComp = anInputVectors->GetNumberOfComponents();
1214 std::vector<vtkFloatingPointType> aTuple(aNbComp);
1216 for (vtkIdType i = 0; i < aNbNeighbourCells; i++) {
1217 vtkIdType aVTKCellId = aNeighbourCells->GetId(i);
1218 vtkIdType anObjCellId = aParent->GetElemObjID(aVTKCellId);
1220 vtkCell* aCurCell = aParent->GetElemCell(anObjCellId);
1222 vtkIdType aNewCellId = aCellsToWarp->InsertNextCell(aCurCell->GetCellType(), aCurCell->GetPointIds());
1224 // get gauss points corresponding to the current cell
1225 vtkIdType aPointVtkId = -1;
1226 vtkIdType aLocalPntId = 0;
1227 aPointVtkId = aGaussPtsIDMapper->GetVTKID(VISU::TGaussPointID(anObjCellId, aLocalPntId));
1229 if (aPointVtkId >= 0) {
1230 // Compute average vector
1231 aCellVectors->Reset();
1232 while (aPointVtkId >= 0) {
1233 anInputVectors->GetTuple(aPointVtkId, &aTuple[0]);
1236 aCellVectors->InsertNextTuple3(aTuple[0], aTuple[1], aTuple[2]);
1237 else if (aNbComp == 2)
1238 aCellVectors->InsertNextTuple3(aTuple[0], aTuple[1], 0);
1239 else if (aNbComp == 1)
1240 aCellVectors->InsertNextTuple3(aTuple[0], 0, 0);
1242 aPointVtkId = aGaussPtsIDMapper->GetVTKID(VISU::TGaussPointID(anObjCellId, ++aLocalPntId));
1245 double aXCoord = 0, anYCoord = 0, aZCoord = 0;
1247 vtkIdType aNbVectors = aCellVectors->GetNumberOfTuples();
1249 for (vtkIdType aVecId = 0; aVecId < aNbVectors; aVecId++) {
1250 aXCoord += aCellVectors->GetComponent(aVecId, 0);
1251 anYCoord += aCellVectors->GetComponent(aVecId, 1);
1252 aZCoord += aCellVectors->GetComponent(aVecId, 2);
1255 aXCoord = aXCoord / aNbVectors;
1256 anYCoord = anYCoord / aNbVectors;
1257 aZCoord = aZCoord / aNbVectors;
1259 // set vector data for the cell
1260 aVectorsToSet->SetTuple3(aNewCellId, aXCoord, anYCoord, aZCoord);
1263 aVectorsToSet->SetTuple3(aNewCellId, 0, 0, 0);
1266 aCellsToWarp->GetCellData()->SetVectors(aVectorsToSet);
1268 aVectorsToSet->Delete();
1269 aCellVectors->Delete();
1270 aNeighbourCells->Delete();
1273 myWarpVector->SetScaleFactor(myGaussPointsPL->GetScale());
1275 myCellDataToPointData->SetInput(aCellsToWarp);
1276 myCellDataToPointData->PassCellDataOn();
1277 aCellsToWarp->Delete();
1279 myWarpVector->SetInput(myCellDataToPointData->GetUnstructuredGridOutput());
1280 vtkUnstructuredGrid* aWarpedDataSet = myWarpVector->GetUnstructuredGridOutput();
1281 aWarpedDataSet->Update();
1282 myCellSource->SetPoints(aWarpedDataSet->GetPoints());
1285 myCellSource->SetPoints(aCellDataSet->GetPoints());
1287 myCellActor->SetVisibility(anIsVisible && theIsHighlight && aShowCellActor);
1293 ::UpdatePickingSettings()
1295 //printf( "VISU_GaussPtsAct::UpdatePickingSettings()\n" );
1296 VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
1297 if(!aPickingSettings)
1300 myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
1301 myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
1303 vtkFloatingPointType aHeight = myGaussPointsPL->GetMaxPointSize()*aPickingSettings->GetPyramidHeight();
1304 vtkFloatingPointType aCursorSize = aPickingSettings->GetCursorSize();
1305 myCursorPyramid->SetPreferences(aHeight,aCursorSize);
1306 myCursorPyramidSelected->SetPreferences(aHeight,aCursorSize);
1308 myHighlightActor->GetProperty()->SetColor( aPickingSettings->GetColor() );
1309 myPointPicker->SetTolerance( aPickingSettings->GetPointTolerance() );
1311 Highlight(isHighlighted());
1316 //----------------------------------------------------------------
1319 ::SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings)
1321 if(myInsideCursorSettings == theInsideCursorSettings)
1324 if(myInsideCursorSettings)
1325 myInsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1327 myInsideCursorSettings = theInsideCursorSettings;
1329 if(theInsideCursorSettings){
1330 theInsideCursorSettings->AddObserver(VISU::UpdateInsideSettingsEvent,
1331 myEventCallbackCommand.GetPointer(),
1333 UpdateInsideCursorSettings();
1339 ::UpdateInsideCursorSettings()
1341 UpdateInsideCursorSettings( myDeviceActor );
1346 ::UpdateInsideCursorSettings( PDeviceActor theActor )
1348 if(!myInsideCursorSettings || myInsideCursorSettings->GetInitial())
1351 VISU_GaussPointsPL* aPipeline = theActor->GetPipeLine();
1353 vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
1355 aPipeline->ShallowCopy(GetGaussPointsPL(), true);
1357 aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1359 aPipeline->SetPrimitiveType( myInsideCursorSettings->GetPrimitiveType() );
1360 aPipeline->SetClamp( myInsideCursorSettings->GetClamp() );
1361 aPipeline->SetImageData( myInsideCursorSettings->GetTexture() );
1362 aPipeline->SetAlphaThreshold( myInsideCursorSettings->GetAlphaThreshold() );
1363 aPipeline->SetResolution( myInsideCursorSettings->GetResolution() );
1364 aPipeline->SetMinSize( myInsideCursorSettings->GetMinSize() );
1365 aPipeline->SetMaxSize( myInsideCursorSettings->GetMaxSize() );
1366 aPipeline->SetMagnification( myInsideCursorSettings->GetMagnification() );
1367 aPipeline->SetMagnificationIncrement( myInsideCursorSettings->GetIncrement() );
1369 if( myInsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1370 theActor->GetProperty()->SetRepresentation( VTK_POINTS );
1372 theActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1374 aPipeline->Update();
1376 Highlight(isHighlighted());
1381 //----------------------------------------------------------------------------
1386 unsigned long int aTime = Superclass::GetMTime();
1387 aTime = std::max(aTime, myGaussPointsPL->GetPointSpriteMapper()->GetMTime() );
1391 void VISU_GaussPtsAct::RemoveAllClippingPlanes()
1393 myFunction->GetFunction()->RemoveAllItems();
1394 myFunction->Modified();
1397 vtkIdType VISU_GaussPtsAct::GetNumberOfClippingPlanes()
1399 return myFunction->GetFunction()->GetNumberOfItems();
1402 bool VISU_GaussPtsAct::AddClippingPlane(vtkPlane* thePlane)
1404 vtkImplicitFunctionCollection* aFunctions = GetClippingPlanes();
1405 aFunctions->InitTraversal();
1406 vtkImplicitFunction* aItem;
1407 while ((aItem = aFunctions->GetNextItem())) {
1408 if (thePlane == aItem)
1411 myFunction->AddFunction(thePlane);
1415 vtkPlane* VISU_GaussPtsAct::GetClippingPlane(vtkIdType theID)
1417 vtkPlane* aPlane = NULL;
1418 if ((theID >= 0) && (theID < GetNumberOfClippingPlanes())) {
1419 vtkImplicitFunctionCollection* aFunction = myFunction->GetFunction();
1420 vtkImplicitFunction* aFun = NULL;
1421 aFunction->InitTraversal();
1422 for (vtkIdType i = 0; i <= theID; i++)
1423 aFun = aFunction->GetNextItem();
1424 aPlane = dynamic_cast<vtkPlane*>(aFun);
1429 vtkImplicitFunctionCollection* VISU_GaussPtsAct::GetClippingPlanes()
1431 return myFunction->GetFunction();
1436 //==============================================================================
1437 vtkStandardNewMacro(VISU_GaussPtsAct1);
1440 //----------------------------------------------------------------------------
1442 ::VISU_GaussPtsAct1():
1443 myInsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1444 myOutsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1445 myOutsideCursorSettings(NULL)
1447 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::VISU_GaussPtsAct1 - this = "<<this);
1449 myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents);
1451 vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
1453 myInsideDeviceActor->SetVisibility(false);
1454 myInsideDeviceActor->SetPickable(false);
1455 myInsideDeviceActor->SetUserMatrix(aMatrix);
1456 myInsideDeviceActor->Delete();
1458 myOutsideDeviceActor->SetVisibility(false);
1459 myOutsideDeviceActor->SetPickable(false);
1460 myOutsideDeviceActor->SetUserMatrix(aMatrix);
1461 myOutsideDeviceActor->Delete();
1466 ::~VISU_GaussPtsAct1()
1468 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::~VISU_GaussPtsAct1 - this = "<<this);
1470 SetOutsideCursorSettings(NULL);
1474 //----------------------------------------------------------------------------
1477 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1479 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::ShallowCopyPL - this = "<<this);
1481 Superclass::ShallowCopyPL(thePipeLine);
1483 UpdateOutsideCursorSettings();
1487 //----------------------------------------------------------------------------
1490 ::AddToRender(vtkRenderer* theRenderer)
1492 Superclass::AddToRender(theRenderer);
1494 //myInsideDeviceActor->AddToRender(theRenderer);
1495 //myOutsideDeviceActor->AddToRender(theRenderer);
1500 ::RemoveFromRender(vtkRenderer* theRenderer)
1502 //myInsideDeviceActor->RemoveFromRender(theRenderer);
1503 //myOutsideDeviceActor->RemoveFromRender(theRenderer);
1505 Superclass::RemoveFromRender(theRenderer);
1510 ::SetTransform(VTKViewer_Transform* theTransform)
1512 Superclass::SetTransform(theTransform);
1514 myInsideDeviceActor->SetTransform(theTransform);
1515 myOutsideDeviceActor->SetTransform(theTransform);
1521 ::RenderOpaqueGeometry(vtkViewport *viewport)
1524 Superclass::RenderOpaqueGeometry(viewport);
1525 GetMatrix(myInsideDeviceActor->GetUserMatrix());
1526 GetMatrix(myOutsideDeviceActor->GetUserMatrix());
1532 ::RenderTranslucentGeometry(vtkViewport *viewport)
1534 Superclass::RenderTranslucentGeometry(viewport);
1535 GetMatrix(myInsideDeviceActor->GetUserMatrix());
1536 GetMatrix(myOutsideDeviceActor->GetUserMatrix());
1541 //----------------------------------------------------------------------------
1544 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1546 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetWidgetCtrl - this = "<<this);
1548 if(myWidgetCtrl == theWidgetCtrl){
1553 myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1554 myInsideDeviceActor->SetVisibility(false);
1556 myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1557 myOutsideDeviceActor->SetVisibility(false);
1560 Superclass::SetWidgetCtrl(theWidgetCtrl);
1563 myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1564 myInsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1566 myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1567 myOutsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1572 //----------------------------------------------------------------------------
1575 ::SetMapperInput(vtkDataSet* theDataSet)
1577 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetMapperInput - this = "<<this);
1579 Superclass::SetMapperInput(theDataSet);
1581 // if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1582 // myInsideDeviceActor->SetPipeLine(aPipeLine);
1583 // aPipeLine->Delete();
1586 // if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1587 // myOutsideDeviceActor->SetPipeLine(aPipeLine);
1588 // aPipeLine->Delete();
1590 // aPipeLine->SetExtractBoundaryCells(true);
1591 // aPipeLine->SetExtractInside(true);
1596 //----------------------------------------------------------------------------
1597 vtkFloatingPointType
1599 ::GetRadius(vtkIdType theObjID,
1601 vtkDataArray *theScalarArray)
1603 VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1604 if(IsSegmentationEnabled()){
1605 if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1606 aPipeLine = myOutsideDeviceActor->GetPipeLine();
1608 aPipeLine = myInsideDeviceActor->GetPipeLine();
1610 return ::GetRadius(theVTKID,theScalarArray,aPipeLine);
1614 //----------------------------------------------------------------------------
1615 vtkFloatingPointType
1617 ::GetMagnification(vtkIdType theObjID)
1619 VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1620 if(IsSegmentationEnabled()){
1621 if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1622 aPipeLine = myOutsideDeviceActor->GetPipeLine();
1624 aPipeLine = myInsideDeviceActor->GetPipeLine();
1626 return aPipeLine->GetMagnification();
1630 //----------------------------------------------------------------------------
1631 vtkFloatingPointType
1633 ::GetClamp(vtkIdType theObjID)
1635 if(IsSegmentationEnabled()){
1636 if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1637 return ::GetClamp(myOutsideDeviceActor->GetPipeLine());
1639 return ::GetClamp(myInsideDeviceActor->GetPipeLine());
1641 return Superclass::GetClamp(theObjID);
1645 //----------------------------------------------------------------
1648 VISU_GaussPtsAct1::SetPosition(double _arg[3]){
1649 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetPosition - this = "<<this);
1650 Superclass::SetPosition(_arg);
1651 myUpdatePositionSignal(_arg);
1656 ::Connect(VISU_GaussPtsAct2* theActor)
1658 mySetVisibilitySignal.connect(boost::bind(&VISU_GaussPtsAct2::SetVisibility,theActor,_1));
1659 myUpdatePositionSignal.connect(boost::bind(&VISU_GaussPtsAct2::SetPosition, theActor,_1));
1664 ::SetVisibility(int theMode)
1666 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetVisibility - this = "<<this);
1668 Superclass::SetVisibility(theMode);
1670 bool aVisisbility = GetVisibility();
1671 bool anIsSegementation = IsSegmentationEnabled();
1672 myDeviceActor->SetVisibility(aVisisbility/* && !anIsSegementation*/);
1673 myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1674 myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1676 mySetVisibilitySignal(GetVisibility());
1679 //----------------------------------------------------------------
1682 ::UpdateInsideCursorSettings()
1684 Superclass::UpdateInsideCursorSettings( myInsideDeviceActor );
1687 //----------------------------------------------------------------
1690 ::SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings)
1692 if(myOutsideCursorSettings == theOutsideCursorSettings)
1695 if(myOutsideCursorSettings)
1696 myOutsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1698 myOutsideCursorSettings = theOutsideCursorSettings;
1700 if(theOutsideCursorSettings)
1702 theOutsideCursorSettings->AddObserver(VISU::UpdateOutsideSettingsEvent,
1703 myEventCallbackCommand.GetPointer(),
1705 UpdateOutsideCursorSettings();
1711 ::UpdateOutsideCursorSettings()
1713 if(!myOutsideCursorSettings || myOutsideCursorSettings->GetInitial())
1716 VISU_GaussPointsPL* aPipeline = myOutsideDeviceActor->GetPipeLine();
1718 vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
1719 vtkFloatingPointType aMagnification = aPipeline->GetMagnification();
1721 aPipeline->ShallowCopy(GetGaussPointsPL(), true);
1723 aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1724 aPipeline->SetExtractBoundaryCells(true);
1725 //aPipeline->SetExtractInside(true);
1726 aPipeline->SetMagnification( aMagnification );
1728 aPipeline->SetPrimitiveType( myOutsideCursorSettings->GetPrimitiveType() );
1730 if( myOutsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1731 myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_POINTS );
1733 myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1735 aPipeline->SetClamp( myOutsideCursorSettings->GetClamp() );
1736 aPipeline->SetImageData( myOutsideCursorSettings->GetTexture() );
1737 aPipeline->SetAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() );
1738 aPipeline->SetResolution( myOutsideCursorSettings->GetResolution() );
1739 aPipeline->SetSize( myOutsideCursorSettings->GetSize() );
1740 aPipeline->SetMagnification( myOutsideCursorSettings->GetMagnification() );
1741 aPipeline->SetMagnificationIncrement( myOutsideCursorSettings->GetIncrement() );
1743 if( myOutsideCursorSettings->GetUniform() )
1745 myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOff();
1746 myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 1 ); // Geometry mode
1747 myOutsideDeviceActor->GetProperty()->SetColor( myOutsideCursorSettings->GetColor() );
1751 myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 2 ); // Outside cursor mode
1752 myOutsideDeviceActor->GetPointSpriteMapper()->SetColorModeToMapScalars();
1753 myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOn();
1756 aPipeline->Update();
1758 Highlight(isHighlighted());
1764 //----------------------------------------------------------------
1767 ::ProcessEvents(vtkObject* theObject,
1768 unsigned long theEvent,
1769 void* theClientData,
1772 if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
1773 if(VISU_GaussPtsAct1* self = dynamic_cast<VISU_GaussPtsAct1*>(anObject))
1774 if(theEvent == VISU::UpdateOutsideSettingsEvent)
1775 self->UpdateOutsideCursorSettings();
1777 Superclass::ProcessEvents(theObject,theEvent,theClientData,theCallData);
1782 ::OnInteractorEvent(unsigned long theEvent)
1785 case vtkCommand::StartInteractionEvent:
1786 myDeviceActor->SetVisibility(GetVisibility());
1787 myInsideDeviceActor->SetVisibility(false);
1788 myOutsideDeviceActor->SetVisibility(false);
1790 case vtkCommand::EnableEvent:
1791 case vtkCommand::DisableEvent:
1792 case vtkCommand::EndInteractionEvent: {
1793 bool aVisisbility = GetVisibility();
1794 bool anIsSegementation = IsSegmentationEnabled();
1795 myDeviceActor->SetVisibility(aVisisbility/* && !anIsSegementation*/);
1796 myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1797 myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1804 Superclass::OnInteractorEvent(theEvent);
1807 //----------------------------------------------------------------------------
1812 unsigned long int aSize = Superclass::GetMemorySize();
1813 if(IsSegmentationEnabled()){
1814 aSize += myInsideDeviceActor->GetMemorySize();
1815 aSize += myOutsideDeviceActor->GetMemorySize();
1822 //==============================================================================
1823 vtkStandardNewMacro(VISU_GaussPtsAct2);
1826 //----------------------------------------------------------------------------
1828 ::VISU_GaussPtsAct2()
1830 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::VISU_GaussPtsAct2 - this = "<<this);
1831 myDeviceActor->SetVisibility(false);
1835 ::~VISU_GaussPtsAct2()
1837 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::~VISU_GaussPtsAct2 - this = "<<this);
1841 //----------------------------------------------------------------------------
1844 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1846 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::ShallowCopyPL - this = "<<this);
1848 Superclass::ShallowCopyPL(thePipeLine);
1851 //----------------------------------------------------------------------------
1853 VISU_GaussPtsAct2::SetPosition(double _arg[3]){
1854 if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct2::SetPosition - this = "<<this);
1855 Superclass::SetPosition(_arg);
1858 //----------------------------------------------------------------------------
1861 ::SetMapperInput(vtkDataSet* theDataSet)
1863 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetMapperInput - this = "<<this);
1864 Superclass::SetMapperInput(theDataSet);
1865 // if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1866 // myDeviceActor->SetPipeLine(aPipeLine);
1867 // myCurrentPL = aPipeLine;
1868 // aPipeLine->Delete();
1870 // myMapper->SetInput(myCurrentPL->GetPickableDataSet());
1871 // SetMapper(myMapper.GetPointer());
1875 //----------------------------------------------------------------------------
1878 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1880 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetWidgetCtrl - this = "<<this);
1882 if(myWidgetCtrl == theWidgetCtrl)
1886 theWidgetCtrl->RemoveObserver(myEventCallbackCommand.GetPointer());
1887 myDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1888 myDeviceActor->SetVisibility(false);
1891 Superclass::SetWidgetCtrl(theWidgetCtrl);
1894 myDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1895 myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1900 //----------------------------------------------------------------------------
1905 if(IsSegmentationEnabled())
1906 return Superclass::GetMemorySize();
1911 //----------------------------------------------------------------------------
1914 ::SetVisibility(int theMode)
1916 if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetVisibility - this = "<<this);
1918 Superclass::SetVisibility(theMode);
1920 myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1925 ::OnInteractorEvent(unsigned long theEvent)
1928 case vtkCommand::EnableEvent:
1929 case vtkCommand::DisableEvent:
1930 myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1931 if(theEvent == vtkCommand::EnableEvent)
1934 case vtkCommand::EndInteractionEvent:
1940 Superclass::OnInteractorEvent(theEvent);