Salome HOME
Issue #3138: Create Import, Export sub-menus in File menu
authorvsv <vsv@opencascade.com>
Fri, 14 Feb 2020 11:45:23 +0000 (14:45 +0300)
committervsv <vsv@opencascade.com>
Fri, 14 Feb 2020 11:45:23 +0000 (14:45 +0300)
src/ExchangePlugin/plugin-Exchange.xml
src/SHAPERGUI/SHAPERGUI.cpp
src/SHAPERGUI/SHAPERGUI.h
src/XGUI/XGUI_SalomeConnector.h
src/XGUI/XGUI_Workshop.cpp
src/XGUI/XGUI_Workshop.h
src/XGUI/XGUI_msg_fr.ts

index f6248194572dc893fb1fb65b91e99adfd10a415e..d47c5cd83339c116ac1519f626dfda6363872f1b 100644 (file)
                 tooltip="Select the part to import the document" />
       </feature>
       <feature id="Import" title="Import" tooltip="Import a file" icon="icons/Exchange/import.png"
-               helpfile="importFeature.html"
-               internal="1">
+               helpfile="importFeature.html" internal="1">
         <file_selector id="file_path" title="Import file" path="">
           <validator id="ExchangePlugin_ImportFormat" parameters="BREP|BRP:BREP,STEP|STP:STEP,IGES|IGS:IGES,XAO:XAO" />
         </file_selector>
       </feature>
       <feature id="Export" title="Export" tooltip="Export to file" icon="icons/Exchange/export.png"
-               helpfile="exportFeature.html">
+               helpfile="exportFeature.html" internal="1">
         <source path="export_widget.xml" />
       </feature>
       <feature id="Dump" title="Dump" tooltip="Dump Python script" icon="icons/Exchange/dump.png"
index e9e7c0c0fddcea68b262c31c391c3977330e9f70..94fe8014a9647b3f085b53fffa44063c4dcaa645 100644 (file)
@@ -699,9 +699,14 @@ QAction* SHAPERGUI::addFeatureOfNested(const QString& theWBName,
 QAction* SHAPERGUI::addDesktopCommand(const QString& theId, const QString& theTitle,
                                            const QString& theTip, const QIcon& theIcon,
                                            const QKeySequence& theKeys, bool isCheckable,
-                                           const char* theMenuSourceText, const int theMenuPosition)
+                                           const char* theMenuSourceText,
+                                           const QString& theSubMenu,
+                                           const int theMenuPosition,
+                                           const int theSuibMenuPosition)
 {
   int aMenu = createMenu(tr(theMenuSourceText), -1, -1);
+  if (!theSubMenu.isNull())
+    aMenu = createMenu(theSubMenu, aMenu, -1, theSuibMenuPosition);
 
   int aId = getNextCommandId();
   myActionsList.append(aId);
index 1c52678385d50ea1ab3a12f52032bbd8579d5f45..f94f08e541423adb13ef1c24d726a4117e123d12 100644 (file)
@@ -91,10 +91,11 @@ Q_OBJECT
   virtual bool isFeatureOfNested(const QAction* theAction);
 
   virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
-                                     const QString& theTip, const QIcon& theIcon,
-                                     const QKeySequence& theKeys, bool isCheckable,
-                                     const char* theMenuSourceText,
-                                     const int theMenuPosition = 10);
+    const QString& theTip, const QIcon& theIcon,
+    const QKeySequence& theKeys, bool isCheckable,
+    const char* theMenuSourceText, const QString& theSubMenu = QString(),
+    const int theMenuPosition = 10,
+    const int theSuibMenuPosition = -1) Standard_OVERRIDE;
 
   virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
                                        const int theMenuPosition = 10);
index acf23e2bedad624445c442cd055e52efed61845f..c249619430129e3c6bc4e0e46efd9c4bf610b579 100644 (file)
@@ -92,13 +92,17 @@ class XGUI_EXPORT XGUI_SalomeConnector
   //! \param isCheckable - is checkable or not
   //! \param theKeys - hot keys
   //! \param theMenuSourceText - a source text of the desktop menu
+  //! \param theSubMenu - a sub-menu name
   //! \param theMenuPosition - a position of the command in the desktop menu
