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