Salome HOME
Merge from V5_1_main 14/05/2010
[modules/visu.git] / src / OBJECT / VISU_PickingSettings.cxx
1 //  Copyright (C) 2007-2010  CEA/DEN, EDF R&D, OPEN CASCADE
2 //
3 //  This library is free software; you can redistribute it and/or
4 //  modify it under the terms of the GNU Lesser General Public
5 //  License as published by the Free Software Foundation; either
6 //  version 2.1 of the License.
7 //
8 //  This library is distributed in the hope that it will be useful,
9 //  but WITHOUT ANY WARRANTY; without even the implied warranty of
10 //  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
11 //  Lesser General Public License for more details.
12 //
13 //  You should have received a copy of the GNU Lesser General Public
14 //  License along with this library; if not, write to the Free Software
15 //  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
16 //
17 //  See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
18 //
19
20 //  VISU OBJECT : interactive object for VISU entities implementation
21 //  File   : VISU_PickingSettings.cxx
22 //  Author : Oleg UVAROV
23 //  Module : VISU
24 //
25 #include "VISU_PickingSettings.h"
26
27 #include "SUIT_ResourceMgr.h"
28 #include "SUIT_Session.h"
29
30 #include <vtkObjectFactory.h>
31
32 vtkStandardNewMacro( VISU_PickingSettings );
33
34 VISU_PickingSettings* VISU_PickingSettings::Get()
35 {
36   static VISU_PickingSettings* aPickingSettings = VISU_PickingSettings::New();
37
38   if( aPickingSettings->GetIsInitial() )
39   {
40     SUIT_ResourceMgr* aResourceMgr = SUIT_Session::session()->resourceMgr();
41
42     aPickingSettings->SetCursorSize( aResourceMgr->doubleValue( "VISU", "picking_cursor_size", 0.5 ) );
43     aPickingSettings->SetPyramidHeight( aResourceMgr->doubleValue( "VISU", "picking_pyramid_height", 10.0 ) );
44     aPickingSettings->SetPointTolerance( aResourceMgr->doubleValue( "VISU", "picking_point_tolerance", 0.1 ) );
45     aPickingSettings->SetInfoWindowEnabled( aResourceMgr->booleanValue( "VISU", "picking_info_window", false ) );
46     aPickingSettings->SetInfoWindowTransparency( aResourceMgr->integerValue( "VISU", "picking_transparency", 50 ) / 100.0 );
47     aPickingSettings->SetInfoWindowPosition( aResourceMgr->integerValue( "VISU", "picking_position", VISU_PickingSettings::TopLeftCorner ) );
48     aPickingSettings->SetCameraMovementEnabled( aResourceMgr->booleanValue( "VISU", "picking_camera_movement", true ) );
49     aPickingSettings->SetZoomFactor( aResourceMgr->doubleValue( "VISU", "picking_zoom_factor", 1.5 ) );
50     aPickingSettings->SetStepNumber( aResourceMgr->integerValue( "VISU", "picking_step_number", 10 ) );
51     aPickingSettings->SetDisplayParentMesh( aResourceMgr->booleanValue( "VISU", "picking_display_parent_mesh", true ) );
52
53     QColor aSelectionColor = aResourceMgr->colorValue( "VISU", "picking_selection_color", Qt::yellow );
54     vtkFloatingPointType aColor[3];
55     aColor[0] = aSelectionColor.red() / 255.0;
56     aColor[1] = aSelectionColor.green() / 255.0;
57     aColor[2] = aSelectionColor.blue() / 255.0;
58     aPickingSettings->SetColor( aColor );
59
60     aPickingSettings->SetIsInitial( false );
61   }
62
63   return aPickingSettings;
64 }
65
66 VISU_PickingSettings::VISU_PickingSettings()
67 {
68   this->IsInitial              = true;
69
70   this->PyramidHeight          = -1;
71   this->CursorSize             = -1;
72   this->PointTolerance         = -1;
73   this->Color[0]               = -1;
74   this->Color[1]               = -1;
75   this->Color[2]               = -1;
76   this->InfoWindowEnabled      = false;
77   this->InfoWindowTransparency = -1;
78   this->InfoWindowPosition     = -1;
79   this->CameraMovementEnabled  = false;
80   this->ZoomFactor             = -1;
81   this->StepNumber             = -1;
82   this->DisplayParentMesh      = false;
83 }
84
85 VISU_PickingSettings::~VISU_PickingSettings()
86 {
87 }