Salome HOME
Merge from V6_main_20120808 08Aug12
[modules/gui.git] / src / VTKViewer / VTKViewer_MarkerDlg.cxx
1 // Copyright (C) 2007-2012  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 #include "VTKViewer_MarkerDlg.h"
21 #include "VTKViewer_MarkerWidget.h"
22
23 #include <SUIT_Application.h>
24 #include <SUIT_MessageBox.h>
25 #include <SUIT_ResourceMgr.h>
26 #include <SUIT_Session.h>
27
28 #include <QFrame>
29 #include <QHBoxLayout>
30 #include <QKeyEvent>
31
32 /*!
33  * Class       : VTKViewer_MarkerDlg
34  * Description : Dialog for specifying point marker parameters
35  */
36
37 /*!
38   Constructor
39 */
40 VTKViewer_MarkerDlg::VTKViewer_MarkerDlg( QWidget* theParent )
41 : QtxDialog( theParent, true, true )
42 {
43   setWindowTitle( tr( "SET_MARKER_TLT" ) );
44
45   myMarkerWidget = new VTKViewer_MarkerWidget( mainFrame() );
46
47   QBoxLayout* aTopLayout = new QHBoxLayout( mainFrame() );
48   aTopLayout->setSpacing( 0 );
49   aTopLayout->setMargin( 0 );
50   aTopLayout->addWidget( myMarkerWidget );
51
52   connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
53 }
54
55 /*!
56   Destructor
57 */
58 VTKViewer_MarkerDlg::~VTKViewer_MarkerDlg()
59 {
60 }
61
62 void VTKViewer_MarkerDlg::setHelpData( const QString& theModuleName,
63                                        const QString& theHelpFileName )
64 {
65   myModuleName = theModuleName;
66   myHelpFileName = theHelpFileName;
67 }
68
69 void VTKViewer_MarkerDlg::keyPressEvent( QKeyEvent* e )
70 {
71   QtxDialog::keyPressEvent( e );
72   if ( e->isAccepted() )
73     return;
74
75   if ( e->key() == Qt::Key_F1 ) {
76     e->accept();
77     onHelp();
78   }
79 }
80
81 void VTKViewer_MarkerDlg::onHelp()
82 {
83   if( myModuleName.isNull() || myHelpFileName.isNull() )
84     return;
85
86   SUIT_Application* app = SUIT_Session::session()->activeApplication();
87   if (app) 
88     app->onHelpContextModule(myModuleName, myHelpFileName);
89   else {
90     QString platform;
91 #ifdef WIN32
92     platform = "winapplication";
93 #else
94     platform = "application";
95 #endif
96     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
97                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
98                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
99                                                                  platform)).
100                              arg(myHelpFileName));
101   }
102 }
103
104 void VTKViewer_MarkerDlg::setCustomMarkerMap( VTK::MarkerMap theMarkerMap )
105 {
106   myMarkerWidget->setCustomMarkerMap( theMarkerMap );
107 }
108
109 VTK::MarkerMap VTKViewer_MarkerDlg::getCustomMarkerMap()
110 {
111   return myMarkerWidget->getCustomMarkerMap();
112 }
113
114 void VTKViewer_MarkerDlg::setStandardMarker( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
115 {
116   myMarkerWidget->setStandardMarker( theMarkerType, theMarkerScale );
117 }
118
119 void VTKViewer_MarkerDlg::setCustomMarker( int theId )
120 {
121   myMarkerWidget->setCustomMarker( theId );
122 }
123
124 VTK::MarkerType VTKViewer_MarkerDlg::getMarkerType() const
125 {
126   return myMarkerWidget->getMarkerType();
127 }
128
129 VTK::MarkerScale VTKViewer_MarkerDlg::getStandardMarkerScale() const
130 {
131   return myMarkerWidget->getStandardMarkerScale();
132 }
133
134 int VTKViewer_MarkerDlg::getCustomMarkerID() const
135 {
136   return myMarkerWidget->getCustomMarkerID();
137 }
138
139 void VTKViewer_MarkerDlg::addExtraStdMarker( VTK::MarkerType theMarkerType, const QPixmap& thePixmap )
140 {
141   myMarkerWidget->addExtraStdMarker( theMarkerType, thePixmap );
142 }