--- /dev/null
+// Copyright (C) 2014 CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Lesser General Public License for more details.
+//
+// You should have received a copy of the GNU Lesser General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+//
+// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
+//
+
+// internal includes
+#include "DXFPlugin_ExportDlg.h"
+#include "DXFPlugin_Operations_i.hh"
+
+// GUI includes
+#include <SUIT_Session.h>
+#include <SUIT_Desktop.h>
+#include <SUIT_Tools.h>
+#include <SUIT_MessageBox.h>
+#include <SUIT_OverrideCursor.h>
+
+#include <SalomeApp_Application.h>
+
+// GEOM includes
+#include <GEOMBase.h>
+#include <GEOM_Operation.h>
+#include <GEOM_Constants.h>
+
+//=================================================================================
+// Constructor
+//=================================================================================
+DXFPlugin_ExportDlg::DXFPlugin_ExportDlg( Handle(SALOME_InteractiveObject)& object, QWidget* parent )
+: SUIT_FileDlg( parent, false, true, true ),
+ GEOMBase_Helper( dynamic_cast<SUIT_Desktop*>( parent ) )
+{
+ setWindowTitle( tr( "DXFPLUGIN_EXPORT_TITLE" ) );
+ setNameFilter( tr( "DXFPLUGIN_DXF_FILES" ) );
+
+ myObject = object;
+ const char* objectName = myObject->getName();
+ selectFile( QString( objectName ) );
+}
+
+//=================================================================================
+// Destructor
+//=================================================================================
+DXFPlugin_ExportDlg::~DXFPlugin_ExportDlg()
+{
+ // no need to delete child widgets, Qt does it all for us
+}
+
+//=================================================================================
+// function : createOperation
+// purpose :
+//=================================================================================
+GEOM::GEOM_IOperations_ptr DXFPlugin_ExportDlg::createOperation()
+{
+ return getGeomEngine()->GetPluginOperations( getStudyId(), "DXFPluginEngine" );
+}
+
+//=================================================================================
+// function : isValid
+// purpose :
+//=================================================================================
+bool DXFPlugin_ExportDlg::isValid( QString& msg )
+{
+ bool ok = true;
+ //@@ add custom validation actions here @@//
+ return ok;
+}
+
+//=================================================================================
+// function : execute
+// purpose :
+//=================================================================================
+bool DXFPlugin_ExportDlg::execute( ObjectList& objects )
+{
+ SalomeApp_Application* app = dynamic_cast< SalomeApp_Application* >( SUIT_Session::session()->activeApplication() );
+ if (!app) return false;
+
+ DXFPlugin::GEOM_IDXFPluginOperations_var aDXFOp = DXFPlugin::GEOM_IDXFPluginOperations::_narrow( getOperation() );
+ if ( aDXFOp->_is_nil() ) return false;
+
+ GEOM::GEOM_Object_var anObj = GEOMBase::ConvertIOinGEOMObject( myObject );
+ if ( anObj->_is_nil() ) return false;
+
+ QString aFile = selectedFile();
+
+ // User has pressed "Cancel" --> stop the operation
+ if ( aFile.isEmpty() )
+ return false;
+
+ GEOM_Operation* anOp = new GEOM_Operation( app, aDXFOp.in() );
+ try {
+ SUIT_OverrideCursor wc;
+ app->putInfo( tr("GEOM_PRP_EXPORT").arg(SUIT_Tools::file( aFile, /*withExten=*/true )) );
+ anOp->start();
+ aDXFOp->ExportDXF( anObj, aFile.toUtf8().constData() );
+ if( aDXFOp->IsDone() )
+ anOp->commit();
+ else {
+ anOp->abort();
+ wc.suspend();
+ SUIT_MessageBox::critical( app->desktop(),
+ QObject::tr("GEOM_ERROR"),
+ QObject::tr("GEOM_PRP_ABORT") + "\n" + QObject::tr( aDXFOp->GetErrorCode() ) );
+ return false;
+ }
+ }
+ catch( const SALOME::SALOME_Exception& S_ex ) {
+ anOp->abort();
+ return false;
+ }
+
+ objects.push_back( anObj._retn() );
+ return true;
+}
+
+void DXFPlugin_ExportDlg::accept()
+{
+ SUIT_FileDlg::accept();
+ onAccept(false);
+}