Back to index

salome-gui  6.5.0
VTKViewer_MarkerDlg.cxx
Go to the documentation of this file.
00001 // Copyright (C) 2007-2012  CEA/DEN, EDF R&D, OPEN CASCADE
00002 //
00003 // This library is free software; you can redistribute it and/or
00004 // modify it under the terms of the GNU Lesser General Public
00005 // License as published by the Free Software Foundation; either
00006 // version 2.1 of the License.
00007 //
00008 // This library is distributed in the hope that it will be useful,
00009 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00010 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00011 // Lesser General Public License for more details.
00012 //
00013 // You should have received a copy of the GNU Lesser General Public
00014 // License along with this library; if not, write to the Free Software
00015 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
00016 //
00017 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
00018 //
00019 
00020 #include "VTKViewer_MarkerDlg.h"
00021 #include "VTKViewer_MarkerWidget.h"
00022 
00023 #include <SUIT_Application.h>
00024 #include <SUIT_MessageBox.h>
00025 #include <SUIT_ResourceMgr.h>
00026 #include <SUIT_Session.h>
00027 
00028 #include <QFrame>
00029 #include <QHBoxLayout>
00030 #include <QKeyEvent>
00031 
00040 VTKViewer_MarkerDlg::VTKViewer_MarkerDlg( QWidget* theParent )
00041 : QtxDialog( theParent, true, true )
00042 {
00043   setWindowTitle( tr( "SET_MARKER_TLT" ) );
00044 
00045   myMarkerWidget = new VTKViewer_MarkerWidget( mainFrame() );
00046 
00047   QBoxLayout* aTopLayout = new QHBoxLayout( mainFrame() );
00048   aTopLayout->setSpacing( 0 );
00049   aTopLayout->setMargin( 0 );
00050   aTopLayout->addWidget( myMarkerWidget );
00051 
00052   connect( this, SIGNAL( dlgHelp() ), this, SLOT( onHelp() ) );
00053 }
00054 
00058 VTKViewer_MarkerDlg::~VTKViewer_MarkerDlg()
00059 {
00060 }
00061 
00062 void VTKViewer_MarkerDlg::setHelpData( const QString& theModuleName,
00063                                        const QString& theHelpFileName )
00064 {
00065   myModuleName = theModuleName;
00066   myHelpFileName = theHelpFileName;
00067 }
00068 
00069 void VTKViewer_MarkerDlg::keyPressEvent( QKeyEvent* e )
00070 {
00071   QtxDialog::keyPressEvent( e );
00072   if ( e->isAccepted() )
00073     return;
00074 
00075   if ( e->key() == Qt::Key_F1 ) {
00076     e->accept();
00077     onHelp();
00078   }
00079 }
00080 
00081 void VTKViewer_MarkerDlg::onHelp()
00082 {
00083   if( myModuleName.isNull() || myHelpFileName.isNull() )
00084     return;
00085 
00086   SUIT_Application* app = SUIT_Session::session()->activeApplication();
00087   if (app) 
00088     app->onHelpContextModule(myModuleName, myHelpFileName);
00089   else {
00090     QString platform;
00091 #ifdef WIN32
00092     platform = "winapplication";
00093 #else
00094     platform = "application";
00095 #endif
00096     SUIT_MessageBox::warning(this, tr("WRN_WARNING"),
00097                              tr("EXTERNAL_BROWSER_CANNOT_SHOW_PAGE").
00098                              arg(app->resourceMgr()->stringValue("ExternalBrowser", 
00099                                                                  platform)).
00100                              arg(myHelpFileName));
00101   }
00102 }
00103 
00104 void VTKViewer_MarkerDlg::setCustomMarkerMap( VTK::MarkerMap theMarkerMap )
00105 {
00106   myMarkerWidget->setCustomMarkerMap( theMarkerMap );
00107 }
00108 
00109 VTK::MarkerMap VTKViewer_MarkerDlg::getCustomMarkerMap()
00110 {
00111   return myMarkerWidget->getCustomMarkerMap();
00112 }
00113 
00114 void VTKViewer_MarkerDlg::setStandardMarker( VTK::MarkerType theMarkerType, VTK::MarkerScale theMarkerScale )
00115 {
00116   myMarkerWidget->setStandardMarker( theMarkerType, theMarkerScale );
00117 }
00118 
00119 void VTKViewer_MarkerDlg::setCustomMarker( int theId )
00120 {
00121   myMarkerWidget->setCustomMarker( theId );
00122 }
00123 
00124 VTK::MarkerType VTKViewer_MarkerDlg::getMarkerType() const
00125 {
00126   return myMarkerWidget->getMarkerType();
00127 }
00128 
00129 VTK::MarkerScale VTKViewer_MarkerDlg::getStandardMarkerScale() const
00130 {
00131   return myMarkerWidget->getStandardMarkerScale();
00132 }
00133 
00134 int VTKViewer_MarkerDlg::getCustomMarkerID() const
00135 {
00136   return myMarkerWidget->getCustomMarkerID();
00137 }
00138 
00139 void VTKViewer_MarkerDlg::addExtraStdMarker( VTK::MarkerType theMarkerType, const QPixmap& thePixmap )
00140 {
00141   myMarkerWidget->addExtraStdMarker( theMarkerType, thePixmap );
00142 }