+  //! \param theSuibMenuPosition - a position of the sub-menu in the desktop menu
   //! returns created action
   virtual QAction* addDesktopCommand(const QString& theId, const QString& theTitle,
                                      const QString& theTip, const QIcon& theIcon,
                                      const QKeySequence& theKeys, bool isCheckable,
                                      const char* theMenuSourceText,
-                                     const int theMenuPosition = 10) = 0;
+                                     const QString& theSubMenu = QString(),
+                                     const int theMenuPosition = 10,
+                                     const int theSuibMenuPosition = -1) = 0;
 
   //! Insert separator into Edit menu of SALOME desktop
   virtual void addDesktopMenuSeparator(const char* theMenuSourceText,
index 799f5c00f172d71a5e96d06d435cd5b7b6381204..ac03c11b233e6c6b352e23bbc15a4864288b232d 100644 (file)
@@ -91,6 +91,7 @@
 #include <ExchangePlugin_ExportPart.h>
 #include <ExchangePlugin_ImportPart.h>
 #include <ExchangePlugin_Import.h>
+#include <ExchangePlugin_ExportFeature.h>
 
 #include <GeomAPI_Pnt.h>
 #include <GeomAPI_ShapeExplorer.h>
@@ -472,38 +473,43 @@ void XGUI_Workshop::initMenu()
 
 
   // Add commands to a file menu
-  aAction = salomeConnector()->addDesktopCommand("SAVEAS_CMD", tr("Export native..."),
-                                             tr("Export the current document into a native file"),
-                                              QIcon(), QKeySequence(),
-                                              false, "MEN_DESK_FILE");
-  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onSaveAs()));
-
-  aAction = salomeConnector()->addDesktopCommand("OPEN_CMD", tr("Import native..."),
+  // Import sub-menu
+  aAction = salomeConnector()->addDesktopCommand("OPEN_CMD", tr("Part set..."),
                                               tr("Import native file"),
                                               QIcon(), QKeySequence(),
-                                              false, "MEN_DESK_FILE");
+                                              false, "MEN_DESK_FILE", tr("Import"), 10, 10);
   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onOpen()));
-  salomeConnector()->addDesktopMenuSeparator("MEN_DESK_FILE");
 
-  aAction = salomeConnector()->addDesktopCommand("EXPORT_PART_CMD", tr("Export part..."),
-                                          tr("Export a part of the current document into a file"),
-                                          QIcon(), QKeySequence(),
-                                          false, "MEN_DESK_FILE");
-  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onExportPart()));
-
-  aAction = salomeConnector()->addDesktopCommand("IMPORT_PART_CMD", tr("Import part..."),
+  aAction = salomeConnector()->addDesktopCommand("IMPORT_PART_CMD", tr("Part..."),
                                           tr("Import structure of a part"),
                                           QIcon(), QKeySequence(),
-                                          false, "MEN_DESK_FILE");
+                                          false, "MEN_DESK_FILE", tr("Import"), 10, 10);
   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onImportPart()));
 
-  aAction = salomeConnector()->addDesktopCommand("IMPORT_SHAPE_CMD", tr("Import shape..."),
-    tr("Import shape from a file"),
+  aAction = salomeConnector()->addDesktopCommand("IMPORT_SHAPE_CMD", tr("From CAD format..."),
+    tr("Import shape from a CAD format file"),
     ModuleBase_IconFactory::loadIcon("icons/Exchange/import.png"),
-    QKeySequence(), false, "MEN_DESK_FILE");
+    QKeySequence(), false, "MEN_DESK_FILE", tr("Import"), 10, 10);
   connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onImportShape()));
 
-  salomeConnector()->addDesktopMenuSeparator("MEN_DESK_FILE");
+  // Export sub-menu
+  aAction = salomeConnector()->addDesktopCommand("SAVEAS_CMD", tr("Part set..."),
+                                             tr("Export the current document into a native file"),
+                                              QIcon(), QKeySequence(),
+                                              false, "MEN_DESK_FILE", tr("Export"), 10, 11);
+  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onSaveAs()));
+
+  aAction = salomeConnector()->addDesktopCommand("EXPORT_PART_CMD", tr("Part..."),
+                                          tr("Export a part of the current document into a file"),
+                                          QIcon(), QKeySequence(),
+                                          false, "MEN_DESK_FILE", tr("Export"), 10, 11);
+  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onExportPart()));
+
+  aAction = salomeConnector()->addDesktopCommand("EXPORT_SHAPE_CMD", tr("To CAD format..."),
+    tr("Export shape to a CAD format file"),
+    ModuleBase_IconFactory::loadIcon("icons/Exchange/export.png"),
+    QKeySequence(), false, "MEN_DESK_FILE", tr("Export"), 10, 11);
+  connect(aAction, SIGNAL(triggered(bool)), this, SLOT(onExportShape()));
 
 #else
   // File commands group
