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})
# 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)
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()
## 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
# ===========
"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.
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
# ====================
# 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}")
# Build variables that will be expanded when configuring Salome<MODULE>Config.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}
# 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()
#### 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@")
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)
#
SET(DXFPLUGIN_RESOURCES_FILES
- ImportExport
+ SalomeApp.xml
+ DXFPlugin.xml
)
INSTALL(FILES ${DXFPLUGIN_RESOURCES_FILES} DESTINATION ${SALOME_DXFPLUGIN_INSTALL_RES_DATA})
+++ /dev/null
-Import: DXF
-Export: DXF
-
-DXF.Import: DXFImport
-DXF.Export: DXFExport
-DXF.Pattern: DXF Files ( *.dxf )
-# 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
# 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)
+++ /dev/null
-# 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})
+++ /dev/null
-// 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 <DXFPLUGIN_exports.h>
-#include <DXFPLUGIN_version.h>
-
-#include <Basics_Utils.hxx>
-
-#include <DxfControl_Writer.hxx>
-#include <IFSelect_ReturnStatus.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TopoDS_Shape.hxx>
-
-#ifdef DXF_HASLICENSE
-#include <DXFPLUGIN_license.h>
-
-#include <Standard_LicenseError.hxx>
-#include <OCCLicense_Activate.hxx>
-#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"
+++ /dev/null
-# 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})
+++ /dev/null
-// 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 <DXFPLUGIN_exports.h>
-#include <DXFPLUGIN_version.h>
-
-#include <Basics_Utils.hxx>
-
-#include <DxfControl_Reader.hxx>
-#include <DxfSection_Block.hxx>
-#include <DxfSection_HSequenceOfObject.hxx>
-#include <DxfSection_Model.hxx>
-#include <DxfSection_Section.hxx>
-#include <IFSelect_ReturnStatus.hxx>
-#include <TCollection_AsciiString.hxx>
-#include <TCollection_HAsciiString.hxx>
-#include <TDF_Label.hxx>
-#include <TDataStd_Name.hxx>
-#include <TNaming_Builder.hxx>
-#include <TopoDS_Shape.hxx>
-#include <TopoDS_Iterator.hxx>
-#include <TransferBRep.hxx>
-#include <Transfer_Binder.hxx>
-#include <Transfer_TransientProcess.hxx>
-#include <XSControl_TransferReader.hxx>
-#include <XSControl_WorkSession.hxx>
-
-#ifdef DXF_HASLICENSE
-#include <DXFPLUGIN_license.h>
-
-#include <Standard_LicenseError.hxx>
-#include <OCCLicense_Activate.hxx>
-#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"
-
--- /dev/null
+// 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
--- /dev/null
+// 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 <DXFPLUGIN_exports.h>
+#include <DXFPLUGIN_version.h>
+
+#include <Basics_Utils.hxx>
+
+#include <DxfControl_Writer.hxx>
+#include <IFSelect_ReturnStatus.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TopoDS_Shape.hxx>
+
+#ifdef DXF_HASLICENSE
+#include <DXFPLUGIN_license.h>
+
+#include <Standard_LicenseError.hxx>
+#include <OCCLicense_Activate.hxx>
+#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"
--- /dev/null
+// 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 <DXFPLUGIN_exports.h>
+#include <DXFPLUGIN_version.h>
+
+#include <Basics_Utils.hxx>
+
+#include <DxfControl_Reader.hxx>
+#include <DxfSection_Block.hxx>
+#include <DxfSection_HSequenceOfObject.hxx>
+#include <DxfSection_Model.hxx>
+#include <DxfSection_Section.hxx>
+#include <IFSelect_ReturnStatus.hxx>
+#include <TCollection_AsciiString.hxx>
+#include <TCollection_HAsciiString.hxx>
+#include <TDF_Label.hxx>
+#include <TDataStd_Name.hxx>
+#include <TNaming_Builder.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Iterator.hxx>
+#include <TransferBRep.hxx>
+#include <Transfer_Binder.hxx>
+#include <Transfer_TransientProcess.hxx>
+#include <XSControl_TransferReader.hxx>
+#include <XSControl_WorkSession.hxx>
+
+#ifdef DXF_HASLICENSE
+#include <DXFPLUGIN_license.h>
+
+#include <Standard_LicenseError.hxx>
+#include <OCCLicense_Activate.hxx>
+#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"
+
--- /dev/null
+// 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
+++ /dev/null
-# 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)
+++ /dev/null
-// 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
+++ /dev/null
-// 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