1 // Copyright (C) 2014-2023 CEA, EDF, OPEN CASCADE
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, or (at your option) any later version.
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.
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
17 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
21 #include "VTKPlugin_ExportDlg.h"
23 #include <SALOMEconfig.h>
24 #include CORBA_SERVER_HEADER(VTKPlugin)
27 #include <SUIT_Session.h>
28 #include <SUIT_ResourceMgr.h>
29 #include <SUIT_ViewManager.h>
31 #include <SalomeApp_Application.h>
32 #include <SalomeApp_DoubleSpinBox.h>
33 #include <SalomeApp_Study.h>
36 #include "GEOM_Constants.h"
39 #include <QApplication>
43 //=================================================================================
45 //=================================================================================
46 VTKPlugin_ExportDlg::VTKPlugin_ExportDlg( const Handle(SALOME_InteractiveObject)& io, QWidget* parent )
47 : SUIT_FileDlg( parent, false, true, true )
49 SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr();
51 QLabel* deflectionLabel = new QLabel( tr( "DEFLECTION" ), this );
53 myDeflectionSB = new SalomeApp_DoubleSpinBox( this );
54 int aPrecision = resMgr->integerValue( "Geometry", "parametric_precision", 6 );
55 myDeflectionSB->setAcceptNames( false );
56 myDeflectionSB->setPrecision( aPrecision );
57 myDeflectionSB->setDecimals( aPrecision );
58 myDeflectionSB->setRange( GEOM::minDeflection(), 1.0 );
59 myDeflectionSB->setSingleStep( 1.0e-04 );
61 layout()->addWidget( deflectionLabel );
62 layout()->addWidget( myDeflectionSB );
64 SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
65 SalomeApp_Study* study = dynamic_cast< SalomeApp_Study* >( app->activeStudy() );
66 int mgrId = app->activeViewManager()->getGlobalId();
67 QVariant v = study->getObjectProperty( mgrId, io->getEntry(), GEOM::propertyName( GEOM::Deflection ), QVariant() );
68 double deflection = v.isValid() ? v.toDouble() : SUIT_Session::session()->resourceMgr()->doubleValue( "Geometry", "deflection_coeff", 0.001 );
69 myDeflectionSB->setValue( deflection );
72 //=================================================================================
74 //=================================================================================
75 VTKPlugin_ExportDlg::~VTKPlugin_ExportDlg()
79 //=================================================================================
81 //=================================================================================
82 double VTKPlugin_ExportDlg::getDeflection() const
84 return myDeflectionSB->value();
87 //=================================================================================
89 //=================================================================================
90 QString VTKPlugin_ExportDlg::getFileName( const Handle(SALOME_InteractiveObject)& io,
91 const QString& filters, const QString& caption,
92 QWidget* parent, double& deflection )
94 QStringList fls = filters.split( ";;", QString::SkipEmptyParts );
96 QString tmpfilename = io->getName();
97 tmpfilename = tmpfilename.simplified();
98 tmpfilename = tmpfilename.replace( QRegExp( "\\*" ), "" ).replace( QRegExp( "\\?" ), "" );
100 VTKPlugin_ExportDlg fd( io, parent );
101 fd.setFileMode( AnyFile );
102 fd.setNameFilters( fls );
103 fd.setWindowTitle( caption );
104 if ( !tmpfilename.isEmpty() )
105 fd.processPath( tmpfilename );
109 if ( fd.exec() == QDialog::Accepted ) {
110 filename = fd.selectedFile();
111 deflection = fd.getDeflection();
114 QApplication::processEvents();