@@ -1321,6 +1327,17 @@ void XGUI_Workshop::onImportShape()
   }
 }
 
+//******************************************************
+void XGUI_Workshop::onExportShape()
+{
+  if (abortAllOperations()) {
+    ModuleBase_OperationFeature* anExportOp = dynamic_cast<ModuleBase_OperationFeature*>(
+        module()->createOperation(ExchangePlugin_ExportFeature::ID()));
+    myPropertyPanel->updateApplyPlusButton(anExportOp->feature());
+    operationMgr()->startOperation(anExportOp);
+  }
+}
+
 //******************************************************
 void XGUI_Workshop::onExportPart()
 {
index 2a3eacc147a1e7beb0fa42e3c9338c95b3f1901d..18f9cd77c3a3932aab81f4262c8e335a068b92e9 100644 (file)
@@ -405,12 +405,15 @@ signals:
   /// Import part structure from a file
   void onImportPart();
 
-  /// Import part structure from a file
+  /// Import shape from a file
   void onImportShape();
 
   /// Export features to a file
   void onExportPart();
 
+  /// Export a shape to a file
+  void onExportShape();
+
 #ifndef HAVE_SALOME
   /// Exit application
   void onExit();
index f6e80a04575f09542b7184e7f5be0a162daa3280..666c304585009f6888dc79de39ba9872133a9b77 100644 (file)
         <source>Windows</source>
         <translation>Fenêtres</translation>
     </message>
+    <message>
+        <source>Iso-lines...</source>
+        <translation>Iso-lines...</translation>
+    </message>
 </context>
 <context>
     <name>XGUI_DataTree</name>
     </message>
     <message>
         <source>Export native...</source>
-        <translation>Exporter natif...</translation>
+        <translation type="vanished">Exporter natif...</translation>
     </message>
     <message>
         <source>Export the current document into a native file</source>
     </message>
     <message>
         <source>Import native...</source>
-        <translation>Importer natif...</translation>
+        <translation type="vanished">Importer natif...</translation>
     </message>
     <message>
         <source>Import native file</source>
@@ -667,7 +671,7 @@ Supprimer des objets du panneau à afficher ?</translation>
     </message>
     <message>
         <source>Export part...</source>
-        <translation>Partie export...</translation>
+        <translation type="vanished">Partie export...</translation>
     </message>
     <message>
         <source>Export a part of the current document into a file</source>
@@ -675,11 +679,47 @@ Supprimer des objets du panneau à afficher ?</translation>
     </message>
     <message>
         <source>Import part...</source>
-        <translation>Importer une partie...</translation>
+        <translation type="vanished">Importer une partie...</translation>
     </message>
     <message>
         <source>Import structure of a part</source>
         <translation>Structure d&apos;importation d&apos;une pièce</translation>
     </message>
+    <message>
+        <source>Part set...</source>
+        <translation>Ensemble de parties...</translation>
+    </message>
+    <message>
+        <source>Import</source>
+        <translation>Importation</translation>
+    </message>
+    <message>
+        <source>Part...</source>
+        <translation>Partie...</translation>
+    </message>
+    <message>
+        <source>From CAD format...</source>
+        <translation>A partir du format CAO...</translation>
+    </message>
+    <message>
+        <source>Import shape from a CAD format file</source>
+        <translation>Importer une forme à partir d&apos;un fichier au format CAO</translation>
+    </message>
+    <message>
+        <source>Export</source>
+        <translation>Exporter</translation>
+    </message>
+    <message>
+        <source>To CAD format...</source>
+        <translation>Au format CAO...</translation>
+    </message>
+    <message>
+        <source>Number of Iso-lines</source>
+        <translation>Nombre de Iso-lignes</translation>
+    </message>
+    <message>
+        <source>Export shape to a CAD format file</source>
+        <translation>Exportation de la forme vers un fichier au format CAO</translation>
+    </message>
 </context>
 </TS>