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