From 587e24773aa198ac31386b569e3bcbce51547efb Mon Sep 17 00:00:00 2001 From: fps Date: Thu, 11 Apr 2013 15:50:20 +0000 Subject: [PATCH] improve export dialog and start import --- idl/GEOM_Gen.idl | 19 +- idl/GEOM_Superv.idl | 5 +- resources/GEOMCatalog.xml.in | 10 +- resources/Makefile.am | 2 +- resources/exportxao.png | Bin 0 -> 608 bytes resources/importxao.png | Bin 0 -> 544 bytes src/GEOMGUI/GEOM_images.ts | 20 +- src/GEOMGUI/GEOM_msg_en.ts | 61 ++++--- src/GEOMGUI/GEOM_msg_fr.ts | 36 ++++ src/GEOMGUI/GeometryGUI.cxx | 8 +- src/GEOMGUI/GeometryGUI_Operations.h | 1 + .../GEOMImpl_IImportExportOperations.cxx | 33 +++- .../GEOMImpl_IImportExportOperations.hxx | 25 +-- src/GEOM_I/GEOM_IImportExportOperations_i.cc | 107 ++++++----- src/GEOM_I/GEOM_IImportExportOperations_i.hh | 30 +-- src/GEOM_I_Superv/GEOM_Superv_i.cc | 22 ++- src/GEOM_I_Superv/GEOM_Superv_i.hh | 5 +- src/GEOM_SWIG/geompyDC.py | 16 +- src/ImportExportGUI/ImportExportGUI.cxx | 2 + .../ImportExportGUI_ExportXAODlg.cxx | 171 ++++++++++++------ .../ImportExportGUI_ExportXAODlg.h | 4 +- src/Makefile.am | 3 +- 22 files changed, 382 insertions(+), 198 deletions(-) create mode 100644 resources/exportxao.png create mode 100644 resources/importxao.png diff --git a/idl/GEOM_Gen.idl b/idl/GEOM_Gen.idl index 1e7b04485..2949b27ef 100644 --- a/idl/GEOM_Gen.idl +++ b/idl/GEOM_Gen.idl @@ -4013,15 +4013,26 @@ module GEOM { /*! * Export a shape to XAO Format - * \param exportingShape Shape to export * \param fileName The name of the exported file - * \param groups List of groups to export - * \param fields List of fields to export + * \param shape The shape to export + * \param groups The list of groups to export + * \param fields The list of fields to export * \return boolean indicating if export was succeful. */ - boolean ExportXAO(in GEOM_Object shape, in string fileName, in ListOfGO groups, in ListOfGO fields); + boolean ExportXAO(in string fileName, in GEOM_Object shape, in ListOfGO groups, in ListOfGO fields); + /*! + * Import a shape from XAO Format + * \param fileName The name of the imported file + * \param shape The imported shape + * \param groups The list of imported groups + * \param fields The list of imported fields + * \return boolean indicating if import was succeful. + */ + + //boolean ImportXAO(in string fileName, out GEOM_Object shape, out ListOfGO groups, out ListOfGO fields); + /*@@ insert new functions before this line @@ do not remove this line @@*/ }; diff --git a/idl/GEOM_Superv.idl b/idl/GEOM_Superv.idl index 0ba232316..8ab115aab 100644 --- a/idl/GEOM_Superv.idl +++ b/idl/GEOM_Superv.idl @@ -626,7 +626,10 @@ module GEOM //-----------------------------------------------------------// // ImportExportOperations // //-----------------------------------------------------------// - boolean ExportXAO(in GEOM_Object exportingShape, in string fileName, in GEOM_List groups, in GEOM_List fields); + boolean ExportXAO(in string fileName, in GEOM_Object exportingShape, + in GEOM_List groups, in GEOM_List fields); +// boolean ImportXAO(in string fileName, out GEOM_Object exportingShape, +// out GEOM_List groups, out GEOM_List fields); /*@@ insert new functions before this line @@ do not remove this line @@*/ }; diff --git a/resources/GEOMCatalog.xml.in b/resources/GEOMCatalog.xml.in index 36e2b904b..ecf47afeb 100644 --- a/resources/GEOMCatalog.xml.in +++ b/resources/GEOMCatalog.xml.in @@ -5312,16 +5312,16 @@ unknown 0 - - theExportingShape - GEOM_Object - Shape to export - theFileName string The name of the exported file + + theExportingShape + GEOM_Object + Shape to export + thelGroups GEOM_List diff --git a/resources/Makefile.am b/resources/Makefile.am index c8090b63d..fca8dfb7f 100644 --- a/resources/Makefile.am +++ b/resources/Makefile.am @@ -256,8 +256,8 @@ ADVANCED_RESOURCES += dlg_pipetshapefilletl2.png dlg_pipetshapefilletr2.png dlg_ ADVANCED_RESOURCES += dlg_pipetshapefilletrf.png # ADVANCED_RESOURCES += divideddisk.png divideddisk_r_ratio.png tree_divideddisk.png ADVANCED_RESOURCES += dividedcylinder.png dividedcylinder_r_h.png +ADVANCED_RESOURCES += exportxao.png importxao.png # tree_dividedcylinder.png -#IMPORTEXPORT_RESOURCES += exportxao.png exportxao_exportingshape_filename_lgroups_lfields.png tree_exportxao.png ##@@ insert new functions before this line @@ do not remove this line @@## dist_salomeres_DATA += $(ADVANCED_RESOURCES) diff --git a/resources/exportxao.png b/resources/exportxao.png new file mode 100644 index 0000000000000000000000000000000000000000..25e5b3d1fe525373a1cef581bc8040a15e65c81c GIT binary patch literal 608 zcmV-m0-ybfP)Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i*h< z4FMjjIUC^s000?uMObu0Z*6U5Zgc=ca%Ew3Wn>_CX>@2HM@dakSAh-}0005INklbF~anmhdbS^?Gq)l6B72ASKARnV3 zLj2eSaqtf?Sp-Qtx2q19E@^UKhunL6a+}5`1bpCd&imeTpYxpeIWJSuI3hBzp+tm; zkr04drKFto>i2yGJOHtocGLW zPmC*dDjFAOIJx(Jzv$O-VttP{9@b^sCuOx99|8e-flpiK_3LX8ZQO}ryLKs!EE_Qr zDW}L8(^Q&Tm((^d?J>tyn73Vi_g9fU2#y<_OiEX)Re;vB86RT9SIB zLASD60wP0P{w(2BFg^B>Y5OYE1?K9EnuYOz^}%2+jm!C?2S5n z5Mar=gUqsE#(;1LMkUG4agnpvJQ9&g8=+Dv1U&p7m*+RRc(J@f?x4)6M%K5>bL-?5 uKO=zgPnUavQfdqsZ&T*2;k|ZBH{1eKDtVjD=!j7O0000Px#24YJ`L;(K){{a7>y{D4^000SaNLh0L01FcU01FcV0GgZ_00007bV*G`2i*h< z4_CX>@2HM@dakSAh-}0004dNklP!s$QdC%aDNE@oNaYnSAHXK8QSHf6!ibHN(=~i;K<_Sk z%)i6!%O*`7CdZc%qJb1Wsu3`1x3iwlQi!xz>OJJ6UWGBB33t^)Y_gTq8`$2!53mry zU2mj{tG*y_B1`2NuC7}x^@2(P%}*{m&Jb|TBq^>e_}M=`;%ozVpJ(w7Ja+r(noFU3 ix49YSRdfLw|5D$|BzaMqKbZ#r0000DLG_PIPETSHAPE_W2 dlg_pipetshapew2.png - + DLG_PIPETSHAPE_FILLET dlg_pipetshapefillet.png @@ -1260,7 +1260,7 @@ DLG_PIPETSHAPE_FILLET_RF dlg_pipetshapefilletrf.png - + DLG_PIPETSHAPE_CHAMFER dlg_pipetshapechamfer.png @@ -1297,7 +1297,7 @@ DLG_PIPETSHAPE_CHAMFER_W dlg_pipetshapechamferw.png - + ICON_OBJBROWSER_ADVANCED_201 tree_pipetshape.png @@ -1337,15 +1337,23 @@ dividedcylinder.png - ICON_DLG_EXPORTXAO_EXPORTINGSHAPE_FILENAME_LGROUPS_LFIELDS - exportxao_exportingshape_filename_lgroups_lfields.png + ICON_DLG_EXPORTXAO + exportxao.png ICO_EXPORTXAO exportxao.png - ICON_OBJBROWSER_IMPORTEXPORT_200 + ICON_DLG_IMPORTXAO + importxao.png + + + ICO_IMPORTXAO + importxao.png + + + ICON_OBJBROWSER_IMPORTEXPORT_204 tree_exportxao.png diff --git a/src/GEOMGUI/GEOM_msg_en.ts b/src/GEOMGUI/GEOM_msg_en.ts index 658891901..9a9da47b3 100644 --- a/src/GEOMGUI/GEOM_msg_en.ts +++ b/src/GEOMGUI/GEOM_msg_en.ts @@ -4856,6 +4856,42 @@ be specified in meters). GEOM_SELECT_IMAGE Select image... + + MEN_IMPORTEXPORT + Import / Export + + + TOP_EXPORTXAO + Export to XAO + + + MEN_EXPORTXAO + Export XAO + + + STB_EXPORTXAO + Export shape to XAO format + + + TOP_IMPORTXAO + Import from XAO + + + MEN_IMPORTXAO + Import XAO + + + STB_IMPORTXAO + Import shape from XAO format + + + GEOM_IMPORTEXPORT_204 + Export XAO + + + XAO_FILES + XAO files (*.xao) + BasicGUI_CurveDlg @@ -5745,7 +5781,7 @@ Do you want to create new material? GEOM_EXPORTXAO_EXPORTINGSHAPE - Exporting Shape + Shape GEOM_EXPORTXAO_FILENAME @@ -5760,27 +5796,4 @@ Do you want to create new material? List of fields - - @default - - MEN_IMPORTEXPORT - Import / Export - - - TOP_EXPORTXAO - Export to XAO - - - MEN_EXPORTXAO - Export XAO - - - STB_EXPORTXAO - Export shape to XAO format - - - GEOM_IMPORTEXPORT_204 - Export XAO - - diff --git a/src/GEOMGUI/GEOM_msg_fr.ts b/src/GEOMGUI/GEOM_msg_fr.ts index 81d5072c6..dea9cceb5 100644 --- a/src/GEOMGUI/GEOM_msg_fr.ts +++ b/src/GEOMGUI/GEOM_msg_fr.ts @@ -4855,6 +4855,42 @@ le paramètre '%1' aux préférences du module Géométrie.GEOM_SELECT_IMAGE Sélectionner une image... + + MEN_IMPORTEXPORT + Import / Export + + + TOP_EXPORTXAO + Export XAO + + + MEN_EXPORTXAO + Export XAO + + + STB_EXPORTXAO + Exporter une forme au format XAO + + + TOP_IMPORTXAO + Import XAO + + + MEN_IMPORTXAO + Import XAO + + + STB_IMPORTXAO + Importer une forme au format XAO + + + GEOM_IMPORTEXPORT_204 + Export XAO + + + XAO_FILES + Fichiers XAO (*.xao) + BasicGUI_CurveDlg diff --git a/src/GEOMGUI/GeometryGUI.cxx b/src/GEOMGUI/GeometryGUI.cxx index 37528db55..1da02642a 100644 --- a/src/GEOMGUI/GeometryGUI.cxx +++ b/src/GEOMGUI/GeometryGUI.cxx @@ -580,6 +580,7 @@ void GeometryGUI::OnGUIEvent( int id ) libName = "AdvancedGUI"; break; case GEOMOp::OpExportXAO: // MENU NEW ENTITY - IMPORTEXPORT - EXPORTXAO + case GEOMOp::OpImportXAO: // MENU NEW ENTITY - IMPORTEXPORT - IMPORTXAO libName = "ImportExportGUI"; break; default: @@ -910,6 +911,7 @@ void GeometryGUI::initialize( CAM_Application* app ) createGeomAction( GEOMOp::OpDividedDisk, "DIVIDEDDISK" ); createGeomAction( GEOMOp::OpDividedCylinder, "DIVIDEDCYLINDER" ); createGeomAction( GEOMOp::OpExportXAO, "EXPORTXAO" ); + createGeomAction( GEOMOp::OpImportXAO, "IMPORTXAO" ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// // ---- create menus -------------------------- @@ -961,7 +963,8 @@ void GeometryGUI::initialize( CAM_Application* app ) int impexpId = createMenu( tr( "MEN_IMPORTEXPORT" ), newEntId, -1 ); - createMenu( GEOMOp::OpExportXAO, impexpId, -1 ); + createMenu( GEOMOp::OpExportXAO, impexpId, -1 ); + createMenu( GEOMOp::OpImportXAO, impexpId, -1 ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// createMenu( separator(), newEntId, -1 ); @@ -1234,7 +1237,8 @@ void GeometryGUI::initialize( CAM_Application* app ) int impexpTbId = createTool( tr( "TOOL_IMPORTEXPORT" ) ); - createTool( GEOMOp::OpExportXAO, impexpTbId ); + createTool( GEOMOp::OpExportXAO, impexpTbId ); + createTool( GEOMOp::OpImportXAO, impexpTbId ); //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@ do not remove this line @@// // ---- create popup menus -------------------------- diff --git a/src/GEOMGUI/GeometryGUI_Operations.h b/src/GEOMGUI/GeometryGUI_Operations.h index f08bb5653..e648539f9 100644 --- a/src/GEOMGUI/GeometryGUI_Operations.h +++ b/src/GEOMGUI/GeometryGUI_Operations.h @@ -194,6 +194,7 @@ namespace GEOMOp { OpDividedCylinder = 10004, // MENU NEW ENTITY - ADVANCED - DIVIDEDCYLINDER // ImportExport ----------------//-------------------------------- OpExportXAO = 10005, // MENU NEW ENTITY - IMPORTEXPORT - EXPORTXAO + OpImportXAO = 10006, // MENU NEW ENTITY - IMPORTEXPORT - IMPORTXAO //@@ insert new functions before this line @@ do not remove this line @@// }; } diff --git a/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx b/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx index b2bb65309..01b7f80be 100644 --- a/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx +++ b/src/GEOMImpl/GEOMImpl_IImportExportOperations.cxx @@ -111,15 +111,15 @@ GEOMImpl_IImportExportOperations::~GEOMImpl_IImportExportOperations() //============================================================================= /*! * Export a shape to XAO Format - * \param shape The shape to export * \param fileName The name of the exported file - * \param groupList The list of groups to export - * \param fieldList The list of fields to export - * \return New GEOM_Object, containing the created shape. + * \param shape The shape to export + * \param groups The list of groups to export + * \param fields The list of fields to export + * \return boolean indicating if export was succeful. */ //============================================================================= -bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape, - const std::string fileName, +bool GEOMImpl_IImportExportOperations::ExportXAO(const std::string fileName, + Handle(GEOM_Object) shape, std::list groupList, std::list fieldList) { @@ -271,4 +271,25 @@ bool GEOMImpl_IImportExportOperations::ExportXAO(Handle(GEOM_Object) shape, return true; } + +//============================================================================= +/*! + * Import a shape from XAO Format + * \param fileName The name of the imported file + * \param shape The imported shape + * \param groups The list of imported groups + * \param fields The list of imported fields + * \return boolean indicating if import was succeful. + */ +//============================================================================= +//bool GEOMImpl_IImportExportOperations::ImportXAO(const std::string fileName, +// Handle(GEOM_Object) shape, +// std::list groupList, +// std::list fieldList) +//{ +// SetErrorCode(KO); +// return true; +//} + + /*@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@*/ diff --git a/src/GEOMImpl/GEOMImpl_IImportExportOperations.hxx b/src/GEOMImpl/GEOMImpl_IImportExportOperations.hxx index 6167f3571..fcc19c39d 100644 --- a/src/GEOMImpl/GEOMImpl_IImportExportOperations.hxx +++ b/src/GEOMImpl/GEOMImpl_IImportExportOperations.hxx @@ -29,14 +29,6 @@ #include -/*class GEOMImpl_IBasicOperations; - class GEOMImpl_IBooleanOperations; - class GEOMImpl_IShapesOperations; - class GEOMImpl_ITransformOperations; - class GEOMImpl_IBlocksOperations; - class GEOMImpl_I3DPrimOperations; - class GEOMImpl_ILocalOperations; - class GEOMImpl_IHealingOperations;*/ class GEOMImpl_IShapesOperations; class GEOMImpl_IGroupOperations; @@ -44,14 +36,7 @@ class GEOMImpl_IImportExportOperations: public GEOM_IOperations { private: - /*GEOMImpl_IBasicOperations* myBasicOperations; - GEOMImpl_IBooleanOperations* myBooleanOperations; - GEOMImpl_IShapesOperations* myShapesOperations; - GEOMImpl_ITransformOperations* myTransformOperations; - GEOMImpl_IBlocksOperations* myBlocksOperations; - GEOMImpl_I3DPrimOperations* my3DPrimOperations; - GEOMImpl_ILocalOperations* myLocalOperations; - GEOMImpl_IHealingOperations* myHealingOperations;*/ + GEOMImpl_IShapesOperations* m_shapesOperations; GEOMImpl_IGroupOperations* m_groupOperations; @@ -59,10 +44,14 @@ public: Standard_EXPORT GEOMImpl_IImportExportOperations(GEOM_Engine* engine, int docID); Standard_EXPORT ~GEOMImpl_IImportExportOperations(); - Standard_EXPORT bool ExportXAO (Handle(GEOM_Object) shape, - const std::string fileName, + Standard_EXPORT bool ExportXAO (const std::string fileName, + Handle(GEOM_Object) shape, std::list groupList, std::list fieldList); +// Standard_EXPORT bool ImportXAO (const std::string fileName, +// Handle(GEOM_Object) shape, +// std::list groupList, +// std::list fieldList); /*@@ insert new functions before this line @@ do not remove this line @@*/ }; #endif diff --git a/src/GEOM_I/GEOM_IImportExportOperations_i.cc b/src/GEOM_I/GEOM_IImportExportOperations_i.cc index 5621e006b..e9c257a48 100644 --- a/src/GEOM_I/GEOM_IImportExportOperations_i.cc +++ b/src/GEOM_I/GEOM_IImportExportOperations_i.cc @@ -36,10 +36,12 @@ * constructor: */ //============================================================================= -GEOM_IImportExportOperations_i::GEOM_IImportExportOperations_i(PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IImportExportOperations* theImpl) -:GEOM_IOperations_i(thePOA, theEngine, theImpl) +GEOM_IImportExportOperations_i::GEOM_IImportExportOperations_i(PortableServer::POA_ptr thePOA, + GEOM::GEOM_Gen_ptr theEngine, ::GEOMImpl_IImportExportOperations* theImpl) +: + GEOM_IOperations_i(thePOA, theEngine, theImpl) { - MESSAGE("GEOM_IImportExportOperations_i::GEOM_IImportExportOperations_i"); + MESSAGE("GEOM_IImportExportOperations_i::GEOM_IImportExportOperations_i"); } //============================================================================= @@ -49,55 +51,74 @@ GEOM_IImportExportOperations_i::GEOM_IImportExportOperations_i(PortableServer::P //============================================================================= GEOM_IImportExportOperations_i::~GEOM_IImportExportOperations_i() { - MESSAGE("GEOM_IImportExportOperations_i::~GEOM_IImportExportOperations_i"); + MESSAGE("GEOM_IImportExportOperations_i::~GEOM_IImportExportOperations_i"); } //============================================================================= /*! * Export a shape to XAO Format - * \param theExportingShape Shape to export - * \param theFileName The name of the exported file - * \param thelGroups List of groups to export - * \param thelFields List of fields to export - * \return New GEOM_Object, containing the created shape. + * \param fileName The name of the exported file + * \param shape The shape to export + * \param groups The list of groups to export + * \param fields The list of fields to export + * \return boolean indicating if export was succeful. */ //============================================================================= -CORBA::Boolean GEOM_IImportExportOperations_i::ExportXAO (GEOM::GEOM_Object_ptr theExportingShape, const char* theFileName, const GEOM::ListOfGO& thelGroups, const GEOM::ListOfGO& thelFields) +CORBA::Boolean GEOM_IImportExportOperations_i::ExportXAO(const char* fileName, + GEOM::GEOM_Object_ptr shape, const GEOM::ListOfGO& groups, const GEOM::ListOfGO& fields) { - bool isGood = false; - //Set a not done flag - GetOperations()->SetNotDone(); - - // Get the reference shape - Handle(GEOM_Object) aReference = GetObjectImpl(theExportingShape); - - //Get the reference groups - int ind = 0; - int aLenGroup = thelGroups.length(); - std::list aGroups; - for (; ind < aLenGroup; ind++) { - Handle(GEOM_Object) aGroup = GetObjectImpl(thelGroups[ind]); - if (aGroup.IsNull()) return false; - aGroups.push_back(aGroup); - } - - //Get the reference point - ind = 0; - int aLenField = thelFields.length(); - std::list aFields; - for (; ind < aLenField; ind++) { - Handle(GEOM_Object) aField = GetObjectImpl(thelFields[ind]); - if (aField.IsNull()) return false; - aFields.push_back(aField); - } - - if (!aReference.IsNull()) - { - // Export XAO - isGood = GetOperations()->ExportXAO(aReference, theFileName, aGroups, aFields); - } + bool isGood = false; + //Set a not done flag + GetOperations()->SetNotDone(); - return isGood; + // Get the reference shape + Handle(GEOM_Object) reference = GetObjectImpl(shape); + + //Get the reference groups + int ind = 0; + std::list groupsObj; + for (; ind < groups.length(); ind++) + { + Handle(GEOM_Object) gobj = GetObjectImpl(groups[ind]); + if (gobj.IsNull()) return false; + groupsObj.push_back(gobj); + } + + //Get the reference point + ind = 0; + std::list fieldsObj; + for (; ind < fields.length(); ind++) + { + Handle(GEOM_Object) fobj = GetObjectImpl(fields[ind]); + if (fobj.IsNull()) return false; + fieldsObj.push_back(fobj); + } + + if (!reference.IsNull()) + { + // Export XAO + isGood = GetOperations()->ExportXAO(fileName, reference, groupsObj, fieldsObj); + } + + return isGood; } +//============================================================================= +/*! + * Import a shape from XAO Format + * \param fileName The name of the imported file + * \param shape The imported shape + * \param groups The list of imported groups + * \param fields The list of imported fields + * \return boolean indicating if import was succeful. + */ +//============================================================================= +//bool GEOMImpl_IImportExportOperations::ImportXAO(const std::string fileName, +// Handle(GEOM_Object), +// std::list > groups, +// std::list > fields) +//{ +// return true; +//} + /*@@ insert new functions before this line @@ do not remove this line @@*/ diff --git a/src/GEOM_I/GEOM_IImportExportOperations_i.hh b/src/GEOM_I/GEOM_IImportExportOperations_i.hh index dbcc9f7a2..f47460bd8 100644 --- a/src/GEOM_I/GEOM_IImportExportOperations_i.hh +++ b/src/GEOM_I/GEOM_IImportExportOperations_i.hh @@ -34,19 +34,25 @@ #include "GEOMImpl_IImportExportOperations.hxx" class GEOM_I_EXPORT GEOM_IImportExportOperations_i : - public virtual POA_GEOM::GEOM_IImportExportOperations, - public virtual GEOM_IOperations_i +public virtual POA_GEOM::GEOM_IImportExportOperations, +public virtual GEOM_IOperations_i { - public: - GEOM_IImportExportOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, - ::GEOMImpl_IImportExportOperations* theImpl); - ~GEOM_IImportExportOperations_i(); - - CORBA::Boolean ExportXAO (GEOM::GEOM_Object_ptr theExportingShape, const char* theFileName, const GEOM::ListOfGO& thelGroups, const GEOM::ListOfGO& thelFields); - /*@@ insert new functions before this line @@ do not remove this line @@*/ - - ::GEOMImpl_IImportExportOperations* GetOperations() - { return (::GEOMImpl_IImportExportOperations*)GetImpl(); } +public: + GEOM_IImportExportOperations_i (PortableServer::POA_ptr thePOA, GEOM::GEOM_Gen_ptr theEngine, + ::GEOMImpl_IImportExportOperations* theImpl); + ~GEOM_IImportExportOperations_i(); + + CORBA::Boolean ExportXAO (const char* fileName, + GEOM::GEOM_Object_ptr shape, + const GEOM::ListOfGO& groups, + const GEOM::ListOfGO& fields); + CORBA::Boolean ImportXAO (const char* fileName, GEOM::GEOM_Object_out shape, + GEOM::ListOfGO_out groups, + GEOM::ListOfGO_out fields); + /*@@ insert new functions before this line @@ do not remove this line @@*/ + + ::GEOMImpl_IImportExportOperations* GetOperations() + { return (::GEOMImpl_IImportExportOperations*)GetImpl();} }; #endif diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.cc b/src/GEOM_I_Superv/GEOM_Superv_i.cc index f6905d3b1..6846808ac 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.cc +++ b/src/GEOM_I_Superv/GEOM_Superv_i.cc @@ -3451,18 +3451,19 @@ GEOM::GEOM_Object_ptr GEOM_Superv_i::MakeDividedCylinder (CORBA::Double theR, //============================================================================= // ExportXAO //============================================================================= -CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr theExportingShape, const char* theFileName, GEOM::GEOM_List_ptr thelGroups, GEOM::GEOM_List_ptr thelFields) +CORBA::Boolean GEOM_Superv_i::ExportXAO (const char* fileName, GEOM::GEOM_Object_ptr shape, + GEOM::GEOM_List_ptr groups, GEOM::GEOM_List_ptr fields) { beginService( " GEOM_Superv_i::ExportXAO" ); MESSAGE("GEOM_Superv_i::ExportXAO"); getImportExportOp(); - if (GEOM_List_i* aListImplG = - dynamic_cast*>(GetServant(thelGroups, myPOA).in())) + if (GEOM_List_i* groupList = + dynamic_cast*>(GetServant(groups, myPOA).in())) { - if (GEOM_List_i* aListImplF = - dynamic_cast*>(GetServant(thelFields, myPOA).in())) + if (GEOM_List_i* fieldList = + dynamic_cast*>(GetServant(fields, myPOA).in())) { - CORBA::Boolean isGood = myImportExportOp->ExportXAO(theExportingShape, theFileName, aListImplG->GetList(), aListImplF->GetList()); + CORBA::Boolean isGood = myImportExportOp->ExportXAO(fileName, shape, groupList->GetList(), fieldList->GetList()); endService( " GEOM_Superv_i::ExportXAO" ); return isGood; } @@ -3470,6 +3471,15 @@ CORBA::Boolean GEOM_Superv_i::ExportXAO (GEOM::GEOM_Object_ptr theExportingShape endService( " GEOM_Superv_i::ExportXAO" ); return false; } + +//============================================================================= +// ImportXAO +//============================================================================= +//CORBA::Boolean GEOM_Superv_i::ImportXAO (const char* fileName, GEOM::GEOM_Object_out shape, +// GEOM::GEOM_List_out groups, GEOM::GEOM_List_out fields) +//{ +// return false; +//} /*@@ insert new functions before this line @@ do not remove this line @@*/ //===================================================================================== diff --git a/src/GEOM_I_Superv/GEOM_Superv_i.hh b/src/GEOM_I_Superv/GEOM_Superv_i.hh index bd6b4cf85..f66cfbcf5 100644 --- a/src/GEOM_I_Superv/GEOM_Superv_i.hh +++ b/src/GEOM_I_Superv/GEOM_Superv_i.hh @@ -715,7 +715,10 @@ public: //-----------------------------------------------------------// // ImportExport Operations // //-----------------------------------------------------------// - CORBA::Boolean ExportXAO (GEOM::GEOM_Object_ptr theExportingShape, const char* theFileName, GEOM::GEOM_List_ptr thelGroups, GEOM::GEOM_List_ptr thelFields); + CORBA::Boolean ExportXAO(const char* fileName, + GEOM::GEOM_Object_ptr shape, GEOM::GEOM_List_ptr groups, GEOM::GEOM_List_ptr fields); +// CORBA::Boolean ImportXAO(const char* fileName, GEOM::GEOM_Object_out shape, +// GEOM::GEOM_List_out groups, GEOM::GEOM_List_out fields); /*@@ insert new functions before this line @@ do not remove this line @@*/ private: diff --git a/src/GEOM_SWIG/geompyDC.py b/src/GEOM_SWIG/geompyDC.py index f515c9e1b..00c0fa5e1 100644 --- a/src/GEOM_SWIG/geompyDC.py +++ b/src/GEOM_SWIG/geompyDC.py @@ -9074,16 +9074,16 @@ class geompyDC(GEOM._objref_GEOM_Gen): return anObj ## Export a shape to XAO Format - # @param theExportingShape Shape to export - # @param theFileName The name of the exported file - # @param thelGroups List of groups to export - # @param thelFields List of fields to export - # @return New GEOM_Object, containing the created shape. + # @param shape Shape to export + # @param fileName The name of the exported file + # @param groups List of groups to export + # @param fields List of fields to export + # @return boolean # # @ref tui_creation_exportxao "Example" - def ExportXAO(self, theExportingShape, theFileName, thelGroups, thelFields): - theExportingShape, theFileName, thelGroups, thelFields, Parameters = ParseParameters(theExportingShape, theFileName, thelGroups, thelFields) - isGood = self.ImpExpOp.ExportXAO(theExportingShape, theFileName, thelGroups, thelFields) + def ExportXAO(self, fileName, shape, groups, fields): + fileName, shape, groups, fields, Parameters = ParseParameters(fileName, shape, groups, fields) + isGood = self.ImpExpOp.ExportXAO(fileName, shape, groups, fields) RaiseIfFailed("ExportXAO", self.ImpExpOp) #if Parameters: anObj.SetParameters(Parameters) return isGood diff --git a/src/ImportExportGUI/ImportExportGUI.cxx b/src/ImportExportGUI/ImportExportGUI.cxx index a79265304..b6b1bb9f3 100644 --- a/src/ImportExportGUI/ImportExportGUI.cxx +++ b/src/ImportExportGUI/ImportExportGUI.cxx @@ -71,6 +71,8 @@ bool ImportExportGUI::OnGUIEvent(int commandId, SUIT_Desktop* parent) case GEOMOp::OpExportXAO: dialog = new ImportExportGUI_ExportXAODlg(getGeometryGUI(), parent); break; + case GEOMOp::OpImportXAO: + break; //@@ insert new functions before this line @@ do not remove this line @@ do not remove this line @@// default: app->putInfo(tr("GEOM_PRP_COMMAND").arg(commandId)); diff --git a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx index 4e069442d..845f74243 100644 --- a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx +++ b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.cxx @@ -30,6 +30,7 @@ #include #include #include +#include #include //#include @@ -54,7 +55,7 @@ ImportExportGUI_ExportXAODlg::ImportExportGUI_ExportXAODlg(GeometryGUI* geometry m_mainObj = GEOM::GEOM_Object::_nil(); SUIT_ResourceMgr* resMgr = SUIT_Session::session()->resourceMgr(); - QPixmap imageOp(resMgr->loadPixmap("GEOM", tr("ICON_DLG_EXPORTXAO_EXPORTINGSHAPE_FILENAME_LGROUPS_LFIELDS"))); + QPixmap imageOp(resMgr->loadPixmap("GEOM", tr("ICON_DLG_EXPORTXAO"))); QPixmap iconSelect(resMgr->loadPixmap("GEOM", tr("ICON_SELECT"))); setWindowTitle(tr("GEOM_EXPORTXAO_TITLE")); @@ -67,57 +68,76 @@ ImportExportGUI_ExportXAODlg::ImportExportGUI_ExportXAODlg(GeometryGUI* geometry mainFrame()->RadioButton3->setAttribute(Qt::WA_DeleteOnClose); mainFrame()->RadioButton3->close(); + // hide name + mainFrame()->GroupBoxName->hide(); + + //**************************** + // Selection Group box QGroupBox* gbxExport = new QGroupBox(parent); - QGridLayout *gridLayoutExport = new QGridLayout(gbxExport); + QGridLayout* gridLayoutExport = new QGridLayout(gbxExport); #ifndef Q_OS_MAC gridLayoutExport->setSpacing(6); -#endif -#ifndef Q_OS_MAC gridLayoutExport->setContentsMargins(9, 9, 9, 9); #endif gridLayoutExport->setObjectName(QString::fromUtf8("gridLayoutExport")); - //**************************** - QLabel* txtLabel1 = new QLabel(tr("GEOM_EXPORTXAO_EXPORTINGSHAPE"), gbxExport); - gridLayoutExport->addWidget(txtLabel1, 0, 0, 1, 1); - - btnSelect = new QPushButton(gbxExport); - btnSelect->setIcon(iconSelect); - gridLayoutExport->addWidget(btnSelect, 0, 1, 1, 1); - + // Line 0 + QLabel* lblShape = new QLabel(tr("GEOM_EXPORTXAO_EXPORTINGSHAPE"), gbxExport); + btnShapeSelect = new QPushButton(gbxExport); + btnShapeSelect->setIcon(iconSelect); ledShape = new QLineEdit(gbxExport); ledShape->setMinimumSize(QSize(100, 0)); - gridLayoutExport->addWidget(ledShape, 0, 2, 1, 1); - //**************************** - QLabel* txtLabel2 = new QLabel(tr("GEOM_EXPORTXAO_FILENAME"), gbxExport); - gridLayoutExport->addWidget(txtLabel2, 1, 0, 1, 1); + gridLayoutExport->addWidget(lblShape, 0, 0, 1, 1); + gridLayoutExport->addWidget(btnShapeSelect, 0, 1, 1, 1); + gridLayoutExport->addWidget(ledShape, 0, 2, 1, 1); + // Line 1 + QLabel* lblFileName = new QLabel(tr("GEOM_EXPORTXAO_FILENAME"), gbxExport); + btnFileSelect = new QPushButton(gbxExport); ledFileName = new QLineEdit(gbxExport); - gridLayoutExport->addWidget(ledFileName, 1, 1, 1, 2); + btnFileSelect->setText("..."); + + gridLayoutExport->addWidget(lblFileName, 1, 0, 1, 1); + gridLayoutExport->addWidget(btnFileSelect, 1, 1, 1, 1); + gridLayoutExport->addWidget(ledFileName, 1, 2, 1, 1); //**************************** - QLabel* txtLabel3 = new QLabel(tr("GEOM_EXPORTXAO_LGROUPS"), gbxExport); - gridLayoutExport->addWidget(txtLabel3, 2, 0, 1, 2); + // Filter Group box + QGroupBox* gbxFilter = new QGroupBox(parent); + + QGridLayout* gridLayoutFilter = new QGridLayout(gbxFilter); +#ifndef Q_OS_MAC + gridLayoutFilter->setSpacing(6); + gridLayoutFilter->setContentsMargins(9, 9, 9, 9); +#endif + gridLayoutFilter->setObjectName(QString::fromUtf8("gbxFilter")); + + // Line 0 + QLabel* lblGroups = new QLabel(tr("GEOM_EXPORTXAO_LGROUPS"), gbxFilter); + QLabel* lblFields = new QLabel(tr("GEOM_EXPORTXAO_LFIELDS"), gbxFilter); - lstGroups = new QListWidget(gbxExport); - gridLayoutExport->addWidget(lstGroups, 3, 0, 1, 2); + gridLayoutFilter->addWidget(lblGroups, 0, 0, 1, 1); + gridLayoutFilter->addWidget(lblFields, 0, 1, 1, 1); - QLabel* txtLabel4 = new QLabel(tr("GEOM_EXPORTXAO_LFIELDS"), gbxExport); - gridLayoutExport->addWidget(txtLabel4, 2, 2, 1, 1); + // Line 1 + lstGroups = new QListWidget(gbxFilter); + lstGroups->setSelectionMode(QAbstractItemView::ExtendedSelection); + lstFields = new QListWidget(gbxFilter); + lstFields ->setSelectionMode(QAbstractItemView::ExtendedSelection); - lstFields = new QListWidget(gbxExport); - gridLayoutExport->addWidget(lstFields, 3, 2, 1, 1); + gridLayoutFilter->addWidget(lstGroups, 1, 0, 1, 1); + gridLayoutFilter->addWidget(lstFields, 1, 1, 1, 1); + //**************************** QVBoxLayout* layout = new QVBoxLayout(centralWidget()); layout->setMargin(0); layout->setSpacing(6); layout->addWidget(gbxExport); + layout->addWidget(gbxFilter); - //QWidget::setTabOrder(PushButton1, LineEdit1); - //QWidget::setTabOrder(LineEdit1, LineEdit2); - + // set help setHelpFileName("create_exportxao_page.html"); Init(); @@ -145,10 +165,13 @@ void ImportExportGUI_ExportXAODlg::Init() connect(buttonOk(), SIGNAL(clicked()), this, SLOT(ClickOnOk())); connect(buttonApply(), SIGNAL(clicked()), this, SLOT(ClickOnApply())); - connect(btnSelect, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); + connect(btnShapeSelect, SIGNAL(clicked()), this, SLOT(SetEditCurrentArgument())); connect(((SalomeApp_Application*) (SUIT_Session::session()->activeApplication()))->selectionMgr(), SIGNAL(currentSelectionChanged()), this, SLOT(SelectionIntoArgument())); + connect(btnFileSelect, SIGNAL(clicked()), this, SLOT(btnFileSelectClicked())); + + initName(tr("GEOM_EXPORTXAO")); SelectionIntoArgument(); } @@ -159,22 +182,33 @@ void ImportExportGUI_ExportXAODlg::Init() //================================================================================= void ImportExportGUI_ExportXAODlg::processObject() { + lstGroups->clear(); + lstFields->clear(); + m_groups.clear(); + m_fields.clear(); + if (m_mainObj->_is_nil()) { ledShape->setText(""); - ledFileName->setText(""); } else { ledShape->setText(GEOMBase::GetName(m_mainObj)); GEOM::GEOM_IShapesOperations_var shapeOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - GEOM::ListOfGO_var groups = shapeOp->GetExistingSubObjects(m_mainObj, true); + // add groups names + GEOM::ListOfGO_var groups = shapeOp->GetExistingSubObjects(m_mainObj, true); for (int i = 0, n = groups->length(); i < n; i++) { - lstGroups->addItem(GEOMBase::GetName(groups[i])); + QListWidgetItem* item = new QListWidgetItem(); + item->setData(Qt::UserRole, QVariant(i)); + item->setText(GEOMBase::GetName(groups[i])); + lstGroups->addItem(item); m_groups.append(GEOM::GeomObjPtr(groups[i].in())); } + lstGroups->sortItems(Qt::AscendingOrder); + + // TODO: add fields } } @@ -214,20 +248,11 @@ void ImportExportGUI_ExportXAODlg::SelectionIntoArgument() SALOME_ListIO selList; selMgr->selectedObjects(selList); - if (selList.Extent() != 1) + if (selList.Extent() == 1) { - processObject(); - return; + m_mainObj = GEOMBase::ConvertIOinGEOMObject(selList.First()); } - /*GEOM::GEOM_Object_var aSelectedObject*/m_mainObj = GEOMBase::ConvertIOinGEOMObject(selList.First()); - - /*if ( aSelectedObject->_is_nil() ) { - processObject(); - return; - }*/ - - //myMainObj = aSelectedObject; processObject(); } @@ -241,6 +266,20 @@ void ImportExportGUI_ExportXAODlg::SetEditCurrentArgument() myEditCurrentArgument = ledShape; SelectionIntoArgument(); } + +//================================================================================= +// function : btnFileSelectClicked() +// purpose : +//================================================================================= +void ImportExportGUI_ExportXAODlg::btnFileSelectClicked() +{ + QString selFile = QFileDialog::getSaveFileName(this, tr("GEOM_SELECT_XAO"), QString(), tr("XAO_FILES")); + if (!selFile.isEmpty()) + { + ledFileName->setText(selFile); + } +} + //================================================================================= // function : ActivateThisDialog() // purpose : @@ -275,11 +314,15 @@ GEOM::GEOM_IOperations_ptr ImportExportGUI_ExportXAODlg::createOperation() //================================================================================= bool ImportExportGUI_ExportXAODlg::isValid(QString& msg) { - bool ok = true; + // check shape + if (ledShape->text().isEmpty()) + return false; - //@@ add custom validation actions here @@// + // check file name + if (ledFileName->text().isEmpty()) + return false; - return ok; + return true; } //================================================================================= @@ -290,23 +333,33 @@ bool ImportExportGUI_ExportXAODlg::execute(ObjectList& objects) { bool res = false; - GEOM::GEOM_Object_var obj; - - GEOM::GEOM_IImportExportOperations_var ieOp = GEOM::GEOM_IImportExportOperations::_narrow(getOperation()); - GEOM::GEOM_IShapesOperations_var shapesOp = getGeomEngine()->GetIShapesOperations(getStudyId()); - GEOM::ListOfGO_var groups = shapesOp->GetExistingSubObjects(m_mainObj, true); + // get selected groups + QList selGroups = lstGroups->selectedItems(); + GEOM::ListOfGO_var groups = new GEOM::ListOfGO(); + groups->length(selGroups.count()); + int i = 0; + for (QList::iterator it = selGroups.begin(); it != selGroups.end(); ++it) + { + QListWidgetItem* item = (*it); + int index = item->data(Qt::UserRole).toInt(); + groups[i++] = m_groups[index].copy(); + } + + // get selected fields + QList selFields = lstFields->selectedItems(); GEOM::ListOfGO_var fields = new GEOM::ListOfGO(); - - groups->length(m_groups.count()); - for (int i = 0; i < m_groups.count(); i++) - groups[i] = m_groups[i].copy(); - fields->length(m_fields.count()); - for (int i = 0; i < m_fields.count(); i++) - fields[i] = m_fields[i].copy(); + for (QList::iterator it = selFields.begin(); it != selFields.end(); ++it) + { + QListWidgetItem* item = (*it); + int index = item->data(Qt::UserRole).toInt(); + fields[i++] = m_fields[index].copy(); + } // call engine function - res = ieOp->ExportXAO(m_mainObj, ledFileName->text().toStdString().c_str(), groups, fields); + GEOM::GEOM_IImportExportOperations_var ieOp = GEOM::GEOM_IImportExportOperations::_narrow(getOperation()); + res = ieOp->ExportXAO(ledFileName->text().toStdString().c_str(), + m_mainObj, groups, fields); return res; } diff --git a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h index c0c212673..60f5b92ad 100644 --- a/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h +++ b/src/ImportExportGUI/ImportExportGUI_ExportXAODlg.h @@ -59,7 +59,8 @@ private: QLineEdit* ledFileName; QListWidget* lstGroups; QListWidget* lstFields; - QPushButton* btnSelect; + QPushButton* btnShapeSelect; + QPushButton* btnFileSelect; private slots: void ClickOnOk(); @@ -68,6 +69,7 @@ private slots: void LineEditReturnPressed(); void SelectionIntoArgument(); void SetEditCurrentArgument(); + void btnFileSelectClicked(); }; #endif // IMPORTEXPORTGUI_EXPORTXAODLG_H diff --git a/src/Makefile.am b/src/Makefile.am index 873ea299c..0ca45f805 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -35,12 +35,13 @@ if GEOM_ENABLE_GUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI EntityGUI BuildGUI \ BooleanGUI TransformationGUI OperationGUI RepairGUI MeasureGUI \ GroupGUI BlocksGUI AdvancedGUI ImportExportGUI GEOM_SWIG_WITHIHM -endif if CPPUNIT_IS_OK SUBDIRS += XAO/tests endif +endif + DIST_SUBDIRS = ARCHIMEDE NMTDS NMTTools GEOMAlgo \ SKETCHER OCC2VTK GEOM BREPExport \ BREPImport IGESExport IGESImport STEPExport STEPImport STLExport \ -- 2.39.2