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