]> SALOME platform Git repositories - modules/visu.git/blob - src/OBJECT/VISU_GaussPtsAct.cxx
Salome HOME
Issue 0020166: EDF 957 VISU : shrink gauss points
[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 ::SetOpacity(vtkFloatingPointType theValue)
527 {
528   GetGaussPointsPL()->SetOpacity(theValue);
529   Superclass::SetOpacity(theValue);
530 }
531
532
533 //----------------------------------------------------------------------------
534 void
535 VISU_GaussPtsAct
536 ::SetFactory(VISU::TActorFactory* theActorFactory)
537
538   using namespace VISU;
539   myGaussPtsActorFactory = dynamic_cast<TGaussPtsActorFactory*>(theActorFactory);
540   myUpdatePrs3dSignal.connect(boost::bind(&TGaussPtsActorFactory::UpdateFromActor,
541                                           myGaussPtsActorFactory,
542                                           _1));
543   Superclass::SetFactory(theActorFactory);
544 }
545
546 VISU::TGaussPtsActorFactory*
547 VISU_GaussPtsAct
548 ::GetGaussPtsFactory()
549 {
550   return myGaussPtsActorFactory;
551 }
552
553
554 //----------------------------------------------------------------------------
555 void
556 VISU_GaussPtsAct
557 ::SetVisibility(int theMode)
558 {
559   Superclass::SetVisibility(theMode);
560   myDeviceActor->SetVisibility(GetVisibility()); // VSV
561   myScalarBarCtrl->SetVisibility(theMode);
562 }
563
564 int
565 VISU_GaussPtsAct
566 ::IsSegmentationEnabled()
567 {
568   return myWidgetCtrl  && myWidgetCtrl->GetEnabled();
569 }
570
571
572 //----------------------------------------------------------------------------
573 void
574 VISU_GaussPtsAct
575 ::SetBarVisibility(bool theMode)
576 {
577   myBarVisibility = theMode;
578   myScalarBarCtrl->SetCtrlVisibility(theMode); 
579   myScalarBarCtrl->SetVisibility(GetVisibility()); 
580 }
581
582 bool
583 VISU_GaussPtsAct
584 ::GetBarVisibility()
585
586   return myBarVisibility;
587 }
588
589 VISU_ScalarBarCtrl* 
590 VISU_GaussPtsAct
591 ::GetScalarBarCtrl()
592 {
593   return myScalarBarCtrl.GetPointer();
594 }
595
596 //----------------------------------------------------------------------------
597 void
598 VISU_GaussPtsAct
599 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
600 {
601   if(theInteractor == myInteractor)
602     return;
603
604   if(myInteractor)
605     myInteractor->RemoveObserver(myEventCallbackCommand.GetPointer());
606   
607   if(theInteractor){
608     theInteractor->AddObserver(vtkCommand::CharEvent, 
609                                myEventCallbackCommand.GetPointer(), 
610                                myPriority);
611     theInteractor->AddObserver(VISU::SetSMDecreaseMagnificationEvent, 
612                                myEventCallbackCommand.GetPointer(), 
613                                myPriority);
614     theInteractor->AddObserver(VISU::SetSMIncreaseMagnificationEvent, 
615                                myEventCallbackCommand.GetPointer(), 
616                                myPriority);
617   }
618   Superclass::SetInteractor(theInteractor);
619
620   Modified();
621 }
622 //-------------------------------------------------------------------------
623 void 
624 VISU_GaussPtsAct
625 ::ProcessEvents(vtkObject* vtkNotUsed(theObject), 
626                 unsigned long theEvent,
627                 void* theClientData, 
628                 void* vtkNotUsed(theCallData))
629 {
630   if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
631     if(VISU_GaussPtsAct* self = dynamic_cast<VISU_GaussPtsAct*>(anObject)) {
632       if(theEvent == VISU::UpdateInsideSettingsEvent)
633         self->UpdateInsideCursorSettings();
634       else
635         self->OnInteractorEvent(theEvent);
636     }
637 }
638
639 //-------------------------------------------------------------------------
640 void
641 VISU_GaussPtsAct
642 ::OnInteractorEvent(unsigned long theEvent)
643 {
644   switch(theEvent){
645   case vtkCommand::CharEvent: {
646     switch(myInteractor->GetKeyCode()) {
647     case 'M' :
648     case 'm' :
649     {
650       if( IsSegmentationEnabled() )
651       {
652         this->ChangeMagnification( myInteractor->GetShiftKey() );
653         return;
654       }
655
656       myChangeMagnification = myInteractor->GetShiftKey();
657       break;
658     }
659     case 'D' :
660     case 'd' :
661     {
662       if( IsSegmentationEnabled() && myWidgetCtrl->IsSphereActive() )
663       {
664         VISU_SphereWidget* aSphereWidget = myWidgetCtrl->GetSphereWidget();
665         aSphereWidget->ChangeRadius( myInteractor->GetShiftKey() );
666         myWidgetCtrl->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
667         myWidgetCtrl->GetInteractor()->Render();
668       }
669       return;
670     }
671     default:
672       return;
673     }
674     myUpdatePrs3dSignal(this);
675     break;
676   }
677   case VISU::SetSMDecreaseMagnificationEvent: 
678   case VISU::SetSMIncreaseMagnificationEvent: 
679     myChangeMagnification = theEvent == VISU::SetSMIncreaseMagnificationEvent;
680     myUpdatePrs3dSignal(this);
681     break;
682   case VISU::UpdatePickingSettingsEvent:
683     UpdatePickingSettings();
684     break;
685   case vtkCommand::EndInteractionEvent:
686   case vtkCommand::EnableEvent:
687   case vtkCommand::DisableEvent: 
688     myCurrentPL->GetMapper()->Update();
689     Highlight(isHighlighted());
690     break;
691   default:
692     break;
693   }
694 }
695
696 //----------------------------------------------------------------------------
697 bool
698 VISU_GaussPtsAct
699 ::IsInfinitive()
700 {
701   if(vtkMapper* aMapper = myDeviceActor->GetMapper()){
702     if(vtkDataSet* aDataSet= aMapper->GetInput()){
703       aDataSet->Update();
704       myIsInfinite = aDataSet->GetNumberOfCells() < 2;
705     }
706   }
707   return myIsInfinite;
708 }
709
710 //----------------------------------------------------------------------------
711 int
712 VISU_GaussPtsAct
713 ::GetPickable()
714 {
715   if(Superclass::GetPickable()){
716     if(vtkMapper* aMapper = GetMapper()){
717       if(vtkDataSet* aDataSet= aMapper->GetInput()){
718         aDataSet->Update();
719         return aDataSet->GetNumberOfCells() > 0;
720       }
721     }
722   }
723
724   return false;
725 }
726
727 //----------------------------------------------------------------------------
728 bool
729 VISU_GaussPtsAct
730 ::PreHighlight(vtkInteractorStyle* theInteractorStyle, 
731                SVTK_SelectionEvent* theSelectionEvent,
732                bool theIsHighlight)
733 {
734   if ( !GetPickable() )
735     return false;
736
737   myPreHighlightActor->SetVisibility(false);
738   myCursorPyramid->SetVisibility(false);  
739
740 /*  if (!myBarVisibility)
741     return false;*/
742
743
744   if(!theIsHighlight)
745     myLastPreHighlightObjID = -1;
746
747   Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
748
749   if(aSelectionMode == ActorSelection || !theIsHighlight)
750     return Superclass::PreHighlight(theInteractorStyle,
751                                     theSelectionEvent,
752                                     theIsHighlight);  
753   
754   bool anIsChanged = (mySelectionMode != aSelectionMode);
755   bool anIsPreselected = myIsPreselected;
756   myIsPreselected = false;
757
758   VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
759   
760   if(aSelectionMode == GaussPointSelection && theIsHighlight){
761     myPointPicker->Pick(theSelectionEvent->myX, 
762                         theSelectionEvent->myY, 
763                         0.0, 
764                         theInteractorStyle->GetCurrentRenderer());
765     
766     if(myPointPicker->GetActor() != this)
767       return (anIsPreselected != myIsPreselected);
768     
769     vtkIdType aVtkId = myPointPicker->GetPointId();
770     
771     if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){
772       vtkIdType anObjId = GetNodeObjId( aVtkId );
773       myIsPreselected = (anObjId >= 0);
774       if(myIsPreselected){
775         anIsChanged = (myLastPreHighlightObjID != anObjId);
776         if(anIsChanged){
777           vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);          
778           //Take into account translation
779           vtkFloatingPointType aLocalNodeCoord[3];
780           this->Transform->Push();
781           this->Transform->PostMultiply();
782           this->Transform->Identity();
783           
784           this->Transform->Translate(this->Position[0],
785                                      this->Position[1],
786                                      this->Position[2]);
787           double aPosition[3];
788           this->Transform->GetPosition(aPosition);
789
790           aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0]; 
791           aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
792           aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
793
794           vtkDataSet* aDataSet = GetInput();
795           vtkPointData* aPointData = aDataSet->GetPointData();
796           if(vtkDataArray *aScalarArray = aPointData->GetScalars()){
797             vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight();
798             aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
799             //vtkFloatingPointType aColor[3] = myPreHighlightActor->GetProperty()->GetColor();
800             vtkFloatingPointType aColor[3];
801             theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor );
802             aColor[0] = 1. - aColor[0];
803             aColor[1] = 1. - aColor[1];
804             aColor[2] = 1. - aColor[2];
805
806             myCursorPyramid->Init(aPyramidHeight,
807                                   aPickingSettings->GetCursorSize(),
808                                   GetRadius(anObjId,aVtkId,aScalarArray),
809                                   GetMagnification(anObjId),
810                                   GetClamp(anObjId),
811                                   aNodeCoord,
812                                   aColor);
813           }
814           this->Transform->Pop();
815           myLastPreHighlightObjID = anObjId;
816         }
817         myCursorPyramid->SetVisibility(true);
818       }
819     }
820   }
821   
822   mySelectionMode = aSelectionMode;
823   anIsChanged |= (anIsPreselected != myIsPreselected);
824
825   return anIsChanged;
826 }
827
828
829 //----------------------------------------------------------------------------
830 inline
831 void
832 ChangeZoom(VISU_PickingSettings *thePickingSettings,
833            vtkRenderer* theRenderer,
834            vtkIdType theInitialHasIndex,
835            vtkIdType theCurrentHasIndex)
836 {
837   if( (theInitialHasIndex + theCurrentHasIndex == 1) && thePickingSettings){
838     vtkCamera *aCamera = theRenderer->GetActiveCamera();
839
840     vtkFloatingPointType aZoomFactor = thePickingSettings->GetZoomFactor();
841     double aScale = aCamera->GetParallelScale();
842     if ( !theInitialHasIndex && theCurrentHasIndex ) {
843       aCamera->SetParallelScale( aScale/aZoomFactor );
844     }
845     else {
846       aCamera->SetParallelScale( aScale*aZoomFactor );
847     }
848   }
849   
850 }
851
852 bool
853 VISU_GaussPtsAct
854 ::Highlight(vtkInteractorStyle* theInteractorStyle, 
855             SVTK_SelectionEvent* theSelectionEvent,
856             bool theIsHighlight)
857
858   if ( !GetPickable() )
859     return false;
860
861   //  int anInitialHasIndex = myIsSubElementsHighlighted && mySelectionMode == GaussPointSelection;
862   Handle(SALOME_InteractiveObject) anIO = getIO();
863   //  myIsSubElementsHighlighted = false;
864
865   Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
866
867   if(!theIsHighlight && aSelectionMode == GaussPointSelection){
868     mySelector->RemoveIObject(anIO);
869
870     /*    ChangeZoom(myPickingSettings,
871                theInteractorStyle,
872                anInitialHasIndex,
873                false,
874                anIO);*/
875
876     return true;
877   }
878   
879 /*  if (!myBarVisibility)
880     return false;*/
881
882
883   if(aSelectionMode == ActorSelection)
884     return Superclass::Highlight(theInteractorStyle,
885                                  theSelectionEvent,
886                                  theIsHighlight);
887
888   if(aSelectionMode == GaussPointSelection && !theSelectionEvent->myIsRectangle){
889
890     vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
891     myPointPicker->Pick(theSelectionEvent->myX, 
892                         theSelectionEvent->myY,
893                         0.0, 
894                         aRenderer);
895
896     if(myPointPicker->GetActor() != this) {
897       mySelector->ClearIObjects();
898
899       /*      ChangeZoom(myPickingSettings,
900                  theInteractorStyle,
901                  anInitialHasIndex,
902                  false,
903                  anIO);*/
904
905       return true;
906     }
907
908     vtkIdType aVtkId = myPointPicker->GetPointId();
909     if( aVtkId >= 0  && mySelector->IsValid( this, aVtkId, true ) && hasIO()) {
910       vtkIdType anObjId = GetNodeObjId( aVtkId );
911       if(anObjId >= 0){
912         //      myIsHighlighted = true;
913         // Update the Selector
914         if(mySelector->IsSelected(myIO))
915           mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
916         else{
917           if(!theSelectionEvent->myIsShift){
918             mySelector->ClearIObjects();
919           }
920           mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
921           mySelector->AddIObject(this);
922         }
923         /*
924         vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
925         //
926         // FlyTo
927         vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor();
928         vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
929         int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
930         
931         anInteractor->SetDolly(0.);
932         anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber());
933         anInteractor->FlyTo(aRenderer,aNodeCoord);
934         aRenderer->ResetCameraClippingRange();
935         anInteractor->SetDolly(aDollyWas);
936         anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
937         
938         anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);*/
939
940         mySelectionMode = aSelectionMode;
941
942         /*      ChangeZoom(myPickingSettings,
943                    theInteractorStyle,
944                    anInitialHasIndex,
945                    true,
946                    anIO);*/
947
948         return true;
949       }// if( anObjId >= 0 ) {
950     }//if( aVtkId >= 0  && mySelector->IsValid( this, aVtkId, true ) && hasIO()) 
951   }//if(!theSelectionEvent->myIsRectangle){
952
953   /* ChangeZoom(myPickingSettings,
954              theInteractorStyle,
955              anInitialHasIndex,
956              false,
957              anIO);*/
958   
959   return false;
960 }
961
962
963
964 void VISU_GaussPtsAct::SetPosition(double _arg[3]){
965   Superclass::SetPosition(_arg);
966   Highlight(isHighlighted());
967 }
968
969 //==================================================================
970 // function : Highlight
971 // purpose  :
972 //==================================================================
973 void
974 VISU_GaussPtsAct
975 ::Highlight(bool theIsHighlight)
976 {
977   if(!mySelector.GetPointer())
978     return;
979
980   VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
981
982   Selection_Mode aSelectionMode = mySelector->SelectionMode();
983   
984   bool anInitialHasIndex = isSubElementsHighlighted() && mySelectionMode == GaussPointSelection;
985   
986   TColStd_IndexedMapOfInteger aMapIndex;
987   mySelector->GetIndex( getIO(), aMapIndex );
988   bool aCurrentHasIndex = aMapIndex.Extent() == 1;
989   bool anIsVisible = GetVisibility() && aCurrentHasIndex && theIsHighlight;
990   bool aShowTextActor = aPickingSettings->GetInfoWindowEnabled();
991   bool aShowCellActor = aPickingSettings->GetDisplayParentMesh();
992
993   myOutlineActor->SetVisibility(false);
994   myCursorPyramid->SetVisibility(false);
995   myTextActor->SetVisibility(anIsVisible && aShowTextActor);
996   myCellActor->SetVisibility(anIsVisible && aShowCellActor);
997   GetScalarBarCtrl()->SetIsMarked(anIsVisible);
998   myCursorPyramidSelected->SetVisibility(anIsVisible);
999   //GetScalarBarCtrl()->Update();
1000
1001   myIsSubElementsHighlighted = aCurrentHasIndex;
1002
1003   // Zoom if necessary
1004   if( GetVisibility() && aPickingSettings->GetCameraMovementEnabled() )
1005   {
1006     ChangeZoom(aPickingSettings,
1007                GetRenderer(),
1008                anInitialHasIndex,
1009                aCurrentHasIndex);
1010   }
1011
1012   if( aSelectionMode == ActorSelection ) {
1013     Superclass::Highlight(theIsHighlight);
1014     return;
1015   }
1016
1017   if(!theIsHighlight)
1018     return;
1019
1020   if( aSelectionMode != GaussPointSelection )
1021     return;
1022
1023   if ( !aCurrentHasIndex || !myBarVisibility )
1024     return;
1025
1026   //  myTextActor->SetVisibility(anIsVisible);
1027   //  myCellActor->SetVisibility(anIsVisible && myPickingSettings->GetDisplayParentMesh());
1028   //  GetScalarBarCtrl()->SetIsMarked(anIsVisible);
1029   //  myCursorPyramidSelected->SetVisibility(anIsVisible);
1030 //GetScalarBarCtrl()->Update();
1031
1032 //  myIsHighlighted = aCurrentHasIndex;
1033
1034   // Zoom if necessary
1035 //   ChangeZoom(myPickingSettings,
1036 //           GetRenderer(),
1037 //           anInitialHasIndex,
1038 //           aCurrentHasIndex);
1039
1040   //  TColStd_IndexedMapOfInteger aMapIndex;
1041   mySelector->GetIndex( getIO(), aMapIndex );
1042   if(aMapIndex.Extent() != 1 || !myBarVisibility) {
1043     return;
1044   }
1045
1046   vtkRenderer *aRenderer = GetRenderer();
1047   vtkCamera* aCamera = aRenderer->GetActiveCamera();
1048
1049   int anObjId = aMapIndex(1);
1050   vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
1051   if ( !aNodeCoord )
1052     return;
1053   //Take into account translation
1054   vtkFloatingPointType aLocalNodeCoord[3];
1055   this->Transform->Push();
1056   this->Transform->PostMultiply();
1057   this->Transform->Identity();
1058   this->Transform->Translate(this->Position[0],
1059                              this->Position[1],
1060                              this->Position[2]);
1061   double aPosition[3];
1062   this->Transform->GetPosition(aPosition);
1063   aLocalNodeCoord[0] = aNodeCoord[0] + aPosition[0]; 
1064   aLocalNodeCoord[1] = aNodeCoord[1] + aPosition[1];
1065   aLocalNodeCoord[2] = aNodeCoord[2] + aPosition[2];
1066   this->Transform->Pop();
1067
1068   vtkFloatingPointType aFocalPnt[3];
1069   aCamera->GetFocalPoint(aFocalPnt);
1070
1071   if ( CheckIsSameVector(aLocalNodeCoord, aFocalPnt, 3 ) ) 
1072     return;
1073
1074   // FlyTo
1075   if( anIsVisible && aPickingSettings->GetCameraMovementEnabled() )
1076   {
1077     vtkRenderWindowInteractor* anInteractor = myInteractor;
1078     vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
1079     int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
1080   
1081     anInteractor->SetDolly(0.0);
1082     anInteractor->SetNumberOfFlyFrames(aPickingSettings->GetStepNumber());
1083     anInteractor->FlyTo(aRenderer, aNodeCoord);
1084     aRenderer->ResetCameraClippingRange();
1085     anInteractor->SetDolly(aDollyWas);
1086     anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
1087     anInteractor->InvokeEvent(SVTK::ChangeRotationPoint, aNodeCoord);
1088   }
1089   //
1090   std::ostringstream aStr;
1091   //  int anObjId = aMapIndex(1);
1092   aStr<<"Global ID: "<<anObjId;
1093   //
1094   vtkIdType aVtkId = GetNodeVTKID(anObjId);
1095   if(aVtkId >= 0){
1096     vtkFloatingPointType aWorldCoord[4] = {aLocalNodeCoord[0], aLocalNodeCoord[1], aLocalNodeCoord[2], 1.};
1097     //
1098     vtkDataSet* aDataSet = GetInput();
1099     vtkPointData* aDataSetAttributes = aDataSet->GetPointData();
1100     //
1101     if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){
1102       vtkFloatingPointType aVal = aScalarArray->GetTuple1(aVtkId);
1103       //
1104       //      GetScalarBarCtrl()->SetIsMarked(true);
1105       GetScalarBarCtrl()->SetMarkValue(aVal);
1106       GetScalarBarCtrl()->Update();
1107       //
1108       vtkFloatingPointType aPyramidHeight = aPickingSettings->GetPyramidHeight();
1109       aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
1110       myCursorPyramidSelected->Init(aPyramidHeight,
1111                                     aPickingSettings->GetCursorSize(),
1112                                     GetRadius(anObjId,aVtkId,aScalarArray),
1113                                     GetMagnification(anObjId),
1114                                     GetClamp(anObjId),
1115                                     aLocalNodeCoord,
1116                                     myHighlightActor->GetProperty()->GetColor());
1117       myCursorPyramidSelected->SetVisibility(anIsVisible && theIsHighlight);
1118       //
1119       const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = 
1120         myGaussPointsPL->GetGaussPtsIDMapper();
1121       VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
1122       
1123       VISU::TGaussPointID aGaussPointID = myGaussPointsPL->GetObjID(anObjId);
1124       VISU::TCellID aCellID = aGaussPointID.first;
1125       VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
1126       aStr<<"\nParentCellID: "<<aCellID;
1127       std::string aParentName = aParent->GetElemName(aCellID);
1128       if(aParentName != "") {
1129         aStr<<"\nParentCellName: '"<<aParentName<<"'";
1130       }
1131       aStr<<"\nLocalPntID: "<<aLocalPntID;
1132       aStr<<"\nScalar: "<<aVal;
1133     }
1134
1135     if(vtkDataArray* aFieldArray = aDataSetAttributes->GetArray("VISU_FIELD")){
1136       int aNbComp = aFieldArray->GetNumberOfComponents();
1137       std::vector<vtkFloatingPointType> aTuple(aNbComp);
1138       aFieldArray->GetTuple(aVtkId, &aTuple[0]);
1139       
1140       aStr<<"\nData: {";
1141       int anId = 0;
1142       while(anId < aNbComp){
1143         vtkFloatingPointType aComp = aTuple[anId++];
1144         aStr<<aComp;
1145         if(anId < aNbComp)
1146           aStr<<"; ";
1147       }
1148       aStr<<"}";
1149     }
1150     //
1151     // myTextActor
1152     std::string aString = aStr.str();
1153     myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
1154     myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
1155     myTextActor->SetWorldPoint(aWorldCoord);
1156     myTextActor->SetText(aString.c_str());
1157     myTextActor->SetVisibility(anIsVisible && theIsHighlight && aShowTextActor);
1158     //
1159     // myCellActor
1160     const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = myGaussPointsPL->GetGaussPtsIDMapper();
1161     VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
1162     //
1163     myCellSource->Reset();
1164     myCellSource->Modified(); // a VTK bug
1165     vtkUnstructuredGrid* aCellDataSet = aParent->GetUnstructuredGridOutput();
1166     
1167     // get parent cell and insert it to myCellSource
1168     VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId);
1169     vtkIdType aCellID = aGaussPointID.first;
1170     vtkCell* aCell = aParent->GetElemCell(aCellID);
1171     myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
1172     
1173     if (myGaussPointsPL->GetIsDeformed()) {
1174       // find neighbour cells ids
1175       vtkIdList* aNeighbourCells = vtkIdList::New();
1176       aNeighbourCells->Allocate(VTK_CELL_SIZE);
1177       
1178       vtkIdList* aCellPoints = aCell->GetPointIds();
1179       
1180       vtkIdList *aPointCells = vtkIdList::New();
1181       aPointCells->Allocate(VTK_CELL_SIZE);
1182       
1183       vtkIdType aNbPoints = aCellPoints->GetNumberOfIds();
1184       for (vtkIdType i = 0; i < aNbPoints; i++) {
1185         aCellDataSet->GetPointCells(aCellPoints->GetId(i), aPointCells);
1186
1187         // add cell ids
1188         vtkIdType aNbCells = aPointCells->GetNumberOfIds();
1189         for (vtkIdType j = 0; j < aNbCells; j++)
1190           aNeighbourCells->InsertUniqueId(aPointCells->GetId(j));
1191       }
1192
1193       aPointCells->Delete();
1194
1195       // get vector data
1196       vtkDataArray* anInputVectors = aDataSetAttributes->GetVectors();
1197       if (!anInputVectors)
1198         return;
1199       
1200       // insert neighbour cells to the special dataset
1201       vtkUnstructuredGrid *aCellsToWarp = vtkUnstructuredGrid::New();
1202       aCellsToWarp->SetPoints(aCellDataSet->GetPoints());
1203
1204       vtkIdType aNbNeighbourCells = aNeighbourCells->GetNumberOfIds();
1205
1206       vtkDataArray *aVectorsToSet = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
1207       aVectorsToSet->SetNumberOfComponents(3);
1208       aVectorsToSet->SetNumberOfTuples(aNbNeighbourCells);
1209
1210       vtkDataArray *aCellVectors = vtkDataArray::CreateDataArray(anInputVectors->GetDataType());
1211       aCellVectors->SetNumberOfComponents(3);
1212       
1213       int aNbComp = anInputVectors->GetNumberOfComponents();
1214       std::vector<vtkFloatingPointType> aTuple(aNbComp);
1215       
1216       for (vtkIdType i = 0; i < aNbNeighbourCells; i++) {
1217         vtkIdType aVTKCellId = aNeighbourCells->GetId(i);
1218         vtkIdType anObjCellId = aParent->GetElemObjID(aVTKCellId);
1219         
1220         vtkCell* aCurCell = aParent->GetElemCell(anObjCellId);
1221         
1222         vtkIdType aNewCellId = aCellsToWarp->InsertNextCell(aCurCell->GetCellType(), aCurCell->GetPointIds());
1223         
1224         // get gauss points corresponding to the current cell
1225         vtkIdType aPointVtkId = -1;
1226         vtkIdType aLocalPntId = 0;
1227         aPointVtkId = aGaussPtsIDMapper->GetVTKID(VISU::TGaussPointID(anObjCellId, aLocalPntId));
1228         
1229         if (aPointVtkId >= 0) {
1230           // Compute average vector
1231           aCellVectors->Reset();
1232           while (aPointVtkId >= 0) {
1233             anInputVectors->GetTuple(aPointVtkId, &aTuple[0]);
1234
1235             if (aNbComp >= 3)
1236               aCellVectors->InsertNextTuple3(aTuple[0], aTuple[1], aTuple[2]);
1237             else if (aNbComp == 2)
1238               aCellVectors->InsertNextTuple3(aTuple[0], aTuple[1], 0);
1239             else if (aNbComp == 1)
1240               aCellVectors->InsertNextTuple3(aTuple[0], 0, 0);
1241
1242             aPointVtkId = aGaussPtsIDMapper->GetVTKID(VISU::TGaussPointID(anObjCellId, ++aLocalPntId));
1243           }
1244
1245           double aXCoord = 0, anYCoord = 0, aZCoord = 0;
1246
1247           vtkIdType aNbVectors = aCellVectors->GetNumberOfTuples();
1248           
1249           for (vtkIdType aVecId = 0; aVecId < aNbVectors; aVecId++) {
1250             aXCoord  += aCellVectors->GetComponent(aVecId, 0);
1251             anYCoord += aCellVectors->GetComponent(aVecId, 1);
1252             aZCoord  += aCellVectors->GetComponent(aVecId, 2);
1253           }
1254
1255           aXCoord = aXCoord / aNbVectors;
1256           anYCoord = anYCoord / aNbVectors;
1257           aZCoord = aZCoord / aNbVectors;
1258           
1259           // set vector data for the cell
1260           aVectorsToSet->SetTuple3(aNewCellId, aXCoord, anYCoord, aZCoord);
1261         }
1262         else
1263           aVectorsToSet->SetTuple3(aNewCellId, 0, 0, 0);
1264       }
1265       
1266       aCellsToWarp->GetCellData()->SetVectors(aVectorsToSet);
1267       
1268       aVectorsToSet->Delete();
1269       aCellVectors->Delete();
1270       aNeighbourCells->Delete();
1271       
1272       // warp
1273       myWarpVector->SetScaleFactor(myGaussPointsPL->GetScale());
1274       
1275       myCellDataToPointData->SetInput(aCellsToWarp);
1276       myCellDataToPointData->PassCellDataOn();
1277       aCellsToWarp->Delete();
1278              
1279       myWarpVector->SetInput(myCellDataToPointData->GetUnstructuredGridOutput());
1280       vtkUnstructuredGrid* aWarpedDataSet = myWarpVector->GetUnstructuredGridOutput();
1281       aWarpedDataSet->Update();
1282       myCellSource->SetPoints(aWarpedDataSet->GetPoints());
1283     }
1284     else
1285       myCellSource->SetPoints(aCellDataSet->GetPoints());
1286     
1287     myCellActor->SetVisibility(anIsVisible && theIsHighlight && aShowCellActor);
1288   }
1289 }
1290
1291 void
1292 VISU_GaussPtsAct
1293 ::UpdatePickingSettings()
1294 {
1295   //printf( "VISU_GaussPtsAct::UpdatePickingSettings()\n" );
1296   VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::Get();
1297   if(!aPickingSettings)
1298     return;
1299
1300   myTextActor->SetModePosition(aPickingSettings->GetInfoWindowPosition());
1301   myTextActor->SetTransparency(aPickingSettings->GetInfoWindowTransparency());
1302
1303   vtkFloatingPointType aHeight = myGaussPointsPL->GetMaxPointSize()*aPickingSettings->GetPyramidHeight();
1304   vtkFloatingPointType aCursorSize = aPickingSettings->GetCursorSize();
1305   myCursorPyramid->SetPreferences(aHeight,aCursorSize);
1306   myCursorPyramidSelected->SetPreferences(aHeight,aCursorSize);
1307
1308   myHighlightActor->GetProperty()->SetColor( aPickingSettings->GetColor() );
1309   myPointPicker->SetTolerance( aPickingSettings->GetPointTolerance() );
1310
1311   Highlight(isHighlighted());
1312
1313   Update();
1314 }
1315
1316 //----------------------------------------------------------------
1317 void
1318 VISU_GaussPtsAct
1319 ::SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings)
1320 {
1321   if(myInsideCursorSettings == theInsideCursorSettings)
1322     return;
1323
1324   if(myInsideCursorSettings)
1325     myInsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1326
1327   myInsideCursorSettings = theInsideCursorSettings;
1328
1329   if(theInsideCursorSettings){
1330     theInsideCursorSettings->AddObserver(VISU::UpdateInsideSettingsEvent, 
1331                                          myEventCallbackCommand.GetPointer(), 
1332                                          myPriority);
1333     UpdateInsideCursorSettings();
1334   }
1335 }
1336
1337 void
1338 VISU_GaussPtsAct
1339 ::UpdateInsideCursorSettings()
1340 {
1341   UpdateInsideCursorSettings( myDeviceActor );
1342 }
1343
1344 void
1345 VISU_GaussPtsAct
1346 ::UpdateInsideCursorSettings( PDeviceActor theActor )
1347 {
1348   if(!myInsideCursorSettings || myInsideCursorSettings->GetInitial())
1349     return;
1350
1351   VISU_GaussPointsPL* aPipeline = theActor->GetPipeLine();
1352
1353   vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
1354
1355   aPipeline->ShallowCopy(GetGaussPointsPL(), true);
1356
1357   aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1358
1359   aPipeline->SetPrimitiveType( myInsideCursorSettings->GetPrimitiveType() );
1360   aPipeline->SetClamp( myInsideCursorSettings->GetClamp() );
1361   aPipeline->SetImageData( myInsideCursorSettings->GetTexture() );
1362   aPipeline->SetAlphaThreshold( myInsideCursorSettings->GetAlphaThreshold() );
1363   aPipeline->SetResolution( myInsideCursorSettings->GetResolution() );
1364   aPipeline->SetMinSize( myInsideCursorSettings->GetMinSize() );
1365   aPipeline->SetMaxSize( myInsideCursorSettings->GetMaxSize() );
1366   aPipeline->SetMagnification( myInsideCursorSettings->GetMagnification() );
1367   aPipeline->SetMagnificationIncrement( myInsideCursorSettings->GetIncrement() );
1368
1369   if( myInsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1370     theActor->GetProperty()->SetRepresentation( VTK_POINTS );
1371   else
1372     theActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1373
1374   aPipeline->Update();
1375
1376   Highlight(isHighlighted());
1377
1378   Update();
1379 }
1380
1381 //----------------------------------------------------------------------------
1382 unsigned long int 
1383 VISU_GaussPtsAct
1384 ::GetMTime()
1385 {
1386   unsigned long int aTime = Superclass::GetMTime();
1387   aTime = std::max(aTime, myGaussPointsPL->GetPointSpriteMapper()->GetMTime() );
1388   return aTime;
1389 }
1390
1391 void VISU_GaussPtsAct::RemoveAllClippingPlanes()
1392 {
1393   myFunction->GetFunction()->RemoveAllItems();
1394   myFunction->Modified();
1395 }
1396
1397 vtkIdType VISU_GaussPtsAct::GetNumberOfClippingPlanes()
1398 {
1399   return myFunction->GetFunction()->GetNumberOfItems();
1400 }
1401
1402 bool VISU_GaussPtsAct::AddClippingPlane(vtkPlane* thePlane)
1403 {
1404   vtkImplicitFunctionCollection* aFunctions = GetClippingPlanes();
1405   aFunctions->InitTraversal();
1406   vtkImplicitFunction* aItem;
1407   while ((aItem = aFunctions->GetNextItem())) {
1408     if (thePlane == aItem)
1409       return false;
1410   }
1411   myFunction->AddFunction(thePlane);
1412   return true;
1413 }
1414
1415 vtkPlane* VISU_GaussPtsAct::GetClippingPlane(vtkIdType theID)
1416 {
1417   vtkPlane* aPlane = NULL;
1418   if ((theID >= 0) && (theID < GetNumberOfClippingPlanes())) {
1419     vtkImplicitFunctionCollection* aFunction = myFunction->GetFunction();
1420     vtkImplicitFunction* aFun = NULL;
1421     aFunction->InitTraversal();
1422     for (vtkIdType i = 0; i <= theID; i++)
1423       aFun = aFunction->GetNextItem();
1424     aPlane = dynamic_cast<vtkPlane*>(aFun);
1425   }
1426   return aPlane;
1427 }
1428
1429 vtkImplicitFunctionCollection* VISU_GaussPtsAct::GetClippingPlanes()
1430 {
1431   return myFunction->GetFunction();
1432 }
1433
1434
1435
1436 //==============================================================================
1437 vtkStandardNewMacro(VISU_GaussPtsAct1);
1438
1439
1440 //----------------------------------------------------------------------------
1441 VISU_GaussPtsAct1
1442 ::VISU_GaussPtsAct1():
1443   myInsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1444   myOutsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1445   myOutsideCursorSettings(NULL)
1446 {
1447   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::VISU_GaussPtsAct1 - this = "<<this);
1448
1449   myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents);
1450
1451   vtkMatrix4x4 *aMatrix = vtkMatrix4x4::New();
1452
1453   myInsideDeviceActor->SetVisibility(false);
1454   myInsideDeviceActor->SetPickable(false);
1455   myInsideDeviceActor->SetUserMatrix(aMatrix);
1456   myInsideDeviceActor->Delete();
1457
1458   myOutsideDeviceActor->SetVisibility(false);
1459   myOutsideDeviceActor->SetPickable(false);
1460   myOutsideDeviceActor->SetUserMatrix(aMatrix);
1461   myOutsideDeviceActor->Delete();
1462   aMatrix->Delete();
1463 }
1464
1465 VISU_GaussPtsAct1
1466 ::~VISU_GaussPtsAct1()
1467 {
1468   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::~VISU_GaussPtsAct1 - this = "<<this);
1469
1470   SetOutsideCursorSettings(NULL);
1471 }
1472
1473
1474 //----------------------------------------------------------------------------
1475 void
1476 VISU_GaussPtsAct1
1477 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1478 {
1479   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::ShallowCopyPL - this = "<<this);
1480
1481   Superclass::ShallowCopyPL(thePipeLine);
1482
1483   UpdateOutsideCursorSettings();
1484 }
1485
1486
1487 //----------------------------------------------------------------------------
1488 void
1489 VISU_GaussPtsAct1
1490 ::AddToRender(vtkRenderer* theRenderer)
1491 {
1492   Superclass::AddToRender(theRenderer);
1493
1494   //myInsideDeviceActor->AddToRender(theRenderer);
1495   //myOutsideDeviceActor->AddToRender(theRenderer);
1496 }
1497
1498 void 
1499 VISU_GaussPtsAct1
1500 ::RemoveFromRender(vtkRenderer* theRenderer)
1501 {
1502   //myInsideDeviceActor->RemoveFromRender(theRenderer);
1503   //myOutsideDeviceActor->RemoveFromRender(theRenderer);
1504
1505   Superclass::RemoveFromRender(theRenderer);
1506 }
1507
1508 void 
1509 VISU_GaussPtsAct1
1510 ::SetTransform(VTKViewer_Transform* theTransform)
1511 {
1512   Superclass::SetTransform(theTransform);
1513
1514   myInsideDeviceActor->SetTransform(theTransform);
1515   myOutsideDeviceActor->SetTransform(theTransform);
1516 }
1517
1518
1519 int
1520 VISU_GaussPtsAct1
1521 ::RenderOpaqueGeometry(vtkViewport *viewport)
1522 {
1523
1524   Superclass::RenderOpaqueGeometry(viewport);
1525   GetMatrix(myInsideDeviceActor->GetUserMatrix());
1526   GetMatrix(myOutsideDeviceActor->GetUserMatrix());
1527   return 1;
1528 }
1529
1530 int
1531 VISU_GaussPtsAct1
1532 ::RenderTranslucentGeometry(vtkViewport *viewport)
1533
1534   Superclass::RenderTranslucentGeometry(viewport);
1535   GetMatrix(myInsideDeviceActor->GetUserMatrix());
1536   GetMatrix(myOutsideDeviceActor->GetUserMatrix());
1537
1538   return 1;
1539 }
1540
1541 //----------------------------------------------------------------------------
1542 void
1543 VISU_GaussPtsAct1
1544 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1545 {
1546   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetWidgetCtrl - this = "<<this);
1547
1548   if(myWidgetCtrl == theWidgetCtrl){
1549     return;
1550   }
1551
1552   if(myWidgetCtrl){
1553     myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1554     myInsideDeviceActor->SetVisibility(false);
1555
1556     myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);  
1557     myOutsideDeviceActor->SetVisibility(false);
1558   }
1559
1560   Superclass::SetWidgetCtrl(theWidgetCtrl);
1561
1562   if(theWidgetCtrl){
1563     myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1564     myInsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1565
1566     myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());  
1567     myOutsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1568   }
1569 }
1570
1571
1572 //----------------------------------------------------------------------------
1573 void
1574 VISU_GaussPtsAct1
1575 ::SetMapperInput(vtkDataSet* theDataSet) 
1576 {
1577   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetMapperInput - this = "<<this);
1578
1579   Superclass::SetMapperInput(theDataSet);
1580
1581 //   if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1582 //     myInsideDeviceActor->SetPipeLine(aPipeLine);
1583 //     aPipeLine->Delete();
1584 //   }
1585
1586 //   if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1587 //     myOutsideDeviceActor->SetPipeLine(aPipeLine);
1588 //     aPipeLine->Delete();
1589
1590 //     aPipeLine->SetExtractBoundaryCells(true);
1591 //     aPipeLine->SetExtractInside(true);
1592 //   }
1593 }
1594
1595
1596 //----------------------------------------------------------------------------
1597 vtkFloatingPointType
1598 VISU_GaussPtsAct1
1599 ::GetRadius(vtkIdType theObjID,
1600             vtkIdType theVTKID,
1601             vtkDataArray *theScalarArray)
1602 {
1603   VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1604   if(IsSegmentationEnabled()){
1605     if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1606       aPipeLine = myOutsideDeviceActor->GetPipeLine();
1607     else
1608       aPipeLine = myInsideDeviceActor->GetPipeLine();
1609   }
1610   return ::GetRadius(theVTKID,theScalarArray,aPipeLine);
1611 }
1612
1613
1614 //----------------------------------------------------------------------------
1615 vtkFloatingPointType 
1616 VISU_GaussPtsAct1
1617 ::GetMagnification(vtkIdType theObjID)
1618 {
1619   VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1620   if(IsSegmentationEnabled()){
1621     if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1622       aPipeLine = myOutsideDeviceActor->GetPipeLine();
1623     else
1624       aPipeLine = myInsideDeviceActor->GetPipeLine();
1625   }
1626   return aPipeLine->GetMagnification();
1627 }
1628
1629
1630 //----------------------------------------------------------------------------
1631 vtkFloatingPointType 
1632 VISU_GaussPtsAct1
1633 ::GetClamp(vtkIdType theObjID)
1634 {
1635   if(IsSegmentationEnabled()){
1636     if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1637       return ::GetClamp(myOutsideDeviceActor->GetPipeLine());
1638     else
1639       return ::GetClamp(myInsideDeviceActor->GetPipeLine());
1640   }
1641   return Superclass::GetClamp(theObjID);
1642 }
1643
1644
1645 //----------------------------------------------------------------
1646
1647 void 
1648 VISU_GaussPtsAct1::SetPosition(double _arg[3]){
1649   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetPosition - this = "<<this);               
1650   Superclass::SetPosition(_arg);
1651   myUpdatePositionSignal(_arg);
1652 }
1653
1654 void 
1655 VISU_GaussPtsAct1
1656 ::Connect(VISU_GaussPtsAct2* theActor)
1657 {
1658   mySetVisibilitySignal.connect(boost::bind(&VISU_GaussPtsAct2::SetVisibility,theActor,_1));
1659   myUpdatePositionSignal.connect(boost::bind(&VISU_GaussPtsAct2::SetPosition, theActor,_1));
1660 }
1661
1662 void
1663 VISU_GaussPtsAct1
1664 ::SetVisibility(int theMode)
1665 {
1666   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetVisibility - this = "<<this);
1667
1668   Superclass::SetVisibility(theMode);
1669
1670   bool aVisisbility = GetVisibility();
1671   bool anIsSegementation = IsSegmentationEnabled();
1672   myDeviceActor->SetVisibility(aVisisbility/* && !anIsSegementation*/);
1673   myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1674   myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1675
1676   mySetVisibilitySignal(GetVisibility());
1677 }
1678
1679 //----------------------------------------------------------------
1680 void
1681 VISU_GaussPtsAct1
1682 ::UpdateInsideCursorSettings()
1683 {
1684   Superclass::UpdateInsideCursorSettings( myInsideDeviceActor );
1685 }
1686
1687 //----------------------------------------------------------------
1688 void
1689 VISU_GaussPtsAct1
1690 ::SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings)
1691 {
1692   if(myOutsideCursorSettings == theOutsideCursorSettings)
1693     return;
1694
1695   if(myOutsideCursorSettings)
1696     myOutsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1697
1698   myOutsideCursorSettings = theOutsideCursorSettings;
1699
1700   if(theOutsideCursorSettings)
1701   {
1702     theOutsideCursorSettings->AddObserver(VISU::UpdateOutsideSettingsEvent, 
1703                                           myEventCallbackCommand.GetPointer(), 
1704                                           myPriority);
1705     UpdateOutsideCursorSettings();
1706   }
1707 }
1708
1709 void
1710 VISU_GaussPtsAct1
1711 ::UpdateOutsideCursorSettings()
1712 {
1713   if(!myOutsideCursorSettings || myOutsideCursorSettings->GetInitial())
1714     return;
1715
1716   VISU_GaussPointsPL* aPipeline = myOutsideDeviceActor->GetPipeLine();
1717
1718   vtkImplicitFunction* anImplicitFunction = aPipeline->GetImplicitFunction();
1719   vtkFloatingPointType aMagnification = aPipeline->GetMagnification();
1720
1721   aPipeline->ShallowCopy(GetGaussPointsPL(), true);
1722
1723   aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1724   aPipeline->SetExtractBoundaryCells(true);
1725   //aPipeline->SetExtractInside(true);
1726   aPipeline->SetMagnification( aMagnification );
1727
1728   aPipeline->SetPrimitiveType( myOutsideCursorSettings->GetPrimitiveType() );
1729
1730   if( myOutsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1731     myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_POINTS );
1732   else
1733     myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1734
1735   aPipeline->SetClamp( myOutsideCursorSettings->GetClamp() );
1736   aPipeline->SetImageData( myOutsideCursorSettings->GetTexture() );
1737   aPipeline->SetAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() );
1738   aPipeline->SetResolution( myOutsideCursorSettings->GetResolution() );
1739   aPipeline->SetSize( myOutsideCursorSettings->GetSize() );
1740   aPipeline->SetMagnification( myOutsideCursorSettings->GetMagnification() );
1741   aPipeline->SetMagnificationIncrement( myOutsideCursorSettings->GetIncrement() );
1742
1743   if( myOutsideCursorSettings->GetUniform() )
1744   {
1745     myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOff();
1746     myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 1 ); // Geometry mode
1747     myOutsideDeviceActor->GetProperty()->SetColor( myOutsideCursorSettings->GetColor() );
1748   }
1749   else
1750   {
1751     myOutsideDeviceActor->GetPointSpriteMapper()->SetPointSpriteMode( 2 ); // Outside cursor mode
1752     myOutsideDeviceActor->GetPointSpriteMapper()->SetColorModeToMapScalars();
1753     myOutsideDeviceActor->GetPointSpriteMapper()->ScalarVisibilityOn();
1754   }
1755
1756   aPipeline->Update();
1757
1758   Highlight(isHighlighted());
1759
1760   Update();
1761 }
1762
1763
1764 //----------------------------------------------------------------
1765 void 
1766 VISU_GaussPtsAct1
1767 ::ProcessEvents(vtkObject* theObject, 
1768                 unsigned long theEvent,
1769                 void* theClientData, 
1770                 void* theCallData)
1771 {
1772   if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
1773     if(VISU_GaussPtsAct1* self = dynamic_cast<VISU_GaussPtsAct1*>(anObject))
1774       if(theEvent == VISU::UpdateOutsideSettingsEvent)
1775         self->UpdateOutsideCursorSettings();
1776
1777   Superclass::ProcessEvents(theObject,theEvent,theClientData,theCallData);
1778 }
1779
1780 void
1781 VISU_GaussPtsAct1
1782 ::OnInteractorEvent(unsigned long theEvent)
1783 {
1784   switch(theEvent){
1785   case vtkCommand::StartInteractionEvent: 
1786     myDeviceActor->SetVisibility(GetVisibility());
1787     myInsideDeviceActor->SetVisibility(false);
1788     myOutsideDeviceActor->SetVisibility(false);
1789     break;
1790   case vtkCommand::EnableEvent: 
1791   case vtkCommand::DisableEvent:
1792   case vtkCommand::EndInteractionEvent: {
1793     bool aVisisbility = GetVisibility();
1794     bool anIsSegementation = IsSegmentationEnabled();
1795     myDeviceActor->SetVisibility(aVisisbility/* && !anIsSegementation*/);
1796     myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1797     myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1798     break;
1799   }
1800   default:
1801     break;
1802   }
1803   
1804   Superclass::OnInteractorEvent(theEvent);
1805 }
1806
1807 //----------------------------------------------------------------------------
1808 unsigned long int
1809 VISU_GaussPtsAct1
1810 ::GetMemorySize()
1811 {
1812   unsigned long int aSize = Superclass::GetMemorySize();
1813   if(IsSegmentationEnabled()){
1814     aSize += myInsideDeviceActor->GetMemorySize();
1815     aSize += myOutsideDeviceActor->GetMemorySize();
1816   }
1817   return aSize;
1818 }
1819
1820
1821
1822 //==============================================================================
1823 vtkStandardNewMacro(VISU_GaussPtsAct2);
1824
1825
1826 //----------------------------------------------------------------------------
1827 VISU_GaussPtsAct2
1828 ::VISU_GaussPtsAct2()
1829 {
1830   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::VISU_GaussPtsAct2 - this = "<<this);
1831   myDeviceActor->SetVisibility(false);
1832 }
1833
1834 VISU_GaussPtsAct2
1835 ::~VISU_GaussPtsAct2()
1836 {
1837   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::~VISU_GaussPtsAct2 - this = "<<this);
1838 }
1839
1840
1841 //----------------------------------------------------------------------------
1842 void
1843 VISU_GaussPtsAct2
1844 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1845 {
1846   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::ShallowCopyPL - this = "<<this);
1847
1848   Superclass::ShallowCopyPL(thePipeLine);
1849 }
1850
1851 //----------------------------------------------------------------------------
1852 void
1853 VISU_GaussPtsAct2::SetPosition(double _arg[3]){
1854   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct2::SetPosition - this = "<<this);       
1855   Superclass::SetPosition(_arg);
1856 }
1857
1858 //----------------------------------------------------------------------------
1859 void
1860 VISU_GaussPtsAct2
1861 ::SetMapperInput(vtkDataSet* theDataSet) 
1862 {
1863   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetMapperInput - this = "<<this);
1864   Superclass::SetMapperInput(theDataSet);
1865 //   if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1866 //     myDeviceActor->SetPipeLine(aPipeLine);
1867 //     myCurrentPL = aPipeLine;
1868 //     aPipeLine->Delete();
1869
1870 //     myMapper->SetInput(myCurrentPL->GetPickableDataSet());
1871 //     SetMapper(myMapper.GetPointer());
1872 //   }
1873 }
1874
1875 //----------------------------------------------------------------------------
1876 void
1877 VISU_GaussPtsAct2
1878 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1879 {
1880   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetWidgetCtrl - this = "<<this);
1881
1882   if(myWidgetCtrl == theWidgetCtrl)
1883     return;
1884
1885   if(myWidgetCtrl){
1886     theWidgetCtrl->RemoveObserver(myEventCallbackCommand.GetPointer());
1887     myDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1888     myDeviceActor->SetVisibility(false);
1889   }
1890
1891   Superclass::SetWidgetCtrl(theWidgetCtrl);
1892
1893   if(theWidgetCtrl){
1894     myDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1895     myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1896   }
1897 }
1898
1899
1900 //----------------------------------------------------------------------------
1901 unsigned long int
1902 VISU_GaussPtsAct2
1903 ::GetMemorySize()
1904 {
1905   if(IsSegmentationEnabled())
1906     return Superclass::GetMemorySize();
1907   return 0;
1908 }
1909
1910
1911 //----------------------------------------------------------------------------
1912 void
1913 VISU_GaussPtsAct2
1914 ::SetVisibility(int theMode)
1915 {
1916   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetVisibility - this = "<<this);
1917
1918   Superclass::SetVisibility(theMode);
1919
1920   myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1921 }
1922
1923 void
1924 VISU_GaussPtsAct2
1925 ::OnInteractorEvent(unsigned long theEvent)
1926 {
1927   switch(theEvent){
1928   case vtkCommand::EnableEvent: 
1929   case vtkCommand::DisableEvent:
1930     myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1931     if(theEvent == vtkCommand::EnableEvent)
1932       Update();
1933     break;
1934   case vtkCommand::EndInteractionEvent:
1935     Update();
1936     break;
1937   default:
1938     break;
1939   }
1940   Superclass::OnInteractorEvent(theEvent);
1941 }