]> SALOME platform Git repositories - modules/visu.git/blob - src/OBJECT/VISU_GaussPtsAct.cxx
Salome HOME
Merge from V6_3_BR 06/06/2011
[modules/visu.git] / src / OBJECT / VISU_GaussPtsAct.cxx
1 // Copyright (C) 2007-2011  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 // Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
4 // CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
5 //
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.
10 //
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.
15 //
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
19 //
20 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 //
22
23 //  VISU OBJECT : interactive object for VISU entities implementation
24 //  File   : VISU_MeshAct.hxx
25 //  Author : Laurent CORNABE with the help of Nicolas REJNERI
26 //  Module : VISU
27 //  $Header$
28 //
29 #include "VISU_GaussPtsAct.h"
30 #include "VISU_GaussPointsPL.hxx"
31 #include "VISU_GaussPtsSettings.h"
32 #include "VISU_GaussPtsDeviceActor.h"
33 #include "VISU_PickingSettings.h"
34 #include "VISU_WidgetCtrl.hxx"
35 #include "VISU_SphereWidget.hxx"
36 #include "VISU_OpenGLPointSpriteMapper.hxx"
37 #include "VISU_ScalarBarCtrl.hxx"
38 #include "VISU_ScalarBarActor.hxx"
39
40 #include "VISU_Event.h" 
41 #include "SVTK_Actor.h"
42 #include "VTKViewer_FramedTextActor.h"
43 #include <SALOME_ExtractPolyDataGeometry.h>
44
45 #include <vtkCamera.h>
46 #include <vtkRenderer.h>
47 #include <vtkPointPicker.h>
48 #include <vtkMatrix4x4.h>
49 #include <vtkScalarBarWidget.h>
50 #include <vtkTextMapper.h>
51 #include <vtkTextProperty.h>
52 #include <vtkImplicitBoolean.h>
53 #include <vtkImplicitFunctionCollection.h>
54 #include <vtkPlane.h>
55
56 #include <vtkPointData.h>
57 #include <vtkCellData.h>
58 #include <vtkDataArray.h>
59
60 #include <vtkSphereSource.h>
61 #include <vtkPolyDataMapper.h>
62 #include <vtkPolyData.h>
63 #include <vtkActor.h>
64 #include <vtkTransform.h>
65
66 #include <vtkObjectFactory.h>
67 #include <vtkCallbackCommand.h>
68 #include <vtkInteractorStyle.h>
69 #include <vtkRenderWindowInteractor.h>
70 #include <vtkOutlineSource.h>
71
72 #include <sstream>
73 #include <boost/bind.hpp>
74
75 #include <vtkUnstructuredGrid.h>
76 #include <vtkPolyDataMapper.h>
77 #include <vtkRenderWindow.h>
78 #include <vtkCellArray.h>
79 #include <vtkWarpVector.h>
80 #include <vtkCellDataToPointData.h>
81 #include <vtkCell.h>
82 #include <vtkMath.h>
83
84 #include <vtkViewport.h>
85
86 #include "utilities.h"
87
88 #ifdef _DEBUG_
89 static int MYDEBUG = 0;
90 static int MYDEBUG1 = 0;
91 static int MYDEBUG2 = 0;
92 #else
93 static int MYDEBUG = 0;
94 static int MYDEBUG1 = 0;
95 static int MYDEBUG2 = 0;
96 #endif
97
98
99 namespace
100 {
101   bool
102   CheckIsSameValue(vtkFloatingPointType theTarget,
103                    vtkFloatingPointType theSource)
104   {
105     static vtkFloatingPointType TOL = 10.0 / VTK_LARGE_FLOAT;
106     return fabs(theTarget - theSource)  < TOL;
107   }
108
109   bool
110   CheckIsSameVector(vtkFloatingPointType* theTarget,
111                     vtkFloatingPointType* theSource,
112                     size_t theLength)
113   {
114     for ( size_t anId = 0; anId < theLength; anId++ ) {
115       if ( !CheckIsSameValue( theTarget[ anId ], theSource[ anId ] ) )
116         return false;
117     }
118
119     return true;
120   }
121   
122 }
123
124 //============================================================================
125 vtkStandardNewMacro(VISU_GaussPtsAct);
126
127 //----------------------------------------------------------------------------
128 VISU_GaussPtsAct
129 ::VISU_GaussPtsAct():
130   myEventCallbackCommand(vtkCallbackCommand::New()),
131   myPriority(0.0),
132   myDeviceActor(VISU_GaussPtsDeviceActor::New()),
133   myWidgetCtrl(NULL),
134   myGaussPointsPL(NULL),
135   myLastPreHighlightObjID(-1),
136   myCursorPyramid(VISU_CursorPyramid::New()),
137   myCursorPyramidSelected(VISU_CursorPyramid::New()),
138   myCellSource(vtkUnstructuredGrid::New()),
139   myCellActor(SVTK_Actor::New()),
140   myScalarBarCtrl(VISU_ScalarBarCtrl::New()),
141   myBarVisibility(true),
142   myInsideCursorSettings(NULL),
143   myCurrentPL(NULL),
144   myMapper(vtkPolyDataMapper::New()),
145   myPolyDataExtractor(SALOME_ExtractPolyDataGeometry::New()),
146   myFunction(vtkImplicitBoolean::New()),
147   myWarpVector(vtkWarpVector::New()),
148   myCellDataToPointData(vtkCellDataToPointData::New())
149 {
150   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::VISU_GaussPtsAct - this = "<<this);
151
152   myEventCallbackCommand->Delete();
153   myDeviceActor->Delete();
154
155   myCursorPyramid->Delete();
156   myCursorPyramid->SetPickable(0);
157   myCursorPyramid->SetVisibility(0);
158
159   myCursorPyramidSelected->Delete();
160   myCursorPyramidSelected->SetPickable(0);
161   myCursorPyramidSelected->SetVisibility(0);
162
163   myCellSource->Delete();
164   myCellActor->Delete();
165
166   myEventCallbackCommand->SetClientData(this); 
167   myEventCallbackCommand->SetCallback(VISU_GaussPtsAct::ProcessEvents);
168
169   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
170
171   myDeviceActor->SetProperty(GetProperty());
172   myDeviceActor->SetUserMatrix(aMatrix);
173   myDeviceActor->SetVisibility(true);
174   myDeviceActor->SetPickable(false);
175
176   myCellSource->Allocate();
177   myCellActor->Initialize();
178   myCellActor->SetRepresentation(VTK_WIREFRAME);
179   myCellActor->SetSource(myCellSource.GetPointer());
180
181   myCellActor->SetVisibility(0);
182   myCellActor->SetPickable(0);
183   myCellActor->GetProperty()->SetAmbient(1.0);
184   myCellActor->GetProperty()->SetDiffuse(0.0);
185
186   myScalarBarCtrl->Delete();
187
188   myMapper->Delete();
189   aMatrix->Delete();
190
191   myWarpVector->Delete();
192   myCellDataToPointData->Delete();
193
194   myPolyDataExtractor->SetImplicitFunction(myFunction);
195   //myPolyDataExtractor->ExtractBoundaryCellsOn();
196
197   myFunction->SetOperationTypeToIntersection();
198   myPolyDataExtractor->Delete();
199   myFunction->Delete();
200
201   if( VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get() )
202     aPickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent, 
203                                   myEventCallbackCommand.GetPointer(), 
204                                   myPriority);
205 }
206
207 VISU_GaussPtsAct
208 ::~VISU_GaussPtsAct()
209 {
210   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::~VISU_GaussPtsAct - this = "<<this);
211   SetWidgetCtrl(NULL);
212   SetInteractor(NULL);
213   SetInsideCursorSettings(NULL);
214 }
215
216
217 //----------------------------------------------------------------------------
218 void
219 VISU_GaussPtsAct
220 ::SetPipeLine(VISU_PipeLine* thePipeLine) 
221 {
222   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::SetPipeLine - this = "<<this);
223
224   myGaussPointsPL = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine);
225
226   Superclass::SetPipeLine(thePipeLine);
227 }
228
229 VISU_GaussPointsPL*
230 VISU_GaussPtsAct
231 ::GetGaussPointsPL()
232 {
233   return myGaussPointsPL.GetPointer();
234 }
235
236 //----------------------------------------------------------------------------
237 void
238 VISU_GaussPtsAct
239 ::DeepCopy(VISU_Actor *theActor)
240 {
241   if(VISU_GaussPtsAct* anActor = dynamic_cast<VISU_GaussPtsAct*>(theActor)){
242     Superclass::DeepCopy(theActor);
243     SetBarVisibility(anActor->GetBarVisibility());
244   }
245 }
246
247 //----------------------------------------------------------------------------
248 void
249 VISU_GaussPtsAct
250 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
251 {
252   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::ShallowCopyPL - this = "<<this);
253   
254   Superclass::ShallowCopyPL(thePipeLine);
255   
256   UpdateInsideCursorSettings();
257   
258   Highlight(isHighlighted());
259 }
260
261
262 //----------------------------------------------------------------------------
263
264 vtkMapper* 
265 VISU_GaussPtsAct
266 ::GetMapper()
267 {
268   //vtkMapper* aMapper = myCurrentPL->GetPointSpriteMapper();
269   //aMapper->Update();
270   //return aMapper;
271   myMapper->Update();
272   return myMapper.GetPointer();
273 }
274
275 vtkFloatingPointType* 
276 VISU_GaussPtsAct
277 ::GetBounds()
278 {
279   return GetMapper()->GetBounds();
280 }
281
282 vtkDataSet* 
283 VISU_GaussPtsAct
284 ::GetInput()
285 {
286   return GetMapper()->GetInput();
287 }
288
289 VISU_PipeLine* 
290 VISU_GaussPtsAct
291 ::GetCurrentPL() 
292
293   return myCurrentPL;
294 }
295
296
297 //----------------------------------------------------------------------------
298 unsigned long int
299 VISU_GaussPtsAct
300 ::GetMemorySize()
301 {
302   vtkDataSet* aDataSet = myDeviceActor->GetMapper()->GetInput();
303   unsigned long int aSize = aDataSet->GetActualMemorySize() * 1024;
304
305   aSize += Superclass::GetMemorySize();
306
307   return aSize;
308 }
309
310 //----------------------------------------------------------------------------
311 void
312 VISU_GaussPtsAct
313 ::AddToRender(vtkRenderer* theRenderer)
314 {
315   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::AddToRender - this = "<<this);
316
317   Superclass::AddToRender(theRenderer);
318
319   myDeviceActor->AddToRender(theRenderer);
320
321   theRenderer->AddActor(myCellActor.GetPointer());
322
323   myCursorPyramid->AddToRender(theRenderer);
324   myCursorPyramidSelected->AddToRender(theRenderer);
325   myScalarBarCtrl->AddToRender(theRenderer);
326 }
327
328 void 
329 VISU_GaussPtsAct
330 ::RemoveFromRender(vtkRenderer* theRenderer)
331 {
332   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::RemoveFromRender - this = "<<this);
333
334   myDeviceActor->RemoveFromRender(theRenderer);
335   
336   theRenderer->RemoveActor(myCellActor.GetPointer());
337   
338   myCursorPyramid->RemoveFromRender(theRenderer);
339   myCursorPyramidSelected->RemoveFromRender(theRenderer);
340   myScalarBarCtrl->RemoveFromRender(theRenderer);
341
342   Superclass::RemoveFromRender(theRenderer);
343 }
344
345 void 
346 VISU_GaussPtsAct
347 ::SetTransform(VTKViewer_Transform* theTransform)
348 {
349   Superclass::SetTransform(theTransform);
350
351   myDeviceActor->SetTransform(theTransform);
352 }
353
354 int
355 VISU_GaussPtsAct
356 ::RenderOpaqueGeometry(vtkViewport *viewport)
357 {
358   GetMatrix(myDeviceActor->GetUserMatrix());
359   return 1;
360 }
361
362 int
363 VISU_GaussPtsAct
364 ::RenderTranslucentGeometry(vtkViewport *viewport)
365 {
366   GetMatrix(myDeviceActor->GetUserMatrix());
367   return 1;
368 }
369
370
371 //----------------------------------------------------------------------------
372 void
373 VISU_GaussPtsAct
374 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
375 {
376   if(myWidgetCtrl == theWidgetCtrl)
377     return;
378
379   if(MYDEBUG) 
380     MESSAGE("VISU_GaussPtsAct::SetWidgetCtrl - this = "<<this<<"; theWidget = "<<theWidgetCtrl);
381
382   if(myWidgetCtrl)
383     myWidgetCtrl->RemoveObserver(myEventCallbackCommand.GetPointer());
384
385   if(theWidgetCtrl){
386     theWidgetCtrl->AddObserver(vtkCommand::EnableEvent, 
387                                myEventCallbackCommand.GetPointer(), 
388                                myPriority);
389     theWidgetCtrl->AddObserver(vtkCommand::DisableEvent, 
390                                myEventCallbackCommand.GetPointer(), 
391                                myPriority);
392     theWidgetCtrl->AddObserver(vtkCommand::StartInteractionEvent, 
393                                myEventCallbackCommand.GetPointer(), 
394                                myPriority);
395     theWidgetCtrl->AddObserver(vtkCommand::EndInteractionEvent, 
396                                myEventCallbackCommand.GetPointer(), 
397                                myPriority);
398   }
399
400   myWidgetCtrl = theWidgetCtrl;
401 }
402
403 bool
404 VISU_GaussPtsAct
405 ::GetChangeMagnification()
406 {
407   return myChangeMagnification;
408 }
409
410 void
411 VISU_GaussPtsAct
412 ::ChangeMagnification( bool up )
413 {
414   myEventCallbackCommand->SetAbortFlag(1);
415
416   vtkFloatingPointType aMagnification = myInsideCursorSettings->GetMagnification();
417   vtkFloatingPointType anIncrement = myInsideCursorSettings->GetIncrement();
418   vtkFloatingPointType coefficient = up ? anIncrement : 1 / anIncrement;
419
420   myInsideCursorSettings->SetMagnification( aMagnification * coefficient );
421   myInsideCursorSettings->InvokeEvent(VISU::UpdateFromSettingsEvent,NULL);
422
423   Update();
424 }
425
426 //----------------------------------------------------------------------------
427 namespace
428 {
429   VISU_GaussPointsPL*
430   CreatePipeLine(VISU_GaussPointsPL* thePipeLine)
431   {
432     VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New();
433     aPipeLine->ShallowCopy(thePipeLine, true);
434     aPipeLine->Update();
435     return aPipeLine;
436   }
437 }
438
439 void
440 VISU_GaussPtsAct
441 ::SetMapperInput(vtkDataSet* theDataSet) 
442 {
443   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::SetMapperInput - this = "<<this);
444
445   myDeviceActor->SetExtractor(myPolyDataExtractor);
446   myDeviceActor->SetPipeLine(GetGaussPointsPL());
447   myCurrentPL = myDeviceActor->GetPipeLine();
448
449   //SetMapper(myCurrentPL->GetPointSpriteMapper());
450
451   //  myPolyDataExtractor->SetInput(myCurrentPL->GetPickableDataSet());
452   //myMapper->SetInput(myPolyDataExtractor->GetOutput());
453   myMapper->SetInput(myCurrentPL->GetPickableDataSet());
454   SetMapper(myMapper.GetPointer());
455 }
456
457
458 //----------------------------------------------------------------------------
459 namespace
460 {
461   inline  
462   vtkFloatingPointType 
463   GetRadius(vtkIdType theVTKID,
464             vtkDataArray *theScalarArray,
465             VISU_GaussPointsPL* theGaussPointsPL)
466   {
467     vtkFloatingPointType aRadius = 0.5;
468     if(theGaussPointsPL->GetPointSpriteMapper()->GetPointSpriteMode() == 1) // Geometry mode
469       aRadius *= theGaussPointsPL->GetSize() * theGaussPointsPL->GetAverageCellSize();
470     else if(theGaussPointsPL->GetBicolor()){
471       vtkFloatingPointType aVal = theScalarArray->GetTuple1(theVTKID);
472       if(aVal > 0.0)
473         aRadius *= theGaussPointsPL->GetMaxSize();
474       else
475         aRadius *= theGaussPointsPL->GetMinSize();
476       aRadius *= theGaussPointsPL->GetAverageCellSize();
477     }else
478       aRadius *= theGaussPointsPL->GetPointSize(theVTKID,theScalarArray);
479
480     return aRadius;
481   }
482 }
483
484 vtkFloatingPointType
485 VISU_GaussPtsAct
486 ::GetRadius(vtkIdType theObjID,
487             vtkIdType theVTKID,
488             vtkDataArray *theScalarArray)
489 {
490   return ::GetRadius(theVTKID,theScalarArray,myDeviceActor->GetPipeLine());
491 }
492
493 //----------------------------------------------------------------------------
494 vtkFloatingPointType 
495 VISU_GaussPtsAct
496 ::GetMagnification(vtkIdType theObjID)
497 {
498   return myDeviceActor->GetPipeLine()->GetMagnification();
499 }
500
501
502 //----------------------------------------------------------------------------
503 namespace
504 {
505   inline  
506   vtkFloatingPointType 
507   GetClamp(VISU_GaussPointsPL* theGaussPointsPL)
508   {
509     vtkFloatingPointType aClamp = theGaussPointsPL->GetClamp();
510     if(theGaussPointsPL->GetPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere)
511       return -aClamp;
512     return aClamp;
513   }
514 }
515
516 vtkFloatingPointType 
517 VISU_GaussPtsAct
518 ::GetClamp(vtkIdType theObjID)
519 {
520   return ::GetClamp(myDeviceActor->GetPipeLine());
521 }
522
523
524 //----------------------------------------------------------------------------
525 void
526 VISU_GaussPtsAct
527 ::SetOpacity(vtkFloatingPointType theValue)
528 {
529   GetGaussPointsPL()->SetOpacity(theValue);
530   Superclass::SetOpacity(theValue);
531 }
532
533
534 //----------------------------------------------------------------------------
535 void
536 VISU_GaussPtsAct
537 ::SetFactory(VISU::TActorFactory* theActorFactory)
538
539   using namespace VISU;
540   myGaussPtsActorFactory = dynamic_cast<TGaussPtsActorFactory*>(theActorFactory);
541   myUpdatePrs3dSignal.connect(boost::bind(&TGaussPtsActorFactory::UpdateFromActor,
542                                           myGaussPtsActorFactory,
543                                           _1));
544   Superclass::SetFactory(theActorFactory);
545 }
546
547 VISU::TGaussPtsActorFactory*
548 VISU_GaussPtsAct
549 ::GetGaussPtsFactory()
550 {
551   return myGaussPtsActorFactory;
552 }
553
554
555 //----------------------------------------------------------------------------
556 void
557 VISU_GaussPtsAct
558 ::SetVisibility(int theMode)
559 {
560   Superclass::SetVisibility(theMode);
561   myDeviceActor->SetVisibility(GetVisibility()); // VSV
562   myScalarBarCtrl->SetVisibility(theMode);
563 }
564
565 int
566 VISU_GaussPtsAct
567 ::IsSegmentationEnabled()
568 {
569   return myWidgetCtrl  && myWidgetCtrl->GetEnabled();
570 }
571
572
573 //----------------------------------------------------------------------------
574 void
575 VISU_GaussPtsAct
576 ::SetBarVisibility(bool theMode)
577 {
578   myBarVisibility = theMode;
579   myScalarBarCtrl->SetCtrlVisibility(theMode); 
580   myScalarBarCtrl->SetVisibility(GetVisibility()); 
581 }
582
583 bool
584 VISU_GaussPtsAct
585 ::GetBarVisibility()
586
587   return myBarVisibility;
588 }
589
590 VISU_ScalarBarCtrl* 
591 VISU_GaussPtsAct
592 ::GetScalarBarCtrl()
593 {
594   return myScalarBarCtrl.GetPointer();
595 }
596
597 //----------------------------------------------------------------------------
598 void
599 VISU_GaussPtsAct
600 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
601 {
602   if(theInteractor == myInteractor)
603     return;
604
605   if(myInteractor)
606     myInteractor->RemoveObserver(myEventCallbackCommand.GetPointer());
607   
608   if(theInteractor){
609     theInteractor->AddObserver(vtkCommand::CharEvent, 
610                                myEventCallbackCommand.GetPointer(), 
611                                myPriority);
612     theInteractor->AddObserver(VISU::SetSMDecreaseMagnificationEvent, 
613                                myEventCallbackCommand.GetPointer(), 
614                                myPriority);
615     theInteractor->AddObserver(VISU::SetSMIncreaseMagnificationEvent, 
616                                myEventCallbackCommand.GetPointer(), 
617                                myPriority);
618   }
619   Superclass::SetInteractor(theInteractor);
620
621   Modified();
622 }
623 //-------------------------------------------------------------------------
624 void 
625 VISU_GaussPtsAct
626 ::ProcessEvents(vtkObject* vtkNotUsed(theObject), 
627                 unsigned long theEvent,
628                 void* theClientData, 
629                 void* vtkNotUsed(theCallData))
630 {
631   if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
632     if(VISU_GaussPtsAct* self = dynamic_cast<VISU_GaussPtsAct*>(anObject)) {
633       if(theEvent == VISU::UpdateInsideSettingsEvent)
634         self->UpdateInsideCursorSettings();
635       else
636         self->OnInteractorEvent(theEvent);
637     }
638 }
639
640 //-------------------------------------------------------------------------
641 void
642 VISU_GaussPtsAct
643 ::OnInteractorEvent(unsigned long theEvent)
644 {
645   switch(theEvent){
646   case vtkCommand::CharEvent: {
647     switch(myInteractor->GetKeyCode()) {
648     case 'M' :
649     case 'm' :
650     {
651       if( IsSegmentationEnabled() )
652       {
653         this->ChangeMagnification( myInteractor->GetShiftKey() );
654         return;
655       }
656
657       myChangeMagnification = myInteractor->GetShiftKey();
658       break;
659     }
660     case 'D' :
661     case 'd' :
662     {
663       if( IsSegmentationEnabled() && myWidgetCtrl->IsSphereActive() )
664       {
665         VISU_SphereWidget* aSphereWidget = myWidgetCtrl->GetSphereWidget();
666         aSphereWidget->ChangeRadius( myInteractor->GetShiftKey() );
667         myWidgetCtrl->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
668         myWidgetCtrl->GetInteractor()->Render();
669       }
670       return;
671     }
672     default:
673       return;
674     }
675     myUpdatePrs3dSignal(this);
676     break;
677   }
678   case VISU::SetSMDecreaseMagnificationEvent: 
679   case VISU::SetSMIncreaseMagnificationEvent: 
680     myChangeMagnification = theEvent == VISU::SetSMIncreaseMagnificationEvent;
681     myUpdatePrs3dSignal(this);
682     break;
683   case VISU::UpdatePickingSettingsEvent:
684     UpdatePickingSettings();
685     break;
686   case vtkCommand::EndInteractionEvent:
687   case vtkCommand::EnableEvent:
688   case vtkCommand::DisableEvent: 
689     myCurrentPL->GetMapper()->Update();
690     Highlight(isHighlighted());
691     break;
692   default:
693     break;
694   }
695 }
696
697 //----------------------------------------------------------------------------
698 bool
699 VISU_GaussPtsAct
700 ::IsInfinitive()
701 {
702   if(vtkMapper* aMapper = myDeviceActor->GetMapper()){
703     if(vtkDataSet* aDataSet= aMapper->GetInput()){
704       aDataSet->Update();
705       myIsInfinite = aDataSet->GetNumberOfCells() < 2;
706     }
707   }
708   return myIsInfinite;
709 }
710
711 //----------------------------------------------------------------------------
712 int
713 VISU_GaussPtsAct
714 ::GetPickable()
715 {
716   if(Superclass::GetPickable()){
717     if(vtkMapper* aMapper = GetMapper()){
718       if(vtkDataSet* aDataSet= aMapper->GetInput()){
719         aDataSet->Update();
720         return aDataSet->GetNumberOfCells() > 0;
721       }
722     }
723   }
724
725   return false;
726 }
727
728 //----------------------------------------------------------------------------
729 bool
730 VISU_GaussPtsAct
731 ::PreHighlight(vtkInteractorStyle* theInteractorStyle, 
732                SVTK_SelectionEvent* theSelectionEvent,
733                bool theIsHighlight)
734 {
735   if ( !GetPickable() )
736     return false;
737
738   myPreHighlightActor->SetVisibility(false);
739   myCursorPyramid->SetVisibility(false);  
740
741 /*  if (!myBarVisibility)
742     return false;*/
743
744
745   if(!theIsHighlight)
746     myLastPreHighlightObjID = -1;
747
748   Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
749
750   if(aSelectionMode == ActorSelection || !theIsHighlight)
751     return Superclass::PreHighlight(theInteractorStyle,
752                                     theSelectionEvent,
753                                     theIsHighlight);  
754   
755   bool anIsChanged = (mySelectionMode != aSelectionMode);
756   bool anIsPreselected = myIsPreselected;
757   myIsPreselected = false;
758
759   VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
760   
761   if(aSelectionMode == GaussPointSelection && theIsHighlight){
762     SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
763     myPointPicker->Pick(theSelectionEvent->myX, 
764                         theSelectionEvent->myY, 
765                         0.0, 
766                         theInteractorStyle->GetCurrentRenderer());
767     
768     if(myPointPicker->GetActor() != this)
769       return (anIsPreselected != myIsPreselected);
770     
771     vtkIdType aVtkId = myPointPicker->GetPointId();
772     
773     if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){
774       vtkIdType anObjId = GetNodeObjId( aVtkId );
775       myIsPreselected = (anObjId >= 0);
776       if(myIsPreselected){
777         anIsChanged = (myLastPreHighlightObjID != anObjId);
778         if(anIsChanged){
779           vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);          
780           //Take into account translation
781           vtkFloatingPointType aLocalNodeCoord[3];
782           this->Transform->Push();
783           this->Transform->PostMultiply();
784           this->Transform->Identity();
785           
786           this->Transform->Translate(this->Position[0],
787                                      this->Position[1],
788                                      this->Position[2]);
789           double aPosition[3];
790           this->Transform->GetPosition(aPosition);
791
792           aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0]; 
793           aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
794           aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
795
796           vtkDataSet* aDataSet = GetInput();
797           vtkPointData* aPointData = aDataSet->GetPointData();
798           if(vtkDataArray *aScalarArray = aPointData->GetScalars()){
799             vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight();
800             aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
801             //vtkFloatingPointType aColor[3] = myPreHighlightActor->GetProperty()->GetColor();
802             vtkFloatingPointType aColor[3];
803             theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor );
804             aColor[0] = 1. - aColor[0];
805             aColor[1] = 1. - aColor[1];
806             aColor[2] = 1. - aColor[2];
807
808             myCursorPyramid->Init(aPyramidHeight,
809                                   aPickingSettings->GetCursorSize(),
810                                   GetRadius(anObjId,aVtkId,aScalarArray),
811                                   GetMagnification(anObjId),
812                                   GetClamp(anObjId),
813                                   aNodeCoord,
814                                   aColor);
815           }
816           this->Transform->Pop();
817           myLastPreHighlightObjID = anObjId;
818         }
819         myCursorPyramid->SetVisibility(true);
820       }
821     }
822   }
823   
824   mySelectionMode = aSelectionMode;
825   anIsChanged |= (anIsPreselected != myIsPreselected);
826
827   return anIsChanged;
828 }
829
830
831 //----------------------------------------------------------------------------
832 inline
833 void
834 ChangeZoom(VISU_PickingSettings *thePickingSettings,
835            vtkRenderer* theRenderer,
836            vtkIdType theInitialHasIndex,
837            vtkIdType theCurrentHasIndex)
838 {
839   if( (theInitialHasIndex + theCurrentHasIndex == 1) && thePickingSettings){
840     vtkCamera *aCamera = theRenderer->GetActiveCamera();
841
842     vtkFloatingPointType aZoomFactor = thePickingSettings->GetZoomFactor();
843     double aScale = aCamera->GetParallelScale();
844     if ( !theInitialHasIndex && theCurrentHasIndex ) {
845       aCamera->SetParallelScale( aScale/aZoomFactor );
846     }
847     else {
848       aCamera->SetParallelScale( aScale*aZoomFactor );
849     }
850   }
851   
852 }
853
854 bool
855 VISU_GaussPtsAct
856 ::Highlight(vtkInteractorStyle* theInteractorStyle, 
857             SVTK_SelectionEvent* theSelectionEvent,
858             bool theIsHighlight)
859
860   if ( !GetPickable() )
861     return false;
862
863   //  int anInitialHasIndex = myIsSubElementsHighlighted && mySelectionMode == GaussPointSelection;
864   Handle(SALOME_InteractiveObject) anIO = getIO();
865   //  myIsSubElementsHighlighted = false;
866
867   Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
868
869   if(!theIsHighlight && aSelectionMode == GaussPointSelection){
870     mySelector->RemoveIObject(anIO);
871
872     /*    ChangeZoom(myPickingSettings,
873                theInteractorStyle,
874                anInitialHasIndex,
875                false,
876                anIO);*/
877
878     return true;
879   }
880   
881 /*  if (!myBarVisibility)
882     return false;*/
883
884
885   if(aSelectionMode == ActorSelection)
886     return Superclass::Highlight(theInteractorStyle,
887                                  theSelectionEvent,
888                                  theIsHighlight);
889
890   if(aSelectionMode == GaussPointSelection && !theSelectionEvent->myIsRectangle){
891     vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
892
893     SVTK::TPickLimiter aPickLimiter( myPointPicker, this );
894     myPointPicker->Pick(theSelectionEvent->myX, 
895                         theSelectionEvent->myY,
896                         0.0, 
897                         aRenderer);
898
899     if(myPointPicker->GetActor() != this) {
900       mySelector->ClearIObjects();
901
902       /*      ChangeZoom(myPickingSettings,
903                  theInteractorStyle,
904                  anInitialHasIndex,
905                  false,
906                  anIO);*/
907
908       return true;
909     }
910
911     vtkIdType aVtkId = myPointPicker->GetPointId();
912     if( aVtkId >= 0  && mySelector->IsValid( this, aVtkId, true ) && hasIO()) {
913       vtkIdType anObjId = GetNodeObjId( aVtkId );
914       if(anObjId >= 0){
915         //      myIsHighlighted = true;
916         // Update the Selector
917         if(mySelector->IsSelected(myIO))
918           mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
919         else{
920           if(!theSelectionEvent->myIsShift){
921             mySelector->ClearIObjects();
922           }
923           mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
924           mySelector->AddIObject(this);
925         }
926         /*
927         vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
928         //
929         // FlyTo
930         vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor();
931         vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
932         int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
933         
934         anInteractor->SetDolly(0.);
935         anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber());
936         anInteractor->FlyTo(aRenderer,aNodeCoord);
937         aRenderer->ResetCameraClippingRange();
938         anInteractor->SetDolly(aDollyWas);
939         anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
940         
941         anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);*/
942
943         mySelectionMode = aSelectionMode;
944
945         /*      ChangeZoom(myPickingSettings,
946                    theInteractorStyle,
947                    anInitialHasIndex,
948                    true,
949                    anIO);*/
950
951         return true;
952       }// if( anObjId >= 0 ) {
953     }//if( aVtkId >= 0  && mySelector->IsValid( this, aVtkId, true ) && hasIO()) 
954   }//if(!theSelectionEvent->myIsRectangle){
955
956   /* ChangeZoom(myPickingSettings,
957              theInteractorStyle,
958              anInitialHasIndex,
959              false,
960              anIO);*/
961   
962   return false;
963 }
964
965
966
967 void VISU_GaussPtsAct::SetPosition(double _arg[3]){
968   Superclass::SetPosition(_arg);
969   Highlight(isHighlighted());
970 }
971
972 //==================================================================
973 // function : Highlight
974 // purpose  :
975 //==================================================================
976 void
977 VISU_GaussPtsAct
978 ::Highlight(bool theIsHighlight)
979 {
980   if(!mySelector.GetPointer())
981     return;
982
983   VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
984
985   Selection_Mode aSelectionMode = mySelector->SelectionMode();
986   
987   bool anInitialHasIndex = isSubElementsHighlighted() && mySelectionMode == GaussPointSelection;
988   
989   TColStd_IndexedMapOfInteger aMapIndex;
990   mySelector->GetIndex( getIO(), aMapIndex );
991   bool aCurrentHasIndex = aMapIndex.Extent() == 1;
992   bool anIsVisible = GetVisibility() && aCurrentHasIndex && theIsHighlight;
993   bool aShowTextActor = aPickingSettings->GetInfoWindowEnabled();
994   bool aShowCellActor = aPickingSettings->GetDisplayParentMesh();
995
996   myOutlineActor->SetVisibility(false);
997   myCursorPyramid->SetVisibility(false);
998   myTextActor->SetVisibility(anIsVisible && aShowTextActor);
999   myCellActor->SetVisibility(anIsVisible && aShowCellActor);
1000   GetScalarBarCtrl()->SetIsMarked(anIsVisible);
1001   myCursorPyramidSelected->SetVisibility(anIsVisible);
1002   //GetScalarBarCtrl()->Update();
1003
1004   myIsSubElementsHighlighted = aCurrentHasIndex;
1005
1006   // Zoom if necessary
1007   if( GetVisibility() && aPickingSettings->GetCameraMovementEnabled() )
1008   {
1009     ChangeZoom(aPickingSettings,
1010                GetRenderer(),
1011                anInitialHasIndex,
1012                aCurrentHasIndex);
1013   }
1014
1015   if( aSelectionMode == ActorSelection ) {
1016     Superclass::Highlight(theIsHighlight);
1017     return;
1018   }
1019
1020   if(!theIsHighlight)
1021     return;
1022
1023   if( aSelectionMode != GaussPointSelection )
1024     return;
1025
1026   if ( !aCurrentHasIndex || !myBarVisibility )
1027     return;
1028
1029   //  myTextActor->SetVisibility(anIsVisible);
1030   //  myCellActor->SetVisibility(anIsVisible && myPickingSettings->GetDisplayParentMesh());
1031   //  GetScalarBarCtrl()->SetIsMarked(anIsVisible);
1032   //  myCursorPyramidSelected->SetVisibility(anIsVisible);
1033 //GetScalarBarCtrl()->Update();
1034
1035   // to fix a bug with incorrect representation after the first highlight action
1036   myIsHighlighted = aCurrentHasIndex;
1037
1038   // Zoom if necessary
1039 //   ChangeZoom(myPickingSettings,
1040 //           GetRenderer(),
1041 //           anInitialHasIndex,
1042 //           aCurrentHasIndex);
1043
1044   //  TColStd_IndexedMapOfInteger aMapIndex;
1045   mySelector->GetIndex( getIO(), aMapIndex );
1046   if(aMapIndex.Extent() != 1 || !myBarVisibility) {
1047     return;
1048   }
1049
1050   vtkRenderer *aRenderer = GetRenderer();
1051   vtkCamera* aCamera = aRenderer->GetActiveCamera();
1052
1053   int anObjId = aMapIndex(1);
1054   vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
1055   if ( !aNodeCoord )
1056     return;
1057   //Take into account translation
1058   vtkFloatingPointType aLocalNodeCoord[3];
1059   this->Transform->Push();
1060   this->Transform->PostMultiply();
1061   this->Transform->Identity();
1062   this->Transform->Translate(this->Position[0],
1063                              this->Position[1],
1064                              this->Position[2]);
1065   double aPosition[3];
1066   this->Transform->GetPosition(aPosition);
1067   aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0]; 
1068   aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
1069   aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
1070   this->Transform->Pop();
1071
1072   vtkFloatingPointType aFocalPnt[3];
1073   aCamera->GetFocalPoint(aFocalPnt);
1074
1075   if ( CheckIsSameVector(aLocalNodeCoord, aFocalPnt, 3 ) ) 
1076     return;
1077
1078   // FlyTo
1079   if( anIsVisible && aPickingSettings->GetCameraMovementEnabled() )
1080   {
1081     vtkRenderWindowInteractor* anInteractor = myInteractor;
1082     vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
1083     int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
1084   
1085     anInteractor->SetDolly(0.0);
1086     anInteractor->SetNumberOfFlyFrames(aPickingSettings->GetStepNumber());
1087     anInteractor->FlyTo(aRenderer, aNodeCoord);
1088     aRenderer->ResetCameraClippingRange();
1089     anInteractor->SetDolly(aDollyWas);
1090     anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
1091     anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);
1092   }
1093   //
1094   std::ostringstream aStr;
1095   //  int anObjId = aMapIndex(1);
1096   aStr<<"Global ID: "<<anObjId;
1097   //
1098   vtkIdType aVtkId = GetNodeVTKID(anObjId);
1099   if(aVtkId >= 0){
1100     vtkFloatingPointType aWorldCoord[4] = {aLocalNodeCoord[0], aLocalNodeCoord[1], aLocalNodeCoord[2], 1.};
1101     //
1102     vtkDataSet* aDataSet = GetInput();
1103     vtkPointData* aDataSetAttributes = aDataSet->GetPointData();
1104     //
1105     if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){
1106       vtkFloatingPointType aVal = aScalarArray->GetTuple1(aVtkId);
1107       //
1108       //      GetScalarBarCtrl()->SetIsMarked(true);
1109       GetScalarBarCtrl()->SetMarkValue(aVal);
1110       GetScalarBarCtrl()->Update();
1111       //
1112       vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight();
1113       aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
1114       myCursorPyramidSelected->Init(aPyramidHeight,
1115                                     aPickingSettings->GetCursorSize(),
1116                                     GetRadius(anObjId,aVtkId,aScalarArray),
1117                                     GetMagnification(anObjId),
1118                                     GetClamp(anObjId),
1119                                     aLocalNodeCoord,
1120                                     myHighlightActor->GetProperty()->GetColor());
1121       myCursorPyramidSelected->SetVisibility(anIsVisible && theIsHighlight);
1122       //
1123       const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = 
1124         myGaussPointsPL->GetGaussPtsIDMapper();
1125       VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
1126       
1127       VISU::TGaussPointID aGaussPointID = myGaussPointsPL->GetObjID(anObjId);
1128       VISU::TCellID aCellID = aGaussPointID.first;
1129       VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
1130       aStr<<"\nParentCellID: "<<aCellID;
1131       std::string aParentName = aParent->GetElemName(aCellID);
1132       if(aParentName != "") {
1133         aStr<<"\nParentCellName: '"<<aParentName<<"'";
1134       }
1135       aStr<<"\nLocalPntID: "<<aLocalPntID;
1136       aStr<<"\nScalar: "<<aVal;
1137     }
1138
1139     if(vtkDataArray* aFieldArray = aDataSetAttributes->GetArray("VISU_FIELD")){
1140       int aNbComp = aFieldArray->GetNumberOfComponents();
1141       std::vector<vtkFloatingPointType> aTuple(aNbComp);
1142       aFieldArray->GetTuple(aVtkId, &aTuple[0]);
1143       
1144       aStr<<"\nData: {";
1145       int anId = 0;
1146       while(anId < aNbComp){
1147         vtkFloatingPointType aComp = aTuple[anId++];
1148         aStr<<aComp;
1149         if(anId < aNbComp)
1150           aStr<<"; ";
1151       }
1152       aStr<<"}";
1153     }
1154     //
1155     // myTextActor
1156     std::string aString = aStr.str();
1157     myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
1158     myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
1159     myTextActor->SetWorldPoint(aWorldCoord);
1160     myTextActor->SetText(aString.c_str());
1161     myTextActor->SetMoveFrameFlag(1);
1162     myTextActor->SetVisibility(anIsVisible && theIsHighlight && aShowTextActor);
1163     //
1164     // myCellActor
1165     const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = myGaussPointsPL->GetGaussPtsIDMapper();
1166     VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
1167     //
1168     myCellSource->Reset();
1169     myCellSource->Modified(); // a VTK bug
1170     vtkUnstructuredGrid* aCellDataSet = aParent->GetUnstructuredGridOutput();
1171     
1172     // get parent cell and insert it to myCellSource
1173     VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId);
1174     vtkIdType aCellID = aGaussPointID.first;
1175     vtkCell* aCell = aParent->GetElemCell(aCellID);
1176     myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
1177     
1178     if (myGaussPointsPL->GetIsDeformed()) {
1179       // find neighbour cells ids
1180       vtkIdList* aNeighbourCells = vtkIdList::New();
1181       aNeighbourCells->Allocate(VTK_CELL_SIZE);
1182       
1183       vtkIdList* aCellPoints = aCell->GetPointIds();
1184       
1185       vtkIdList *aPointCells = vtkIdList::New();
1186       aPointCells->Allocate(VTK_CELL_SIZE);
1187       
1188       vtkIdType aNbPoints = aCellPoints->GetNumberOfIds();
1189       for (vtkIdType i = 0; i < aNbPoints; i++) {
1190         aCellDataSet->GetPointCells(aCellPoints->GetId(i), aPointCells);
1191
1192         // add cell ids
1193         vtkIdType aNbCells = aPointCells->GetNumberOfIds();
1194         for (vtkIdType j = 0; j < aNbCells; j++)
1195           aNeighbourCells->InsertUniqueId(aPointCells->GetId(j));
1196       }
1197
1198       aPointCells->Delete();
1199
1200       // get vector data
1201       vtkDataArray* anInputVectors = aDataSetAttributes->GetVectors();
1202       if (!anInputVectors)
1203         return;
1204       
1205       // insert neighbour cells to the special dataset
1206       vtkUnstructuredGrid *aCellsToWarp = vtkUnstructuredGrid::New();
1207       aCellsToWarp->SetPoints(aCellDataSet->GetPoints());
1208
1209       vtkIdType aNbNeighbourCells = aNeighbourCells->GetNumberOfIds();
1210
1211       vtkDataArray *aVectorsToSet = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
1212       aVectorsToSet->SetNumberOfComponents(3);
1213       aVectorsToSet->SetNumberOfTuples(aNbNeighbourCells);
1214
1215       vtkDataArray *aCellVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
1216       aCellVectors->SetNumberOfComponents(3);
1217       
1218       int aNbComp = anInputVectors->GetNumberOfComponents();
1219       std::vector<vtkFloatingPointType> aTuple(aNbComp);
1220       
1221       for (vtkIdType i = 0; i < aNbNeighbourCells; i++) {
1222         vtkIdType aVTKCellId = aNeighbourCells->GetId(i);
1223         vtkIdType anObjCellId = aParent->GetElemObjID(aVTKCellId);
1224         
1225         vtkCell* aCurCell = aParent->GetElemCell(anObjCellId);
1226         
1227         vtkIdType aNewCellId = aCellsToWarp->InsertNextCell(aCurCell->GetCellType(), aCurCell->GetPointIds());
1228         
1229         // get gauss points corresponding to the current cell
1230         vtkIdType aPointVtkId = -1;
1231         vtkIdType aLocalPntId = 0;
1232         aPointVtkId = aGaussPtsIDMapper->GetVTKID(VISU::TGaussPointID(anObjCellId, aLocalPntId));
1233         
1234         if (aPointVtkId >= 0) {
1235           // Compute average vector
1236           aCellVectors->Reset();
1237           while (aPointVtkId >= 0) {
1238             anInputVectors->GetTuple(aPointVtkId, &aTuple[0]);
1239
1240             if (aNbComp >= 3)
1241               aCellVectors->InsertNextTuple3(aTuple[0], aTuple[1], aTuple[2]);
1242             else if (aNbComp == 2)
1243               aCellVectors->InsertNextTuple3(aTuple[0], aTuple[1], 0);
1244             else if (aNbComp == 1)
1245               aCellVectors->InsertNextTuple3(aTuple[0], 0, 0);
1246
1247             aPointVtkId = aGaussPtsIDMapper->GetVTKID(VISU::TGaussPointID(anObjCellId, ++aLocalPntId));
1248           }
1249
1250           double aXCoord = 0, anYCoord = 0, aZCoord = 0;
1251
1252           vtkIdType aNbVectors = aCellVectors->GetNumberOfTuples();
1253           
1254           for (vtkIdType aVecId = 0; aVecId < aNbVectors; aVecId++) {
1255             aXCoord  += aCellVectors->GetComponent(aVecId, 0);
1256             anYCoord += aCellVectors->GetComponent(aVecId, 1);
1257             aZCoord  += aCellVectors->GetComponent(aVecId, 2);
1258           }
1259
1260           aXCoord = aXCoord / aNbVectors;
1261           anYCoord = anYCoord / aNbVectors;
1262           aZCoord = aZCoord / aNbVectors;
1263           
1264           // set vector data for the cell
1265           aVectorsToSet->SetTuple3(aNewCellId, aXCoord, anYCoord, aZCoord);
1266         }
1267         else
1268           aVectorsToSet->SetTuple3(aNewCellId, 0, 0, 0);
1269       }
1270       
1271       aCellsToWarp->GetCellData()->SetVectors(aVectorsToSet);
1272       
1273       aVectorsToSet->Delete();
1274       aCellVectors->Delete();
1275       aNeighbourCells->Delete();
1276       
1277       // warp
1278       myWarpVector->SetScaleFactor(myGaussPointsPL->GetScale());
1279       
1280       myCellDataToPointData->SetInput(aCellsToWarp);
1281       myCellDataToPointData->PassCellDataOn();
1282       aCellsToWarp->Delete();
1283              
1284       myWarpVector->SetInput(myCellDataToPointData->GetUnstructuredGridOutput());
1285       vtkUnstructuredGrid* aWarpedDataSet = myWarpVector->GetUnstructuredGridOutput();
1286       aWarpedDataSet->Update();
1287       myCellSource->SetPoints(aWarpedDataSet->GetPoints());
1288     }
1289     else
1290       myCellSource->SetPoints(aCellDataSet->GetPoints());
1291     
1292     myCellActor->SetVisibility(anIsVisible && theIsHighlight && aShowCellActor);
1293   }
1294 }
1295
1296 void
1297 VISU_GaussPtsAct
1298 ::UpdatePickingSettings()
1299 {
1300   //printf( "VISU_GaussPtsAct::UpdatePickingSettings()\n" );
1301   VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
1302   if(!aPickingSettings)
1303     return;
1304
1305   myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
1306   myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
1307
1308   vtkFloatingPointType aHeight = myGaussPointsPL->GetMaxPointSize()*aPickingSettings->GetPyramidHeight();
1309   vtkFloatingPointType aCursorSize = aPickingSettings->GetCursorSize();
1310   myCursorPyramid->SetPreferences(aHeight,aCursorSize);
1311   myCursorPyramidSelected->SetPreferences(aHeight,aCursorSize);
1312
1313   myHighlightActor->GetProperty()->SetColor( aPickingSettings->GetColor() );
1314   myPointPicker->SetTolerance( aPickingSettings->GetPointTolerance() );
1315
1316   Highlight(isHighlighted());
1317
1318   Update();
1319 }
1320
1321 //----------------------------------------------------------------
1322 void
1323 VISU_GaussPtsAct
1324 ::SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings)
1325 {
1326   if(myInsideCursorSettings == theInsideCursorSettings)
1327     return;
1328
1329   if(myInsideCursorSettings)
1330     myInsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1331
1332   myInsideCursorSettings = theInsideCursorSettings;
1333
1334   if(theInsideCursorSettings){
1335     theInsideCursorSettings->AddObserver(VISU::UpdateInsideSettingsEvent, 
1336                                          myEventCallbackCommand.GetPointer(), 
1337                                          myPriority);
1338     UpdateInsideCursorSettings();
1339   }
1340 }
1341
1342 void
1343 VISU_GaussPtsAct
1344 ::UpdateInsideCursorSettings()
1345 {
1346   UpdateInsideCursorSettings( myDeviceActor );
1347 }
1348
1349 void
1350 VISU_GaussPtsAct
1351 ::UpdateInsideCursorSettings( PDeviceActor theActor )
1352 {
1353   if(!myInsideCursorSettings || myInsideCursorSettings->GetInitial())
1354     return;
1355
1356   VISU_GaussPointsPL* aPipeline = theActor->GetPipeLine();
1357
1358   vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
1359
1360   aPipeline->ShallowCopy(GetGaussPointsPL(), true);
1361
1362   aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1363
1364   aPipeline->SetPrimitiveType( myInsideCursorSettings->GetPrimitiveType() );
1365   aPipeline->SetClamp( myInsideCursorSettings->GetClamp() );
1366   aPipeline->SetImageData( myInsideCursorSettings->GetTexture() );
1367   aPipeline->SetAlphaThreshold( myInsideCursorSettings->GetAlphaThreshold() );
1368   aPipeline->SetResolution( myInsideCursorSettings->GetResolution() );
1369   aPipeline->SetMinSize( myInsideCursorSettings->GetMinSize() );
1370   aPipeline->SetMaxSize( myInsideCursorSettings->GetMaxSize() );
1371   aPipeline->SetMagnification( myInsideCursorSettings->GetMagnification() );
1372   aPipeline->SetMagnificationIncrement( myInsideCursorSettings->GetIncrement() );
1373
1374   if( myInsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1375     theActor->GetProperty()->SetRepresentation( VTK_POINTS );
1376   else
1377     theActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1378
1379   aPipeline->Update();
1380
1381   Highlight(isHighlighted());
1382
1383   Update();
1384 }
1385
1386 //----------------------------------------------------------------------------
1387 unsigned long int 
1388 VISU_GaussPtsAct
1389 ::GetMTime()
1390 {
1391   unsigned long int aTime = Superclass::GetMTime();
1392   aTime = std::max(aTime, myGaussPointsPL->GetPointSpriteMapper()->GetMTime() );
1393   return aTime;
1394 }
1395
1396 void VISU_GaussPtsAct::RemoveAllClippingPlanes()
1397 {
1398   myFunction->GetFunction()->RemoveAllItems();
1399   myFunction->Modified();
1400 }
1401
1402 vtkIdType VISU_GaussPtsAct::GetNumberOfClippingPlanes()
1403 {
1404   return myFunction->GetFunction()->GetNumberOfItems();
1405 }
1406
1407 bool VISU_GaussPtsAct::AddClippingPlane(vtkPlane* thePlane)
1408 {
1409   vtkImplicitFunctionCollection* aFunctions = GetClippingPlanes();
1410   aFunctions->InitTraversal();
1411   vtkImplicitFunction* aItem;
1412   while ((aItem = aFunctions->GetNextItem())) {
1413     if (thePlane == aItem)
1414       return false;
1415   }
1416   myFunction->AddFunction(thePlane);
1417   return true;
1418 }
1419
1420 vtkPlane* VISU_GaussPtsAct::GetClippingPlane(vtkIdType theID)
1421 {
1422   vtkPlane* aPlane = NULL;
1423   if ((theID >= 0) && (theID < GetNumberOfClippingPlanes())) {
1424     vtkImplicitFunctionCollection* aFunction = myFunction->GetFunction();
1425     vtkImplicitFunction* aFun = NULL;
1426     aFunction->InitTraversal();
1427     for (vtkIdType i = 0; i <= theID; i++)
1428       aFun = aFunction->GetNextItem();
1429     aPlane = dynamic_cast<vtkPlane*>(aFun);
1430   }
1431   return aPlane;
1432 }
1433
1434 vtkImplicitFunctionCollection* VISU_GaussPtsAct::GetClippingPlanes()
1435 {
1436   return myFunction->GetFunction();
1437 }
1438
1439 //----------------------------------------------------------------------------
1440 vtkDataSet* VISU_GaussPtsAct::GetValLabelsInput()
1441 {
1442   return GetInput();
1443 }
1444
1445
1446
1447 //==============================================================================
1448 vtkStandardNewMacro(VISU_GaussPtsAct1);
1449
1450
1451 //----------------------------------------------------------------------------
1452 VISU_GaussPtsAct1
1453 ::VISU_GaussPtsAct1():
1454   myInsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1455   myOutsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1456   myOutsideCursorSettings(NULL)
1457 {
1458   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::VISU_GaussPtsAct1 - this = "<<this);
1459
1460   myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents);
1461
1462   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
1463
1464   myInsideDeviceActor->SetVisibility(false);
1465   myInsideDeviceActor->SetPickable(false);
1466   myInsideDeviceActor->SetUserMatrix(aMatrix);
1467   myInsideDeviceActor->Delete();
1468
1469   myOutsideDeviceActor->SetVisibility(false);
1470   myOutsideDeviceActor->SetPickable(false);
1471   myOutsideDeviceActor->SetUserMatrix(aMatrix);
1472   myOutsideDeviceActor->Delete();
1473   aMatrix->Delete();
1474 }
1475
1476 VISU_GaussPtsAct1
1477 ::~VISU_GaussPtsAct1()
1478 {
1479   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::~VISU_GaussPtsAct1 - this = "<<this);
1480
1481   SetOutsideCursorSettings(NULL);
1482 }
1483
1484
1485 //----------------------------------------------------------------------------
1486 void
1487 VISU_GaussPtsAct1
1488 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1489 {
1490   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::ShallowCopyPL - this = "<<this);
1491
1492   Superclass::ShallowCopyPL(thePipeLine);
1493
1494   UpdateOutsideCursorSettings();
1495 }
1496
1497
1498 //----------------------------------------------------------------------------
1499 void
1500 VISU_GaussPtsAct1
1501 ::AddToRender(vtkRenderer* theRenderer)
1502 {
1503   Superclass::AddToRender(theRenderer);
1504
1505   //myInsideDeviceActor->AddToRender(theRenderer);
1506   //myOutsideDeviceActor->AddToRender(theRenderer);
1507 }
1508
1509 void 
1510 VISU_GaussPtsAct1
1511 ::RemoveFromRender(vtkRenderer* theRenderer)
1512 {
1513   //myInsideDeviceActor->RemoveFromRender(theRenderer);
1514   //myOutsideDeviceActor->RemoveFromRender(theRenderer);
1515
1516   Superclass::RemoveFromRender(theRenderer);
1517 }
1518
1519 void 
1520 VISU_GaussPtsAct1
1521 ::SetTransform(VTKViewer_Transform* theTransform)
1522 {
1523   Superclass::SetTransform(theTransform);
1524
1525   myInsideDeviceActor->SetTransform(theTransform);
1526   myOutsideDeviceActor->SetTransform(theTransform);
1527 }
1528
1529
1530 int
1531 VISU_GaussPtsAct1
1532 ::RenderOpaqueGeometry(vtkViewport *viewport)
1533 {
1534
1535   Superclass::RenderOpaqueGeometry(viewport);
1536   GetMatrix(myInsideDeviceActor->GetUserMatrix());
1537   GetMatrix(myOutsideDeviceActor->GetUserMatrix());
1538   return 1;
1539 }
1540
1541 int
1542 VISU_GaussPtsAct1
1543 ::RenderTranslucentGeometry(vtkViewport *viewport)
1544
1545   Superclass::RenderTranslucentGeometry(viewport);
1546   GetMatrix(myInsideDeviceActor->GetUserMatrix());
1547   GetMatrix(myOutsideDeviceActor->GetUserMatrix());
1548
1549   return 1;
1550 }
1551
1552 //----------------------------------------------------------------------------
1553 void
1554 VISU_GaussPtsAct1
1555 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1556 {
1557   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetWidgetCtrl - this = "<<this);
1558
1559   if(myWidgetCtrl == theWidgetCtrl){
1560     return;
1561   }
1562
1563   if(myWidgetCtrl){
1564     myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1565     myInsideDeviceActor->SetVisibility(false);
1566
1567     myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);  
1568     myOutsideDeviceActor->SetVisibility(false);
1569   }
1570
1571   Superclass::SetWidgetCtrl(theWidgetCtrl);
1572
1573   if(theWidgetCtrl){
1574     myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1575     myInsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1576
1577     myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());  
1578     myOutsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1579   }
1580 }
1581
1582
1583 //----------------------------------------------------------------------------
1584 void
1585 VISU_GaussPtsAct1
1586 ::SetMapperInput(vtkDataSet* theDataSet) 
1587 {
1588   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetMapperInput - this = "<<this);
1589
1590   Superclass::SetMapperInput(theDataSet);
1591
1592 //   if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1593 //     myInsideDeviceActor->SetPipeLine(aPipeLine);
1594 //     aPipeLine->Delete();
1595 //   }
1596
1597 //   if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1598 //     myOutsideDeviceActor->SetPipeLine(aPipeLine);
1599 //     aPipeLine->Delete();
1600
1601 //     aPipeLine->SetExtractBoundaryCells(true);
1602 //     aPipeLine->SetExtractInside(true);
1603 //   }
1604 }
1605
1606
1607 //----------------------------------------------------------------------------
1608 vtkFloatingPointType
1609 VISU_GaussPtsAct1
1610 ::GetRadius(vtkIdType theObjID,
1611             vtkIdType theVTKID,
1612             vtkDataArray *theScalarArray)
1613 {
1614   VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1615   if(IsSegmentationEnabled()){
1616     if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1617       aPipeLine = myOutsideDeviceActor->GetPipeLine();
1618     else
1619       aPipeLine = myInsideDeviceActor->GetPipeLine();
1620   }
1621   return ::GetRadius(theVTKID,theScalarArray,aPipeLine);
1622 }
1623
1624
1625 //----------------------------------------------------------------------------
1626 vtkFloatingPointType 
1627 VISU_GaussPtsAct1
1628 ::GetMagnification(vtkIdType theObjID)
1629 {
1630   VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1631   if(IsSegmentationEnabled()){
1632     if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1633       aPipeLine = myOutsideDeviceActor->GetPipeLine();
1634     else
1635       aPipeLine = myInsideDeviceActor->GetPipeLine();
1636   }
1637   return aPipeLine->GetMagnification();
1638 }
1639
1640
1641 //----------------------------------------------------------------------------
1642 vtkFloatingPointType 
1643 VISU_GaussPtsAct1
1644 ::GetClamp(vtkIdType theObjID)
1645 {
1646   if(IsSegmentationEnabled()){
1647     if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1648       return ::GetClamp(myOutsideDeviceActor->GetPipeLine());
1649     else
1650       return ::GetClamp(myInsideDeviceActor->GetPipeLine());
1651   }
1652   return Superclass::GetClamp(theObjID);
1653 }
1654
1655
1656 //----------------------------------------------------------------
1657
1658 void 
1659 VISU_GaussPtsAct1::SetPosition(double _arg[3]){
1660   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetPosition - this = "<<this);               
1661   Superclass::SetPosition(_arg);
1662   myUpdatePositionSignal(_arg);
1663 }
1664
1665 void 
1666 VISU_GaussPtsAct1
1667 ::Connect(VISU_GaussPtsAct2* theActor)
1668 {
1669   mySetVisibilitySignal.connect(boost::bind(&VISU_GaussPtsAct2::SetVisibility,theActor,_1));
1670   myUpdatePositionSignal.connect(boost::bind(&VISU_GaussPtsAct2::SetPosition, theActor,_1));
1671 }
1672
1673 void
1674 VISU_GaussPtsAct1
1675 ::SetVisibility(int theMode)
1676 {
1677   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetVisibility - this = "<<this);
1678
1679   Superclass::SetVisibility(theMode);
1680
1681   bool aVisisbility = GetVisibility();
1682   bool anIsSegementation = IsSegmentationEnabled();
1683   myDeviceActor->SetVisibility(aVisisbility/* && !anIsSegementation*/);
1684   myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1685   myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1686
1687   mySetVisibilitySignal(GetVisibility());
1688 }
1689
1690 //----------------------------------------------------------------
1691 void
1692 VISU_GaussPtsAct1
1693 ::UpdateInsideCursorSettings()
1694 {
1695   Superclass::UpdateInsideCursorSettings( myInsideDeviceActor );
1696 }
1697
1698 //----------------------------------------------------------------
1699 void
1700 VISU_GaussPtsAct1
1701 ::SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings)
1702 {
1703   if(myOutsideCursorSettings == theOutsideCursorSettings)
1704     return;
1705
1706   if(myOutsideCursorSettings)
1707     myOutsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1708
1709   myOutsideCursorSettings = theOutsideCursorSettings;
1710
1711   if(theOutsideCursorSettings)
1712   {
1713     theOutsideCursorSettings->AddObserver(VISU::UpdateOutsideSettingsEvent, 
1714                                           myEventCallbackCommand.GetPointer(), 
1715                                           myPriority);
1716     UpdateOutsideCursorSettings();
1717   }
1718 }
1719
1720 void
1721 VISU_GaussPtsAct1
1722 ::UpdateOutsideCursorSettings()
1723 {
1724   if(!myOutsideCursorSettings || myOutsideCursorSettings->GetInitial())
1725     return;
1726
1727   VISU_GaussPointsPL* aPipeline = myOutsideDeviceActor->GetPipeLine();
1728
1729   vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
1730   vtkFloatingPointType aMagnification = aPipeline->GetMagnification();
1731
1732   aPipeline->ShallowCopy(GetGaussPointsPL(), true);
1733
1734   aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1735   aPipeline->SetExtractBoundaryCells(true);
1736   //aPipeline->SetExtractInside(true);
1737   aPipeline->SetMagnification( aMagnification );
1738
1739   aPipeline->SetPrimitiveType( myOutsideCursorSettings->GetPrimitiveType() );
1740
1741   if( myOutsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1742     myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_POINTS );
1743   else
1744     myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1745
1746   aPipeline->SetClamp( myOutsideCursorSettings->GetClamp() );
1747   aPipeline->SetImageData( myOutsideCursorSettings->GetTexture() );
1748   aPipeline->SetAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() );
1749   aPipeline->SetResolution( myOutsideCursorSettings->GetResolution() );
1750   aPipeline->SetSize( myOutsideCursorSettings->GetSize() );
1751   aPipeline->SetMagnification( myOutsideCursorSettings->GetMagnification() );
1752   aPipeline->SetMagnificationIncrement( myOutsideCursorSettings->GetIncrement() );
1753
1754   if( myOutsideCursorSettings->GetUniform() )
1755   {
1756     myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOff();
1757     myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 1 ); // Geometry mode
1758     myOutsideDeviceActor->GetProperty()->SetColor( myOutsideCursorSettings->GetColor() );
1759   }
1760   else
1761   {
1762     myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 2 ); // Outside cursor mode
1763     myOutsideDeviceActor->GetPointSpriteMapper()->SetColorModeToMapScalars();
1764     myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOn();
1765   }
1766
1767   aPipeline->Update();
1768
1769   Highlight(isHighlighted());
1770
1771   Update();
1772 }
1773
1774
1775 //----------------------------------------------------------------
1776 void 
1777 VISU_GaussPtsAct1
1778 ::ProcessEvents(vtkObject* theObject, 
1779                 unsigned long theEvent,
1780                 void* theClientData, 
1781                 void* theCallData)
1782 {
1783   if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
1784     if(VISU_GaussPtsAct1* self = dynamic_cast<VISU_GaussPtsAct1*>(anObject))
1785       if(theEvent == VISU::UpdateOutsideSettingsEvent)
1786         self->UpdateOutsideCursorSettings();
1787
1788   Superclass::ProcessEvents(theObject,theEvent,theClientData,theCallData);
1789 }
1790
1791 void
1792 VISU_GaussPtsAct1
1793 ::OnInteractorEvent(unsigned long theEvent)
1794 {
1795   switch(theEvent){
1796   case vtkCommand::StartInteractionEvent: 
1797     myDeviceActor->SetVisibility(GetVisibility());
1798     myInsideDeviceActor->SetVisibility(false);
1799     myOutsideDeviceActor->SetVisibility(false);
1800     break;
1801   case vtkCommand::EnableEvent: 
1802   case vtkCommand::DisableEvent:
1803   case vtkCommand::EndInteractionEvent: {
1804     bool aVisisbility = GetVisibility();
1805     bool anIsSegementation = IsSegmentationEnabled();
1806     myDeviceActor->SetVisibility(aVisisbility/* && !anIsSegementation*/);
1807     myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1808     myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1809     break;
1810   }
1811   default:
1812     break;
1813   }
1814   
1815   Superclass::OnInteractorEvent(theEvent);
1816 }
1817
1818 //----------------------------------------------------------------------------
1819 unsigned long int
1820 VISU_GaussPtsAct1
1821 ::GetMemorySize()
1822 {
1823   unsigned long int aSize = Superclass::GetMemorySize();
1824   if(IsSegmentationEnabled()){
1825     aSize += myInsideDeviceActor->GetMemorySize();
1826     aSize += myOutsideDeviceActor->GetMemorySize();
1827   }
1828   return aSize;
1829 }
1830
1831
1832
1833 //==============================================================================
1834 vtkStandardNewMacro(VISU_GaussPtsAct2);
1835
1836
1837 //----------------------------------------------------------------------------
1838 VISU_GaussPtsAct2
1839 ::VISU_GaussPtsAct2()
1840 {
1841   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::VISU_GaussPtsAct2 - this = "<<this);
1842   myDeviceActor->SetVisibility(false);
1843 }
1844
1845 VISU_GaussPtsAct2
1846 ::~VISU_GaussPtsAct2()
1847 {
1848   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::~VISU_GaussPtsAct2 - this = "<<this);
1849 }
1850
1851
1852 //----------------------------------------------------------------------------
1853 void
1854 VISU_GaussPtsAct2
1855 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1856 {
1857   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::ShallowCopyPL - this = "<<this);
1858
1859   Superclass::ShallowCopyPL(thePipeLine);
1860 }
1861
1862 //----------------------------------------------------------------------------
1863 void
1864 VISU_GaussPtsAct2::SetPosition(double _arg[3]){
1865   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct2::SetPosition - this = "<<this);       
1866   Superclass::SetPosition(_arg);
1867 }
1868
1869 //----------------------------------------------------------------------------
1870 void
1871 VISU_GaussPtsAct2
1872 ::SetMapperInput(vtkDataSet* theDataSet) 
1873 {
1874   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetMapperInput - this = "<<this);
1875   Superclass::SetMapperInput(theDataSet);
1876 //   if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1877 //     myDeviceActor->SetPipeLine(aPipeLine);
1878 //     myCurrentPL = aPipeLine;
1879 //     aPipeLine->Delete();
1880
1881 //     myMapper->SetInput(myCurrentPL->GetPickableDataSet());
1882 //     SetMapper(myMapper.GetPointer());
1883 //   }
1884 }
1885
1886 //----------------------------------------------------------------------------
1887 void
1888 VISU_GaussPtsAct2
1889 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1890 {
1891   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetWidgetCtrl - this = "<<this);
1892
1893   if(myWidgetCtrl == theWidgetCtrl)
1894     return;
1895
1896   if(myWidgetCtrl){
1897     theWidgetCtrl->RemoveObserver(myEventCallbackCommand.GetPointer());
1898     myDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1899     myDeviceActor->SetVisibility(false);
1900   }
1901
1902   Superclass::SetWidgetCtrl(theWidgetCtrl);
1903
1904   if(theWidgetCtrl){
1905     myDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1906     myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1907   }
1908 }
1909
1910
1911 //----------------------------------------------------------------------------
1912 unsigned long int
1913 VISU_GaussPtsAct2
1914 ::GetMemorySize()
1915 {
1916   if(IsSegmentationEnabled())
1917     return Superclass::GetMemorySize();
1918   return 0;
1919 }
1920
1921
1922 //----------------------------------------------------------------------------
1923 void
1924 VISU_GaussPtsAct2
1925 ::SetVisibility(int theMode)
1926 {
1927   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetVisibility - this = "<<this);
1928
1929   Superclass::SetVisibility(theMode);
1930
1931   myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1932 }
1933
1934 void
1935 VISU_GaussPtsAct2
1936 ::OnInteractorEvent(unsigned long theEvent)
1937 {
1938   switch(theEvent){
1939   case vtkCommand::EnableEvent: 
1940   case vtkCommand::DisableEvent:
1941     myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1942     if(theEvent == vtkCommand::EnableEvent)
1943       Update();
1944     break;
1945   case vtkCommand::EndInteractionEvent:
1946     Update();
1947     break;
1948   default:
1949     break;
1950   }
1951   Superclass::OnInteractorEvent(theEvent);
1952 }