]> SALOME platform Git repositories - modules/visu.git/blob - src/OBJECT/VISU_GaussPtsAct.cxx
Salome HOME
ac8ca23961befa6ce8a222d79f576e2901a005c2
[modules/visu.git] / src / OBJECT / VISU_GaussPtsAct.cxx
1 //  VISU OBJECT : interactive object for VISU entities implementation
2 //
3 //  Copyright (C) 2003  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 //
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_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 "SALOME_ExtractGeometry.h"
40
41 #include "VISU_Event.h" 
42 #include "SVTK_Actor.h"
43
44 #include <vtkCamera.h>
45 #include <vtkRenderer.h>
46 #include <vtkPointPicker.h>
47 #include <vtkScalarBarWidget.h>
48 #include <vtkScalarBarActor.h>
49 #include <vtkTextMapper.h>
50 #include <vtkTextProperty.h>
51
52 #include <vtkCellData.h>
53 #include <vtkPointData.h>
54
55 #include <vtkDataArray.h>
56 #include <vtkFloatArray.h>
57
58 #include <vtkSphereSource.h>
59 #include <vtkPolyDataMapper.h>
60 #include <vtkPolyData.h>
61 #include <vtkActor.h>
62
63 #include <vtkObjectFactory.h>
64 #include <vtkCallbackCommand.h>
65 #include <vtkInteractorStyle.h>
66 #include <vtkRenderWindowInteractor.h>
67 #include <vtkOutlineSource.h>
68
69 #include <sstream>
70 #include <boost/bind.hpp>
71
72 #include <vtkUnstructuredGrid.h>
73 #include <vtkDataSetMapper.h>
74 #include <vtkRenderWindow.h>
75 #include <vtkCellArray.h>
76 #include <vtkCell.h>
77 #include <vtkMath.h>
78
79 #include <vtkViewport.h>
80
81 #include "utilities.h"
82
83 #ifdef _DEBUG_
84 static int MYDEBUG = 0;
85 static int MYDEBUG1 = 0;
86 static int MYDEBUG2 = 0;
87 #else
88 static int MYDEBUG = 0;
89 static int MYDEBUG1 = 0;
90 static int MYDEBUG2 = 0;
91 #endif
92
93
94 //============================================================================
95 vtkStandardNewMacro(VISU_GaussPtsAct);
96
97 //----------------------------------------------------------------------------
98 VISU_GaussPtsAct
99 ::VISU_GaussPtsAct():
100   myEventCallbackCommand(vtkCallbackCommand::New()),
101   myPriority(0.0),
102   myDeviceActor(VISU_GaussPtsDeviceActor::New()),
103   myWidgetCtrl(NULL),
104   myGaussPointsPL(NULL),
105   myLastObjPointID(-1),
106   myTextActor(VISU_FramedTextActor::New()),
107   myCursorPyramid(VISU_CursorPyramid::New()),
108   myCursorPyramidSelected(VISU_CursorPyramid::New()),
109   myCellSource(vtkUnstructuredGrid::New()),
110   myCellActor(SVTK_Actor::New()),
111   myScalarBarCtrl(VISU_ScalarBarCtrl::New()),
112   myBarVisibility(true),
113   myPickingSettings(NULL),
114   myInsideCursorSettings(NULL),
115   myCurrentPL(NULL)
116 {
117   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::VISU_GaussPtsAct - this = "<<this);
118
119   myEventCallbackCommand->Delete();
120   myDeviceActor->Delete();
121   myTextActor->Delete();
122
123   myCursorPyramid->Delete();
124   myCursorPyramid->SetPickable(0);
125   myCursorPyramid->SetVisibility(0);
126
127   myCursorPyramidSelected->Delete();
128   myCursorPyramidSelected->SetPickable(0);
129   myCursorPyramidSelected->SetVisibility(0);
130
131   myCellSource->Delete();
132   myCellActor->Delete();
133
134   myEventCallbackCommand->SetClientData(this); 
135   myEventCallbackCommand->SetCallback(VISU_GaussPtsAct::ProcessEvents);
136
137   myDeviceActor->SetProperty(GetProperty());
138   myDeviceActor->SetVisibility(true);
139   myDeviceActor->SetPickable(false);
140
141   myTextActor->SetVisibility(false);
142   myTextActor->SetPickable(false);
143
144   myCellSource->Allocate();
145   myCellActor->Initialize();
146   myCellActor->SetRepresentation(VTK_WIREFRAME);
147   myCellActor->SetSource(myCellSource.GetPointer());
148   
149   myCellActor->SetVisibility(0);
150   myCellActor->SetPickable(0);
151   myCellActor->GetProperty()->SetAmbient(1.0);
152   myCellActor->GetProperty()->SetDiffuse(0.0);
153
154   myScalarBarCtrl->Delete();
155 }
156
157 VISU_GaussPtsAct
158 ::~VISU_GaussPtsAct()
159 {
160   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::~VISU_GaussPtsAct - this = "<<this);
161   SetWidgetCtrl(NULL);
162   SetInteractor(NULL);
163   SetPickingSettings(NULL);
164   SetInsideCursorSettings(NULL);
165 }
166
167
168 //----------------------------------------------------------------------------
169 void
170 VISU_GaussPtsAct
171 ::SetPipeLine(VISU_PipeLine* thePipeLine) 
172 {
173   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::SetPipeLine - this = "<<this);
174
175   myGaussPointsPL = dynamic_cast<VISU_GaussPointsPL*>(thePipeLine);
176
177   Superclass::SetPipeLine(thePipeLine);
178 }
179
180 VISU_GaussPointsPL*
181 VISU_GaussPtsAct
182 ::GetGaussPointsPL()
183 {
184   return myGaussPointsPL.GetPointer();
185 }
186
187 void
188 VISU_GaussPtsAct
189 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
190 {
191   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::ShallowCopyPL - this = "<<this);
192
193   Superclass::ShallowCopyPL(thePipeLine);
194
195   UpdateInsideCursorSettings();
196
197   Highlight(isHighlighted());
198 }
199
200
201 //----------------------------------------------------------------------------
202 vtkMapper* 
203 VISU_GaussPtsAct
204 ::GetMapper()
205 {
206   myMapper->Update();
207   return Superclass::GetMapper();
208 }
209
210 vtkFloatingPointType* 
211 VISU_GaussPtsAct
212 ::GetBounds()
213 {
214   return GetMapper()->GetBounds();
215 }
216
217 vtkDataSet* 
218 VISU_GaussPtsAct
219 ::GetInput()
220 {
221   return GetMapper()->GetInput();
222 }
223
224 VISU_PipeLine* 
225 VISU_GaussPtsAct
226 ::GetCurrentPL() 
227
228   return myCurrentPL;
229 }
230
231
232 //----------------------------------------------------------------------------
233 void
234 VISU_GaussPtsAct
235 ::AddToRender(vtkRenderer* theRenderer)
236 {
237   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::AddToRender - this = "<<this);
238
239   Superclass::AddToRender(theRenderer);
240
241   myDeviceActor->AddToRender(theRenderer);
242
243   theRenderer->AddActor(myTextActor.GetPointer());
244   theRenderer->AddActor(myCellActor.GetPointer());
245
246   myCursorPyramid->AddToRender(theRenderer);
247   myCursorPyramidSelected->AddToRender(theRenderer);
248   myScalarBarCtrl->AddToRender(theRenderer);
249 }
250
251 void 
252 VISU_GaussPtsAct
253 ::RemoveFromRender(vtkRenderer* theRenderer)
254 {
255   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::RemoveFromRender - this = "<<this);
256
257   Superclass::RemoveFromRender(theRenderer);
258
259   myDeviceActor->RemoveFromRender(theRenderer);
260   
261   theRenderer->RemoveActor(myTextActor.GetPointer());
262   theRenderer->RemoveActor(myCellActor.GetPointer());
263   
264   myCursorPyramid->RemoveFromRender(theRenderer);
265   myCursorPyramidSelected->RemoveFromRender(theRenderer);
266   myScalarBarCtrl->RemoveFromRender(theRenderer);
267 }
268
269 void 
270 VISU_GaussPtsAct
271 ::SetTransform(VTKViewer_Transform* theTransform)
272 {
273   Superclass::SetTransform(theTransform);
274
275   myDeviceActor->SetTransform(theTransform);
276 }
277
278 int
279 VISU_GaussPtsAct
280 ::RenderOpaqueGeometry(vtkViewport *viewport)
281 {
282   return 1;
283 }
284
285 int
286 VISU_GaussPtsAct
287 ::RenderTranslucentGeometry(vtkViewport *viewport)
288 {
289   return 1;
290 }
291
292
293 //----------------------------------------------------------------------------
294 void
295 VISU_GaussPtsAct
296 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
297 {
298   if(myWidgetCtrl == theWidgetCtrl)
299     return;
300
301   if(MYDEBUG) 
302     MESSAGE("VISU_GaussPtsAct::SetWidgetCtrl - this = "<<this<<"; theWidget = "<<theWidgetCtrl);
303
304   if(myWidgetCtrl)
305     myWidgetCtrl->RemoveObserver(myEventCallbackCommand.GetPointer());
306
307   if(theWidgetCtrl){
308     theWidgetCtrl->AddObserver(vtkCommand::EnableEvent, 
309                                myEventCallbackCommand.GetPointer(), 
310                                myPriority);
311     theWidgetCtrl->AddObserver(vtkCommand::DisableEvent, 
312                                myEventCallbackCommand.GetPointer(), 
313                                myPriority);
314     theWidgetCtrl->AddObserver(vtkCommand::StartInteractionEvent, 
315                                myEventCallbackCommand.GetPointer(), 
316                                myPriority);
317     theWidgetCtrl->AddObserver(vtkCommand::EndInteractionEvent, 
318                                myEventCallbackCommand.GetPointer(), 
319                                myPriority);
320   }
321
322   myWidgetCtrl = theWidgetCtrl;
323 }
324
325 bool
326 VISU_GaussPtsAct
327 ::GetChangeMagnification()
328 {
329   return myChangeMagnification;
330 }
331
332 void
333 VISU_GaussPtsAct
334 ::ChangeMagnification( bool up )
335 {
336   myEventCallbackCommand->SetAbortFlag(1);
337
338   vtkFloatingPointType aMagnification = myInsideCursorSettings->GetMagnification();
339   vtkFloatingPointType anIncrement = myInsideCursorSettings->GetIncrement();
340   vtkFloatingPointType coefficient = up ? anIncrement : 1 / anIncrement;
341
342   myInsideCursorSettings->SetMagnification( aMagnification * coefficient );
343   myInsideCursorSettings->InvokeEvent(VISU::UpdateFromSettingsEvent,NULL);
344
345   Update();
346 }
347
348 //----------------------------------------------------------------------------
349 namespace
350 {
351   VISU_GaussPointsPL*
352   CreatePipeLine(VISU_GaussPointsPL* thePipeLine)
353   {
354     VISU_GaussPointsPL* aPipeLine = VISU_GaussPointsPL::New();
355     aPipeLine->SetGaussPtsIDMapper(thePipeLine->GetGaussPtsIDMapper());
356     aPipeLine->ShallowCopy(thePipeLine);
357     aPipeLine->Update();
358     return aPipeLine;
359   }
360 }
361
362 void
363 VISU_GaussPtsAct
364 ::SetMapperInput(vtkDataSet* theDataSet) 
365 {
366   if(MYDEBUG) MESSAGE("VISU_GaussPtsAct::SetMapperInput - this = "<<this);
367
368   myDeviceActor->SetPipeLine(GetGaussPointsPL());
369   myCurrentPL = myDeviceActor->GetPipeLine();
370
371   myMapper->SetInput(myCurrentPL->GetPickableDataSet());
372   SetMapper(myMapper.GetPointer());
373 }
374
375
376 //----------------------------------------------------------------------------
377 namespace
378 {
379   inline  
380   vtkFloatingPointType 
381   GetRadius(vtkIdType theVTKID,
382             vtkDataArray *theScalarArray,
383             VISU_GaussPointsPL* theGaussPointsPL)
384   {
385     vtkFloatingPointType aRadius = 0.5;
386     if(theGaussPointsPL->GetPSMapper()->GetPointSpriteMode() == 1) // Geometry mode
387       aRadius *= theGaussPointsPL->GetSize() * theGaussPointsPL->GetAverageCellSize();
388     else if(theGaussPointsPL->GetBicolor()){
389       vtkFloatingPointType aVal = theScalarArray->GetTuple1(theVTKID);
390       if(aVal > 0.0)
391         aRadius *= theGaussPointsPL->GetMaxSize();
392       else
393         aRadius *= theGaussPointsPL->GetMinSize();
394       aRadius *= theGaussPointsPL->GetAverageCellSize();
395     }else
396       aRadius *= theGaussPointsPL->GetPointSize(theVTKID,theScalarArray);
397
398     return aRadius;
399   }
400 }
401
402 vtkFloatingPointType
403 VISU_GaussPtsAct
404 ::GetRadius(vtkIdType theObjID,
405             vtkIdType theVTKID,
406             vtkDataArray *theScalarArray)
407 {
408   return ::GetRadius(theVTKID,theScalarArray,myDeviceActor->GetPipeLine());
409 }
410
411 //----------------------------------------------------------------------------
412 vtkFloatingPointType 
413 VISU_GaussPtsAct
414 ::GetMagnification(vtkIdType theObjID)
415 {
416   return myDeviceActor->GetPipeLine()->GetMagnification();
417 }
418
419
420 //----------------------------------------------------------------------------
421 namespace
422 {
423   inline  
424   vtkFloatingPointType 
425   GetClamp(VISU_GaussPointsPL* theGaussPointsPL)
426   {
427     vtkFloatingPointType aClamp = theGaussPointsPL->GetClamp();
428     if(theGaussPointsPL->GetPrimitiveType() == VISU_OpenGLPointSpriteMapper::GeomSphere)
429       return -aClamp;
430     return aClamp;
431   }
432 }
433
434 vtkFloatingPointType 
435 VISU_GaussPtsAct
436 ::GetClamp(vtkIdType theObjID)
437 {
438   return ::GetClamp(myDeviceActor->GetPipeLine());
439 }
440
441
442 //----------------------------------------------------------------------------
443 void
444 VISU_GaussPtsAct
445 ::SetFactory(VISU::TActorFactory* theActorFactory)
446
447   using namespace VISU;
448   myGaussPtsActorFactory = dynamic_cast<TGaussPtsActorFactory*>(theActorFactory);
449   myUpdatePrs3dSignal.connect(boost::bind(&TGaussPtsActorFactory::UpdateFromActor,
450                                           myGaussPtsActorFactory,
451                                           _1));
452   Superclass::SetFactory(theActorFactory);
453 }
454
455 VISU::TGaussPtsActorFactory*
456 VISU_GaussPtsAct
457 ::GetGaussPtsFactory()
458 {
459   return myGaussPtsActorFactory;
460 }
461
462
463 //----------------------------------------------------------------------------
464 void
465 VISU_GaussPtsAct
466 ::SetVisibility(int theMode)
467 {
468   Superclass::SetVisibility(theMode);
469   myScalarBarCtrl->SetVisibility(theMode);
470   Highlight(isHighlighted());
471 }
472
473 int
474 VISU_GaussPtsAct
475 ::IsSegmentationEnabled()
476 {
477   return myWidgetCtrl  && myWidgetCtrl->GetEnabled();
478 }
479
480
481 //----------------------------------------------------------------------------
482 void
483 VISU_GaussPtsAct
484 ::SetBarVisibility(bool theMode)
485 {
486   myBarVisibility = theMode;
487   myScalarBarCtrl->SetCtrlVisibility(theMode); 
488   myScalarBarCtrl->SetVisibility(GetVisibility()); 
489 }
490
491 bool
492 VISU_GaussPtsAct
493 ::GetBarVisibility()
494
495   return myBarVisibility;
496 }
497
498 VISU_ScalarBarCtrl* 
499 VISU_GaussPtsAct
500 ::GetScalarBarCtrl()
501 {
502   return myScalarBarCtrl.GetPointer();
503 }
504
505 //----------------------------------------------------------------------------
506 void
507 VISU_GaussPtsAct
508 ::SetInteractor(vtkRenderWindowInteractor* theInteractor)
509 {
510   if(theInteractor == myInteractor)
511     return;
512
513   if(myInteractor)
514     myInteractor->RemoveObserver(myEventCallbackCommand.GetPointer());
515   
516   if(theInteractor){
517     theInteractor->AddObserver(vtkCommand::CharEvent, 
518                                myEventCallbackCommand.GetPointer(), 
519                                myPriority);
520     theInteractor->AddObserver(VISU::SetSMDecreaseMagnificationEvent, 
521                                myEventCallbackCommand.GetPointer(), 
522                                myPriority);
523     theInteractor->AddObserver(VISU::SetSMIncreaseMagnificationEvent, 
524                                myEventCallbackCommand.GetPointer(), 
525                                myPriority);
526   }
527   Superclass::SetInteractor(theInteractor);
528
529   Modified();
530 }
531 //-------------------------------------------------------------------------
532 void 
533 VISU_GaussPtsAct
534 ::ProcessEvents(vtkObject* vtkNotUsed(theObject), 
535                 unsigned long theEvent,
536                 void* theClientData, 
537                 void* vtkNotUsed(theCallData))
538 {
539   if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
540     if(VISU_GaussPtsAct* self = dynamic_cast<VISU_GaussPtsAct*>(anObject)) {
541       if(theEvent == VISU::UpdateInsideSettingsEvent)
542         self->UpdateInsideCursorSettings();
543       else
544         self->OnInteractorEvent(theEvent);
545     }
546 }
547
548 //-------------------------------------------------------------------------
549 void
550 VISU_GaussPtsAct
551 ::OnInteractorEvent(unsigned long theEvent)
552 {
553   switch(theEvent){
554   case vtkCommand::CharEvent: {
555     switch(myInteractor->GetKeyCode()) {
556     case 'M' :
557     case 'm' :
558     {
559       if( IsSegmentationEnabled() )
560       {
561         this->ChangeMagnification( myInteractor->GetShiftKey() );
562         return;
563       }
564
565       myChangeMagnification = myInteractor->GetShiftKey();
566       break;
567     }
568     case 'D' :
569     case 'd' :
570     {
571       if( IsSegmentationEnabled() && myWidgetCtrl->IsSphereActive() )
572       {
573         VISU_SphereWidget* aSphereWidget = myWidgetCtrl->GetSphereWidget();
574         aSphereWidget->ChangeRadius( myInteractor->GetShiftKey() );
575         myWidgetCtrl->InvokeEvent(vtkCommand::EndInteractionEvent,NULL);
576         myWidgetCtrl->GetInteractor()->Render();
577       }
578       return;
579     }
580     default:
581       return;
582     }
583     myUpdatePrs3dSignal(this);
584     break;
585   }
586   case VISU::SetSMDecreaseMagnificationEvent: 
587   case VISU::SetSMIncreaseMagnificationEvent: 
588     myChangeMagnification = theEvent == VISU::SetSMIncreaseMagnificationEvent;
589     myUpdatePrs3dSignal(this);
590     break;
591   case VISU::UpdatePickingSettingsEvent:
592     UpdatePickingSettings();
593     break;
594   case vtkCommand::EndInteractionEvent:
595   case vtkCommand::EnableEvent:
596   case vtkCommand::DisableEvent: 
597     myCurrentPL->GetMapper()->Update();
598     Highlight(isHighlighted());
599     break;
600   default:
601     break;
602   }
603 }
604
605 //----------------------------------------------------------------------------
606 bool
607 VISU_GaussPtsAct
608 ::IsInfinitive()
609 {
610   if(vtkMapper* aMapper = myDeviceActor->GetMapper()){
611     if(vtkDataSet* aDataSet= aMapper->GetInput()){
612       aDataSet->Update();
613       myIsInfinite = aDataSet->GetNumberOfCells() < 2;
614     }
615   }
616   return myIsInfinite;
617 }
618
619 //----------------------------------------------------------------------------
620 int
621 VISU_GaussPtsAct
622 ::GetPickable()
623 {
624   if(Superclass::GetPickable()){
625     if(vtkMapper* aMapper = GetMapper()){
626       if(vtkDataSet* aDataSet= aMapper->GetInput()){
627         aDataSet->Update();
628         return aDataSet->GetNumberOfCells() > 0;
629       }
630     }
631   }
632
633   return false;
634 }
635
636 //----------------------------------------------------------------------------
637 bool
638 VISU_GaussPtsAct
639 ::PreHighlight(vtkInteractorStyle* theInteractorStyle, 
640                SVTK_SelectionEvent* theSelectionEvent,
641                bool theIsHighlight)
642 {
643   if ( !GetPickable() )
644     return false;
645
646   myPreHighlightActor->SetVisibility(false);
647   myCursorPyramid->SetVisibility(false);  
648
649   if (!myBarVisibility)
650     return false;
651
652
653   if(!theIsHighlight)
654     myLastObjPointID = -1;
655
656   Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
657
658   if(aSelectionMode == ActorSelection || !theIsHighlight)
659     return Superclass::PreHighlight(theInteractorStyle,
660                                     theSelectionEvent,
661                                     theIsHighlight);  
662   
663   bool anIsChanged = (mySelectionMode != aSelectionMode);
664   bool anIsPreselected = myIsPreselected;
665   myIsPreselected = false;
666   
667   if(aSelectionMode == GaussPointSelection && theIsHighlight){
668     myPointPicker->Pick(theSelectionEvent->myX, 
669                         theSelectionEvent->myY, 
670                         0.0, 
671                         theInteractorStyle->GetCurrentRenderer());
672     
673     if(myPointPicker->GetActor() != this)
674       return (anIsPreselected != myIsPreselected);
675     
676     vtkIdType aVtkId = myPointPicker->GetPointId();
677     
678     if(aVtkId >= 0 && mySelector->IsValid(this,aVtkId,true) && hasIO()){
679       vtkIdType anObjId = GetNodeObjId( aVtkId );
680       myIsPreselected = (anObjId >= 0);
681       if(myIsPreselected){
682         anIsChanged = (myLastObjPointID != anObjId);
683         if(anIsChanged){
684           vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
685           vtkDataSet* aDataSet = GetInput();
686           vtkCellData* aCellData = aDataSet->GetCellData();
687           if(vtkDataArray *aScalarArray = aCellData->GetScalars()){
688             vtkFloatingPointType aPyramidHeight = myPickingSettings->GetPyramidHeight();
689             aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
690             //vtkFloatingPointType aColor[3] = myPreHighlightActor->GetProperty()->GetColor();
691             vtkFloatingPointType aColor[3];
692             theInteractorStyle->GetCurrentRenderer()->GetBackground( aColor );
693             aColor[0] = 1. - aColor[0];
694             aColor[1] = 1. - aColor[1];
695             aColor[2] = 1. - aColor[2];
696
697             myCursorPyramid->Init(aPyramidHeight,
698                                   myPickingSettings->GetCursorSize(),
699                                   GetRadius(anObjId,aVtkId,aScalarArray),
700                                   GetMagnification(anObjId),
701                                   GetClamp(anObjId),
702                                   aNodeCoord,
703                                   aColor);
704           }
705           myLastObjPointID = anObjId;
706         }
707         myCursorPyramid->SetVisibility(true);
708       }
709     }
710   }
711   
712   mySelectionMode = aSelectionMode;
713   anIsChanged |= (anIsPreselected != myIsPreselected);
714
715   return anIsChanged;
716 }
717
718
719 //----------------------------------------------------------------------------
720 inline
721 void
722 ChangeZoom(VISU_PickingSettings *thePickingSettings,
723            vtkInteractorStyle* theInteractorStyle,
724            int theInitialHasIndex,
725            int theCurrentHasIndex,
726            const Handle(SALOME_InteractiveObject)& theIO)
727 {
728   if(theInitialHasIndex + theCurrentHasIndex == 1){
729     vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
730     vtkCamera *aCamera = aRenderer->GetActiveCamera();
731     vtkFloatingPointType aZoomFactor = thePickingSettings->GetZoomFactor();
732     double aScale = aCamera->GetParallelScale();
733     if (!theInitialHasIndex && theCurrentHasIndex) {
734       aCamera->SetParallelScale(aScale/aZoomFactor);
735     }
736     else {
737       aCamera->SetParallelScale(aScale*aZoomFactor);
738     }
739   }
740   
741 }
742
743 bool
744 VISU_GaussPtsAct
745 ::Highlight(vtkInteractorStyle* theInteractorStyle, 
746             SVTK_SelectionEvent* theSelectionEvent,
747             bool theIsHighlight)
748
749   if ( !GetPickable() )
750     return false;
751
752   int anInitialHasIndex = myIsHighlighted && mySelectionMode == GaussPointSelection;
753   Handle(SALOME_InteractiveObject) anIO = getIO();
754   myIsHighlighted = false;
755
756   Selection_Mode aSelectionMode = theSelectionEvent->mySelectionMode;
757
758   if(!theIsHighlight && aSelectionMode == GaussPointSelection){
759     mySelector->RemoveIObject(anIO);
760
761     ChangeZoom(myPickingSettings,
762                theInteractorStyle,
763                anInitialHasIndex,
764                false,
765                anIO);
766
767     return true;
768   }
769   
770   if (!myBarVisibility)
771     return false;
772
773
774   if(aSelectionMode == ActorSelection)
775     return Superclass::Highlight(theInteractorStyle,
776                                  theSelectionEvent,
777                                  theIsHighlight);
778
779   if(aSelectionMode == GaussPointSelection && !theSelectionEvent->myIsRectangle){
780
781     vtkRenderer *aRenderer = theInteractorStyle->GetCurrentRenderer();
782     myPointPicker->Pick(theSelectionEvent->myX, 
783                         theSelectionEvent->myY,
784                         0.0, 
785                         aRenderer);
786
787     if(myPointPicker->GetActor() != this) {
788       mySelector->ClearIObjects();
789
790       ChangeZoom(myPickingSettings,
791                  theInteractorStyle,
792                  anInitialHasIndex,
793                  false,
794                  anIO);
795
796       return true;
797     }
798
799     vtkIdType aVtkId = myPointPicker->GetPointId();
800     if( aVtkId >= 0  && mySelector->IsValid( this, aVtkId, true ) && hasIO()) {
801       vtkIdType anObjId = GetNodeObjId( aVtkId );
802       if(anObjId >= 0){
803         myIsHighlighted = true;
804         // Update the Selector
805         if(mySelector->IsSelected(myIO))
806           mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
807         else{
808           if(!theSelectionEvent->myIsShift){
809             mySelector->ClearIObjects();
810           }
811           mySelector->AddOrRemoveIndex(myIO,anObjId,theSelectionEvent->myIsShift);
812           mySelector->AddIObject(this);
813         }
814         //
815         vtkFloatingPointType* aNodeCoord = GetNodeCoord(anObjId);
816         //
817         // FlyTo
818         vtkRenderWindowInteractor* anInteractor = theInteractorStyle->GetInteractor();
819         vtkFloatingPointType aDollyWas = anInteractor->GetDolly();
820         int aNumberOfFlyFramesWas = anInteractor->GetNumberOfFlyFrames();
821         
822         anInteractor->SetDolly(0.);
823         anInteractor->SetNumberOfFlyFrames(myPickingSettings->GetStepNumber());
824         anInteractor->FlyTo(aRenderer,aNodeCoord);
825         aRenderer->ResetCameraClippingRange();
826         anInteractor->SetDolly(aDollyWas);
827         anInteractor->SetNumberOfFlyFrames(aNumberOfFlyFramesWas);
828         
829         mySelectionMode = aSelectionMode;
830
831         ChangeZoom(myPickingSettings,
832                    theInteractorStyle,
833                    anInitialHasIndex,
834                    true,
835                    anIO);
836
837         return true;
838         //
839       }// if( anObjId >= 0 ) {
840     }//if( aVtkId >= 0  && mySelector->IsValid( this, aVtkId, true ) && hasIO()) 
841   }//if(!theSelectionEvent->myIsRectangle){
842
843   ChangeZoom(myPickingSettings,
844              theInteractorStyle,
845              anInitialHasIndex,
846              false,
847              anIO);
848   
849   return false;
850 }
851
852 //==================================================================
853 // function : Highlight
854 // purpose  :
855 //==================================================================
856 void
857 VISU_GaussPtsAct
858 ::Highlight(bool theIsHighlight)
859 {
860   if(!mySelector.GetPointer())
861     return;
862
863   myOutlineActor->SetVisibility(false);
864   myTextActor->SetVisibility(false);
865   myCursorPyramidSelected->SetVisibility(false);
866   myCursorPyramid->SetVisibility(false);
867   myCellActor->SetVisibility(false);
868   GetScalarBarCtrl()->SetIsMarked(false);
869   GetScalarBarCtrl()->Update();
870
871   if(!theIsHighlight)
872     return;
873
874   bool anIsVisible = GetVisibility();
875
876   Selection_Mode aSelectionMode = mySelector->SelectionMode();
877
878   if(aSelectionMode == ActorSelection)
879     Superclass::highlight(theIsHighlight);
880   else if(aSelectionMode != GaussPointSelection)
881     return;
882
883   TColStd_IndexedMapOfInteger aMapIndex;
884   mySelector->GetIndex( getIO(), aMapIndex );
885   if(aMapIndex.Extent() != 1 || !myBarVisibility) {
886     return;
887   }
888   //
889   std::ostringstream aStr;
890   int anObjId = aMapIndex(1);
891   aStr<<"Global ID: "<<anObjId;
892   //
893   vtkIdType aVtkId = GetNodeVTKID(anObjId);
894   if(aVtkId >= 0){
895     vtkFloatingPointType *aNodeCoord = GetNodeCoord(anObjId);
896     vtkFloatingPointType aWorldCoord[4] = {aNodeCoord[0], aNodeCoord[1], aNodeCoord[2], 1.};
897     //
898     vtkDataSet* aDataSet = GetInput();
899     vtkCellData* aDataSetAttributes = aDataSet->GetCellData();
900     //
901     if(vtkDataArray* aScalarArray = aDataSetAttributes->GetScalars()){
902       vtkFloatingPointType aVal = aScalarArray->GetTuple1(aVtkId);
903       //
904       GetScalarBarCtrl()->SetIsMarked(true);
905       GetScalarBarCtrl()->SetMarkValue(aVal);
906       GetScalarBarCtrl()->Update();
907       //
908       vtkFloatingPointType aPyramidHeight = myPickingSettings->GetPyramidHeight();
909       aPyramidHeight = aPyramidHeight*myGaussPointsPL->GetMaxPointSize();
910       myCursorPyramidSelected->Init(aPyramidHeight,
911                                     myPickingSettings->GetCursorSize(),
912                                     GetRadius(anObjId,aVtkId,aScalarArray),
913                                     GetMagnification(anObjId),
914                                     GetClamp(anObjId),
915                                     aNodeCoord,
916                                     myHighlightActor->GetProperty()->GetColor());
917       myCursorPyramidSelected->SetVisibility(anIsVisible && theIsHighlight);
918       //
919       const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = 
920         myGaussPointsPL->GetGaussPtsIDMapper();
921       VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
922       
923       VISU::TGaussPointID aGaussPointID = myGaussPointsPL->GetObjID(anObjId);
924       VISU::TCellID aCellID = aGaussPointID.first;
925       VISU::TLocalPntID aLocalPntID = aGaussPointID.second;
926       aStr<<"\nParentCellID: "<<aCellID;
927       std::string aParentName = aParent->GetElemName(aCellID);
928       if(aParentName != "") {
929         aStr<<"\nParentCellName: '"<<aParentName<<"'";
930       }
931       aStr<<"\nLocalPntID: "<<aLocalPntID;
932       aStr<<"\nScalar: "<<aVal;
933     }
934
935     if(vtkDataArray* aFieldArray = aDataSetAttributes->GetArray("VISU_FIELD")){
936       if(vtkFloatArray *aFloatArray = dynamic_cast<vtkFloatArray*>(aFieldArray)){
937         int aNbComp = aFloatArray->GetNumberOfComponents();
938         aStr<<"\nData: {";
939         int anId = 0;
940         while(anId < aNbComp){
941           vtkFloatingPointType aComp = aFloatArray->GetComponent(aVtkId,anId++);
942           aStr<<aComp;
943           if(anId < aNbComp)
944             aStr<<"; ";
945         }
946         aStr<<"}";
947       }
948     }
949     //
950     // myTextActor
951     std::string aString = aStr.str();
952     myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition());
953     myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency());
954     myTextActor->SetWorldPoint(aWorldCoord);
955     myTextActor->SetText(aString.c_str());
956     myTextActor->SetVisibility(anIsVisible && theIsHighlight);
957     //
958     // myCellActor
959     if(myPickingSettings->GetDisplayParentMesh()){
960       const VISU::PGaussPtsIDMapper& aGaussPtsIDMapper = 
961         myGaussPointsPL->GetGaussPtsIDMapper();
962       VISU::TNamedIDMapper* aParent = aGaussPtsIDMapper->GetParent();
963       
964       myCellSource->Reset();
965       myCellSource->Modified(); // a VTK bug
966       myCellSource->SetPoints(aParent->GetVTKOutput()->GetPoints());
967       
968       VISU::TGaussPointID aGaussPointID = aGaussPtsIDMapper->GetObjID(anObjId);
969       vtkIdType aCellID = aGaussPointID.first;
970       vtkCell* aCell = aParent->GetElemCell(aCellID);
971       myCellSource->InsertNextCell(aCell->GetCellType(),aCell->GetPointIds());
972       myCellActor->SetVisibility(anIsVisible && theIsHighlight);
973       myCellActor->SetRepresentation(VTK_WIREFRAME);
974     }
975   }
976 }
977
978
979 //----------------------------------------------------------------
980 void
981 VISU_GaussPtsAct
982 ::SetPickingSettings(VISU_PickingSettings* thePickingSettings)
983 {
984   if(myPickingSettings == thePickingSettings)
985     return;
986
987   if(myPickingSettings)
988     myPickingSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
989
990   myPickingSettings = thePickingSettings;
991
992   if(thePickingSettings)
993   {
994     thePickingSettings->AddObserver(VISU::UpdatePickingSettingsEvent, 
995                                     myEventCallbackCommand.GetPointer(), 
996                                     myPriority);
997     this->UpdatePickingSettings();
998   }
999 }
1000
1001 void
1002 VISU_GaussPtsAct
1003 ::UpdatePickingSettings()
1004 {
1005   if(!myPickingSettings || myPickingSettings->GetInitial())
1006     return;
1007
1008   myTextActor->SetModePosition(myPickingSettings->GetInfoWindowPosition());
1009   myTextActor->SetTransparency(myPickingSettings->GetInfoWindowTransparency());
1010
1011   vtkFloatingPointType aHeight = myGaussPointsPL->GetMaxPointSize()*myPickingSettings->GetPyramidHeight();
1012   vtkFloatingPointType aCursorSize = myPickingSettings->GetCursorSize();
1013   myCursorPyramid->SetPreferences(aHeight,aCursorSize);
1014   myCursorPyramidSelected->SetPreferences(aHeight,aCursorSize);
1015
1016   myHighlightActor->GetProperty()->SetColor( myPickingSettings->GetColor() );
1017   myPointPicker->SetTolerance( myPickingSettings->GetPointTolerance() );
1018
1019   Highlight(isHighlighted());
1020
1021   Update();
1022 }
1023
1024 //----------------------------------------------------------------
1025 void
1026 VISU_GaussPtsAct
1027 ::SetInsideCursorSettings(VISU_InsideCursorSettings* theInsideCursorSettings)
1028 {
1029   if(myInsideCursorSettings == theInsideCursorSettings)
1030     return;
1031
1032   if(myInsideCursorSettings)
1033     myInsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1034
1035   myInsideCursorSettings = theInsideCursorSettings;
1036
1037   if(theInsideCursorSettings){
1038     theInsideCursorSettings->AddObserver(VISU::UpdateInsideSettingsEvent, 
1039                                          myEventCallbackCommand.GetPointer(), 
1040                                          myPriority);
1041     UpdateInsideCursorSettings();
1042   }
1043 }
1044
1045 void
1046 VISU_GaussPtsAct
1047 ::UpdateInsideCursorSettings()
1048 {
1049   UpdateInsideCursorSettings( myDeviceActor );
1050 }
1051
1052 void
1053 VISU_GaussPtsAct
1054 ::UpdateInsideCursorSettings( PDeviceActor theActor )
1055 {
1056   if(!myInsideCursorSettings || myInsideCursorSettings->GetInitial())
1057     return;
1058
1059   VISU_GaussPointsPL* aPipeline = theActor->GetPipeLine();
1060
1061   SALOME_ExtractGeometry* anExtractGeometry = aPipeline->GetExtractGeometryFilter();
1062   vtkImplicitFunction* anImplicitFunction = anExtractGeometry->GetImplicitFunction();
1063
1064   aPipeline->ShallowCopy(GetGaussPointsPL());
1065
1066   aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1067
1068   aPipeline->SetPrimitiveType( myInsideCursorSettings->GetPrimitiveType() );
1069   aPipeline->SetClamp( myInsideCursorSettings->GetClamp() );
1070   aPipeline->SetImageData( myInsideCursorSettings->GetTexture() );
1071   aPipeline->SetAlphaThreshold( myInsideCursorSettings->GetAlphaThreshold() );
1072   aPipeline->SetResolution( myInsideCursorSettings->GetResolution() );
1073   aPipeline->SetMinSize( myInsideCursorSettings->GetMinSize() );
1074   aPipeline->SetMaxSize( myInsideCursorSettings->GetMaxSize() );
1075   aPipeline->SetMagnification( myInsideCursorSettings->GetMagnification() );
1076   aPipeline->SetMagnificationIncrement( myInsideCursorSettings->GetIncrement() );
1077
1078   if( myInsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1079     theActor->GetProperty()->SetRepresentation( VTK_POINTS );
1080   else
1081     theActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1082
1083   aPipeline->Update();
1084
1085   Highlight(isHighlighted());
1086
1087   Update();
1088 }
1089
1090 //==============================================================================
1091 vtkStandardNewMacro(VISU_GaussPtsAct1);
1092
1093
1094 //----------------------------------------------------------------------------
1095 VISU_GaussPtsAct1
1096 ::VISU_GaussPtsAct1():
1097   myInsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1098   myOutsideDeviceActor(VISU_GaussPtsDeviceActor::New()),
1099   myOutsideCursorSettings(NULL)
1100 {
1101   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::VISU_GaussPtsAct1 - this = "<<this);
1102
1103   myEventCallbackCommand->SetCallback(VISU_GaussPtsAct1::ProcessEvents);
1104
1105   myInsideDeviceActor->SetVisibility(false);
1106   myInsideDeviceActor->SetPickable(false);
1107   myInsideDeviceActor->Delete();
1108
1109   myOutsideDeviceActor->SetVisibility(false);
1110   myOutsideDeviceActor->SetPickable(false);
1111   myOutsideDeviceActor->Delete();
1112 }
1113
1114 VISU_GaussPtsAct1
1115 ::~VISU_GaussPtsAct1()
1116 {
1117   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::~VISU_GaussPtsAct1 - this = "<<this);
1118
1119   SetOutsideCursorSettings(NULL);
1120 }
1121
1122
1123 //----------------------------------------------------------------------------
1124 void
1125 VISU_GaussPtsAct1
1126 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1127 {
1128   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::ShallowCopyPL - this = "<<this);
1129
1130   Superclass::ShallowCopyPL(thePipeLine);
1131
1132   UpdateOutsideCursorSettings();
1133 }
1134
1135
1136 //----------------------------------------------------------------------------
1137 void
1138 VISU_GaussPtsAct1
1139 ::AddToRender(vtkRenderer* theRenderer)
1140 {
1141   Superclass::AddToRender(theRenderer);
1142
1143   myInsideDeviceActor->AddToRender(theRenderer);
1144   myOutsideDeviceActor->AddToRender(theRenderer);
1145 }
1146
1147 void 
1148 VISU_GaussPtsAct1
1149 ::RemoveFromRender(vtkRenderer* theRenderer)
1150 {
1151   Superclass::RemoveFromRender(theRenderer);
1152
1153   myInsideDeviceActor->RemoveFromRender(theRenderer);
1154   myOutsideDeviceActor->RemoveFromRender(theRenderer);
1155 }
1156
1157 void 
1158 VISU_GaussPtsAct1
1159 ::SetTransform(VTKViewer_Transform* theTransform)
1160 {
1161   Superclass::SetTransform(theTransform);
1162
1163   myInsideDeviceActor->SetTransform(theTransform);
1164   myOutsideDeviceActor->SetTransform(theTransform);
1165 }
1166
1167
1168 //----------------------------------------------------------------------------
1169 void
1170 VISU_GaussPtsAct1
1171 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1172 {
1173   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetWidgetCtrl - this = "<<this);
1174
1175   if(myWidgetCtrl == theWidgetCtrl){
1176     return;
1177   }
1178
1179   if(myWidgetCtrl){
1180     myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1181     myInsideDeviceActor->SetVisibility(false);
1182
1183     myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);  
1184     myOutsideDeviceActor->SetVisibility(false);
1185   }
1186
1187   Superclass::SetWidgetCtrl(theWidgetCtrl);
1188
1189   if(theWidgetCtrl){
1190     myInsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1191     myInsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1192
1193     myOutsideDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());  
1194     myOutsideDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1195   }
1196 }
1197
1198
1199 //----------------------------------------------------------------------------
1200 void
1201 VISU_GaussPtsAct1
1202 ::SetMapperInput(vtkDataSet* theDataSet) 
1203 {
1204   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetMapperInput - this = "<<this);
1205
1206   Superclass::SetMapperInput(theDataSet);
1207
1208   if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1209     myInsideDeviceActor->SetPipeLine(aPipeLine);
1210     aPipeLine->Delete();
1211   }
1212
1213   if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1214     myOutsideDeviceActor->SetPipeLine(aPipeLine);
1215     aPipeLine->Delete();
1216
1217     SALOME_ExtractGeometry* anExtractGeometry = aPipeLine->GetExtractGeometryFilter();
1218     anExtractGeometry->SetExtractBoundaryCells(true);
1219     anExtractGeometry->SetExtractInside(true);
1220   }
1221 }
1222
1223
1224 //----------------------------------------------------------------------------
1225 vtkFloatingPointType
1226 VISU_GaussPtsAct1
1227 ::GetRadius(vtkIdType theObjID,
1228             vtkIdType theVTKID,
1229             vtkDataArray *theScalarArray)
1230 {
1231   VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1232   if(IsSegmentationEnabled()){
1233     if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1234       aPipeLine = myOutsideDeviceActor->GetPipeLine();
1235     else
1236       aPipeLine = myInsideDeviceActor->GetPipeLine();
1237   }
1238   return ::GetRadius(theVTKID,theScalarArray,aPipeLine);
1239 }
1240
1241
1242 //----------------------------------------------------------------------------
1243 vtkFloatingPointType 
1244 VISU_GaussPtsAct1
1245 ::GetMagnification(vtkIdType theObjID)
1246 {
1247   VISU_GaussPointsPL* aPipeLine = myDeviceActor->GetPipeLine();
1248   if(IsSegmentationEnabled()){
1249     if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1250       aPipeLine = myOutsideDeviceActor->GetPipeLine();
1251     else
1252       aPipeLine = myInsideDeviceActor->GetPipeLine();
1253   }
1254   return aPipeLine->GetMagnification();
1255 }
1256
1257
1258 //----------------------------------------------------------------------------
1259 vtkFloatingPointType 
1260 VISU_GaussPtsAct1
1261 ::GetClamp(vtkIdType theObjID)
1262 {
1263   if(IsSegmentationEnabled()){
1264     if(myInsideDeviceActor->GetPipeLine()->GetNodeVTKID(theObjID) < 0)
1265       return ::GetClamp(myOutsideDeviceActor->GetPipeLine());
1266     else
1267       return ::GetClamp(myInsideDeviceActor->GetPipeLine());
1268   }
1269   return Superclass::GetClamp(theObjID);
1270 }
1271
1272
1273 //----------------------------------------------------------------
1274 void 
1275 VISU_GaussPtsAct1
1276 ::Connect(VISU_GaussPtsAct2* theActor)
1277 {
1278   mySetVisibilitySignal.connect(boost::bind(&VISU_GaussPtsAct2::SetVisibility,theActor,_1));
1279 }
1280
1281 void
1282 VISU_GaussPtsAct1
1283 ::SetVisibility(int theMode)
1284 {
1285   if(MYDEBUG1) MESSAGE("VISU_GaussPtsAct1::SetVisibility - this = "<<this);
1286
1287   Superclass::SetVisibility(theMode);
1288
1289   bool aVisisbility = GetVisibility();
1290   bool anIsSegementation = IsSegmentationEnabled();
1291   myDeviceActor->SetVisibility(aVisisbility && !anIsSegementation);
1292   myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1293   myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1294
1295   mySetVisibilitySignal(GetVisibility());
1296 }
1297
1298 //----------------------------------------------------------------
1299 void
1300 VISU_GaussPtsAct1
1301 ::UpdateInsideCursorSettings()
1302 {
1303   Superclass::UpdateInsideCursorSettings( myInsideDeviceActor );
1304 }
1305
1306 //----------------------------------------------------------------
1307 void
1308 VISU_GaussPtsAct1
1309 ::SetOutsideCursorSettings(VISU_OutsideCursorSettings* theOutsideCursorSettings)
1310 {
1311   if(myOutsideCursorSettings == theOutsideCursorSettings)
1312     return;
1313
1314   if(myOutsideCursorSettings)
1315     myOutsideCursorSettings->RemoveObserver(myEventCallbackCommand.GetPointer());
1316
1317   myOutsideCursorSettings = theOutsideCursorSettings;
1318
1319   if(theOutsideCursorSettings)
1320   {
1321     theOutsideCursorSettings->AddObserver(VISU::UpdateOutsideSettingsEvent, 
1322                                           myEventCallbackCommand.GetPointer(), 
1323                                           myPriority);
1324     UpdateOutsideCursorSettings();
1325   }
1326 }
1327
1328 void
1329 VISU_GaussPtsAct1
1330 ::UpdateOutsideCursorSettings()
1331 {
1332   if(!myOutsideCursorSettings || myOutsideCursorSettings->GetInitial())
1333     return;
1334
1335   VISU_GaussPointsPL* aPipeline = myOutsideDeviceActor->GetPipeLine();
1336
1337   SALOME_ExtractGeometry* anExtractGeometry = aPipeline->GetExtractGeometryFilter();
1338   vtkImplicitFunction* anImplicitFunction = anExtractGeometry->GetImplicitFunction();
1339   vtkFloatingPointType aMagnification = aPipeline->GetMagnification();
1340
1341   aPipeline->ShallowCopy(GetGaussPointsPL());
1342
1343   aPipeline->SetImplicitFunction(anImplicitFunction); // To restore
1344   anExtractGeometry->SetExtractBoundaryCells(true);
1345   anExtractGeometry->SetExtractInside(true);
1346   aPipeline->SetMagnification( aMagnification );
1347
1348   aPipeline->SetPrimitiveType( myOutsideCursorSettings->GetPrimitiveType() );
1349
1350   if( myOutsideCursorSettings->GetPrimitiveType() != VISU_OpenGLPointSpriteMapper::GeomSphere )
1351     myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_POINTS );
1352   else
1353     myOutsideDeviceActor->GetProperty()->SetRepresentation( VTK_SURFACE );
1354
1355   aPipeline->SetClamp( myOutsideCursorSettings->GetClamp() );
1356   aPipeline->SetImageData( myOutsideCursorSettings->GetTexture() );
1357   aPipeline->SetAlphaThreshold( myOutsideCursorSettings->GetAlphaThreshold() );
1358   aPipeline->SetResolution( myOutsideCursorSettings->GetResolution() );
1359   aPipeline->SetSize( myOutsideCursorSettings->GetSize() );
1360   aPipeline->SetMagnification( myOutsideCursorSettings->GetMagnification() );
1361   aPipeline->SetMagnificationIncrement( myOutsideCursorSettings->GetIncrement() );
1362
1363   if( myOutsideCursorSettings->GetUniform() )
1364   {
1365     myOutsideDeviceActor->GetPSMapper()->ScalarVisibilityOff();
1366     myOutsideDeviceActor->GetPSMapper()->SetPointSpriteMode( 1 ); // Geometry mode
1367     myOutsideDeviceActor->GetProperty()->SetColor( myOutsideCursorSettings->GetColor() );
1368   }
1369   else
1370   {
1371     myOutsideDeviceActor->GetPSMapper()->SetPointSpriteMode( 2 ); // Outside cursor mode
1372     myOutsideDeviceActor->GetPSMapper()->SetColorModeToMapScalars();
1373     myOutsideDeviceActor->GetPSMapper()->ScalarVisibilityOn();
1374   }
1375
1376   aPipeline->Update();
1377
1378   Highlight(isHighlighted());
1379
1380   Update();
1381 }
1382
1383
1384 //----------------------------------------------------------------
1385 void 
1386 VISU_GaussPtsAct1
1387 ::ProcessEvents(vtkObject* theObject, 
1388                 unsigned long theEvent,
1389                 void* theClientData, 
1390                 void* theCallData)
1391 {
1392   if(vtkObject* anObject = reinterpret_cast<vtkObject*>(theClientData))
1393     if(VISU_GaussPtsAct1* self = dynamic_cast<VISU_GaussPtsAct1*>(anObject))
1394       if(theEvent == VISU::UpdateOutsideSettingsEvent)
1395         self->UpdateOutsideCursorSettings();
1396
1397   Superclass::ProcessEvents(theObject,theEvent,theClientData,theCallData);
1398 }
1399
1400 void
1401 VISU_GaussPtsAct1
1402 ::OnInteractorEvent(unsigned long theEvent)
1403 {
1404   switch(theEvent){
1405   case vtkCommand::StartInteractionEvent: 
1406     myDeviceActor->SetVisibility(GetVisibility());
1407     myInsideDeviceActor->SetVisibility(false);
1408     myOutsideDeviceActor->SetVisibility(false);
1409     break;
1410   case vtkCommand::EnableEvent: 
1411   case vtkCommand::DisableEvent:
1412   case vtkCommand::EndInteractionEvent: {
1413     bool aVisisbility = GetVisibility();
1414     bool anIsSegementation = IsSegmentationEnabled();
1415     myDeviceActor->SetVisibility(aVisisbility && !anIsSegementation);
1416     myInsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1417     myOutsideDeviceActor->SetVisibility(aVisisbility && anIsSegementation);
1418     break;
1419   }
1420   default:
1421     break;
1422   }
1423   
1424   Superclass::OnInteractorEvent(theEvent);
1425 }
1426
1427
1428 //==============================================================================
1429 vtkStandardNewMacro(VISU_GaussPtsAct2);
1430
1431
1432 //----------------------------------------------------------------------------
1433 VISU_GaussPtsAct2
1434 ::VISU_GaussPtsAct2()
1435 {
1436   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::VISU_GaussPtsAct2 - this = "<<this);
1437   myDeviceActor->SetVisibility(false);
1438 }
1439
1440 VISU_GaussPtsAct2
1441 ::~VISU_GaussPtsAct2()
1442 {
1443   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::~VISU_GaussPtsAct2 - this = "<<this);
1444 }
1445
1446
1447 //----------------------------------------------------------------------------
1448 void
1449 VISU_GaussPtsAct2
1450 ::ShallowCopyPL(VISU_PipeLine* thePipeLine)
1451 {
1452   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::ShallowCopyPL - this = "<<this);
1453
1454   Superclass::ShallowCopyPL(thePipeLine);
1455 }
1456
1457
1458 //----------------------------------------------------------------------------
1459 void
1460 VISU_GaussPtsAct2
1461 ::SetMapperInput(vtkDataSet* theDataSet) 
1462 {
1463   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetMapperInput - this = "<<this);
1464
1465   if(VISU_GaussPointsPL* aPipeLine = CreatePipeLine(GetGaussPointsPL())){
1466     myDeviceActor->SetPipeLine(aPipeLine);
1467     myCurrentPL = aPipeLine;
1468     aPipeLine->Delete();
1469
1470     myMapper->SetInput(myCurrentPL->GetPickableDataSet());
1471     SetMapper(myMapper.GetPointer());
1472   }
1473 }
1474
1475 //----------------------------------------------------------------------------
1476 void
1477 VISU_GaussPtsAct2
1478 ::SetWidgetCtrl(VISU_WidgetCtrl* theWidgetCtrl)
1479 {
1480   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetWidgetCtrl - this = "<<this);
1481
1482   if(myWidgetCtrl == theWidgetCtrl)
1483     return;
1484
1485   if(myWidgetCtrl){
1486     theWidgetCtrl->RemoveObserver(myEventCallbackCommand.GetPointer());
1487     myDeviceActor->GetPipeLine()->SetImplicitFunction(NULL);
1488     myDeviceActor->SetVisibility(false);
1489   }
1490
1491   Superclass::SetWidgetCtrl(theWidgetCtrl);
1492
1493   if(theWidgetCtrl){
1494     myDeviceActor->GetPipeLine()->SetImplicitFunction(theWidgetCtrl->ImplicitFunction());
1495     myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1496   }
1497 }
1498
1499
1500 //----------------------------------------------------------------------------
1501 void
1502 VISU_GaussPtsAct2
1503 ::SetVisibility(int theMode)
1504 {
1505   if(MYDEBUG2) MESSAGE("VISU_GaussPtsAct2::SetVisibility - this = "<<this);
1506
1507   Superclass::SetVisibility(theMode);
1508
1509   myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1510 }
1511
1512 void
1513 VISU_GaussPtsAct2
1514 ::OnInteractorEvent(unsigned long theEvent)
1515 {
1516   switch(theEvent){
1517   case vtkCommand::EnableEvent: 
1518   case vtkCommand::DisableEvent:
1519     myDeviceActor->SetVisibility(GetVisibility() && IsSegmentationEnabled());
1520     if(theEvent == vtkCommand::EnableEvent)
1521       Update();
1522     break;
1523   case vtkCommand::EndInteractionEvent:
1524     Update();
1525     break;
1526   default:
1527     break;
1528   }
1529   Superclass::OnInteractorEvent(theEvent);
1530 }