From: mpa Date: Thu, 4 Sep 2014 07:04:00 +0000 (+0400) Subject: Implementation of DXFPLUGIN as a GEOM plugin (removed and renamed files) X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=c27036cb463951b6ea910e2e185fed09cfe7c148;p=plugins%2Fdxfplugin.git Implementation of DXFPLUGIN as a GEOM plugin (removed and renamed files) --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 0e28b99..a70a8bf 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -42,6 +42,7 @@ IF(EXISTS ${KERNEL_ROOT_DIR}) LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files") INCLUDE(SalomeMacros) FIND_PACKAGE(SalomeKERNEL REQUIRED) + KERNEL_WITH_CORBA() #check whether KERNEL builded with CORBA ADD_DEFINITIONS(${KERNEL_DEFINITIONS}) INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS}) ELSE(EXISTS ${KERNEL_ROOT_DIR}) @@ -56,9 +57,38 @@ SET(BUILD_SHARED_LIBS TRUE) # Local macros: LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm_local/cmake_files") +# Find GEOM +# =========== +SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM") +IF(EXISTS ${GEOM_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "${GEOM_ROOT_DIR}/adm_local/cmake_files") + FIND_PACKAGE(SalomeGEOM REQUIRED) + ADD_DEFINITIONS(${GEOM_DEFINITIONS}) + INCLUDE_DIRECTORIES(${GEOM_INCLUDE_DIRS}) +ELSE(EXISTS ${GEOM_ROOT_DIR}) + MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM, please define GEOM_ROOT_DIR") +ENDIF(EXISTS ${GEOM_ROOT_DIR}) + +SET(SALOME_BUILD_GUI ${SALOME_GEOM_BUILD_GUI}) + +# Find GUI(optional) +IF(SALOME_BUILD_GUI) + SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI") + IF(EXISTS ${GUI_ROOT_DIR}) + LIST(APPEND CMAKE_MODULE_PATH "${GUI_ROOT_DIR}/adm_local/cmake_files") + FIND_PACKAGE(SalomeGUI) + FULL_GUI(FALSE) #check whether GUI builded in full mode and with CORBA + ADD_DEFINITIONS(${GUI_DEFINITIONS}) + INCLUDE_DIRECTORIES(${GUI_INCLUDE_DIRS}) + ELSE(EXISTS ${GUI_ROOT_DIR}) + MESSAGE(STATUS "GUI_ROOT_DIR is not well defined, DXFPLUGIN will be built without GUI!!!") + ENDIF(EXISTS ${GUI_ROOT_DIR}) + SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI) +ENDIF(SALOME_BUILD_GUI) + # User options # ============ -#OPTION(SALOME_BUILD_DOC "Generate SALOME DXFPLUGIN documentation" ON) #for use in the future +OPTION(SALOME_BUILD_DOC "Generate SALOME DXFPLUGIN documentation" ON) OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON) IF(SALOME_BUILD_TESTS) @@ -70,7 +100,7 @@ OPTION(DXF_WRITE_LICENSE "DXF write license key" "") IF(DXF_READ_LICENSE OR DXF_WRITE_LICENSE) IF(NOT DXF_READ_LICENSE) - MESSAGE(WARNING "DXF read license keys are not specified! Runtime license will be required!") + MESSAGE(WARNING "DXF read license key is not specified! Runtime license will be required!") ELSEIF(NOT DXF_WRITE_LICENSE) MESSAGE(WARNING "DXF write license key is not specified! Runtime license will be required!") ENDIF() @@ -83,8 +113,18 @@ ENDIF() ## DXFPLUGIN specifics ## +FIND_PACKAGE(SalomePython REQUIRED) FIND_PACKAGE(SalomeCAS REQUIRED) FIND_PACKAGE(SalomeDXF REQUIRED) +FIND_PACKAGE(SalomeOmniORB REQUIRED) +FIND_PACKAGE(SalomeOmniORBPy REQUIRED) +IF(SALOME_BUILD_GUI) + FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui) +ENDIF() +IF(SALOME_BUILD_DOC) + FIND_PACKAGE(SalomeDoxygen) + SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC) +ENDIF() # Directories # =========== @@ -95,6 +135,7 @@ SET(SALOME_INSTALL_CMAKE_LOCAL adm_local/cmake_files CACHE PATH "Install path: local SALOME CMake files") SET(SALOME_INSTALL_RES share/salome/resources CACHE PATH "Install path: SALOME resources") SET(SALOME_INSTALL_DOC share/doc/salome CACHE PATH "Install path: SALOME documentation") +SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff") # Specific to DXFPLUGIN: SET(SALOME_DXFPLUGIN_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/dxfplugin" CACHE PATH. @@ -104,14 +145,18 @@ MARK_AS_ADVANCED(SALOME_INSTALL_BINS SALOME_INSTALL_LIBS SALOME_INSTALL_HEADERS) MARK_AS_ADVANCED(SALOME_INSTALL_CMAKE_LOCAL SALOME_INSTALL_RES SALOME_INSTALL_DOC) # Accumulate environment variables for DXFPLUGIN module +SALOME_ACCUMULATE_ENVIRONMENT(PYTHONPATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_PYTHON}) SALOME_ACCUMULATE_ENVIRONMENT(LD_LIBRARY_PATH NOCHECK ${CMAKE_INSTALL_PREFIX}/${SALOME_INSTALL_LIBS}) # Sources # ======== - +ADD_SUBDIRECTORY(idl) ADD_SUBDIRECTORY(adm_local) ADD_SUBDIRECTORY(resources) ADD_SUBDIRECTORY(src) +IF(SALOME_BUILD_DOC) + ADD_SUBDIRECTORY(doc) +ENDIF() # Header configuration # ==================== @@ -126,15 +171,23 @@ INCLUDE(CMakePackageConfigHelpers) # List of targets in this project we want to make visible to the rest of the world. # They all have to be INSTALL'd with the option "EXPORT ${PROJECT_NAME}TargetGroup" SET(_${PROJECT_NAME}_exposed_targets - DXFExport DXFImport + SalomeIDLDXFPlugin DXFPluginEngine ) +IF(SALOME_BUILD_GUI) + LIST(APPEND _${PROJECT_NAME}_exposed_targets + DXFPluginGUI + ) +ENDIF() + # Add all targets to the build-tree export set EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets} FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake) # Ensure the variables are always defined for the configure: SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}") +SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}") +SET(GEOM_ROOT_DIR "${GEOM_ROOT_DIR}") SET(DXF_ROOT_DIR "${DXF_ROOT_DIR}") SET(OCCLICENSE_ROOT_DIR "${OCCLICENSE_ROOT_DIR}") @@ -142,12 +195,12 @@ SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/inc # Build variables that will be expanded when configuring SalomeConfig.cmake: SALOME_CONFIGURE_PREPARE(DXF) - + CONFIGURE_PACKAGE_CONFIG_FILE(${PROJECT_NAME}Config.cmake.in ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake INSTALL_DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" PATH_VARS CONF_INCLUDE_DIRS SALOME_INSTALL_CMAKE_LOCAL CMAKE_INSTALL_PREFIX - KERNEL_ROOT_DIR DXF_ROOT_DIR OCCLICENSE_ROOT_DIR) + KERNEL_ROOT_DIR GUI_ROOT_DIR GEOM_ROOT_DIR DXF_ROOT_DIR OCCLICENSE_ROOT_DIR) WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake VERSION ${${PROJECT_NAME_UC}_VERSION} diff --git a/SalomeDXFPLUGINConfig.cmake.in b/SalomeDXFPLUGINConfig.cmake.in index 8c82a7e..bc01c7a 100644 --- a/SalomeDXFPLUGINConfig.cmake.in +++ b/SalomeDXFPLUGINConfig.cmake.in @@ -29,7 +29,7 @@ # Load the dependencies for the libraries of @PROJECT_NAME@ # (contains definitions for IMPORTED targets). This is only # imported if we are not built as a subproject (in this case targets are already there) -IF(NOT TARGET DXFExport AND NOT @PROJECT_NAME@_BINARY_DIR) +IF(NOT TARGET DXFPluginEngine AND NOT @PROJECT_NAME@_BINARY_DIR) INCLUDE("@PACKAGE_SALOME_INSTALL_CMAKE_LOCAL@/@PROJECT_NAME@Targets.cmake") ENDIF() @@ -47,11 +47,13 @@ SET(DXFPLUGIN_DEFINITIONS) #### Now the specificities # Options exported by the package: -#SET(SALOME_DXFPLUGIN_BUILD_DOC @SALOME_BUILD_DOC@) +SET(SALOME_DXFPLUGIN_BUILD_DOC @SALOME_BUILD_DOC@) SET(SALOME_DXFPLUGIN_BUILD_TESTS @SALOME_BUILD_TESTS@) # Level 1 prerequisites: SET_AND_CHECK(KERNEL_ROOT_DIR_EXP "@PACKAGE_KERNEL_ROOT_DIR@") +SET_AND_CHECK(GUI_ROOT_DIR_EXP "@PACKAGE_GUI_ROOT_DIR@") +SET_AND_CHECK(GEOM_ROOT_DIR_EXP "@PACKAGE_GEOM_ROOT_DIR@") SET_AND_CHECK(DXF_ROOT_DIR_EXP "@PACKAGE_DXF_ROOT_DIR@") SET_AND_CHECK(OCCLICENSE_ROOT_DIR_EXP "@PACKAGE_OCCLICENSE_ROOT_DIR@") @@ -94,5 +96,6 @@ SET(SALOME_INSTALL_RES "@SALOME_INSTALL_RES@") SET(SALOME_INSTALL_DOC "@SALOME_INSTALL_DOC@") # Exposed DXFPLUGIN targets: -SET(DXFPLUGIN_DXFExport DXFExport) -SET(DXFPLUGIN_DXFImport DXFImport) \ No newline at end of file +SET(DXFPLUGIN_SalomeIDLDXFPlugin SalomeIDLDXFPlugin) +SET(DXFPLUGIN_DXFPluginEngine DXFPluginEngine) +SET(DXFPLUGIN_DXFPluginGUI DXFPluginGUI) diff --git a/resources/CMakeLists.txt b/resources/CMakeLists.txt index 2f1d5c1..b9588c8 100644 --- a/resources/CMakeLists.txt +++ b/resources/CMakeLists.txt @@ -18,7 +18,8 @@ # SET(DXFPLUGIN_RESOURCES_FILES - ImportExport + SalomeApp.xml + DXFPlugin.xml ) INSTALL(FILES ${DXFPLUGIN_RESOURCES_FILES} DESTINATION ${SALOME_DXFPLUGIN_INSTALL_RES_DATA}) diff --git a/resources/ImportExport b/resources/ImportExport deleted file mode 100644 index d4ab129..0000000 --- a/resources/ImportExport +++ /dev/null @@ -1,6 +0,0 @@ -Import: DXF -Export: DXF - -DXF.Import: DXFImport -DXF.Export: DXFExport -DXF.Pattern: DXF Files ( *.dxf ) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 5eb403f..c6a6cab 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1,4 +1,4 @@ -# Copyright (C) 2014 OPEN CASCADE +# 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 @@ -17,6 +17,142 @@ # See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com # -ADD_SUBDIRECTORY(common) -ADD_SUBDIRECTORY(DXFExport) -ADD_SUBDIRECTORY(DXFImport) +IF(SALOME_BUILD_GUI) + INCLUDE(UseQt4Ext) + INCLUDE(${QT_USE_FILE}) +ENDIF() + +# --- options --- + +# additional include directories +INCLUDE_DIRECTORIES( + ${CAS_INCLUDE_DIRS} + ${DXF_INCLUDE_DIRS} + ${KERNEL_INCLUDE_DIRS} + ${GUI_INCLUDE_DIRS} + ${PROJECT_BINARY_DIR} + ${PROJECT_BINARY_DIR}/idl + ) + +IF(SALOME_BUILD_GUI) + INCLUDE_DIRECTORIES( + ${QT_INCLUDE_DIRS} + ) +ENDIF() + +# additional preprocessor / compiler flags +ADD_DEFINITIONS( + ${CAS_DEFINITIONS} + ) + +IF(SALOME_BUILD_GUI) +ADD_DEFINITIONS( + ${QT_DEFINITIONS} + ) +ENDIF() + +# libraries to link to +SET(_link_LIBRARIES + ${CAS_TKXSBase} + ${DXF_LIBRARIES} + ${KERNEL_SALOMEBasics} + ${KERNEL_SALOMELocalTrace} + ${KERNEL_OpUtil} + ${GEOM_SalomeIDLGEOM} + ${GEOM_GEOMEngine} + ${GEOM_GEOMImpl} + ${GEOM_GEOMClient} + SalomeIDLDXFPlugin + ) + +IF(SALOME_BUILD_GUI) + SET(_link_LIBRARIES + ${_link_LIBRARIES} + ${GEOM_GEOMBase} + ) +ENDIF() + + +# --- headers --- + +SET(DXFPluginEngine_HEADERS + DXFPlugin_Operations_i.hh + DXFPlugin_Engine.hxx + DXFPlugin_OperationsCreator.hh + DXFPlugin_IOperations.hxx + DXFPlugin_IExport.hxx + DXFPlugin_IImport.hxx + DXFPlugin_ImportDriver.hxx + DXFPlugin_ExportDriver.hxx + DXFPlugin_IECallBack.hxx + ) + +IF(SALOME_BUILD_GUI) + # header files / to be processed by moc + SET(_moc_HEADERS + DXFPlugin_ExportDlg.h + DXFPlugin_ImportDlg.h + ) +ENDIF() + +# --- sources --- + +IF(SALOME_BUILD_GUI) + # sources / moc wrappings + QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS}) + + SET(DXFPluginGUI_SOURCES + DXFPluginGUI.cxx + DXFPlugin_ExportDlg.cxx + DXFPlugin_ImportDlg.cxx + ${_moc_SOURCES} + ) +ENDIF() + +SET(DXFPluginEngine_SOURCES + DXFPluginEngine.cxx + DXFPlugin_OperationsCreator.cc + DXFPlugin_Operations_i.cc + DXFPlugin_IOperations.cxx + DXFPlugin_ExportDriver.cxx + DXFPlugin_ImportDriver.cxx + DXFPlugin_IECallBack.cxx + ) + +# resource files / to be processed by lrelease +SET(DXFPlugin_RESOURCES + resources/DXFPlugin_msg_en.ts + resources/DXFPlugin_msg_fr.ts + resources/DXFPlugin_msg_ja.ts + ) + +# DXF plugin scripts +SET(_python_DXF_SCRIPTS + DXFPluginBuilder.py + __init__.py +) + +# --- rules --- + +# install Engine library +ADD_LIBRARY(DXFPluginEngine ${DXFPluginEngine_SOURCES}) +TARGET_LINK_LIBRARIES(DXFPluginEngine ${_link_LIBRARIES}) +INSTALL(TARGETS DXFPluginEngine EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + +# install GUI library +IF(SALOME_BUILD_GUI) + ADD_LIBRARY(DXFPluginGUI ${DXFPluginGUI_SOURCES}) + TARGET_LINK_LIBRARIES(DXFPluginGUI ${_link_LIBRARIES}) + INSTALL(TARGETS DXFPluginGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) + # install resources + QT4_INSTALL_TS_RESOURCES("${DXFPlugin_RESOURCES}" "${SALOME_DXFPLUGIN_INSTALL_RES_DATA}") +ENDIF() + +# install headers +INSTALL(FILES ${DXFPluginEngine_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS}) + +# install python scripts +SALOME_INSTALL_SCRIPTS("${_python_DXF_SCRIPTS}" ${SALOME_INSTALL_PYTHON}/salome/DXFPlugin DEF_PERMS) + +# configure license file +CONFIGURE_FILE(DXFPlugin_license.h.in DXFPlugin_license.h) diff --git a/src/DXFExport/CMakeLists.txt b/src/DXFExport/CMakeLists.txt deleted file mode 100644 index 512ef53..0000000 --- a/src/DXFExport/CMakeLists.txt +++ /dev/null @@ -1,55 +0,0 @@ -# Copyright (C) 2014 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 -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${DXF_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/src/common - ${CMAKE_SOURCE_DIR}/src/common -) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} -) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKernel} - ${CAS_TKXSBase} - ${DXF_LIBRARIES} - ${KERNEL_SALOMEBasics} -) - -# --- sources --- - -# sources / static -SET(DXFExport_SOURCES - DXFExport.cxx -) - -# --- rules --- - -ADD_LIBRARY(DXFExport ${DXFExport_SOURCES}) -TARGET_LINK_LIBRARIES(DXFExport ${_link_LIBRARIES} ) -INSTALL(TARGETS DXFExport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/src/DXFExport/DXFExport.cxx b/src/DXFExport/DXFExport.cxx deleted file mode 100644 index 4727f53..0000000 --- a/src/DXFExport/DXFExport.cxx +++ /dev/null @@ -1,98 +0,0 @@ -// Copyright (C) 2014 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 -// - -#include -#include - -#include - -#include -#include -#include -#include - -#ifdef DXF_HASLICENSE -#include - -#include -#include -#endif // DXF_HASLICENSE - -extern "C" -{ - /*! - \brief Get version of the plugin. - \return the version of the plugin - */ - DXFPLUGIN_EXPORT - int GetVersion() - { - return DXFPLUGIN_VERSION; - } - - /*! - \brief Get version of the plugin. - \return the string representation of the plugin's version - */ - DXFPLUGIN_EXPORT - char* GetVersionStr() - { - return (char*)DXFPLUGIN_VERSION_STR; - } - - /*! - \brief Export shape to the DXF format. - \param theShape shape being exported - \param theFileName file path - \param theFormatName file format signature - \return error status (0 in case of success) - */ - DXFPLUGIN_EXPORT - int Export(const TopoDS_Shape& theShape, - const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& theFormatName) - { -#ifdef DXF_HASLICENSE - try { - OCCLicense_Activate("DXF-W-"OCC_VERSION_STRING, DXF_WRITE_LICENSE); - } - catch (Standard_LicenseError) { - return 1; - } -#endif // DXF_HASLICENSE - - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - DxfControl_Writer aWriter; - - try { - IFSelect_ReturnStatus status ; - status = aWriter.TransferShape(theShape); - if ( status == IFSelect_RetDone ) - status = aWriter.WriteFile( theFileName.ToCString() ) ; - if ( status == IFSelect_RetDone ) - return 1; - } - catch(Standard_Failure) { - return 1; - } - return 0; - } -} // end of extern "C" diff --git a/src/DXFImport/CMakeLists.txt b/src/DXFImport/CMakeLists.txt deleted file mode 100644 index ca4eba5..0000000 --- a/src/DXFImport/CMakeLists.txt +++ /dev/null @@ -1,59 +0,0 @@ -# Copyright (C) 2014 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 -# - -# --- options --- - -# additional include directories -INCLUDE_DIRECTORIES( - ${CAS_INCLUDE_DIRS} - ${DXF_INCLUDE_DIRS} - ${CMAKE_BINARY_DIR} - ${CMAKE_BINARY_DIR}/src/common - ${CMAKE_SOURCE_DIR}/src/common -) - -# additional preprocessor / compiler flags -ADD_DEFINITIONS( - ${CAS_DEFINITIONS} -) - -# libraries to link to -SET(_link_LIBRARIES - ${CAS_TKernel} - ${CAS_TKXSBase} - ${CAS_TKCAF} - ${CAS_TKLCAF} - ${CAS_TKMath} - ${CAS_TKBRep} - ${DXF_LIBRARIES} - ${KERNEL_SALOMEBasics} -) - -# --- sources --- - -# sources / static -SET(DXFImport_SOURCES - DXFImport.cxx -) - -# --- rules --- - -ADD_LIBRARY(DXFImport ${DXFImport_SOURCES}) -TARGET_LINK_LIBRARIES(DXFImport ${_link_LIBRARIES} ) -INSTALL(TARGETS DXFImport EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS}) diff --git a/src/DXFImport/DXFImport.cxx b/src/DXFImport/DXFImport.cxx deleted file mode 100644 index 39ca9ae..0000000 --- a/src/DXFImport/DXFImport.cxx +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (C) 2014 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 -// - -#include -#include - -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#ifdef DXF_HASLICENSE -#include - -#include -#include -#endif // DXF_HASLICENSE - -extern "C" -{ - /*! - \brief Get version of the plugin. - \return the version of the plugin - */ - DXFPLUGIN_EXPORT - int GetVersion() - { - return DXFPLUGIN_VERSION; - } - - /*! - \brief Get version of the plugin. - \return the string representation of the plugin's version - */ - DXFPLUGIN_EXPORT - char* GetVersionStr() - { - return (char*)DXFPLUGIN_VERSION_STR; - } - - /*! - \brief Import shape from the DXF format. - \param theFileName file path - \param theFormatName file format signature - \param theError error description, if there's any, is returned via this parameter - \param theShapeLabel a label in the CAF tree where shape attributes are set to - \return imported shape - */ - DXFPLUGIN_EXPORT - TopoDS_Shape Import(const TCollection_AsciiString& theFileName, - const TCollection_AsciiString& /*theFormatName*/, - TCollection_AsciiString& theError, - const TDF_Label& theShapeLabel) - { - TopoDS_Shape aResShape; - -#ifdef DXF_HASLICENSE - try { - OCCLicense_Activate( "DXF-R-"OCC_VERSION_STRING, DXF_READ_LICENSE); - } - catch (Standard_LicenseError) { - return aResShape; - } -#endif - - // Set "C" numeric locale to save numbers correctly - Kernel_Utils::Localizer loc; - - DxfControl_Reader aReader; - - try { - IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); - if (status == IFSelect_RetDone) { - aReader.TransferRoots(); - aResShape = aReader.OneShape(); - - // ATTENTION: this is a workaround for mantis issue 0020442 remark 0010776 - // It should be removed after patching OCCT for bug OCC22436 - // (fix for OCCT is expected in service pack next to OCCT6.3sp12) - if (aResShape.ShapeType() == TopAbs_COMPOUND) { - int nbSub1 = 0; - TopoDS_Shape currShape; - TopoDS_Iterator It (aResShape, Standard_True, Standard_True); - for (; It.More(); It.Next()) { - nbSub1++; - currShape = It.Value(); - } - if (nbSub1 == 1) - aResShape = currShape; - } - Handle(DxfSection_Model) aModel = Handle(DxfSection_Model)::DownCast( aReader.WS()->Model() ); - Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); - if (!TR.IsNull()) { - Handle(Transfer_TransientProcess) TP = TR->TransientProcess(); - - Handle(DxfSection_Section) aBlocks = aModel->FindSection("BLOCKS"); - if (aBlocks.IsNull()) return aResShape; - - Handle(DxfSection_HSequenceOfObject) anObjects = aBlocks->GetObjects(); - if (anObjects.IsNull()) return aResShape; - - for (Standard_Integer i = 1; i <= anObjects->Length(); i++) { - Handle(DxfSection_Block) aBlock = Handle(DxfSection_Block)::DownCast(anObjects->Value(i)); - if (aBlock.IsNull()) continue; - Handle(TCollection_HAsciiString) aName = aBlock->GetBlockName1(); - if (aName.IsNull()) continue; - - Handle(Transfer_Binder) binder = TP->Find ( aBlock ); - if (binder.IsNull()) continue; - TopoDS_Shape aResShape = TransferBRep::ShapeResult (binder); - if (aResShape.IsNull()) continue; - - // create label and set shape - TDF_Label L; - TDF_TagSource aTag; - L = aTag.NewChild(theShapeLabel); - TNaming_Builder tnBuild(L); - tnBuild.Generated(aResShape); - - // set a name - TCollection_ExtendedString str(aName->ToCString()); - TDataStd_Name::Set(L,str); - } - } - } - else { - theError = "Wrong format of the imported file. Can't import file."; - aResShape.Nullify(); - } - } - catch (Standard_Failure) { - Handle(Standard_Failure) aFail = Standard_Failure::Caught(); - theError = aFail->GetMessageString(); - aResShape.Nullify(); - } - return aResShape; - } -} // end of extern "C" - diff --git a/src/DXFPlugin_Engine.hxx b/src/DXFPlugin_Engine.hxx new file mode 100644 index 0000000..87680c1 --- /dev/null +++ b/src/DXFPlugin_Engine.hxx @@ -0,0 +1,33 @@ +// Copyright (C) 2014 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 +// + +#if !defined (__DXFPLUGIN_EXPORTS_H) +#define __DXFPLUGIN_EXPORTS_H + +#ifdef WIN32 +# if defined DXFExport_EXPORTS || defined DXFXPORTS_EXPORTS || defined DXFImport_EXPORTS || defined DXFIMPORT_EXPORTS +# define DXFPLUGIN_EXPORT __declspec(dllexport) +# else +# define DXFPLUGIN_EXPORT __declspec(dllimport) +# endif +#else // WIN32 +# define DXFPLUGIN_EXPORT +#endif // WIN32 + +#endif // __DXFPLUGIN_EXPORTS_H diff --git a/src/DXFPlugin_ExportDriver.cxx b/src/DXFPlugin_ExportDriver.cxx new file mode 100644 index 0000000..4727f53 --- /dev/null +++ b/src/DXFPlugin_ExportDriver.cxx @@ -0,0 +1,98 @@ +// Copyright (C) 2014 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 +// + +#include +#include + +#include + +#include +#include +#include +#include + +#ifdef DXF_HASLICENSE +#include + +#include +#include +#endif // DXF_HASLICENSE + +extern "C" +{ + /*! + \brief Get version of the plugin. + \return the version of the plugin + */ + DXFPLUGIN_EXPORT + int GetVersion() + { + return DXFPLUGIN_VERSION; + } + + /*! + \brief Get version of the plugin. + \return the string representation of the plugin's version + */ + DXFPLUGIN_EXPORT + char* GetVersionStr() + { + return (char*)DXFPLUGIN_VERSION_STR; + } + + /*! + \brief Export shape to the DXF format. + \param theShape shape being exported + \param theFileName file path + \param theFormatName file format signature + \return error status (0 in case of success) + */ + DXFPLUGIN_EXPORT + int Export(const TopoDS_Shape& theShape, + const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& theFormatName) + { +#ifdef DXF_HASLICENSE + try { + OCCLicense_Activate("DXF-W-"OCC_VERSION_STRING, DXF_WRITE_LICENSE); + } + catch (Standard_LicenseError) { + return 1; + } +#endif // DXF_HASLICENSE + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + DxfControl_Writer aWriter; + + try { + IFSelect_ReturnStatus status ; + status = aWriter.TransferShape(theShape); + if ( status == IFSelect_RetDone ) + status = aWriter.WriteFile( theFileName.ToCString() ) ; + if ( status == IFSelect_RetDone ) + return 1; + } + catch(Standard_Failure) { + return 1; + } + return 0; + } +} // end of extern "C" diff --git a/src/DXFPlugin_ImportDriver.cxx b/src/DXFPlugin_ImportDriver.cxx new file mode 100644 index 0000000..39ca9ae --- /dev/null +++ b/src/DXFPlugin_ImportDriver.cxx @@ -0,0 +1,171 @@ +// Copyright (C) 2014 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 +// + +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef DXF_HASLICENSE +#include + +#include +#include +#endif // DXF_HASLICENSE + +extern "C" +{ + /*! + \brief Get version of the plugin. + \return the version of the plugin + */ + DXFPLUGIN_EXPORT + int GetVersion() + { + return DXFPLUGIN_VERSION; + } + + /*! + \brief Get version of the plugin. + \return the string representation of the plugin's version + */ + DXFPLUGIN_EXPORT + char* GetVersionStr() + { + return (char*)DXFPLUGIN_VERSION_STR; + } + + /*! + \brief Import shape from the DXF format. + \param theFileName file path + \param theFormatName file format signature + \param theError error description, if there's any, is returned via this parameter + \param theShapeLabel a label in the CAF tree where shape attributes are set to + \return imported shape + */ + DXFPLUGIN_EXPORT + TopoDS_Shape Import(const TCollection_AsciiString& theFileName, + const TCollection_AsciiString& /*theFormatName*/, + TCollection_AsciiString& theError, + const TDF_Label& theShapeLabel) + { + TopoDS_Shape aResShape; + +#ifdef DXF_HASLICENSE + try { + OCCLicense_Activate( "DXF-R-"OCC_VERSION_STRING, DXF_READ_LICENSE); + } + catch (Standard_LicenseError) { + return aResShape; + } +#endif + + // Set "C" numeric locale to save numbers correctly + Kernel_Utils::Localizer loc; + + DxfControl_Reader aReader; + + try { + IFSelect_ReturnStatus status = aReader.ReadFile(theFileName.ToCString()); + if (status == IFSelect_RetDone) { + aReader.TransferRoots(); + aResShape = aReader.OneShape(); + + // ATTENTION: this is a workaround for mantis issue 0020442 remark 0010776 + // It should be removed after patching OCCT for bug OCC22436 + // (fix for OCCT is expected in service pack next to OCCT6.3sp12) + if (aResShape.ShapeType() == TopAbs_COMPOUND) { + int nbSub1 = 0; + TopoDS_Shape currShape; + TopoDS_Iterator It (aResShape, Standard_True, Standard_True); + for (; It.More(); It.Next()) { + nbSub1++; + currShape = It.Value(); + } + if (nbSub1 == 1) + aResShape = currShape; + } + Handle(DxfSection_Model) aModel = Handle(DxfSection_Model)::DownCast( aReader.WS()->Model() ); + Handle(XSControl_TransferReader) TR = aReader.WS()->TransferReader(); + if (!TR.IsNull()) { + Handle(Transfer_TransientProcess) TP = TR->TransientProcess(); + + Handle(DxfSection_Section) aBlocks = aModel->FindSection("BLOCKS"); + if (aBlocks.IsNull()) return aResShape; + + Handle(DxfSection_HSequenceOfObject) anObjects = aBlocks->GetObjects(); + if (anObjects.IsNull()) return aResShape; + + for (Standard_Integer i = 1; i <= anObjects->Length(); i++) { + Handle(DxfSection_Block) aBlock = Handle(DxfSection_Block)::DownCast(anObjects->Value(i)); + if (aBlock.IsNull()) continue; + Handle(TCollection_HAsciiString) aName = aBlock->GetBlockName1(); + if (aName.IsNull()) continue; + + Handle(Transfer_Binder) binder = TP->Find ( aBlock ); + if (binder.IsNull()) continue; + TopoDS_Shape aResShape = TransferBRep::ShapeResult (binder); + if (aResShape.IsNull()) continue; + + // create label and set shape + TDF_Label L; + TDF_TagSource aTag; + L = aTag.NewChild(theShapeLabel); + TNaming_Builder tnBuild(L); + tnBuild.Generated(aResShape); + + // set a name + TCollection_ExtendedString str(aName->ToCString()); + TDataStd_Name::Set(L,str); + } + } + } + else { + theError = "Wrong format of the imported file. Can't import file."; + aResShape.Nullify(); + } + } + catch (Standard_Failure) { + Handle(Standard_Failure) aFail = Standard_Failure::Caught(); + theError = aFail->GetMessageString(); + aResShape.Nullify(); + } + return aResShape; + } +} // end of extern "C" + diff --git a/src/DXFPlugin_license.h.in b/src/DXFPlugin_license.h.in new file mode 100644 index 0000000..545d181 --- /dev/null +++ b/src/DXFPlugin_license.h.in @@ -0,0 +1,26 @@ +// Copyright (C) 2014 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 +// + +#if !defined(__DXFPLUGIN_LICENSE_H) +#define __DXFPLUGIN_LICENSE_H + +#define DXF_READ_LICENSE "@DXF_READ_LICENSE@" +#define DXF_WRITE_LICENSE "@DXF_WRITE_LICENSE@" + +#endif // __DXFPLUGIN_LICENSE_H diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt deleted file mode 100644 index dbc1750..0000000 --- a/src/common/CMakeLists.txt +++ /dev/null @@ -1,20 +0,0 @@ -# Copyright (C) 2014 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 -# - -CONFIGURE_FILE(DXFPLUGIN_license.h.in DXFPLUGIN_license.h) diff --git a/src/common/DXFPLUGIN_exports.h b/src/common/DXFPLUGIN_exports.h deleted file mode 100644 index 87680c1..0000000 --- a/src/common/DXFPLUGIN_exports.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2014 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 -// - -#if !defined (__DXFPLUGIN_EXPORTS_H) -#define __DXFPLUGIN_EXPORTS_H - -#ifdef WIN32 -# if defined DXFExport_EXPORTS || defined DXFXPORTS_EXPORTS || defined DXFImport_EXPORTS || defined DXFIMPORT_EXPORTS -# define DXFPLUGIN_EXPORT __declspec(dllexport) -# else -# define DXFPLUGIN_EXPORT __declspec(dllimport) -# endif -#else // WIN32 -# define DXFPLUGIN_EXPORT -#endif // WIN32 - -#endif // __DXFPLUGIN_EXPORTS_H diff --git a/src/common/DXFPLUGIN_license.h.in b/src/common/DXFPLUGIN_license.h.in deleted file mode 100644 index 545d181..0000000 --- a/src/common/DXFPLUGIN_license.h.in +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright (C) 2014 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 -// - -#if !defined(__DXFPLUGIN_LICENSE_H) -#define __DXFPLUGIN_LICENSE_H - -#define DXF_READ_LICENSE "@DXF_READ_LICENSE@" -#define DXF_WRITE_LICENSE "@DXF_WRITE_LICENSE@" - -#endif // __DXFPLUGIN_LICENSE_H