Salome HOME
Merging with V7_main branch.
authoradv <adv@opencascade.com>
Mon, 18 Nov 2013 11:33:19 +0000 (11:33 +0000)
committeradv <adv@opencascade.com>
Mon, 18 Nov 2013 11:33:19 +0000 (11:33 +0000)
76 files changed:
CMake/UsePyQt4EXT.cmake [new file with mode: 0644]
CMakeLists.txt
adm_local/CMakeLists.txt [deleted file]
adm_local/cmake_files/CMakeLists.txt [deleted file]
adm_local/cmake_files/FindSalomeHYDRO.cmake [deleted file]
src/HYDROCurveCreator/CMakeLists.txt
src/HYDROCurveCreator/CurveCreator_Curve.cxx
src/HYDROCurveCreator/CurveCreator_Curve.hxx
src/HYDROCurveCreator/CurveCreator_Displayer.cxx [new file with mode: 0644]
src/HYDROCurveCreator/CurveCreator_Displayer.h [new file with mode: 0644]
src/HYDROCurveCreator/CurveCreator_ICurve.hxx
src/HYDROCurveCreator/CurveCreator_Utils.cxx [new file with mode: 0644]
src/HYDROCurveCreator/CurveCreator_Utils.h [new file with mode: 0644]
src/HYDROCurveCreator/CurveCreator_Widget.cxx
src/HYDROCurveCreator/CurveCreator_Widget.h
src/HYDROData/CMakeLists.txt
src/HYDROData/HYDROData_AltitudeObject.h
src/HYDROData/HYDROData_Bathymetry.h
src/HYDROData/HYDROData_CalculationCase.cxx
src/HYDROData/HYDROData_CalculationCase.h
src/HYDROData/HYDROData_Document.h
src/HYDROData/HYDROData_IAltitudeObject.h
src/HYDROData/HYDROData_IPolyline.cxx
src/HYDROData/HYDROData_IPolyline.h
src/HYDROData/HYDROData_Image.h
src/HYDROData/HYDROData_Iterator.cxx
src/HYDROData/HYDROData_Iterator.h
src/HYDROData/HYDROData_Obstacle.cxx
src/HYDROData/HYDROData_Obstacle.h
src/HYDROData/HYDROData_Polyline.h
src/HYDROData/HYDROData_PolylineXY.cxx [new file with mode: 0755]
src/HYDROData/HYDROData_PolylineXY.h [new file with mode: 0644]
src/HYDROData/HYDROData_Profile.cxx
src/HYDROData/HYDROData_Profile.h
src/HYDROData/HYDROData_ProfileUZ.cxx
src/HYDROData/HYDROData_ProfileUZ.h
src/HYDROData/HYDROData_Region.cxx
src/HYDROData/HYDROData_Region.h
src/HYDROData/HYDROData_Zone.h
src/HYDROGUI/CMakeLists.txt
src/HYDROGUI/HYDROGUI_AISCurve.cxx [deleted file]
src/HYDROGUI/HYDROGUI_AISCurve.h [deleted file]
src/HYDROGUI/HYDROGUI_DataModel.cxx
src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ExportCalculationOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Module.cxx
src/HYDROGUI/HYDROGUI_Module.h
src/HYDROGUI/HYDROGUI_OCCDisplayer.cxx
src/HYDROGUI/HYDROGUI_ObstacleDlg.cxx [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_ObstacleDlg.h [new file with mode: 0644]
src/HYDROGUI/HYDROGUI_Operations.cxx
src/HYDROGUI/HYDROGUI_Operations.h
src/HYDROGUI/HYDROGUI_PolylineDlg.cxx
src/HYDROGUI/HYDROGUI_PolylineDlg.h
src/HYDROGUI/HYDROGUI_PolylineOp.cxx
src/HYDROGUI/HYDROGUI_PolylineOp.h
src/HYDROGUI/HYDROGUI_Shape.cxx
src/HYDROGUI/HYDROGUI_Tool.cxx
src/HYDROGUI/HYDROGUI_Tool.h
src/HYDROGUI/resources/HYDROGUI_msg_en.ts
src/HYDROPy/CMakeLists.txt
src/HYDROPy/HYDROData.py.in [deleted file]
src/HYDROPy/HYDROData.sip
src/HYDROPy/HYDROData_Bathymetry.sip
src/HYDROPy/HYDROData_Calculation.sip [deleted file]
src/HYDROPy/HYDROData_CalculationCase.sip [new file with mode: 0644]
src/HYDROPy/HYDROData_Document.sip
src/HYDROPy/HYDROData_Entity.sip
src/HYDROPy/HYDROData_Image.sip
src/HYDROPy/HYDROData_Object.sip
src/HYDROPy/HYDROData_Polyline.sip
src/HYDROPy/configure.py [deleted file]

diff --git a/CMake/UsePyQt4EXT.cmake b/CMake/UsePyQt4EXT.cmake
new file mode 100644 (file)
index 0000000..27bcce9
--- /dev/null
@@ -0,0 +1,93 @@
+# Copyright (C) 2012-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# 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
+#
+# Author: Vadim SANDLER, Open CASCADE S.A.S. (vadim.sandler@opencascade.com)
+
+####################################################################
+#
+# PYQT4_WRAP_SIP_EXT macro
+#
+# Generate C++ wrappings for *.sip files by processing them with sip.
+#
+# USAGE: PYQT4_WRAP_SIP_EXT(output_files sip_files)
+#
+# ARGUMENTS:
+#   output_files [out] variable where output file names are listed to
+#   sip_files    [in]  list of *.sip files
+# 
+# NOTES:
+#   - Input files are considered relative to the current source directory.
+#   - Output files are generated in the current build directory.
+#   - This version of macro requires class(es) definition in the 
+#     *.sip file to be started on a new line without any preceeding characters.
+#
+# TODO:
+#   - Check if dependency of static sources on generated headers works properly:
+#     if header is changed, dependant sources should be recompiled.
+# 
+####################################################################
+MACRO(PYQT4_WRAP_SIP_EXT outfiles)
+  FOREACH(_input ${ARGN})
+    FILE(STRINGS ${_input} _sip_modules REGEX "%Module")
+    FILE(STRINGS ${_input} _sip_includes REGEX "%Include")
+    FILE(STRINGS ${_input} _sip_classes REGEX "^class ")
+    SET(_output)
+   
+    FOREACH(_sip_module ${_sip_modules})
+      STRING(REGEX MATCH ".*%Module *\\( *name=.*\\).*" _mod_name "${_sip_module}")
+      IF (_mod_name)
+        STRING(REGEX REPLACE ".*%Module *\\( *name=(.*).*\\).*" "\\1" _mod_name ${_sip_module})
+      ELSE()
+        STRING(REGEX REPLACE ".*%Module *(.*)" "\\1" _mod_name ${_sip_module})
+      ENDIF()
+      SET(_mod_header "sipAPI${_mod_name}.h")
+      SET(_mod_source "sip${_mod_name}cmodule${PYQT_CXX_EXT}")
+      LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/${_mod_source})
+      SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/${_mod_source})
+    ENDFOREACH()
+
+    FOREACH(_sip_include ${_sip_includes})
+      STRING(REGEX REPLACE ".*%Include +(.*)\\.sip *" "\\1" _include_name ${_sip_include})
+      SET(_include_source "sip${_mod_name}${_include_name}${PYQT_CXX_EXT}")
+      LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/${_include_source})
+      SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/${_include_source})
+    ENDFOREACH()
+
+    FOREACH(_sip_class ${_sip_classes})
+      STRING(REGEX MATCH ".*class +.* *:" _class_name "${_sip_class}")
+      IF (_class_name)
+        STRING(REGEX REPLACE ".*class +(.*) *:.*" "\\1" _class_name ${_sip_class})
+      ELSE()
+        STRING(REGEX REPLACE ".*class *(.*)" "\\1" _class_name ${_sip_class})
+      ENDIF()
+      STRING(STRIP ${_class_name} _class_name)
+      SET(_class_source "sip${_mod_name}${_class_name}${PYQT_CXX_EXT}")
+      LIST(APPEND _output ${CMAKE_CURRENT_BINARY_DIR}/${_class_source})
+      SET(${outfiles} ${${outfiles}} ${CMAKE_CURRENT_BINARY_DIR}/${_class_source})
+    ENDFOREACH()
+    
+    ADD_CUSTOM_COMMAND(
+      OUTPUT ${_output}
+      COMMAND ${SIP_EXECUTABLE} ${PYQT_SIPFLAGS} ${CMAKE_CURRENT_SOURCE_DIR}/${_input}
+      MAIN_DEPENDENCY ${_input}
+      )
+      
+  ENDFOREACH()
+ENDMACRO(PYQT4_WRAP_SIP_EXT)
+
+
index 0bd2fb02845673f28ab1368f812adb0283324a72..115fcd23879f7b51f97f61836c948aa33cb8c554 100644 (file)
-cmake_minimum_required (VERSION 2.6)
+CMAKE_MINIMUM_REQUIRED(VERSION 2.8.8 FATAL_ERROR)
+INCLUDE(CMakeDependentOption)
 
-project (HYDRO)
+PROJECT(SalomeHYDRO C CXX)
+
+# Ensure a proper linker behavior:
+CMAKE_POLICY(SET CMP0003 NEW)
+
+# Versioning
+# ===========
+# Project name, upper case
+STRING(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC)
+
+SET(${PROJECT_NAME_UC}_MAJOR_VERSION 0)
+SET(${PROJECT_NAME_UC}_MINOR_VERSION 1)
+SET(${PROJECT_NAME_UC}_PATCH_VERSION 0)
+SET(${PROJECT_NAME_UC}_VERSION
+  ${${PROJECT_NAME_UC}_MAJOR_VERSION}.${${PROJECT_NAME_UC}_MINOR_VERSION}.${${PROJECT_NAME_UC}_PATCH_VERSION})
+SET(${PROJECT_NAME_UC}_VERSION_DEV 1)
 
 IF(WIN32)
   ADD_DEFINITIONS(-DWNT)
 ENDIF(WIN32)
 
+# Find KERNEL
+# ==============
 SET(KERNEL_ROOT_DIR $ENV{KERNEL_ROOT_DIR} CACHE PATH "Path to the Salome KERNEL")
-IF(EXISTS ${KERNEL_ROOT_DIR})
-  INCLUDE(${KERNEL_ROOT_DIR}/salome_adm/cmake_files/FindKERNEL.cmake)
-ELSE(EXISTS ${KERNEL_ROOT_DIR})
-  MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR")
-ENDIF(EXISTS ${KERNEL_ROOT_DIR})
-
-SET(GUI_ROOT_DIR $ENV{GUI_ROOT_DIR} CACHE PATH "Path to the Salome GUI")
-IF(EXISTS ${GUI_ROOT_DIR})
-  INCLUDE(${GUI_ROOT_DIR}/adm_local/cmake_files/FindGUI.cmake)
-ELSE(EXISTS ${GUI_ROOT_DIR})
-  MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR")
-ENDIF(EXISTS ${GUI_ROOT_DIR})
+IF( EXISTS ${KERNEL_ROOT_DIR} )
+  LIST(APPEND CMAKE_MODULE_PATH "${KERNEL_ROOT_DIR}/salome_adm/cmake_files")
+  INCLUDE(SalomeMacros)
+  FIND_PACKAGE(SalomeKERNEL REQUIRED)
+  ADD_DEFINITIONS(${KERNEL_DEFINITIONS})
+  INCLUDE_DIRECTORIES(${KERNEL_INCLUDE_DIRS})
+ELSE( EXISTS ${KERNEL_ROOT_DIR} )
+  MESSAGE(FATAL_ERROR "We absolutely need a Salome KERNEL, please define KERNEL_ROOT_DIR or turn option SALOME_HYDRO_USE_KERNEL to OFF !")
+ENDIF( EXISTS ${KERNEL_ROOT_DIR} )
+
+# Find SALOME GUI (optional)
+# ==============
+OPTION(SALOME_BUILD_GUI "Build GUI of HYDRO" ON)
+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)
+  ELSE(EXISTS ${GUI_ROOT_DIR})
+    MESSAGE(FATAL_ERROR "We absolutely need a Salome GUI, please define GUI_ROOT_DIR or turn option SALOME_BUILD_GUI to OFF !")
+  ENDIF(EXISTS ${GUI_ROOT_DIR})
+  SALOME_LOG_OPTIONAL_PACKAGE(SalomeGUI SALOME_BUILD_GUI)
+ENDIF(SALOME_BUILD_GUI)
 
+# Find GEOM
+# ===========
 SET(GEOM_ROOT_DIR $ENV{GEOM_ROOT_DIR} CACHE PATH "Path to the Salome GEOM")
 IF(EXISTS ${GEOM_ROOT_DIR})
-  INCLUDE(${GEOM_ROOT_DIR}/adm_local/cmake_files/FindGEOM.cmake)
+  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})
+  IF(SALOME_BUILD_GUI)
+    IF(NOT SALOME_GEOM_BUILD_GUI)
+      MESSAGE(FATAL_ERROR "We absolutely need a Salome GEOM with GUI, please set SALOME_BUILD_GUI=ON in GEOM module")
+    ENDIF(NOT SALOME_GEOM_BUILD_GUI)
+  ENDIF(SALOME_BUILD_GUI)
 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(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${KERNEL_ROOT_DIR}/salome_adm/cmake_files ${GUI_ROOT_DIR}/adm_local/cmake_files)
-find_package(SalomeQT4)
-find_package(SalomeCAS)
-find_package(SalomeCPPUNIT)
+# Platform setup
+# ==============
+INCLUDE(SalomeSetupPlatform)   # From SalomeMacros
+# Always build libraries as shared objects:
+SET(BUILD_SHARED_LIBS TRUE)
+# Local macros:
+LIST(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/adm/cmake")
+
+# User options
+# ============
+# (some options may have already been defined in KERNEL) 
+OPTION(SALOME_BUILD_DOC "Generate HYDRO documentation" ON)
+OPTION(SALOME_BUILD_TESTS "Build HYDRO tests" ON)
+
+# Prerequisites
+# =============
+# Find "big" prerequisites first - they reference themselves many others
+#   -> this can helps to find the smaller prerequisites and detect conflicts.
+# In our case KERNEL may have already loaded many prerequisites which are also used in HYDRO:
+
+##
+## From KERNEL:
+##
+
+# Mandatory products
+FIND_PACKAGE(SalomePython    REQUIRED)
+
+# Optional products:
+IF(SALOME_BUILD_TESTS)
+  ENABLE_TESTING()
+  FIND_PACKAGE(SalomeCppUnit)
+  SALOME_LOG_OPTIONAL_PACKAGE(CppUnit SALOME_BUILD_TESTS)  
+ENDIF()
+
+IF(SALOME_BUILD_DOC)
+  IF(SALOME_USE_MPI)
+    FIND_PACKAGE(SalomeMPI) # needed for doc generation by Sphinx
+    SALOME_LOG_OPTIONAL_PACKAGE(MPI SALOME_BUILD_DOC)
+  ENDIF()  
+  FIND_PACKAGE(SalomeDoxygen)
+  FIND_PACKAGE(SalomeSphinx)
+  SALOME_LOG_OPTIONAL_PACKAGE(Doxygen SALOME_BUILD_DOC)
+  SALOME_LOG_OPTIONAL_PACKAGE(Sphinx SALOME_BUILD_DOC)
+ENDIF()
+
+# Find optional GUI libraries
+IF(SALOME_BUILD_GUI)
+  # Qt4
+  FIND_PACKAGE(SalomeQt4 REQUIRED COMPONENTS QtCore QtGui)
+ENDIF(SALOME_BUILD_GUI)
+
+##
+## HYDRO specifics
+##
+
+FIND_PACKAGE(SalomeCAS REQUIRED)
+
+FIND_PACKAGE(SalomeSIP REQUIRED)  # should come after Python and before PyQt4
+
+FIND_PACKAGE(SalomePyQt4 REQUIRED)
+
+
+# Detection summary:
+SALOME_PACKAGE_REPORT_AND_CHECK()
+
+# Directories
+# ===========
+SET(SALOME_INSTALL_BINS "${SALOME_INSTALL_BINS}" CACHE PATH "Install path: SALOME binaries")
+SET(SALOME_INSTALL_LIBS "${SALOME_INSTALL_LIBS}" CACHE PATH "Install path: SALOME libs")
+SET(SALOME_INSTALL_IDLS "${SALOME_INSTALL_IDLS}" CACHE PATH "Install path: SALOME IDL files")
+SET(SALOME_INSTALL_HEADERS "${SALOME_INSTALL_HEADERS}" CACHE PATH "Install path: SALOME headers")
+SET(SALOME_INSTALL_SCRIPT_SCRIPTS "${SALOME_INSTALL_SCRIPT_SCRIPTS}" CACHE PATH 
+  "Install path: SALOME scripts")
+SET(SALOME_INSTALL_SCRIPT_DATA "${SALOME_INSTALL_SCRIPT_DATA}" CACHE PATH 
+  "Install path: SALOME script data")
+SET(SALOME_INSTALL_SCRIPT_PYTHON "${SALOME_INSTALL_SCRIPT_PYTHON}" CACHE PATH 
+  "Install path: SALOME Python scripts")
+SET(SALOME_INSTALL_PYTHON "${SALOME_INSTALL_PYTHON}" CACHE PATH "Install path: SALOME Python stuff")
+SET(SALOME_INSTALL_PYTHON_SHARED "${SALOME_INSTALL_PYTHON_SHARED}" CACHE PATH 
+  "Install path: SALOME Python shared modules")
+SET(SALOME_INSTALL_CMAKE_LOCAL adm/cmake CACHE PATH 
+  "Install path: local SALOME CMake files") 
+SET(SALOME_INSTALL_AMCONFIG_LOCAL adm/unix CACHE PATH
+  "Install path: local SALOME config files (obsolete, to be removed)")
+
+SET(SALOME_INSTALL_RES "${SALOME_INSTALL_RES}" CACHE PATH "Install path: SALOME resources")
+SET(SALOME_INSTALL_DOC "${SALOME_INSTALL_DOC}" CACHE PATH "Install path: SALOME documentation")
+
+# Specific to HYDRO:
+SET(SALOME_HYDRO_INSTALL_RES_DATA "${SALOME_INSTALL_RES}/hydro" CACHE PATH 
+  "Install path: SALOME HYDRO specific data")
+SET(SALOME_HYDRO_INSTALL_RES_SCRIPTS "${SALOME_INSTALL_RES}/hydro" CACHE PATH 
+  "Install path: SALOME HYDRO scripts")
+SET(SALOME_HYDRO_INSTALL_SAMPLES share/salome/hydrosamples CACHE PATH
+  "Install path: SALOME HYDRO samples")
+MARK_AS_ADVANCED(
+  SALOME_HYDRO_INSTALL_RES_DATA
+  SALOME_HYDRO_INSTALL_RES_SCRIPTS
+  SALOME_HYDRO_INSTALL_SAMPLES
+  )
+
+# Sources 
+# ========
+ADD_SUBDIRECTORY (src/HYDROCurveCreator)
+ADD_SUBDIRECTORY (src/HYDROData)
+ADD_SUBDIRECTORY (src/HYDROGUI)
+ADD_SUBDIRECTORY (src/HYDROPy)
+IF(SALOME_BUILD_DOC)
+  #ADD_SUBDIRECTORY(doc)
+ENDIF()
+
+# Header configuration
+# ====================
+SALOME_XVERSION(${PROJECT_NAME})
+SALOME_CONFIGURE_FILE(HYDRO_version.h.in HYDRO_version.h INSTALL ${SALOME_INSTALL_HEADERS})
+
+# Configuration export
+# (here only the level 1 prerequisites are exposed)
+# ====================
+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 
+  HYDROData HYDROPy
+)
+
+IF(SALOME_BUILD_TESTS)
+  #LIST(APPEND _${PROJECT_NAME}_exposed_targets <insert_test_targets_here>)
+ENDIF(SALOME_BUILD_TESTS)
+
+IF(SALOME_BUILD_GUI)
+  LIST(APPEND _${PROJECT_NAME}_exposed_targets 
+    HYDROGUI HYDROCurveCreator
+  )
+ENDIF(SALOME_BUILD_GUI)
+
+# Add all targets to the build-tree export set
+EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
+  FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
+
+# Create the configuration files:
+#   - in the build tree:
+
+#      Ensure the variables are always defined for the configure:
+SET(KERNEL_ROOT_DIR "${KERNEL_ROOT_DIR}")
+SET(GUI_ROOT_DIR "${GUI_ROOT_DIR}")
+SET(SIP_ROOT_DIR "${SIP_ROOT_DIR}")
+SET(QT4_ROOT_DIR "${QT4_ROOT_DIR}")
+SET(PYQT4_ROOT_DIR "${PYQT4_ROOT_DIR}")
+SET(CAS_ROOT_DIR "${CAS_ROOT_DIR}")
+SET(CONF_INCLUDE_DIRS "${PROJECT_SOURCE_DIR}/include" "${PROJECT_BINARY_DIR}/include")
+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 GUI_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR CAS_ROOT_DIR)
 
-set(HYDRO_salomeres_DATA share/salome/resources/hydro)
+#   - in the install tree (VSR 16/08/2013: TEMPORARILY COMMENT THIS - TO REMOVE?):
+#       Get the relative path of the include directory so 
+#       we can register it in the generated configuration files:
+#SET(CONF_INCLUDE_DIRS "${CMAKE_INSTALL_PREFIX}/${INSTALL_INCLUDE_DIR}")
+#CONFIGURE_PACKAGE_CONFIG_FILE(adm_local/cmake_files/${PROJECT_NAME}Config.cmake.in 
+#    ${PROJECT_BINARY_DIR}/to_install/${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 GUI_ROOT_DIR SIP_ROOT_DIR QT4_ROOT_DIR PYQT4_ROOT_DIR EXPAT_ROOT_DIR QSCINTILLA_ROOT_DIR)
 
-add_subdirectory (src/HYDROCurveCreator)
-add_subdirectory (src/HYDROData)
-add_subdirectory (src/HYDROGUI)
-add_subdirectory (src/HYDROPy)
+WRITE_BASIC_PACKAGE_VERSION_FILE(${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake
+    VERSION ${${PROJECT_NAME_UC}_VERSION}
+    COMPATIBILITY AnyNewerVersion)
+  
+# Install the CMake configuration files:
+INSTALL(FILES
+  "${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
+  "${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
+  DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}")
 
-enable_testing()
+# Install the export set for use with the install-tree
+INSTALL(EXPORT ${PROJECT_NAME}TargetGroup DESTINATION "${SALOME_INSTALL_CMAKE_LOCAL}" 
+        FILE ${PROJECT_NAME}Targets.cmake)
diff --git a/adm_local/CMakeLists.txt b/adm_local/CMakeLists.txt
deleted file mode 100644 (file)
index 4425df4..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-
-ADD_SUBDIRECTORY(cmake_files)
diff --git a/adm_local/cmake_files/CMakeLists.txt b/adm_local/cmake_files/CMakeLists.txt
deleted file mode 100644 (file)
index 48d8df9..0000000
+++ /dev/null
@@ -1,10 +0,0 @@
-
-# ===============================================================
-# Files to be installed
-# ===============================================================
-
-# These files are data, module or lib files
-SET(_adm_data
-  FindSalomeHYDRO.cmake
-)
-INSTALL(FILES ${_adm_data} DESTINATION ${SALOME_INSTALL_CMAKE_LOCAL})
diff --git a/adm_local/cmake_files/FindSalomeHYDRO.cmake b/adm_local/cmake_files/FindSalomeHYDRO.cmake
deleted file mode 100644 (file)
index 1fe8757..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-
-IF(NOT SalomeHYDRO_FIND_QUIETLY)
-  MESSAGE(STATUS "Looking for Salome HYDRO ...")
-ENDIF()
-
-SET(CMAKE_PREFIX_PATH "${HYDRO_ROOT_DIR}")
-
-SALOME_FIND_PACKAGE(SalomeHYDRO SalomeHYDRO CONFIG)
-
-IF(NOT SalomeHYDRO_FIND_QUIETLY)
-  MESSAGE(STATUS "Found Salome HYDRO: ${HYDRO_ROOT_DIR}")
-ENDIF()
-
-FOREACH(_res ${SalomeHYDRO_EXTRA_ENV})
-  SALOME_ACCUMULATE_ENVIRONMENT(${_res} "${SalomeHYDRO_EXTRA_ENV_${_res}}")
-ENDFOREACH()
\ No newline at end of file
index 5b29efdf76e0ce6ec45a73b2064384ebbdc39b37..e225ade5d26b8ea9eebaea1e31ff54c358c06851 100644 (file)
@@ -1,17 +1,36 @@
-
-include(../../CMake/Common.cmake)
-include(../../CMake/UseQT4EXT.cmake)
+# Copyright (C) 2012-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+#
+# This library is free software; you can redistribute it and/or
+# modify it under the terms of the GNU Lesser General Public
+# License as published by the Free Software Foundation; either
+# version 2.1 of the License.
+#
+# 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(SALOME_BUILD_GUI)
+  INCLUDE(${QT_USE_FILE})
+ENDIF(SALOME_BUILD_GUI)
 
 # --- options ---
 
 # additional include directories
 INCLUDE_DIRECTORIES(
-  ${QT_INCLUDES}
+  ${QT_INCLUDE_DIRS}
   ${PTHREAD_INCLUDE_DIR}
   ${CAS_INCLUDE_DIRS}
   ${KERNEL_INCLUDE_DIRS}
-  ${GEOM_ROOT_DIR}/include/salome
-  ${GUI_ROOT_DIR}/include/salome
+  ${GUI_INCLUDE_DIRS}
+  ${GEOM_INCLUDE_DIRS}
 )
 
 # additional preprocessor / compiler flags
@@ -23,67 +42,76 @@ ADD_DEFINITIONS(
 
 # libraries to link to
 SET(_link_LIBRARIES
-  ${QT_LIBRARIES}
-  ${qtx}
-  ${suit}
-  ${OCCViewer}
   ${GEOM_GEOMUtils}
-  ${CAS_TKV3d} ${CAS_TKBRep} ${CAS_TKService}
 )
+IF(SALOME_BUILD_GUI)
+  LIST(APPEND _link_LIBRARIES
+    ${GUI_qtx}
+    ${GUI_suit}
+    ${GUI_OCCViewer}
+  )
+ENDIF(SALOME_BUILD_GUI)
 
 # --- headers ---
 
-# header files / to be processed by moc
-SET(_moc_HEADERS
+IF(SALOME_BUILD_GUI)
+  # header files / to be processed by moc
+  SET(_moc_HEADERS
     CurveCreator_NewSectionDlg.h
     CurveCreator_TreeView.h
 #    CurveCreator_UndoOptsDlg.h
     CurveCreator_Widget.h
-)
+  )
+ENDIF(SALOME_BUILD_GUI)
 
 # header files / no processing
 SET(_other_HEADERS
   CurveCreator.hxx
+  CurveCreator_Displayer.h
   CurveCreator_Curve.hxx
   CurveCreator_Diff.hxx
   CurveCreator_ICurve.hxx
-  CurveCreator_Listener.hxx
   CurveCreator_Macro.hxx
   CurveCreator_Operation.hxx
   CurveCreator_Section.hxx
+  CurveCreator_Utils.h
 )
 
 # header files / to install
-SET(CurveCreator_HEADERS ${_moc_HEADERS} ${_other_HEADERS})
+SET(HYDROCurveCreator_HEADERS ${_moc_HEADERS} ${_other_HEADERS})
 
 # --- sources ---
 
-# sources / moc wrappings
-QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS})
+IF(SALOME_BUILD_GUI)
+  # sources / moc wrappings
+  QT4_WRAP_CPP(_moc_SOURCES ${_moc_HEADERS})
+ENDIF(SALOME_BUILD_GUI)
 
 # sources / static
 SET(_other_SOURCES
+  CurveCreator_Displayer.cxx
   CurveCreator_Curve.cxx
   CurveCreator_Diff.cxx
   CurveCreator_Operation.cxx
+  CurveCreator_Utils.cxx
 )
-
-LIST(APPEND _other_SOURCES
+IF(SALOME_BUILD_GUI)
+  LIST(APPEND _other_SOURCES
     CurveCreator_NewSectionDlg.cxx
     CurveCreator_TreeView.cxx
 #    CurveCreator_UndoOptsDlg.cxx
     CurveCreator_Widget.cxx
   )
+ENDIF(SALOME_BUILD_GUI)
 
 # sources / to compile
-SET(CurveCreator_SOURCES ${_other_SOURCES} ${_moc_SOURCES})
+SET(HYDROCurveCreator_SOURCES ${_other_SOURCES} ${_moc_SOURCES})
 
 # --- rules ---
 
-ADD_LIBRARY(HYDROCurveCreator SHARED ${CurveCreator_SOURCES} ${CurveCreator_HEADERS})
-TARGET_LINK_LIBRARIES(HYDROCurveCreator ${_link_LIBRARIES})
+ADD_LIBRARY(HYDROCurveCreator ${HYDROCurveCreator_SOURCES} ${HYDROCurveCreator_HEADERS})
+TARGET_LINK_LIBRARIES(HYDROCurveCreator ${_link_LIBRARIES} ${CAS_TKGeomAlgo})
+INSTALL(TARGETS HYDROCurveCreator EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
 
-set(PROJECT_HEADERS ${CurveCreator_SOURCES})
-set(PROJECT_LIBRARIES HYDROCurveCreator)
+INSTALL(FILES ${HYDROCurveCreator_HEADERS} DESTINATION ${SALOME_INSTALL_HEADERS})
 
-include(../../CMake/CommonInstall.cmake)
index 83b4c68fc98176050c5a92a258b2ceed92c66f12..8f878e255c33e667919e72b0ec9e898f43efb9e1 100644 (file)
 
 #include "CurveCreator.hxx"
 #include "CurveCreator_Section.hxx"
-#include "CurveCreator_Listener.hxx"
+#include "CurveCreator_Displayer.h"
+
+#include <AIS_Point.hxx>
+#include <AIS_Line.hxx>
+#include <AIS_Shape.hxx>
+#include <BRepBuilderAPI_MakeEdge.hxx>
+#include <BRepBuilderAPI_MakeWire.hxx>
+#include <Geom_CartesianPoint.hxx>
+#include <gp_Pnt.hxx>
+#include <gp_Lin.hxx>
+#include <TopoDS_Edge.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopoDS_Wire.hxx>
+#include <TColgp_HArray1OfPnt.hxx>
+#include <GeomAPI_Interpolate.hxx>
 
 #include <stdio.h>
 
@@ -35,7 +49,7 @@
 CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimension )
 : myIsLocked  (false),
   myDimension (theDimension),
-  myListener(NULL),
+  myDisplayer (NULL),
   myNbUndos   (0),
   myNbRedos   (0),
   myUndoDepth (-1),
@@ -84,21 +98,21 @@ std::string CurveCreator_Curve::getUniqSectionName() const
 }
 
 //=======================================================================
-// function: setListener
-// purpose: set curve changes listener
+// function: setDisplayer
+// purpose: set curve changes Displayer
 //=======================================================================
-void CurveCreator_Curve::setListener( CurveCreator_Listener* theListener )
+void CurveCreator_Curve::setDisplayer( CurveCreator_Displayer* theDisplayer )
 {
-  myListener = theListener;
+  myDisplayer = theDisplayer;
 }
 
 //=======================================================================
-// function: removeListener
-// purpose: remove the attached listener
+// function: removeDisplayer
+// purpose: remove the attached Displayer
 //=======================================================================
-void CurveCreator_Curve::removeListener()
+void CurveCreator_Curve::removeDisplayer()
 {
-  myListener = NULL;
+  myDisplayer = NULL;
 }
 
 //=======================================================================
@@ -152,6 +166,81 @@ int CurveCreator_Curve::toICoord(const int theIPnt) const
   return theIPnt * myDimension;
 }
 
+std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructSection( int theISection ) const
+{
+  std::vector<Handle_AIS_InteractiveObject> aSectionRepresentation;
+
+  CurveCreator::SectionType aSectType = getSectionType( theISection );
+  int aSectSize = getNbPoints( theISection );
+  bool aSectIsClosed = isClosed( theISection );
+
+  if( aSectType == CurveCreator::Polyline )
+  {
+    int iPoint = 0; 
+    for( ; iPoint < ( aSectSize - 1 ) ; iPoint++ ){
+      Handle_AIS_Point anAISPnt = getAISPoint(theISection, iPoint);
+      aSectionRepresentation.push_back( anAISPnt );
+      Handle_AIS_Line aLine = getAISLine( theISection, iPoint, iPoint+1 );
+      aSectionRepresentation.push_back( aLine );
+    }
+    if( aSectSize != 0 ){
+      Handle_AIS_Point anAISPnt = getAISPoint(theISection, iPoint); 
+      aSectionRepresentation.push_back( anAISPnt );
+      if( isClosed(theISection) && ( aSectSize > 1 ) ){
+        Handle_AIS_Line aLine = getAISLine( theISection, iPoint, 0 );
+        aSectionRepresentation.push_back( aLine );
+      }
+    }
+  }
+  else if( aSectType == CurveCreator::Spline )
+  {
+    std::vector<double> aPoints;
+    for( int iPoint = 0; iPoint < aSectSize; iPoint++ )
+    {
+      Handle_AIS_Point anAISPnt = getAISPoint( theISection, iPoint );
+      aSectionRepresentation.push_back( anAISPnt );
+
+      CurveCreator::Coordinates aCoords = getPoint( theISection, iPoint );
+      double aX = aCoords[0];
+      double aY = aCoords[1];
+      double aZ = aCoords[2];
+      aPoints.push_back( aX );
+      aPoints.push_back( aY );
+    }
+
+    if( aSectSize > 1 )
+    {
+      Handle(Geom_BSplineCurve) aBSplineCurve;
+      // fill array for algorithm by the received coordinates
+      int aLen = aPoints.size() / 2;
+      Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt (1, aLen);
+      std::vector<double>::const_iterator aListIter = aPoints.begin();
+      for (int ind = 1; ind <= aLen; ind++) {
+        gp_Pnt aPnt(gp::Origin());
+        aPnt.SetX(*aListIter);
+        aListIter++;
+        aPnt.SetY(*aListIter);
+        aListIter++;
+        aPnt.SetZ(0);
+        aHCurvePoints->SetValue(ind, aPnt);
+      }
+      // compute BSpline
+      GeomAPI_Interpolate aGBC(aHCurvePoints, aSectIsClosed, gp::Resolution());
+      aGBC.Perform();
+      if (aGBC.IsDone()) {
+        aBSplineCurve = aGBC.Curve();
+      }
+      TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSplineCurve ).Edge();
+
+      TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire();
+
+      Handle(AIS_Shape) aShape = new AIS_Shape( aWire );
+      aSectionRepresentation.push_back( aShape );
+    }
+  }
+  return aSectionRepresentation;
+}
+
 //=======================================================================
 // function: setUndoDepth
 // purpose:
@@ -210,6 +299,54 @@ int CurveCreator_Curve::getUndoDepth() const
   return myUndoDepth;
 }
 
+Handle_AIS_Point CurveCreator_Curve::getAISPoint( int theISection, int theIPoint ) const
+{
+  double anX, anY, aZ;
+  getCoordinates( theISection, theIPoint, anX, anY, aZ );
+  gp_Pnt aPoint( anX, anY, aZ);
+
+  AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));
+  return aPnt;
+}
+
+Handle_AIS_Line CurveCreator_Curve::getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const
+{
+  double anX, anY, aZ;
+  getCoordinates( theISection, theIPoint1, anX, anY, aZ );
+  gp_Pnt aPoint1( anX, anY, aZ);
+
+  double anX2, anY2, aZ2;
+  getCoordinates( theISection, theIPoint2, anX2, anY2, aZ2 );
+//MTN to avoid crash during line construction
+  if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){
+    aZ2 += 1e-7;
+  }
+
+  gp_Pnt aPoint2( anX2, anY2, aZ2 );
+
+  AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) );
+  return aLine;
+}
+
+void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const
+{
+  CurveCreator::Coordinates aCoords = getPoint( theISection, theIPoint );
+  theX = aCoords[0];
+  theY = aCoords[1];
+  theZ = 0.;
+  if( getDimension() == CurveCreator::Dim3d ){
+    theZ = aCoords[2];
+  }
+}
+
+void CurveCreator_Curve::redisplayCurve()
+{
+  if( myDisplayer ) {
+    myDisplayer->erase();
+    myDisplayer->display( constructWire() );
+  }
+}
+
 /************   Implementation of INTERFACE methods   ************/
 
 /***********************************************/
@@ -265,6 +402,9 @@ bool CurveCreator_Curve::redo()
 //=======================================================================
 bool CurveCreator_Curve::clear()
 {
+  // erase curve from the viewer
+  if( myDisplayer )
+    myDisplayer->erase();
   // Delete all allocated data.
   int i = 0;
   const int aNbSections = getNbSections();
@@ -274,8 +414,6 @@ bool CurveCreator_Curve::clear()
   }
 
   mySections.clear();
-  if( myListener )
-    myListener->curveChanged();
   
   return true;
 }
@@ -297,8 +435,7 @@ bool CurveCreator_Curve::join( const int theISectionTo,
                                aSection2->myPoints.end());
 
     removeSection(theISectionFrom);
-    if( myListener )
-      myListener->curveChanged();
+    redisplayCurve();
 
     finishOperation();
     return true;
@@ -338,8 +475,7 @@ int CurveCreator_Curve::addSection
   aSection->myType     = theType;
   aSection->myIsClosed = theIsClosed;
   mySections.push_back(aSection);
-  if( myListener )
-    myListener->sectionAdded( -1 );
+  redisplayCurve();
 
   finishOperation();
   return mySections.size()-1;
@@ -389,8 +525,7 @@ bool CurveCreator_Curve::removeSection( const int theISection )
     delete *anIterRm;
     mySections.erase(anIterRm);
   }
-  if( myListener )
-    myListener->sectionRemoved(theISection);
+  redisplayCurve();
 
   finishOperation();
   return true;
@@ -437,15 +572,11 @@ bool CurveCreator_Curve::setClosed( const int theISection,
 
     for (i = 0; i < aSize; i++) {
       mySections[i]->myIsClosed = theIsClosed;
-      if( myListener ){
-        myListener->sectionClosed( theISection, theIsClosed );
-      }
+      redisplayCurve();
     }
   } else {
     mySections.at(theISection)->myIsClosed = theIsClosed;
-    if( myListener ){
-      myListener->sectionClosed( theISection, theIsClosed );
-    }
+    redisplayCurve();
   }
   return true;
 }
@@ -490,13 +621,11 @@ bool CurveCreator_Curve::setSectionType( const int theISection,
     for (; i < aNbSections; i++) {
       mySections[i]->myType = theType;
     }
-    if( myListener )
-      myListener->curveChanged();
+    redisplayCurve();
   } else {
     if( mySections.at(theISection)->myType != theType ){
       mySections.at(theISection)->myType = theType;
-      if( myListener )
-        myListener->sectionTypeChanged(theISection);
+      redisplayCurve();
     }
   }
   return true;
@@ -533,8 +662,7 @@ bool CurveCreator_Curve::addPoints( const CurveCreator::Coordinates& theCoords,
       anIterPosition = aSection->myPoints.begin() + toICoord(theIPnt);
     aSection->myPoints.insert(anIterPosition,
                               theCoords.begin(), theCoords.end());
-    if( myListener )
-      myListener->pointInserted( theISection, -1 );
+    redisplayCurve();
     res = true;
   }
   finishOperation();
@@ -562,8 +690,7 @@ bool CurveCreator_Curve::setPoint( const int theISection,
     for (i = 0; i < myDimension; i++) {
       aSection->myPoints.at(toICoord(theIPnt) + i) = theNewCoords[i];
     }
-    if( myListener )
-      myListener->pointChanged( theISection, theIPnt );
+    redisplayCurve();
     
     res = true;
   }
@@ -588,8 +715,7 @@ bool CurveCreator_Curve::removePoint( const int theISection, const int theIPnt )
     CurveCreator::Coordinates::iterator anIterPosition =
       aSection->myPoints.begin() + toICoord(theIPnt);
     aSection->myPoints.erase( anIterPosition );
-    if( myListener )
-      myListener->pointRemoved( theISection, theIPnt );
+    redisplayCurve();
     res = true;
   }
   finishOperation();
@@ -624,6 +750,15 @@ CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection )
 /***********************************************/
 /***       Presentation methods              ***/
 /***********************************************/
-/*  TopoDS_Wire CurveCreator_Curve::constructWire() const
-{
-}*/
+std::vector<Handle_AIS_InteractiveObject> CurveCreator_Curve::constructWire() const
+{
+  std::vector<Handle_AIS_InteractiveObject> aCurveRepresentation;
+  std::vector<Handle_AIS_InteractiveObject> aSectionObjects;
+  for( int iSection = 0 ; iSection < getNbSections() ; iSection++ ){
+    aSectionObjects = constructSection( iSection );
+    for( int iObject = 0 ; iObject < aSectionObjects.size() ; iObject++ ){
+      aCurveRepresentation.push_back( aSectionObjects.at(iObject) );
+    }
+  }
+  return aCurveRepresentation;
+}
index 656b312b06dc683e84287132a4f45c5f5e196588..d5428008528831ac6cba1a87f70bd5e2f322752f 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2013  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
 #include "CurveCreator.hxx"
 #include "CurveCreator_Diff.hxx"
 
+#include <AIS_Point.hxx>
+#include <AIS_Line.hxx>
+#include <AIS_InteractiveObject.hxx>
+
 #include <list>
 
 struct CurveCreator_Section;
-class CurveCreator_Listener;
+class CurveCreator_Displayer;
 
 /**
  *  The CurveCreator_Curve object is represented as one or more sets of
@@ -43,7 +47,7 @@ class CurveCreator_Listener;
  */
 class CURVECREATOR_EXPORT CurveCreator_Curve : public CurveCreator_ICurve
 {
-private:
+protected:
   typedef std::list<CurveCreator_Diff> ListDiff;
 
 public:
@@ -62,11 +66,11 @@ public:
   //! Return unique section name
   virtual std::string getUniqSectionName() const;
 
-  //! Set curve creator listener object
-  virtual void setListener( CurveCreator_Listener* theWatcher );
+  //! Set curve creator Displayer object
+  virtual void setDisplayer( CurveCreator_Displayer* theDisplayer );
 
-  //! Remove curve creator listener object
-  virtual void removeListener();
+  //! Remove curve creator Displayer object
+  virtual void removeDisplayer();
 
   /** Set depth of undo operations (unlimited if \a theDepth is -1
    *  or disabled if \a theDepth is 0)
@@ -85,6 +89,8 @@ public:
    */
   virtual int toICoord(const int theIPnt) const;
 
+  ListAISObjects constructSection( int theISection ) const;
+
 protected:
   /** This method updates all undo/redo information required to be updated
    *  after curve modification operation. It returns false if undo/redo
@@ -92,6 +98,11 @@ protected:
    */
   virtual bool addEmptyDiff();
 
+  Handle_AIS_Point getAISPoint( int theISection, int theIPoint ) const;
+  Handle_AIS_Line  getAISLine( int theISection, int theIPoint1, int theIPoint2 ) const;
+  void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
+
+  void redisplayCurve();
 
 public:
   /************   Implementation of INTERFACE methods   ************/
@@ -209,14 +220,14 @@ public:
   /***********************************************/
   /***       Presentation methods              ***/
   /***********************************************/
-//  virtual TopoDS_Wire constructWire() const;
+  virtual ListAISObjects constructWire() const;
 
 public:
 
   bool                            myIsLocked;
   CurveCreator::Sections          mySections;   //!< curve data
   CurveCreator::Dimension         myDimension;  //!< curve dimension
-  CurveCreator_Listener*          myListener;   //!< listener
+  CurveCreator_Displayer*         myDisplayer;  //!< curve displayer
 
 private:
 
diff --git a/src/HYDROCurveCreator/CurveCreator_Displayer.cxx b/src/HYDROCurveCreator/CurveCreator_Displayer.cxx
new file mode 100644 (file)
index 0000000..2de7bf1
--- /dev/null
@@ -0,0 +1,57 @@
+#include "CurveCreator_Displayer.h"
+
+CurveCreator_Displayer::CurveCreator_Displayer( Handle_AIS_InteractiveContext theContext ) :
+  myContext( theContext )
+{
+  myObjects.clear();
+}
+
+CurveCreator_Displayer::~CurveCreator_Displayer(void)
+{
+  erase();
+  for( int i = 0 ; i < myObjects.size() ; i++ ){
+    myObjects[i].Nullify();
+  }
+  myObjects.clear();
+}
+
+void CurveCreator_Displayer::display( AISObjectsList theCurveObjects )
+{
+  myObjects = theCurveObjects;
+  if(myObjects.empty())
+    return;
+  for( int i = 0 ; i < myObjects.size() ; i++ ){
+    myContext->Display(myObjects[i], Standard_False);
+  }
+  myContext->UpdateCurrentViewer();
+}
+
+void CurveCreator_Displayer::erase()
+{
+  if(myObjects.empty())
+    return;
+  for( int i = 0 ; i < myObjects.size() ; i++ ){
+    myContext->Erase(myObjects[i], Standard_False);
+  }
+  myContext->UpdateCurrentViewer();
+}
+
+Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL )
+{
+  if( isHL ){
+    return Quantity_Color( 1., 0., 0., Quantity_TOC_RGB );
+  }
+  return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );
+}
+
+void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL )
+{
+  return;
+  //TODO:
+  Quantity_Color aColor = getActiveColor( isHL );
+  for( int i = 0 ; i < theObjects.size() ; i++ ){
+    theObjects[i]->SetColor(aColor);
+    myContext->Display(theObjects[i], Standard_False);
+  }
+  myContext->UpdateCurrentViewer();
+}
diff --git a/src/HYDROCurveCreator/CurveCreator_Displayer.h b/src/HYDROCurveCreator/CurveCreator_Displayer.h
new file mode 100644 (file)
index 0000000..58f667b
--- /dev/null
@@ -0,0 +1,31 @@
+#ifndef CURVECREATOR_AIS_CURVE_H
+#define CURVECREATOR_AIS_CURVE_H
+
+#include "CurveCreator_Macro.hxx"
+
+#include <AIS_InteractiveObject.hxx>
+#include <AIS_InteractiveContext.hxx>
+
+#include <vector>
+
+class CURVECREATOR_EXPORT CurveCreator_Displayer
+{
+typedef std::vector<Handle_AIS_InteractiveObject> AISObjectsList;
+
+public:
+  CurveCreator_Displayer(Handle_AIS_InteractiveContext theContext );
+  ~CurveCreator_Displayer(void);
+
+  void display( AISObjectsList theCurveObjects );
+  void erase();
+  void highlight( const AISObjectsList& theObjects, bool isHL );
+
+protected:
+  Quantity_Color getActiveColor( bool isHL );
+
+private:
+  Handle_AIS_InteractiveContext myContext;
+  AISObjectsList                myObjects;
+};
+
+#endif
index 5f269c864cbc1cb28e63e7d3e636a598adc8add5..fd5e63d5b5e5518d999bc69487208ce82ebbba55 100644 (file)
@@ -25,7 +25,9 @@
 
 #include "CurveCreator_Macro.hxx"
 #include <deque>
-#include <string>
+#include <vector>
+
+#include <AIS_InteractiveObject.hxx>
 
 namespace CurveCreator
 {
@@ -54,6 +56,9 @@ namespace CurveCreator
  */
 class CURVECREATOR_EXPORT CurveCreator_ICurve
 {
+public:
+  typedef std::vector<Handle_AIS_InteractiveObject> ListAISObjects;
+
 public:
   /***********************************************/
   /***          Undo/Redo methods              ***/
@@ -164,7 +169,7 @@ public:
   /***********************************************/
   /***       Presentation methods              ***/
   /***********************************************/
-//  virtual TopoDS_Wire constructWire() const = 0;
+  virtual ListAISObjects constructWire() const = 0;
 };
 
 #endif
diff --git a/src/HYDROCurveCreator/CurveCreator_Utils.cxx b/src/HYDROCurveCreator/CurveCreator_Utils.cxx
new file mode 100644 (file)
index 0000000..3077961
--- /dev/null
@@ -0,0 +1,51 @@
+// Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// 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 "CurveCreator_Utils.h"
+
+#include <gp_Pln.hxx>
+#include <ProjLib.hxx>
+#include <ElSLib.hxx>
+
+
+//=======================================================================
+// function : ConvertClickToPoint()
+// purpose  : Returns the point clicked in 3D view
+//=======================================================================
+gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView )
+{
+  V3d_Coordinate XEye, YEye, ZEye, XAt, YAt, ZAt;
+  aView->Eye( XEye, YEye, ZEye );
+
+  aView->At( XAt, YAt, ZAt );
+  gp_Pnt EyePoint( XEye, YEye, ZEye );
+  gp_Pnt AtPoint( XAt, YAt, ZAt );
+
+  gp_Vec EyeVector( EyePoint, AtPoint );
+  gp_Dir EyeDir( EyeVector );
+
+  gp_Pln PlaneOfTheView = gp_Pln( AtPoint, EyeDir );
+  Standard_Real X, Y, Z;
+  aView->Convert( x, y, X, Y, Z );
+  gp_Pnt ConvertedPoint( X, Y, Z );
+
+  gp_Pnt2d ConvertedPointOnPlane = ProjLib::Project( PlaneOfTheView, ConvertedPoint );
+  gp_Pnt ResultPoint = ElSLib::Value( ConvertedPointOnPlane.X(), ConvertedPointOnPlane.Y(), PlaneOfTheView );
+  return ResultPoint;
+}
diff --git a/src/HYDROCurveCreator/CurveCreator_Utils.h b/src/HYDROCurveCreator/CurveCreator_Utils.h
new file mode 100644 (file)
index 0000000..f727601
--- /dev/null
@@ -0,0 +1,44 @@
+// Copyright (C) 2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Lesser General Public
+// License as published by the Free Software Foundation; either
+// version 2.1 of the License.
+//
+// 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
+//
+
+#ifndef CURVECREATOR_UTILS_H
+#define CURVECREATOR_UTILS_H
+
+#include "CurveCreator_Macro.hxx"
+
+#include <gp_Pnt.hxx>
+#include <V3d_View.hxx>
+
+class CurveCreator_Utils
+{
+public:
+
+  /*!
+   * \brief Returns the point clicked in 3D view.
+   *
+   * \param x The X coordinate in the view.
+   * \param y The Y coordinate in the view.
+   * \param theView View where the given point takes place.
+   * \retval gp_Pnt Returns the point clicked in 3D view
+   */
+  CURVECREATOR_EXPORT static gp_Pnt ConvertClickToPoint( int x, int y, Handle(V3d_View) theView );
+
+};
+
+#endif // CURVECREATOR_UTILS_H
index fe6d6b8848cf55a46adf683ab10d816ef845d594..441d059ee710fbb37d5281b4993b2c9d96f2d64b 100644 (file)
@@ -24,6 +24,7 @@
 #include "CurveCreator.hxx"
 //#include "CurveCreator_NewPointDlg.h"
 #include "CurveCreator_NewSectionDlg.h"
+#include "CurveCreator_Utils.h"
 
 #include <GEOMUtils.hxx>
 
 
 #include <BRep_Tool.hxx>
 #include <TopoDS.hxx>
+#include <gp_Lin.hxx>
+#include <gp_Dir.hxx>
 
 #include <AIS_ListOfInteractive.hxx>
 #include <AIS_ListIteratorOfListOfInteractive.hxx>
 #include <AIS_Shape.hxx>
 #include <AIS_Point.hxx>
+#include <AIS_Line.hxx>
+#include <Geom_Point.hxx>
 #include <StdSelect_BRepOwner.hxx>
 
 #include <QHBoxLayout>
 #include <QApplication>
 #include <QTableWidget>
 
-#define LOCAL_SELECTION_TOLERANCE 0.0001
+const double LOCAL_SELECTION_TOLERANCE = 0.0001;
+const int POINT_INDEX_COLUMN_WIDTH = 50;
 
 CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
                                          CurveCreator_ICurve *theCurve,
-                                         Qt::WindowFlags fl) :
-    QWidget(parent), myNewSectionEditor(NULL), myCurve(theCurve), mySection(0)
+                                         Qt::WindowFlags fl)
+: QWidget(parent), myNewSectionEditor(NULL), myCurve(theCurve), mySection(0), myDragStarted( false ),
+  myOCCViewer( 0 )
 {
-    myNewSectionEditor = new CurveCreator_NewSectionDlg( this );
-    myNewSectionEditor->hide();
-    connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()) );
-    connect( myNewSectionEditor, SIGNAL(modifySection()), this, SLOT(onModifySection()) );
-    connect( myNewSectionEditor, SIGNAL(cancelSection()), this, SLOT(onCancelSection()) );
-
-    QGroupBox* aSectionGroup = new QGroupBox(tr("Sections"),this);
-
-    mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup);
-    connect( mySectionView, SIGNAL(selectionChanged()), this, SLOT( onSelectionChanged() ) );
-    connect( mySectionView, SIGNAL(sectionEntered(int)), this, SLOT(onEditSection(int)) );
-    connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) );
-
-    myLocalPointView = new QTableWidget();
-    myLocalPointView->setVisible( false );
-    myLocalPointView->setColumnCount( 3 );
-    QStringList aLabels;
-    //aLabels << tr( "IDENTIFIER_LABEL" ) << tr( "X_POSITION_LBL" ) << tr( "Y_POSITION_LBL" );
-    aLabels << tr( "id" ) << tr( "X" ) << tr( "Y" );
-    myLocalPointView->setHorizontalHeaderLabels( aLabels );
-    connect( myLocalPointView, SIGNAL( cellChanged( int, int ) ),
-             this, SLOT( onLocalPointChanged( int, int ) ) );
-
-    QToolBar* aTB = new QToolBar(tr("TOOL_BAR_TLT"), aSectionGroup);
+  myNewSectionEditor = new CurveCreator_NewSectionDlg( this );
+  myNewSectionEditor->hide();
+  connect( myNewSectionEditor, SIGNAL(addSection()), this, SLOT(onAddNewSection()) );
+  connect( myNewSectionEditor, SIGNAL(modifySection()), this, SLOT(onModifySection()) );
+  connect( myNewSectionEditor, SIGNAL(cancelSection()), this, SLOT(onCancelSection()) );
+
+  QGroupBox* aSectionGroup = new QGroupBox(tr("Sections"),this);
+
+  mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup);
+  connect( mySectionView, SIGNAL(selectionChanged()), this, SLOT( onSelectionChanged() ) );
+  connect( mySectionView, SIGNAL(sectionEntered(int)), this, SLOT(onEditSection(int)) );
+  connect( mySectionView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(onContextMenu(QPoint)) );
+
+  myLocalPointView = new QTableWidget();
+  myLocalPointView->setVisible( false );
+  myLocalPointView->setColumnCount( 3 );
+  myLocalPointView->setColumnWidth( 0, POINT_INDEX_COLUMN_WIDTH );
+  QStringList aLabels;
+  //aLabels << tr( "IDENTIFIER_LABEL" ) << tr( "X_POSITION_LBL" ) << tr( "Y_POSITION_LBL" );
+  aLabels << tr( "id" ) << tr( "X" ) << tr( "Y" );
+  myLocalPointView->setHorizontalHeaderLabels( aLabels );
+  connect( myLocalPointView, SIGNAL( cellChanged( int, int ) ),
+           this, SLOT( onLocalPointChanged( int, int ) ) );
+
+  QToolBar* aTB = new QToolBar(tr("TOOL_BAR_TLT"), aSectionGroup);
 //    QToolButton* anUndoBtn = new QToolButton(aTB);
 
-    SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
-    QPixmap anUndoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_UNDO")));
-    QPixmap aRedoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_REDO")));
-    QPixmap aNewSectionPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_SECTION")));
-    QPixmap aNewPointPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_POINT")));
-    QPixmap anEditPointsPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_EDIT_POINTS")));
-    QPixmap aDetectPointsPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_EDIT_POINTS")));
-    QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
-    QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
-    QPixmap aRemovePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_DELETE")));
-    QPixmap aJoinPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_JOIN")));
-    QPixmap aStepUpPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_UP")));
-    QPixmap aStepDownPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN")));
-
-    QAction* anAct = createAction( UNDO_ID, tr("UNDO"), anUndoPixmap, tr("UNDO_TLT"), 
-                                   QKeySequence(Qt::ControlModifier|Qt::Key_Z) );
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onUndo()) );
-    aTB->addAction(anAct);
-
-    anAct = createAction( REDO_ID, tr("REDO"), aRedoPixmap, tr("REDO_TLT"), 
-                          QKeySequence(Qt::ControlModifier|Qt::Key_Y) );
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onRedo()) );
-    aTB->addAction(anAct);
-
-    aTB->addSeparator();
-
-    anAct = createAction( NEW_SECTION_ID, tr("NEW_SECTION"), aNewSectionPixmap, tr("NEW_SECTION_TLT"), 
-                          QKeySequence(Qt::ControlModifier|Qt::Key_N) );
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onNewSection()) );
-    aTB->addAction(anAct);
-    aTB->addSeparator();
-
-    anAct = createAction( ADDITION_MODE_ID, tr("ADDITION_MODE"), aNewPointPixmap, tr("ADDITION_MODE_TLT"), 
-                          QKeySequence() );
-    anAct->setCheckable(true);
-    connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onAdditionMode(bool)) );
-    connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) );
-    aTB->addAction(anAct);
-    
-    anAct = createAction( MODIFICATION_MODE_ID, tr("MODIFICATION_MODE"), anEditPointsPixmap, tr("MODIFICATION_MODE_TLT"), 
-                          QKeySequence() );
-    anAct->setCheckable(true);
-    connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onModificationMode(bool)) );
-    connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) );
-    aTB->addAction(anAct);
-
-    anAct = createAction( DETECTION_MODE_ID, tr("DETECTION_MODE"), aDetectPointsPixmap, tr("DETECTION_MODE_TLT"), 
-                          QKeySequence() );
-    anAct->setCheckable(true);
-    connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onDetectionMode(bool)) );
-    connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) );
-    aTB->addAction(anAct);
-
-    anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), QPixmap(), tr("CLOSE_SECTIONS_TLT"), 
-                          QKeySequence(Qt::ControlModifier|Qt::Key_W) );
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onCloseSections()) );
-
-    anAct = createAction( UNCLOSE_SECTIONS_ID, tr("UNCLOSE_SECTIONS"), QPixmap(), 
-                          tr("UNCLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_S) );
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onUncloseSections()) );
-
-    anAct = createAction( SET_SECTIONS_POLYLINE_ID, tr("SET_SECTIONS_POLYLINE"), 
-                          aPolylinePixmap, tr("SET_POLYLINE_TLT"), 
-                          QKeySequence(Qt::ControlModifier|Qt::Key_E) );
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onSetPolyline()) );
-
-    anAct = createAction( SET_SECTIONS_SPLINE_ID, tr("SET_SECTIONS_SPLINE"), aSplinePixmap, 
-                          tr("SET_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) );
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) );
-
-    anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, tr("REMOVE_TLT"), 
-                          QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) );
-    connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) );
-    aTB->addAction(anAct);
-    aTB->addSeparator();
-
-    anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"), 
-                          QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );
-    connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );
-    aTB->addAction(anAct);
-    aTB->addSeparator();
-
-    anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"), 
-                          QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );
-    connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );
-
-    anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"), 
-                          QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) );
-    connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );
-
-    QVBoxLayout* aSectLayout = new QVBoxLayout();
-    aSectLayout->setMargin( 5 );
-    aSectLayout->setSpacing( 5 );
-    aSectLayout->addWidget(aTB);
-    aSectLayout->addWidget(mySectionView);
-    aSectLayout->addWidget( myLocalPointView );
-    aSectionGroup->setLayout(aSectLayout);
-    QVBoxLayout* aLay = new QVBoxLayout();
-    aLay->setMargin( 0 );
-    aLay->setSpacing( 5 );
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+  QPixmap anUndoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_UNDO")));
+  QPixmap aRedoPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_REDO")));
+  QPixmap aNewSectionPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_SECTION")));
+  QPixmap aNewPointPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_NEW_POINT")));
+  QPixmap anEditPointsPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_EDIT_POINTS")));
+  QPixmap aDetectPointsPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_EDIT_POINTS")));
+  QPixmap aPolylinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_POLYLINE")));
+  QPixmap aSplinePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
+  QPixmap aRemovePixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_DELETE")));
+  QPixmap aJoinPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_JOIN")));
+  QPixmap aStepUpPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_UP")));
+  QPixmap aStepDownPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN")));
+
+  QAction* anAct = createAction( UNDO_ID, tr("UNDO"), anUndoPixmap, tr("UNDO_TLT"), 
+                                 QKeySequence(Qt::ControlModifier|Qt::Key_Z) );
+  connect(anAct, SIGNAL(triggered()), this, SLOT(onUndo()) );
+  aTB->addAction(anAct);
+
+  anAct = createAction( REDO_ID, tr("REDO"), aRedoPixmap, tr("REDO_TLT"), 
+                        QKeySequence(Qt::ControlModifier|Qt::Key_Y) );
+  connect(anAct, SIGNAL(triggered()), this, SLOT(onRedo()) );
+  aTB->addAction(anAct);
+
+  aTB->addSeparator();
+
+  anAct = createAction( NEW_SECTION_ID, tr("NEW_SECTION"), aNewSectionPixmap, tr("NEW_SECTION_TLT"), 
+                        QKeySequence(Qt::ControlModifier|Qt::Key_N) );
+  connect(anAct, SIGNAL(triggered()), this, SLOT(onNewSection()) );
+  aTB->addAction(anAct);
+  aTB->addSeparator();
+
+  anAct = createAction( ADDITION_MODE_ID, tr("ADDITION_MODE"), aNewPointPixmap, tr("ADDITION_MODE_TLT"), 
+                        QKeySequence() );
+  anAct->setCheckable(true);
+  connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onAdditionMode(bool)) );
+  connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) );
+  aTB->addAction(anAct);
+  
+  anAct = createAction( MODIFICATION_MODE_ID, tr("MODIFICATION_MODE"), anEditPointsPixmap, tr("MODIFICATION_MODE_TLT"), 
+                        QKeySequence() );
+  anAct->setCheckable(true);
+  connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onModificationMode(bool)) );
+  connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) );
+  aTB->addAction(anAct);
+
+  anAct = createAction( DETECTION_MODE_ID, tr("DETECTION_MODE"), aDetectPointsPixmap, tr("DETECTION_MODE_TLT"), 
+                        QKeySequence() );
+  anAct->setCheckable(true);
+  connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onDetectionMode(bool)) );
+  connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) );
+  aTB->addAction(anAct);
+
+  anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), QPixmap(), tr("CLOSE_SECTIONS_TLT"), 
+                        QKeySequence(Qt::ControlModifier|Qt::Key_W) );
+  connect(anAct, SIGNAL(triggered()), this, SLOT(onCloseSections()) );
+
+  anAct = createAction( UNCLOSE_SECTIONS_ID, tr("UNCLOSE_SECTIONS"), QPixmap(), 
+                        tr("UNCLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_S) );
+  connect(anAct, SIGNAL(triggered()), this, SLOT(onUncloseSections()) );
+
+  anAct = createAction( SET_SECTIONS_POLYLINE_ID, tr("SET_SECTIONS_POLYLINE"), 
+                        aPolylinePixmap, tr("SET_POLYLINE_TLT"), 
+                        QKeySequence(Qt::ControlModifier|Qt::Key_E) );
+  connect(anAct, SIGNAL(triggered()), this, SLOT(onSetPolyline()) );
+
+  anAct = createAction( SET_SECTIONS_SPLINE_ID, tr("SET_SECTIONS_SPLINE"), aSplinePixmap, 
+                        tr("SET_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) );
+  connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) );
+
+  anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, tr("REMOVE_TLT"), 
+                        QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) );
+  connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) );
+  aTB->addAction(anAct);
+  aTB->addSeparator();
+
+  anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"), 
+                        QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );
+  connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );
+  aTB->addAction(anAct);
+  aTB->addSeparator();
+
+  anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"), 
+                        QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );
+  connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );
+
+  anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"), 
+                        QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) );
+  connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );
+
+  QVBoxLayout* aSectLayout = new QVBoxLayout();
+  aSectLayout->setMargin( 5 );
+  aSectLayout->setSpacing( 5 );
+  aSectLayout->addWidget(aTB);
+  aSectLayout->addWidget(mySectionView);
+  aSectLayout->addWidget( myLocalPointView );
+  aSectionGroup->setLayout(aSectLayout);
+  QVBoxLayout* aLay = new QVBoxLayout();
+  aLay->setMargin( 0 );
+  aLay->setSpacing( 5 );
 //    aLay->addLayout(aNameLayout);
-    aLay->addWidget(aSectionGroup);
-    setLayout(aLay);
-    onSelectionChanged();
-
-    /*OCCViewer_Viewer* anOCCViewer = getOCCViewer();
-    if (anOCCViewer) {
-      OCCViewer_ViewWindow* aWnd = dynamic_cast<OCCViewer_ViewWindow*>(anOCCViewer->getViewManager()->getActiveView());
-      if ( aWnd )
-        aWnd->installEventFilter( this );
-    }*/
+  aLay->addWidget(aSectionGroup);
+  setLayout(aLay);
+  onSelectionChanged();
 }
 
-//=======================================================================
-// function: getUniqSectionName
-// purpose: return unique section name
-//=======================================================================
+/**
+ * Set an OCC viewer
+ */
+void CurveCreator_Widget::setOCCViewer( OCCViewer_Viewer* theViewer )
+{
+  if ( myOCCViewer ) {
+    OCCViewer_ViewManager* aViewManager = dynamic_cast<OCCViewer_ViewManager*>
+                                                    ( myOCCViewer->getViewManager() );
+    disconnect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
+           this, SLOT( onMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
+    disconnect( aViewManager, SIGNAL( mouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ),
+           this, SLOT( onMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
+    disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
+           this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
+  }
+
+  myOCCViewer = theViewer;
+  if ( myOCCViewer ) {
+    //OCCViewer_ViewWindow* aWnd = dynamic_cast<OCCViewer_ViewWindow*>(myOCCViewer->getViewManager()->getActiveView());
+    //if ( aWnd )
+    //  aWnd->installEventFilter( this );
+    OCCViewer_ViewManager* aViewManager = dynamic_cast<OCCViewer_ViewManager*>
+                                                    ( myOCCViewer->getViewManager() );
+    connect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
+           this, SLOT( onMousePress( SUIT_ViewWindow*, QMouseEvent* ) ) );
+    connect( aViewManager, SIGNAL( mouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ),
+           this, SLOT( onMouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ) );
+    connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
+           this, SLOT( onMouseMove( SUIT_ViewWindow*, QMouseEvent* ) ) );
+  }
+}
+
+/**
+ * Returns current OCC viewer
+ */
 OCCViewer_Viewer* CurveCreator_Widget::getOCCViewer()
 {
-  OCCViewer_Viewer* anOCCViewer = 0;
-
-  OCCViewer_ViewWindow* aViewWindow = 0;
-  SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
-  if ( activeStudy )
-    aViewWindow = dynamic_cast<OCCViewer_ViewWindow*>(SUIT_Session::session()->activeApplication()->desktop()->activeWindow());
-  if ( aViewWindow == 0 )
-    return anOCCViewer;
-  OCCViewer_ViewManager* aViewManager = dynamic_cast<OCCViewer_ViewManager*>(aViewWindow->getViewManager());
-  if ( aViewManager == 0 )
-    return anOCCViewer;
-
-  anOCCViewer = aViewManager->getOCCViewer();
-  return anOCCViewer;
+  return myOCCViewer;
 }
 
 /*!
@@ -234,8 +253,10 @@ OCCViewer_Viewer* CurveCreator_Widget::getOCCViewer()
 */
 /*bool CurveCreator_Widget::eventFilter( QObject* theWatched, QEvent* theEvent )
 {
-  OCCViewer_Viewer* anOCCViewer = getOCCViewer();
-  Handle(AIS_InteractiveContext) aContext = anOCCViewer->getAISContext();
+  OCCViewer_Viewer* aViewer = getOCCViewer();
+  if ( !aViewer )
+    return;
+  Handle(AIS_InteractiveContext) aContext = aViewer->getAISContext();
   bool isLocalContext = aContext->HasOpenedContext();
   if ( !isLocalContext )
     return QWidget::eventFilter( theWatched, theEvent );
@@ -292,28 +313,37 @@ void CurveCreator_Widget::onSelectionChanged()
       }*/
       if( aSelSections.size() == 1 ){
         anEnabledAct << ADDITION_MODE_ID << MODIFICATION_MODE_ID << DETECTION_MODE_ID;
+        anEnabledAct << REMOVE_ID;
       }
-      if (myActionMap[ADDITION_MODE_ID]->isChecked()) {
-        mySection = -1;
-        myPointNum = -1;
-        QList<int> aSelSection = mySectionView->getSelectedSections();
-        if( aSelSection.size() > 0 ){
-          mySection = aSelSection[0];
-          myPointNum = myCurve->getNbPoints(mySection);
+      switch ( getActionMode() ) {
+        case AdditionMode: {
+          mySection = -1;
+          myPointNum = -1;
+          QList<int> aSelSection = mySectionView->getSelectedSections();
+          if( aSelSection.size() > 0 ){
+            mySection = aSelSection[0];
+            myPointNum = myCurve->getNbPoints(mySection);
+          }
         }
-      } else if (myActionMap[MODIFICATION_MODE_ID]->isChecked()) {
-        anEnabledAct << REMOVE_ID;
-        anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID;
-        int aSectCnt = myCurve->getNbSections();
-        if( aSectCnt > 0 )
-          anEnabledAct << CLEAR_ALL_ID;
-        if( aSectCnt > 1 )
-          anEnabledAct << JOIN_ALL_ID;
-        if( aSelSections.size() > 1 ){
-          anEnabledAct << JOIN_ID;
+        break;
+        case ModificationMode: {
+         anEnabledAct << CLOSE_SECTIONS_ID << UNCLOSE_SECTIONS_ID << SET_SECTIONS_POLYLINE_ID << SET_SECTIONS_SPLINE_ID;
+          int aSectCnt = myCurve->getNbSections();
+          if( aSectCnt > 0 )
+            anEnabledAct << CLEAR_ALL_ID;
+          if( aSectCnt > 1 )
+            anEnabledAct << JOIN_ALL_ID;
+          if( aSelSections.size() > 1 ){
+            anEnabledAct << JOIN_ID;
+          }
+        }
+        break;
+        case DetectionMode: {
         }
-      } else if (myActionMap[DETECTION_MODE_ID]->isChecked()) {
-      } else { //no active mode
+        break;
+        case NoneMode:
+        default:
+        break;
       }
       /*if( aSelSections[ aSelSections.size() - 1 ] < ( myCurve->getNbSections() - 1 ) ){
         anEnabledAct << DOWN_ID;
@@ -364,25 +394,22 @@ void CurveCreator_Widget::onSelectionChanged()
 
 void CurveCreator_Widget::onAdditionMode(bool checked)
 {
-  if( !myCurve )
+  OCCViewer_Viewer* aViewer = getOCCViewer();
+  if( !myCurve || !aViewer )
     return;
-  OCCViewer_Viewer* anOCCViewer = getOCCViewer();
-  Handle(AIS_InteractiveContext) aContext = anOCCViewer->getAISContext();
+
+  Handle(AIS_InteractiveContext) aContext = aViewer->getAISContext();
   OCCViewer_ViewManager* aViewManager = dynamic_cast<OCCViewer_ViewManager*>
-                                                    (anOCCViewer->getViewManager());
+                                                    (aViewer->getViewManager());
 //  if ( aViewManager->getType() == OCCViewer_Viewer::Type() ) {
-  if( anOCCViewer ) {
+  if( aViewer ) {
     if (checked) {
 /*      myGuiState = aViewWindow->saveState();
-      anOCCViewer->enableMultiselection(false);
-      anOCCViewer->enableSelection(false);*/
-      connect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
-             this, SLOT( onGetCoordsByClick( SUIT_ViewWindow*, QMouseEvent* ) ) );
+      aViewer->enableMultiselection(false);
+      aViewer->enableSelection(false);*/
     } else {
-      disconnect( aViewManager, SIGNAL( mousePress( SUIT_ViewWindow*, QMouseEvent* ) ),
-             this, SLOT( onGetCoordsByClick( SUIT_ViewWindow*, QMouseEvent* ) ) );
-/*      anOCCViewer->enableMultiselection(true);
-      anOCCViewer->enableSelection(true);
+/*      aViewer->enableMultiselection(true);
+      aViewer->enableSelection(true);
       aViewWindow->restoreState( myGuiState );*/
       return;
     }
@@ -407,37 +434,6 @@ void CurveCreator_Widget::onAdditionMode(bool checked)
 void CurveCreator_Widget::onModificationMode(bool checked)
 {
   myLocalPointView->setVisible( checked );
-  OCCViewer_Viewer* anOCCViewer = getOCCViewer();
-  OCCViewer_ViewManager* aViewManager = dynamic_cast<OCCViewer_ViewManager*>
-                                                    (anOCCViewer->getViewManager());
-/*
-  SUIT_ViewWindow* aViewWindow = 0;
-  SUIT_Study* activeStudy = SUIT_Session::session()->activeApplication()->activeStudy();
-  if ( activeStudy )
-    aViewWindow = SUIT_Session::session()->activeApplication()->desktop()->activeWindow();
-  if ( aViewWindow == 0 )
-    return;
-  SUIT_ViewManager* aViewManager = aViewWindow->getViewManager();*/
-  if ( aViewManager->getType() == OCCViewer_Viewer::Type() ) {
-    if (checked) {
-      connect( aViewManager, SIGNAL( mouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ),
-             this, SLOT( onPointSelect( SUIT_ViewWindow*, QMouseEvent* ) ) );
-      connect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
-             this, SLOT( onPointDrag( SUIT_ViewWindow*, QMouseEvent* ) ) );
-    }
-    else {
-      disconnect( aViewManager, SIGNAL( mouseRelease( SUIT_ViewWindow*, QMouseEvent* ) ),
-             this, SLOT( onPointSelect( SUIT_ViewWindow*, QMouseEvent* ) ) );
-      disconnect( aViewManager, SIGNAL( mouseMove( SUIT_ViewWindow*, QMouseEvent* ) ),
-             this, SLOT( onPointDrag( SUIT_ViewWindow*, QMouseEvent* ) ) );
-      return;
-    }
-  }
-  //NDS OCCViewer_ViewWindow* anOCCWnd = dynamic_cast<OCCViewer_ViewWindow*>(aViewWindow);
-  //anOCCWnd->activateStartPointSelection();
-    // activate selection ------>
-  //OCCViewer_Viewer* anOCCViewer = dynamic_cast<OCCViewer_Viewer*>(aViewManager->getViewModel());
-
   setLocalPointContext( true );
 }
 
@@ -535,6 +531,20 @@ QAction* CurveCreator_Widget::getAction(ActionId theId)
   return NULL;
 }
 
+CurveCreator_Widget::ActionMode CurveCreator_Widget::getActionMode() const
+{
+  ActionMode aMode = NoneMode;
+
+  if ( myActionMap[ADDITION_MODE_ID]->isChecked() )
+    aMode = AdditionMode;
+  else if ( myActionMap[MODIFICATION_MODE_ID]->isChecked() )
+    aMode = ModificationMode;
+  else if ( myActionMap[DETECTION_MODE_ID]->isChecked() )
+    aMode = DetectionMode;
+
+  return aMode;
+}
+
 void CurveCreator_Widget::onEditSection( int theSection )
 {
   if( !myCurve )
@@ -619,29 +629,17 @@ void CurveCreator_Widget::onRemove()
 {
   if( !myCurve )
     return;
-  QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
-  int aCurrSect=-1;
-  int aRemoveCnt = 0;
-//  myCurve->startOperation();
-  for( int i = 0 ; i < aSelPoints.size() ; i++ ){
-    if( aCurrSect != aSelPoints[i].first ){
-      aRemoveCnt = 0;
-      aCurrSect = aSelPoints[i].first;
-    }
-    int aPntIndx = aSelPoints[i].second - aRemoveCnt;
-    myCurve->removePoint( aCurrSect, aPntIndx );
-    mySectionView->pointsRemoved( aCurrSect, aPntIndx );
-    aRemoveCnt++;
-  }
-  QList<int> aSections = mySectionView->getSelectedSections();
-  for( int i = 0 ; i < aSections.size() ; i++ ){
-    int aSectNum = aSections[i] - (i);
-    myCurve->removeSection( aSectNum );
-    mySectionView->sectionsRemoved( aSectNum );
+
+  switch( getActionMode() ) {
+    case NoneMode:
+      removeSection();
+    break;
+    case ModificationMode:
+      removePoint();
+    break;
+    default:
+      break;
   }
-//  myCurve->finishOperation();
-  mySectionView->clearSelection();
-  updateUndoRedo();
 }
 
 void CurveCreator_Widget::onClearAll()
@@ -818,16 +816,16 @@ QList< QPair< int, int > > CurveCreator_Widget::getSelectedPoints()
 // function : GeometryGUI::onGetCoordsByClick()
 // purpose  : Manage mouse press events in Additon mode
 //=================================================================================
-void CurveCreator_Widget::onGetCoordsByClick( SUIT_ViewWindow* theViewWindow, QMouseEvent* pe )
+void CurveCreator_Widget::onGetCoordsByClick( QMouseEvent* pe )
 {
   if (pe->button() != Qt::LeftButton)
     return;
 
-  if ( theViewWindow->getViewManager()->getType() == OCCViewer_Viewer::Type() &&
-       pe->modifiers() != Qt::ControlModifier ) {
-    OCCViewer_Viewer* anOCCViewer =
-      ( (OCCViewer_ViewManager*)( theViewWindow->getViewManager() ) )->getOCCViewer();
-    Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();
+  if ( pe->modifiers() != Qt::ControlModifier ) {
+  OCCViewer_Viewer* aViewer = getOCCViewer();
+  if ( !aViewer )
+    return;
+    Handle(AIS_InteractiveContext) ic = aViewer->getAISContext();
 
     gp_Pnt aPnt;    
 
@@ -847,7 +845,8 @@ void CurveCreator_Widget::onGetCoordsByClick( SUIT_ViewWindow* theViewWindow, QM
       aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) );
     else*/
     {
-      OCCViewer_ViewPort3d* vp =  ((OCCViewer_ViewWindow*)theViewWindow)->getViewPort();
+      OCCViewer_ViewPort3d* vp =
+        ((OCCViewer_ViewWindow*)aViewer->getViewManager()->getActiveView())->getViewPort();
       aPnt = GEOMUtils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
     }
     // set the coordinates into dialog
@@ -863,55 +862,102 @@ void CurveCreator_Widget::onGetCoordsByClick( SUIT_ViewWindow* theViewWindow, QM
 }
 
 //=================================================================================
-// function : HYDROGUI_PolylineOp::onPointSelect()
+// function : CurveCreator_Widget::onMousePress()
+// purpose  : Manage mouse press events in Modification mode
+//=================================================================================
+void CurveCreator_Widget::onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent )
+{
+  if ( theEvent->button() != Qt::LeftButton )
+    return;
+
+  switch( getActionMode() ) {
+    case ModificationMode: {
+      //store initial cursor position for Drag&Drop
+      setDragStarted( true, theEvent->pos() );
+      break;
+    }
+    case AdditionMode: {
+      onGetCoordsByClick( theEvent );
+      break;
+    }
+    default:
+      break;
+  }
+}
+
+//=================================================================================
+// function : HYDROGUI_PolylineOp::onMouseRelease()
 // purpose  : Manage mouse press events in Modification mode
 //=================================================================================
-void CurveCreator_Widget::onPointSelect( SUIT_ViewWindow* theViewWindow, QMouseEvent* pe )
+void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent )
 {
+  if ( getActionMode() != ModificationMode || !myDragStarted )
+    return;
+
+  setDragStarted( false );
   //store initial cursor position for Drag&Drop
-  if (pe->button() == Qt::LeftButton)
-    myDragStartPosition = pe->pos();
-  
-  //gp_Pnt aPnt;
-  OCCViewer_Viewer* anOCCViewer = 
-      ( (OCCViewer_ViewManager*)( theViewWindow->getViewManager() ) )->getOCCViewer();
-  Handle(AIS_InteractiveContext) aContext = anOCCViewer->getAISContext();
-  
-  //ic->InitSelected();
-  //if ( pe->modifiers() == Qt::ShiftModifier )
-  //  ic->ShiftSelect();  // Append selection
-  //else
-  //  ic->Select();       // New selection
-  
-  /*ic->InitSelected();
-  if ( ic->MoreSelected() ) {
-    TopoDS_Shape aShape = ic->SelectedShape();
-    Standard_Boolean hasdet = ic->HasDetectedShape();
-    Standard_Boolean hassel = ic->HasSelectedShape();
-    Standard_Integer nbcur = ic->NbCurrents();
-    Standard_Integer nbsel = ic->NbSelected();
-    if(!aShape.IsNull())
-      if ( aShape.ShapeType() == TopAbs_VERTEX )
-        aPnt = BRep_Tool::Pnt( TopoDS::Vertex( ic->SelectedShape() ) );
+  //QPoint aPos = theEvent->pos();
+  //if (pe->button() == Qt::LeftButton)
+  //  myDragStartPosition = pe->pos();
+
+  QPoint aPos = theEvent->pos();
+  // check whether the segment is clicked an a new point should be added to the segment
+  if ( insertPointToSelectedSegment( aPos.x(), aPos.y() ) ) {
+    setSelectedPonts( 0 );
+    updateUndoRedo();
   }
-  
-  Qt::KeyboardModifiers modifiers = pe->modifiers();
-//  aSketcherDlg->OnPointSelected( modifiers, aPnt );  // "feed" the point to point construction dialog*/
 
+  // updates the input panel table to show the selected point coordinates
   updateLocalPointView();
 }
 
 //=================================================================================
-// function : GeometryGUI::onPointDrag()
+// function : GeometryGUI::onMouseMove()
 // purpose  : Manage mouse move events in Modification mode
 //=================================================================================
-void CurveCreator_Widget::onPointDrag( SUIT_ViewWindow* theViewWindow, QMouseEvent* pe )
+void CurveCreator_Widget::onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent )
 {
-  if ( !(pe->buttons() & Qt::LeftButton) )
+  if ( getActionMode() != ModificationMode || !myDragStarted )
     return;
-  if ( (pe->pos() - myDragStartPosition).manhattanLength() < QApplication::startDragDistance() )
+
+  OCCViewer_Viewer* aViewer = getOCCViewer();
+  if ( !aViewer )
     return;
-/*  
+
+  //if ( !(pe->buttons() & Qt::LeftButton) )
+  //  return;
+  QPoint aPos = theEvent->pos();
+  if ( (aPos - myDragStartPosition).manhattanLength() < QApplication::startDragDistance() )
+    return;
+
+  //setLocalPointContext( false );
+  OCCViewer_ViewWindow* aWindow =
+           (OCCViewer_ViewWindow*)aViewer->getViewManager()->getActiveView();
+  gp_Pnt aStartPnt = GEOMUtils::ConvertClickToPoint( myDragStartPosition.x(), myDragStartPosition.y(),
+                                                     aWindow->getViewPort()->getView() );
+  gp_Pnt anEndPnt = GEOMUtils::ConvertClickToPoint( aPos.x(), aPos.y(),
+                                                    aWindow->getViewPort()->getView() );
+  double aXDelta = aStartPnt.X() - anEndPnt.X();
+  double anYDelta = aStartPnt.Y() - anEndPnt.Y();
+
+  int aSectionId = 0;
+  int aPointId;
+  std::deque<float> aChangedPos;
+  for ( int i = 0, aNb = myDragPoints.size(); i < aNb; i++ ) {
+    aPointId = myDragPoints[i];
+    aChangedPos = myCurve->getPoint( aSectionId, aPointId );
+    if ( aChangedPos.size() < 2 )
+      continue;
+    aChangedPos[0] = aChangedPos[0] - aXDelta;
+    aChangedPos[1] = aChangedPos[1] - anYDelta;
+    myCurve->setPoint( aSectionId, aPointId, aChangedPos );
+  }
+
+  //setLocalPointContext( true );
+  setSelectedPonts( aSectionId, myDragPoints );
+
+  myDragStartPosition = aPos;
+  /*  
   QDrag *drag = new QDrag(this);
   QMimeData *mimeData = new QMimeData;
   
@@ -958,29 +1004,105 @@ void CurveCreator_Widget::onLocalPointChanged( int theRow, int theColumn )
   setSelectedPonts( aSection, aSelPoints );
 }
 
-int CurveCreator_Widget::findLocalPointIndex( int theSectionId, float theX, float theY )
+/**
+ * Removes a selected section from the curve. Updates undo/redo status
+ */
+void CurveCreator_Widget::removeSection()
 {
-  int aPntIndex = -1;
+  QList< QPair<int,int> > aSelPoints = mySectionView->getSelectedPoints();
+  int aCurrSect=-1;
+  int aRemoveCnt = 0;
+//  myCurve->startOperation();
+  for( int i = 0 ; i < aSelPoints.size() ; i++ ){
+    if( aCurrSect != aSelPoints[i].first ){
+      aRemoveCnt = 0;
+      aCurrSect = aSelPoints[i].first;
+    }
+    int aPntIndx = aSelPoints[i].second - aRemoveCnt;
+    myCurve->removePoint( aCurrSect, aPntIndx );
+    mySectionView->pointsRemoved( aCurrSect, aPntIndx );
+    aRemoveCnt++;
+  }
+  QList<int> aSections = mySectionView->getSelectedSections();
+  for( int i = 0 ; i < aSections.size() ; i++ ){
+    int aSectNum = aSections[i] - (i);
+    myCurve->removeSection( aSectNum );
+    mySectionView->sectionsRemoved( aSectNum );
+  }
+//  myCurve->finishOperation();
+  mySectionView->clearSelection();
+  updateUndoRedo();
+}
 
-  CurveCreator::Coordinates aCoords;
-  for ( int i = 0, aNb = myCurve->getNbPoints( theSectionId ); i < aNb && aPntIndex < 0; i++ ) {
-    aCoords = myCurve->getPoint( theSectionId, i );
-    if ( aCoords.size() < 2 )
+/**
+ * Removes a selected points from the curve. Updates undo/redo status
+ */
+void CurveCreator_Widget::removePoint()
+{
+  int aSectionId = 0;
+  QList<int> aPoints;
+  qSort( aPoints );
+  getSelectedPonts( aSectionId, aPoints );
+
+  int aCurrSect=-1;
+  int aRemoveCnt = 0;
+
+  for( int i = aPoints.size()-1; i >= 0; i-- ){
+    int aPntIndx = aPoints[i];
+    myCurve->removePoint( aSectionId, aPntIndx );
+    mySectionView->pointsRemoved( aSectionId, aPntIndx );
+  }
+}
+
+bool CurveCreator_Widget::insertPointToSelectedSegment( const int theX,
+                                                        const int theY )
+{
+  OCCViewer_Viewer* aViewer = getOCCViewer();
+  if ( !aViewer )
+    return false;
+
+  int aPoint1 = -1, aPoint2 = -1;
+
+  gp_Pnt aPoint;
+  bool isFoundPoint = false;
+  Handle(AIS_InteractiveContext) aContext = aViewer->getAISContext();
+  for ( aContext->InitSelected(); aContext->MoreSelected() && !isFoundPoint;
+        aContext->NextSelected() ) {
+    TopoDS_Shape aTShape = aContext->SelectedShape();
+    if ( !aTShape.IsNull() && aTShape.ShapeType() == TopAbs_VERTEX )
       continue;
-    if ( fabs( aCoords[0] - theX ) < LOCAL_SELECTION_TOLERANCE &&
-         fabs( aCoords[1] - theY ) < LOCAL_SELECTION_TOLERANCE )
-      aPntIndex = i;
+    else {
+      Handle(SelectMgr_EntityOwner) anOwner = aContext->SelectedOwner();
+      if ( anOwner.IsNull() )
+        continue;
+      const TopLoc_Location& aLocation = anOwner->Location();
+      Handle(AIS_InteractiveObject) anAIS = Handle(AIS_InteractiveObject)::DownCast( anOwner->Selectable() );
+      isFoundPoint = pointOnObject( anAIS, theX, theY, aPoint, aPoint1, aPoint2 );
+    }
   }
+  // insert the point to the model curve
+  bool isDone = false;
+  if ( isFoundPoint && aPoint1 >= 0 && aPoint2 >= 0 ) {
+    int aSection = 0;
+    CurveCreator::Coordinates aCoords;
+    aCoords.push_back( aPoint.X() );
+    aCoords.push_back( aPoint.Y() );
 
-  return aPntIndex;
+    int anInsertPos = aPoint1 < aPoint2 ? aPoint1 + 1 : aPoint2 + 1;
+    myCurve->addPoints( aCoords, aSection, anInsertPos );
+    mySectionView->pointsAdded( aSection, myCurve->getNbPoints( aSection ) );
+
+    isDone = true;
+  }
+  return isDone;
 }
 
 void CurveCreator_Widget::updateLocalPointView()
 {
-  OCCViewer_Viewer* anOCCViewer = getOCCViewer();
-  if ( !anOCCViewer )
+  OCCViewer_Viewer* aViewer = getOCCViewer();
+  if ( !aViewer )
     return;
-  Handle(AIS_InteractiveContext) aContext = anOCCViewer->getAISContext();
+  Handle(AIS_InteractiveContext) aContext = aViewer->getAISContext();
 
   bool isBlocked = myLocalPointView->blockSignals(true);
   gp_Pnt aPnt;
@@ -1024,8 +1146,10 @@ void CurveCreator_Widget::updateLocalPointView()
 
 void CurveCreator_Widget::setLocalPointContext( const bool theOpen )
 {
-  OCCViewer_Viewer* anOCCViewer = getOCCViewer();
-  Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();
+  OCCViewer_Viewer* aViewer = getOCCViewer();
+  if ( !aViewer )
+    return;
+  Handle(AIS_InteractiveContext) ic = aViewer->getAISContext();
 
   if ( theOpen ) {
     // Open local context if there is no one
@@ -1079,7 +1203,11 @@ void CurveCreator_Widget::addLocalPointToTable( const double theX, const double
   QTableWidgetItem* anItem;
 
   myLocalPointView->setRowCount( aRowId+1 );
-  anItem = new QTableWidgetItem( QString::number( aRowId + 1 ) );
+
+  int aPointSection = 0;
+  int aPointIndex = findLocalPointIndex( aPointSection, theX, theY );
+
+  anItem = new QTableWidgetItem( QString::number( aPointIndex + 1 ) );
   anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
   myLocalPointView->setItem( aRowId, 0, anItem );
 
@@ -1092,8 +1220,24 @@ void CurveCreator_Widget::addLocalPointToTable( const double theX, const double
   myLocalPointView->setItem( aRowId, 2, anItem );
 }
 
+/**
+ * Set drag operation started. Save the position and a list of dragged points
+ * \param theState the drag operation state: started/finished
+ * \param thePoint the start drag position
+ */
+void CurveCreator_Widget::setDragStarted( const bool theState, const QPoint& thePoint )
+{
+  myDragStarted = theState;
+  if ( myDragStarted ) {
+    myDragStartPosition = thePoint;
+    getSelectedPonts( 0, myDragPoints );
+  }
+}
+
 void CurveCreator_Widget::getSelectedPonts( int theSectionId, QList<int>& thePoints )
 {
+  thePoints.clear();
+
   float aPrevX, aPrevY;
   int aPntIndex;
   for ( int i = 0, aNb = myLocalPointView->rowCount(); i < aNb; i++ ) {
@@ -1108,13 +1252,13 @@ void CurveCreator_Widget::getSelectedPonts( int theSectionId, QList<int>& thePoi
 
 void CurveCreator_Widget::setSelectedPonts( const int theSectionId, const QList<int>& thePoints )
 {
-  OCCViewer_Viewer* anOCCViewer = getOCCViewer();
-  if ( !anOCCViewer )
+  OCCViewer_Viewer* aViewer = getOCCViewer();
+  if ( !aViewer )
     return;
 
   AIS_ListOfInteractive aListToSelect;
 
-  Handle(AIS_InteractiveContext) ic = anOCCViewer->getAISContext();
+  Handle(AIS_InteractiveContext) ic = aViewer->getAISContext();
   if ( !ic->HasOpenedContext() )
     return;
 
@@ -1140,6 +1284,89 @@ void CurveCreator_Widget::setSelectedPonts( const int theSectionId, const QList<
       aListToSelect.Append( anAIS );
   }
 
-  anOCCViewer->setObjectsSelected( aListToSelect );
+  aViewer->setObjectsSelected( aListToSelect );
   updateLocalPointView();
 }
+
+/**
+ * Returns a point index in the model curve by the point coordinates in the viewer
+ * \param theX the X coordinate of the point
+ * \param theY the Y coordinate of the point
+ */
+int CurveCreator_Widget::findLocalPointIndex( int theSectionId, float theX, float theY )
+{
+  int aPntIndex = -1;
+
+  CurveCreator::Coordinates aCoords;
+  for ( int i = 0, aNb = myCurve->getNbPoints( theSectionId ); i < aNb && aPntIndex < 0; i++ ) {
+    aCoords = myCurve->getPoint( theSectionId, i );
+    if ( aCoords.size() < 2 )
+      continue;
+    if ( fabs( aCoords[0] - theX ) < LOCAL_SELECTION_TOLERANCE &&
+         fabs( aCoords[1] - theY ) < LOCAL_SELECTION_TOLERANCE )
+      aPntIndex = i;
+  }
+
+  return aPntIndex;
+}
+
+/**
+ * Checks whether the point belongs to the OCC object
+ * \param theObject a line or shape with a bspline inside
+ * \param theX the X coordinate in the view.
+ * \param theY the Y coordinate in the view.
+ * \param thePoint the output point to be append to the model curve
+ * \param thePoint1 the output point to bound the line where a new point should be inserted
+ * \param thePoint2 the output point to bound the line where a new point should be inserted
+ */
+bool CurveCreator_Widget::pointOnObject( Handle(AIS_InteractiveObject) theObject,
+                                         const int theX, const int theY,
+                                         gp_Pnt& thePoint,
+                                         int& thePoint1, int& thePoint2 )
+{
+  bool isFound = false;
+
+  OCCViewer_Viewer* aViewer = getOCCViewer();
+  if ( theObject.IsNull() || !aViewer )
+    return isFound;
+
+  OCCViewer_ViewWindow* aWindow =
+           (OCCViewer_ViewWindow*)aViewer->getViewManager()->getActiveView();
+  thePoint = GEOMUtils::ConvertClickToPoint( theX, theY,
+                                             aWindow->getViewPort()->getView() );
+
+  Handle(AIS_Line) aLine = Handle(AIS_Line)::DownCast( theObject );
+  if ( !aLine.IsNull() ) {
+    Handle(Geom_Point) aPStart;
+    Handle(Geom_Point) aPEnd;
+    aLine->Points( aPStart, aPEnd );
+
+    Standard_Real aStartX = aPStart->X(),
+                  aStartY = aPStart->Y(),
+                  aStartZ = aPStart->Z();
+    Standard_Real anEndX = aPEnd->X(),
+                  anEndY = aPEnd->Y(),
+                  anEndZ = aPEnd->Z();
+    // TODO: check whether the point belong to the selected line
+    gp_Lin aLin( gp_Pnt( aPStart->X(), aPStart->Y(), aPStart->Z() ),
+                gp_Dir( gp_Vec( gp_Pnt( aPStart->X(), aPStart->Y(), aPStart->Z() ),
+                                gp_Pnt( aPEnd->X(), aPEnd->Y(), aPEnd->Z() ) ) ) );
+    double aDistance = aLin.Distance( thePoint );
+
+
+    if ( aLin.Contains( thePoint, LOCAL_SELECTION_TOLERANCE ) ) {
+      // find the neighbour points
+      thePoint1 = findLocalPointIndex( 0, aPStart->X(), aPStart->Y() );
+      thePoint2 = findLocalPointIndex( 0, aPEnd->X(),   aPEnd->Y() );
+
+      isFound = thePoint1 >= 0 && thePoint2 >= 0;
+    }
+  }
+  else {
+    Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast( theObject );
+    if ( !aShape.IsNull() ) {
+      // find the neighbour points
+    }
+  }
+  return isFound;
+}
index 22d57e91198dcec4fb0fa43612fc274ee09fd1ba..bbc58f69476e2420b5c202a6229ef57848b1ae59 100644 (file)
@@ -28,6 +28,7 @@
 #include <QMap>
 
 #include <SUIT_ViewWindow.h>
+#include <AIS_InteractiveObject.hxx>
 
 class OCCViewer_Viewer;
 
@@ -41,100 +42,133 @@ class CurveCreator_NewSectionDlg;
 
 class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
 {
-    Q_OBJECT
+  Q_OBJECT
 public:
-    explicit CurveCreator_Widget( QWidget* parent,
-                      CurveCreator_ICurve *theCurve,
-                      Qt::WindowFlags fl=0 );
+  explicit CurveCreator_Widget( QWidget* parent,
+                                CurveCreator_ICurve *theCurve,
+                                Qt::WindowFlags fl=0 );
 
-    OCCViewer_Viewer* getOCCViewer();
+  void setOCCViewer( OCCViewer_Viewer* theViewer );
+  OCCViewer_Viewer* getOCCViewer();
 
-    //virtual bool eventFilter( QObject* theWatched, QEvent* theEvent );
+  //virtual bool eventFilter( QObject* theWatched, QEvent* theEvent );
 
-    //! Return unique section name
-    std::string getUniqSectionName(CurveCreator_ICurve* theCurve) const;
+  //! Return unique section name
+  std::string getUniqSectionName(CurveCreator_ICurve* theCurve) const;
 
-    void setCurve( CurveCreator_ICurve* theCurve );
+  void setCurve( CurveCreator_ICurve* theCurve );
 
-    QList<int> getSelectedSections();
-    QList< QPair< int, int > > getSelectedPoints();
+  QList<int> getSelectedSections();
+  QList< QPair< int, int > > getSelectedPoints();
 
 signals:
-    void selectionChanged();
-    void subOperationStarted( QWidget* );
-    void subOperationFinished( QWidget* );
+  void selectionChanged();
+  void subOperationStarted( QWidget* );
+  void subOperationFinished( QWidget* );
 
 public slots:
 
 protected slots:
-    void     onAdditionMode(bool checked);
-    void     onModificationMode(bool checked);
-    void     onDetectionMode(bool checked);
-    void     onModeChanged(bool checked);
-    void     onNewSection();
-    void     onSelectionChanged();
-    void     onAddNewPoint(const CurveCreator::Coordinates& theCoords);
-    void     onAddNewSection();
-    void     onEditSection( int theSection );
-    void     onModifySection();
-    void     onCancelSection();
-    void     onJoin();
-    void     onRemove();
-    void     onClearAll();
-    void     onJoinAll();
-    void     onSetSpline();
-    void     onSetPolyline();
-    void     onCloseSections();
-    void     onUncloseSections();
-    void     onUndo();
-    void     onRedo();
-    void     onUndoSettings();
-    void     onContextMenu(QPoint thePoint);
-    void     onGetCoordsByClick( SUIT_ViewWindow*, QMouseEvent* );
-    void     onPointSelect( SUIT_ViewWindow*, QMouseEvent* );
-    void     onPointDrag( SUIT_ViewWindow*, QMouseEvent* );
-    void     onLocalPointChanged( int theRow, int theColumn );
+  void     onAdditionMode(bool checked);
+  void     onModificationMode(bool checked);
+  void     onDetectionMode(bool checked);
+  void     onModeChanged(bool checked);
+  void     onNewSection();
+  void     onSelectionChanged();
+  void     onAddNewPoint(const CurveCreator::Coordinates& theCoords);
+  void     onAddNewSection();
+  void     onEditSection( int theSection );
+  void     onModifySection();
+  void     onCancelSection();
+  void     onJoin();
+  void     onRemove();
+  void     onClearAll();
+  void     onJoinAll();
+  void     onSetSpline();
+  void     onSetPolyline();
+  void     onCloseSections();
+  void     onUncloseSections();
+  void     onUndo();
+  void     onRedo();
+  void     onUndoSettings();
+  void     onContextMenu(QPoint thePoint);
+  void     onGetCoordsByClick( QMouseEvent* );
+
+  void     onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent );
+  void     onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent );
+  void     onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent );
+
+  void     onLocalPointChanged( int theRow, int theColumn );
+
 protected:
-    enum ActionId{ UNDO_ID, 
-                   REDO_ID, 
-                   NEW_SECTION_ID, 
-                   ADDITION_MODE_ID, 
-                   REMOVE_ID, 
-                   REMOVE_ALL_ID, 
-                   JOIN_ID,
-                   JOIN_ALL_ID, 
-                   CLOSE_SECTIONS_ID, 
-                   UNCLOSE_SECTIONS_ID,
-                   SET_SECTIONS_POLYLINE_ID, 
-                   SET_SECTIONS_SPLINE_ID, 
-                   CLEAR_ALL_ID, 
-                   SEPARATOR_ID, 
-                   MODIFICATION_MODE_ID, 
-                   DETECTION_MODE_ID 
-    };
+  enum ActionId{ UNDO_ID, 
+                 REDO_ID, 
+                 NEW_SECTION_ID, 
+                 ADDITION_MODE_ID, 
+                 REMOVE_ID, 
+                 REMOVE_ALL_ID, 
+                 JOIN_ID,
+                 JOIN_ALL_ID, 
+                 CLOSE_SECTIONS_ID, 
+                 UNCLOSE_SECTIONS_ID,
+                 SET_SECTIONS_POLYLINE_ID, 
+                 SET_SECTIONS_SPLINE_ID, 
+                 CLEAR_ALL_ID, 
+                 SEPARATOR_ID, 
+                 MODIFICATION_MODE_ID, 
+                 DETECTION_MODE_ID 
+  };
+
+  enum ActionMode {
+    AdditionMode,
+    ModificationMode,
+    DetectionMode,
+    NoneMode
+  };
+
 private:
-    QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
-                           const QString& theToolTip, const QKeySequence& theShortcut );
-    QAction* getAction(ActionId theId);
-    void     updateUndoRedo();
-    int      findLocalPointIndex( int theSectionId, float theX, float theY );
-    void     updateLocalPointView();
-    void     setLocalPointContext( const bool theOpen );
-    void     addLocalPointToTable( const double theX, const double theY );
-
-    void getSelectedPonts( const int theSectionId, QList<int>& thePoints );
-    void setSelectedPonts( const int theSectionId, const QList<int>& thePoints );
+  QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
+                         const QString& theToolTip, const QKeySequence& theShortcut );
+  QAction* getAction(ActionId theId);
+  ActionMode getActionMode() const;
+
+  void     updateUndoRedo();
+
+  void removeSection();
+  void removePoint();
+  bool insertPointToSelectedSegment( const int theXPosition,
+                                     const int theYPosition );
+  void updateLocalPointView();
+  void setLocalPointContext( const bool theOpen );
+  void addLocalPointToTable( const double theX, const double theY );
+
+  void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
+
+  void getSelectedPonts( const int theSectionId, QList<int>& thePoints );
+  void setSelectedPonts( const int theSectionId, const QList<int>& thePoints = QList<int>() );
+
+
+  // curve algorithm
+  int  findLocalPointIndex( int theSectionId, float theX, float theY );
+
+  // OCC algorithm
+  bool pointOnObject( Handle(AIS_InteractiveObject) theObject,
+                      const int theX, const int theY,
+                      gp_Pnt& thePoint, int& thePoint1, int& thePoint2 );
 
 private:
-    QMap<ActionId, QAction*>    myActionMap;
-    CurveCreator_ICurve*         myCurve;
-    CurveCreator_TreeView*      mySectionView;
-    QTableWidget*               myLocalPointView;
-    CurveCreator_NewSectionDlg* myNewSectionEditor;
-    int                         mySection;
-    int                         myPointNum;
-    QPoint                      myDragStartPosition;
-    QByteArray                  myGuiState;
+  QMap<ActionId, QAction*>    myActionMap;
+  CurveCreator_ICurve*         myCurve;
+  CurveCreator_TreeView*      mySectionView;
+  QTableWidget*               myLocalPointView;
+  CurveCreator_NewSectionDlg* myNewSectionEditor;
+  OCCViewer_Viewer*           myOCCViewer;
+  int                         mySection;
+  int                         myPointNum;
+  bool                        myDragStarted;
+  QList<int>                  myDragPoints;
+  QPoint                      myDragStartPosition;
+  QByteArray                  myGuiState;
 };
 
 #endif // CURVECREATOR_WIDGET_H
index 30d7e9869229573dfdb2c667a9a4dc21e89b24fa..d0356ae57c3afef61750948607af654049c1cea7 100644 (file)
@@ -1,4 +1,4 @@
-include(../../CMake/Common.cmake)
+#include(../../CMake/Common.cmake)
 
 set(PROJECT_HEADERS
     HYDROData.h
@@ -24,6 +24,7 @@ set(PROJECT_HEADERS
     HYDROData_Obstacle.h
     HYDROData_OperationsFactory.h
     HYDROData_Polyline.h
+    HYDROData_PolylineXY.h
     HYDROData_Profile.h
     HYDROData_ProfileUZ.h
     HYDROData_Region.h
@@ -58,6 +59,7 @@ set(PROJECT_SOURCES
     HYDROData_Obstacle.cxx
     HYDROData_OperationsFactory.cxx
     HYDROData_Polyline.cxx
+    HYDROData_PolylineXY.cxx
     HYDROData_Profile.cxx
     HYDROData_ProfileUZ.cxx
     HYDROData_Region.cxx
@@ -73,23 +75,27 @@ add_definitions(
   -DHYDRODATA_EXPORTS
   ${CAS_DEFINITIONS}
   ${QT_DEFINITIONS}
-  ${GUI_CXXFLAGS}
+#  ${GUI_CXXFLAGS}
+  ${GUI_DEFINITIONS}
 )
 
 include_directories(
   ${CAS_INCLUDE_DIRS}
   ${QT_INCLUDES}
   ${CMAKE_CURRENT_SOURCE_DIR}
-  ${GUI_ROOT_DIR}/include/salome
+  ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROCurveCreator
+#  ${GUI_ROOT_DIR}/include/salome
+  ${GUI_INCLUDE_DIRS}
 )
 
 add_library(HYDROData SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS})
-target_link_libraries(HYDROData ${CAS_OCAF} ${CAS_OCAFVIS} ${CAS_TKG3d} ${CAS_TKGeomBase} ${CAS_TKGeomAlgo} ${CAS_TKBrep} ${CAS_TKTopAlgo} ${CAS_TKBO} ${QT_LIBRARIES} ${ImageComposer})
+target_link_libraries(HYDROData HYDROCurveCreator ${CAS_OCAF} ${CAS_OCAFVIS} ${CAS_TKG3d} ${CAS_TKGeomBase} ${CAS_TKGeomAlgo} ${CAS_TKBrep} ${CAS_TKIGES} ${CAS_TKSTEP} ${CAS_TKTopAlgo} ${CAS_TKBO} ${QT_LIBRARIES} ${GUI_ImageComposer})
+INSTALL(TARGETS HYDROData EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
 
 set(PROJECT_LIBRARIES HYDROData)
 
 # tests
-if(CPPUNIT_IS_OK)
+if(SALOME_BUILD_TESTS)
 
   set(TEST_HEADERS 
     test_HYDROData_Bathymetry.h
@@ -101,7 +107,6 @@ if(CPPUNIT_IS_OK)
     test_HYDROData_Iterator.h
     test_HYDROData_OperationsFactory.h
     test_HYDROData_Polyline.h
-    test_HYDROData_Profile.h
   )
 
   set(TEST_SOURCES 
@@ -115,13 +120,12 @@ if(CPPUNIT_IS_OK)
     test_HYDROData_Iterator.cxx
     test_HYDROData_OperationsFactory.cxx
     test_HYDROData_Polyline.cxx
-    test_HYDROData_Profile.cxx
   )
   
   set(TEST_EXE test_HYDROData)
   include(../../CMake/CPPUnitTests.cmake)
-  target_link_libraries(test_HYDROData ${CAS_OCAF} ${CAS_MODELER} ${QT_LIBRARIES} ${CPPUNIT_LIBS} HYDROData)
-  
-endif(CPPUNIT_IS_OK)
+  target_link_libraries(test_HYDROData ${CAS_OCAF} ${CAS_MODELER} ${QT_LIBRARIES} ${CPPUNIT_LIBRARIES} HYDROData)
+
+endif(SALOME_BUILD_TESTS)
 
-include(../../CMake/CommonInstall.cmake)
+#include(../../CMake/CommonInstall.cmake)
index ef0be8c55263bbd38d8b68888862a7f0aa3ab407..ca397e1b70a88be11eb2bb985a3db2c6cda27f5a 100644 (file)
@@ -59,12 +59,12 @@ protected:
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
    */
-  HYDROData_AltitudeObject();
+  HYDRODATA_EXPORT HYDROData_AltitudeObject();
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
-  ~HYDROData_AltitudeObject();
+  HYDRODATA_EXPORT  ~HYDROData_AltitudeObject();
 };
 
 #endif
index db928f7a506b994deb3efb9ffbdfc297660c4a98..7c4f092da723d9e40f382439599b2f47f40830f4 100644 (file)
@@ -115,12 +115,12 @@ protected:
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
    */
-  HYDROData_Bathymetry();
+  HYDRODATA_EXPORT HYDROData_Bathymetry();
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
-  ~HYDROData_Bathymetry();
+  HYDRODATA_EXPORT ~HYDROData_Bathymetry();
 };
 
 #endif
index 326af7419c0f7746e9db70e867cd481ed8489769..39e5489ed3e0d01b0d18158d517b59e1596064d7 100644 (file)
@@ -11,6 +11,9 @@
 #include "HYDROData_Tool.h"
 #include "HYDROData_Zone.h"
 
+#include <TopoDS_Shell.hxx>
+#include <BRep_Builder.hxx>
+
 #define CALCULATION_REGIONS_PREF GetName() + "_Reg"
 #define CALCULATION_ZONES_PREF GetName() + "_Zone"
 
@@ -321,3 +324,41 @@ Handle(HYDROData_Region) HYDROData_CalculationCase::addNewRegion()
   return aNewRegion;
 }
 
+TopoDS_Shell HYDROData_CalculationCase::GetShell()
+{
+  TopoDS_Shell aShell;
+
+  // Make shell
+  BRep_Builder aBuilder;
+  aBuilder.MakeShell( aShell );
+
+  bool isShellEmpty = true;
+
+  // Make shell containing all region shapes
+  HYDROData_SequenceOfObjects aCaseRegions = GetRegions();
+  HYDROData_SequenceOfObjects::Iterator aRegionIter( aCaseRegions );
+  for ( ; aRegionIter.More(); aRegionIter.Next() ) {
+    Handle(HYDROData_Region) aRegion =
+      Handle(HYDROData_Region)::DownCast( aRegionIter.Value() );
+    if( aRegion.IsNull() ) {
+      continue;
+    }
+
+    TopoDS_Shape aRegionShape = aRegion->GetShape();
+
+    // Add shape (face or shell) corresponding to the region into the shell
+    if( !aRegionShape.IsNull() ) {
+      aBuilder.Add( aShell, aRegionShape );
+      isShellEmpty = false;
+    }
+  } // regions iterator
+
+  // Check if no shapes were added to the shell
+  if ( isShellEmpty ) {
+    aShell.Nullify();
+  }
+
+  return aShell;
+}
+
+
index 77edbf778faa997b627d62276f4abb03a8f1b855..2b471335d3fb53c54cc81095c3e9a4df4cbda543 100644 (file)
@@ -5,6 +5,8 @@
 
 #include <HYDROData_Entity.h>
 
+class TopoDS_Shell;
+
 class Handle(HYDROData_Object);
 class Handle(HYDROData_Region);
 class Handle(HYDROData_Zone);
@@ -130,6 +132,12 @@ public:
    */
   HYDRODATA_EXPORT virtual void RemoveRegions();
 
+  /**
+   * Returns shell containing faces which correspond to regions.
+   * \return shell as TopoDS_Shell
+   */
+  HYDRODATA_EXPORT virtual TopoDS_Shell GetShell();
+
 private:
 
   /**
@@ -147,12 +155,12 @@ protected:
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
    */
-  HYDROData_CalculationCase();
+  HYDRODATA_EXPORT HYDROData_CalculationCase();
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
-  ~HYDROData_CalculationCase();
+  HYDRODATA_EXPORT ~HYDROData_CalculationCase();
 };
 
 #endif
index 13bdffb007a9cdbe653e3d4065be3e46bf4ecf19..569a588db71fee40bad246eb2213fbc893cf26bc 100644 (file)
@@ -118,17 +118,17 @@ protected:
   friend class test_HYDROData_Document;
 
   //! Creates new document: private because "Document" method must be used instead of direct creation.
-  HYDROData_Document();
+  HYDRODATA_EXPORT HYDROData_Document();
   //! Creates new document by existing OCAF structure
-  HYDROData_Document(const Handle(TDocStd_Document)& theDoc);
+  HYDRODATA_EXPORT HYDROData_Document(const Handle(TDocStd_Document)& theDoc);
   //! Deletes all high-level data, managed this document
-  ~HYDROData_Document();
+  HYDRODATA_EXPORT ~HYDROData_Document();
 
   //! Returns the new identifier of the new object (may be used for correct ordering of objects)
   HYDRODATA_EXPORT int NewID();
 
   //! Returns the label where the objects are located (used by Iterator)
-  TDF_Label LabelOfObjects();
+  HYDRODATA_EXPORT TDF_Label LabelOfObjects();
 
 private:
   
index ceb393519f0edf23543288600f42952ef8d7cd92..4c7799280c182c7f01486b5128e529bd9c0fe64a 100644 (file)
@@ -57,12 +57,12 @@ protected:
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
    */
-  HYDROData_IAltitudeObject();
+  HYDRODATA_EXPORT HYDROData_IAltitudeObject();
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
-  ~HYDROData_IAltitudeObject();
+  HYDRODATA_EXPORT ~HYDROData_IAltitudeObject();
 };
 
 #endif
index 20fe2099ea3e0d96f04f8cf927a3ac8707ecde4b..00f7a04a0479222525be537c568cbc55d8a59b94 100755 (executable)
@@ -1,15 +1,20 @@
 
 #include "HYDROData_IPolyline.h"
 
-#include <gp_XY.hxx>
+#include "HYDROData_Document.h"
 
+#include <TDataStd_BooleanList.hxx>
+#include <TDataStd_ExtStringList.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_IntegerList.hxx>
 #include <TDataStd_RealList.hxx>
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity)
 IMPLEMENT_STANDARD_RTTIEXT(HYDROData_IPolyline, HYDROData_Entity)
 
 HYDROData_IPolyline::HYDROData_IPolyline()
-: HYDROData_Entity()
+: HYDROData_Entity(),
+  myIsOperation( false )
 {
 }
 
@@ -17,9 +22,198 @@ HYDROData_IPolyline::~HYDROData_IPolyline()
 {
 }
 
-int HYDROData_IPolyline::NbPoints( const int theSectionIndex ) const
+int HYDROData_IPolyline::getNbUndo() const
 {
-  return GetPoints( theSectionIndex ).Length();
+  return getNbOperations();
+}
+
+bool HYDROData_IPolyline::undo()
+{
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+  if ( aDocument.IsNull() )
+    return false;
+
+  if ( getNbUndo() < 1 )
+    return false;
+
+  aDocument->Undo();
+
+  int aNbUndoedOperations = getNbUndoedOperations();
+  setNbUndoedOperations( aNbUndoedOperations + 1 ); 
+
+  return true;
+}
+
+int HYDROData_IPolyline::getNbRedo() const
+{
+  return getNbUndoedOperations();
+}
+
+bool HYDROData_IPolyline::redo()
+{
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+  if ( aDocument.IsNull() )
+    return false;
+
+  if ( getNbRedo() < 1 )
+    return false;
+
+  aDocument->Redo();
+
+  int aNbUndoedOperations = getNbUndoedOperations();
+  setNbUndoedOperations( aNbUndoedOperations - 1 ); 
+
+  return true;
+}
+
+CurveCreator::Dimension HYDROData_IPolyline::getDimension() const
+{
+  return CurveCreator::Dim2d;
+}
+
+CurveCreator::Coordinates HYDROData_IPolyline::getPoint( const int theISection, 
+                                                         const int theIPnt ) const
+{
+  CurveCreator::Coordinates aResPoint;
+  if ( theISection < 0 || theIPnt < 0 )
+    return aResPoint;
+
+  CurveCreator::Coordinates aSectPoints = getPoints( theISection );
+  if ( theIPnt >= aSectPoints.size() )
+    return aResPoint;
+
+  CurveCreator::Coordinates::reverse_iterator anIt = aSectPoints.rbegin();
+
+  aResPoint.push_back( *anIt++ );
+  aResPoint.push_back( *anIt );
+
+  return aResPoint;
+}
+
+
+int HYDROData_IPolyline::getNbPoints( const int theSectionIndex ) const
+{
+  return getPoints( theSectionIndex ).size();
+}
+
+void HYDROData_IPolyline::startOperation()
+{
+  if ( myIsOperation )
+    return;
+
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+  if ( aDocument.IsNull() )
+    return;
+  
+  aDocument->StartOperation();
+  
+  myIsOperation = true;
+}
+
+void HYDROData_IPolyline::commitOperation()
+{
+  if ( !myIsOperation )
+    return;
+
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+  if ( aDocument.IsNull() )
+    return;
+
+  int aNbOperations = getNbOperations();
+  setNbOperations( aNbOperations + 1 ); 
+
+  aDocument->CommitOperation();
+
+  myIsOperation = false;
+}
+
+void HYDROData_IPolyline::abortOperation()
+{
+  if ( !myIsOperation )
+    return;
+
+  Handle(HYDROData_Document) aDocument = HYDROData_Document::Document( myLab );
+  if ( aDocument.IsNull() )
+    return;
+
+  aDocument->AbortOperation();
+
+  myIsOperation = false;
+}
+
+void HYDROData_IPolyline::setNbOperations( const int theNb )
+{
+  TDF_Label anOpLabel = myLab.FindChild( DataTag_Operations ).FindChild( OperationsTag_Commited );
+  TDataStd_Integer::Set( anOpLabel, theNb );
+}
+
+int HYDROData_IPolyline::getNbOperations() const
+{
+  TDF_Label aLabel = myLab.FindChild( DataTag_Operations, false );
+  if ( aLabel.IsNull() )
+    return 0;
+
+  TDF_Label anOpLabel = aLabel.FindChild( OperationsTag_Commited, false );
+  if ( anOpLabel.IsNull() )
+    return 0;
+
+  Handle(TDataStd_Integer) anOpCount;
+  if ( !anOpLabel.FindAttribute( TDataStd_Integer::GetID(), anOpCount ) )
+    return 0;
+
+  return anOpCount->Get();
+}
+
+void HYDROData_IPolyline::setNbUndoedOperations( const int theNb )
+{
+  TDF_Label anUndoedLabel = myLab.FindChild( DataTag_Operations ).FindChild( OperationsTag_Undoed );
+  TDataStd_Integer::Set( anUndoedLabel, theNb );
+}
+
+int HYDROData_IPolyline::getNbUndoedOperations() const
+{
+  TDF_Label aLabel = myLab.FindChild( DataTag_Operations, false );
+  if ( aLabel.IsNull() )
+    return 0;
+
+  TDF_Label anUndoedLabel = aLabel.FindChild( OperationsTag_Undoed, false );
+  if ( anUndoedLabel.IsNull() )
+    return 0;
+
+  Handle(TDataStd_Integer) anUndoedCount;
+  if ( !anUndoedLabel.FindAttribute( TDataStd_Integer::GetID(), anUndoedCount ) )
+    return 0;
+
+  return anUndoedCount->Get();
+}
+
+void HYDROData_IPolyline::getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
+                                            Handle(TDataStd_IntegerList)&   theTypesList,
+                                            Handle(TDataStd_BooleanList)&   theClosuresList,
+                                            const bool                      theIsCreate ) const
+{
+  TDF_Label aSectsLabel = myLab.FindChild( DataTag_Sections, theIsCreate );
+  if ( aSectsLabel.IsNull() )
+    return;
+
+  Handle(TDataStd_ExtStringList) aNamesList;
+  if ( !aSectsLabel.FindAttribute( TDataStd_ExtStringList::GetID(), aNamesList ) && theIsCreate )
+    aNamesList = TDataStd_ExtStringList::Set( aSectsLabel );
+
+  Handle(TDataStd_IntegerList) aTypesList;
+  if ( !aSectsLabel.FindAttribute( TDataStd_IntegerList::GetID(), aTypesList ) && theIsCreate )
+    aTypesList = TDataStd_IntegerList::Set( aSectsLabel );
+
+  Handle(TDataStd_BooleanList) aClosuresList;
+  if ( !aSectsLabel.FindAttribute( TDataStd_BooleanList::GetID(), aClosuresList ) && theIsCreate )
+    aClosuresList = TDataStd_BooleanList::Set( aSectsLabel );
+}
+
+void HYDROData_IPolyline::removeSectionsLists()
+{
+  TDF_Label aSectsLabel = myLab.FindChild( DataTag_Sections, false );
+  if ( !aSectsLabel.IsNull() )
+    aSectsLabel.ForgetAllAttributes();
 }
 
 void HYDROData_IPolyline::getPointsLists( const int                  theSectionIndex,
@@ -53,13 +247,20 @@ void HYDROData_IPolyline::getPointsLists( const int                  theSectionI
   }
 }
 
-void HYDROData_IPolyline::removePointsLists( const int theSectionIndex ) const
+void HYDROData_IPolyline::removePointsLists( const int theSectionIndex )
 {
   TDF_Label aLabel = myLab.FindChild( DataTag_Points, false );
   if ( aLabel.IsNull() )
     return;
 
-  TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
-  if ( !aSectLabel.IsNull() )
-    aSectLabel.ForgetAllAttributes();
+  if ( theSectionIndex == -1 )
+  {
+    aLabel.ForgetAllAttributes();
+  }
+  else
+  {
+    TDF_Label aSectLabel = aLabel.FindChild( theSectionIndex, false );
+    if ( !aSectLabel.IsNull() )
+      aSectLabel.ForgetAllAttributes();
+  }
 }
index 9155f6930bb12d49058ac50e8d9ed6e1ca4d4eff..ebb57a313b47d99ab2d95d4a9a6232be80914333 100644 (file)
@@ -4,22 +4,22 @@
 
 #include "HYDROData_Entity.h"
 
+#include <CurveCreator.hxx>
+#include <CurveCreator_ICurve.hxx>
 
 DEFINE_STANDARD_HANDLE(HYDROData_IPolyline, HYDROData_Entity)
 
-class gp_XY;
 class TopoDS_Wire;
 class Handle(TDataStd_RealList);
+class Handle(TDataStd_ExtStringList);
+class Handle(TDataStd_IntegerList);
+class Handle(TDataStd_BooleanList);
 
 /**\class HYDROData_IPolyline
  * \brief Base class that stores/retreives information about the 2D points.
  */
-class HYDROData_IPolyline : public HYDROData_Entity
+class HYDROData_IPolyline : public HYDROData_Entity, public CurveCreator_ICurve
 {
-public:
-
-  typedef gp_XY                       Point;
-  typedef NCollection_Sequence<Point> PointsList;
 
 protected:
   /**
@@ -28,7 +28,18 @@ protected:
   enum DataTag
   {
     DataTag_First = HYDROData_Entity::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_Sections,
     DataTag_Points,
+    DataTag_Operations
+  };
+
+  /**
+   * Enumeration of tags corresponding to the operations child lable
+   */
+  enum OperationsTag
+  {
+    OperationsTag_Commited,
+    OperationsTag_Undoed
   };
 
 public:
@@ -37,89 +48,82 @@ public:
   /**
    * Returns the 3D presentation of all points.
    */
-  HYDRODATA_EXPORT virtual TopoDS_Wire GetWire() const = 0;
+  HYDRODATA_EXPORT virtual ListAISObjects constructWire() const = 0;
 
 
-  /**
-   * Returns number of sections.
-   */
-  HYDRODATA_EXPORT virtual int NbSections() const = 0;
+public:
 
-  /**
-   * Adds new one section.
-   * \param theIsClosed flag indicates type of polyline
-   */
-  HYDRODATA_EXPORT virtual void AddSection( const bool theIsClosed ) = 0;
+  // Implementation of ICurvePolyline interface
+  
+  /***********************************************/
+  /***          Undo/Redo methods              ***/
+  /***********************************************/
 
-  /**
-   * Returns true if section with given index is closed.
-   * \param theSectionIndex index of section
-   */
-  HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const = 0;
+  //! Get number of available undo operations
+  HYDRODATA_EXPORT virtual int getNbUndo() const;
 
-  /**
-   * Removes section with given index.
-   * \param theSectionIndex index of section
-   */
-  HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex ) = 0;
+  //! Undo previous operation
+  HYDRODATA_EXPORT virtual bool undo();
 
-  /**
-   * Removes all sections.
-   */
-  HYDRODATA_EXPORT virtual void RemoveSections() = 0;
+  //! Get number of available redo operations
+  HYDRODATA_EXPORT virtual int getNbRedo() const;
 
+  //! Redo last previously "undone" operation
+  HYDRODATA_EXPORT virtual bool redo();
 
-  /**
-   * Return number of profile points.
-   * \return number of points
-   */
-  HYDRODATA_EXPORT int NbPoints( const int theSectionIndex = -1 ) const;
 
-  /**
-   * Adds new point for section with index "theSectionIndex".
-   * \param theSectionIndex index of section
-   * \param thePoint point to add
-   * \param theBeforeIndex if not equal -1 then insert point before this index
-   */
-  HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
-                                          const Point& thePoint,
-                                          const int    theBeforeIndex = -1 ) = 0;
+  /***********************************************/
+  /***           Point methods                 ***/
+  /***********************************************/
 
-  /**
-   * Replaces point for section with index "theSectionIndex".
-   * \param theSectionIndex index of section
-   * \param thePointIndex index of point to replace
-   * \param thePoint new point
-   */
-  HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
-                                          const int    thePointIndex,
-                                          const Point& thePoint ) = 0;
+  //! Get the dimension.
+  HYDRODATA_EXPORT virtual CurveCreator::Dimension getDimension() const;
 
-  /**
-   * Removes point from section with index "theSectionIndex".
-   * \param theSectionIndex index of section
-   * \param thePointIndex index of point
-   */
-  HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
-                                             const int thePointIndex ) = 0;
 
+  //! Get coordinates of specified point
+  HYDRODATA_EXPORT virtual CurveCreator::Coordinates getPoint( const int theISection, 
+                                                               const int theIPnt ) const;
 
   /**
-   * Returns list of points.
-   * \param theSectionIndex if not equal -1 then list of points returned
-   *                        only for section with this index
-   * \return list of points
+   *  Get number of points in specified section or (the total number of points
+   *  in Curve if theISection is equal to -1).
    */
-  HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const = 0;
+  HYDRODATA_EXPORT virtual int getNbPoints( const int theISection = -1 ) const;
+
 
 protected:
 
+  void startOperation();
+
+  void commitOperation();
+
+  void abortOperation();
+
+
+  void setNbOperations( const int theNb );
+
+  int  getNbOperations() const;
+
+  
+  void setNbUndoedOperations( const int theNb );
+
+  int  getNbUndoedOperations() const;
+
+
+  void getSectionsLists( Handle(TDataStd_ExtStringList)& theNamesList,
+                         Handle(TDataStd_IntegerList)&   theTypesList,
+                         Handle(TDataStd_BooleanList)&   theClosuresList,
+                         const bool                      theIsCreate = true ) const;
+
+  void removeSectionsLists();
+
+
   void getPointsLists( const int                  theSectionIndex,
                        Handle(TDataStd_RealList)& theListX,
                        Handle(TDataStd_RealList)& theListY,
                        const bool                 theIsCreate = true ) const;
 
-  void removePointsLists( const int theSectionIndex ) const;
+  void removePointsLists( const int theSectionIndex = -1 );
 
 protected:
 
@@ -127,12 +131,16 @@ protected:
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
    */
-  HYDROData_IPolyline();
+  HYDRODATA_EXPORT HYDROData_IPolyline();
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
-  ~HYDROData_IPolyline();
+  HYDRODATA_EXPORT ~HYDROData_IPolyline();
+
+protected:
+
+  bool myIsOperation;
 };
 
 #endif
index 90dec9c3210a6cba816ac85c1825ddb53e46b65c..633edbe8cc879a3ed5476cee61d3391f9534f00d 100644 (file)
@@ -343,12 +343,12 @@ protected:
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
    */
-  HYDROData_Image();
+  HYDRODATA_EXPORT HYDROData_Image();
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
-  ~HYDROData_Image();
+  HYDRODATA_EXPORT ~HYDROData_Image();
 
 };
 
index c446ad61d9267140dbe83a528a5177a70c214c01..f33065fab44a56230b684b79524d472d473a986d 100644 (file)
@@ -11,6 +11,7 @@
 #include "HYDROData_ImmersibleZone.h"
 #include "HYDROData_Obstacle.h"
 #include "HYDROData_Polyline.h"
+#include "HYDROData_PolylineXY.h"
 #include "HYDROData_Profile.h"
 #include "HYDROData_ProfileUZ.h"
 #include "HYDROData_VisualState.h"
@@ -142,6 +143,9 @@ Handle(HYDROData_Entity) HYDROData_Iterator::Object( const TDF_Label& theLabel )
     case KIND_PROFILEUZ:
       aResult = new HYDROData_ProfileUZ();
       break;
+    case KIND_POLYLINEXY:
+      aResult = new HYDROData_PolylineXY();
+      break;
     case KIND_CALCULATION:
       aResult = new HYDROData_CalculationCase();
       break;
index 4a9edcf40e810b6093ff0d9c564295559182b9d4..d09d360dab383eab5be0733c3e18127c86773ea0 100644 (file)
@@ -46,13 +46,15 @@ public:
    * \param theDoc document where object will be located
    * \param theKind kind of the new object, can not be UNKNOWN
    */
-  static Handle(HYDROData_Entity) CreateObject( TDF_Label&        theNewLabel, 
-                                                const ObjectKind& theObjectKind );
+  static HYDRODATA_EXPORT Handle(HYDROData_Entity) CreateObject(
+    TDF_Label&        theNewLabel, 
+    const ObjectKind& theObjectKind );
 
   /**
    * Returns object associated to the given label.
    */
-  static Handle(HYDROData_Entity) Object( const TDF_Label& theLabel );
+  static HYDRODATA_EXPORT Handle(HYDROData_Entity) Object( 
+    const TDF_Label& theLabel );
 
 protected:
 
index 80552d910580725770c3b2ca09dd81852ca8b5fe..b83e7cb8af3c9ed39658e0462e520e10b30c4e2f 100644 (file)
@@ -3,10 +3,26 @@
 
 #include "HYDROData_Document.h"
 
+#include <Basics_Utils.hxx>
+
+#include <BRepTools.hxx>
+#include <BRep_Builder.hxx>
+#include <IGESControl_Reader.hxx>
+#include <IGESData_IGESModel.hxx>
+#include <STEPControl_Reader.hxx>
+#include <Interface_Static.hxx>
+#include <TopoDS_Iterator.hxx>
 #include <TopoDS_Shape.hxx>
+#include <TDataStd_AsciiString.hxx>
+#include <TColStd_SequenceOfAsciiString.hxx>
+#include <TopExp_Explorer.hxx>
 
+#include <QFile>
+#include <QFileInfo>
 #include <QStringList>
 
+#include <Standard_ErrorHandler.hxx> // CAREFUL ! position of this file is critic
+
 #define PYTHON_OBSTACLE_ID "KIND_OBSTACLE"
 
 IMPLEMENT_STANDARD_HANDLE(HYDROData_Obstacle,HYDROData_ArtificialObject)
@@ -56,5 +72,232 @@ TopoDS_Shape HYDROData_Obstacle::GetShape3D() const
   return getShape3D();
 }
 
+bool HYDROData_Obstacle::ImportFromFile( const QString& theFilePath )
+{
+  // Check the file existence
+  QFileInfo aFileInfo( theFilePath );
+  if ( !aFileInfo.exists() ) {
+    return false;
+  }
+
+  bool aRes = false;
+  TopoDS_Shape aShape;
+
+  // Import file
+  QString aFileSuf = aFileInfo.suffix().toLower();
+  if ( aFileSuf == "brep" ) {
+    aShape = ImportBREP( theFilePath );
+  } else if ( aFileSuf == "iges" || aFileSuf == "igs" ) {
+    aShape = ImportIGES( theFilePath );
+  } else if ( aFileSuf == "step" ) {
+    aShape = ImportSTEP( theFilePath );
+  }
+  // Check the result shape
+  aRes = !aShape.IsNull();
+
+  // Set shape to the obstacle in case of success
+  if ( aRes ) {
+    SetShape3D( aShape );
+    SetFilePath( theFilePath );
+  }
+
+  return aRes;
+}
+
+void HYDROData_Obstacle::SetFilePath( const QString& theFilePath )
+{
+  TCollection_AsciiString anAsciiStr( theFilePath.toStdString().c_str() );
+  TDataStd_AsciiString::Set( myLab.FindChild( DataTag_FilePath ), anAsciiStr );
+}
 
+QString HYDROData_Obstacle::GetFilePath() const
+{
+  QString aRes;
+
+  Handle(TDataStd_AsciiString) anAsciiStr;
+  if ( myLab.FindChild( DataTag_FilePath ).FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) )
+    aRes = QString( anAsciiStr->Get().ToCString() );
 
+  return aRes;
+}
+
+void HYDROData_Obstacle::SetGeomObjectEntry( const QString& theEntry )
+{
+  TCollection_AsciiString anAsciiStr( theEntry.toStdString().c_str() );
+  TDataStd_AsciiString::Set( myLab.FindChild( DataTag_GeomObjectEntry ), anAsciiStr );
+}
+
+QString HYDROData_Obstacle::GetGeomObjectEntry() const
+{
+  QString aRes;
+
+  Handle(TDataStd_AsciiString) anAsciiStr;
+  if ( myLab.FindChild( DataTag_GeomObjectEntry ).FindAttribute( TDataStd_AsciiString::GetID(), anAsciiStr ) )
+    aRes = QString( anAsciiStr->Get().ToCString() );
+
+  return aRes;
+}
+
+TopoDS_Shape HYDROData_Obstacle::ImportBREP( const QString& theFilePath ) const
+{
+  TopoDS_Shape aResShape;
+
+  BRep_Builder aBrepBuilder;
+  BRepTools::Read( aResShape, qPrintable(theFilePath), aBrepBuilder );
+
+  return aResShape;
+}
+
+TopoDS_Shape HYDROData_Obstacle::ImportIGES( const QString& theFilePath ) const
+{
+  TopoDS_Shape aResShape;
+
+  // Set "C" numeric locale to save numbers correctly
+  Kernel_Utils::Localizer loc;
+
+  IGESControl_Reader aReader;
+
+  Interface_Static::SetCVal("xstep.cascade.unit","M");
+
+  try {
+    OCC_CATCH_SIGNALS;
+
+    IFSelect_ReturnStatus status = aReader.ReadFile(qPrintable(theFilePath));
+
+    if (status == IFSelect_RetDone) {
+      // Rescale units
+      Handle(IGESData_IGESModel) aModel =
+        Handle(IGESData_IGESModel)::DownCast(aReader.Model());
+      if (!aModel.IsNull()) {
+        IGESData_GlobalSection aGS = aModel->GlobalSection();
+        aGS.SetUnitFlag(6);
+        aModel->SetGlobalSection(aGS);
+      }
+    
+      aReader.ClearShapes();
+      aReader.TransferRoots();
+
+      aResShape = aReader.OneShape();
+    } 
+    else {
+      aResShape.Nullify();
+    }
+  }
+  catch(Standard_Failure) {
+    aResShape.Nullify();
+  }
+
+  return aResShape;
+}
+
+TopoDS_Shape HYDROData_Obstacle::ImportSTEP( const QString& theFilePath ) const
+{
+  TopoDS_Shape aResShape;
+
+  // Set "C" numeric locale to save numbers correctly
+  Kernel_Utils::Localizer loc;
+
+  STEPControl_Reader aReader;
+
+  // Convert to METERS
+  Interface_Static::SetCVal("xstep.cascade.unit","M");
+  Interface_Static::SetIVal("read.step.ideas", 1);
+  Interface_Static::SetIVal("read.step.nonmanifold", 1);
+
+  BRep_Builder B;
+  TopoDS_Compound compound;
+  B.MakeCompound(compound);
+
+  try {
+    OCC_CATCH_SIGNALS;
+
+    IFSelect_ReturnStatus status = aReader.ReadFile( qPrintable(theFilePath) );
+
+    if (status == IFSelect_RetDone) {
+      // Rescale units
+      // set UnitFlag to units from file
+      TColStd_SequenceOfAsciiString anUnitLengthNames;
+      TColStd_SequenceOfAsciiString anUnitAngleNames;
+      TColStd_SequenceOfAsciiString anUnitSolidAngleNames;
+      aReader.FileUnits(anUnitLengthNames, anUnitAngleNames, anUnitSolidAngleNames);
+      if (anUnitLengthNames.Length() > 0) {
+        TCollection_AsciiString aLenUnits = anUnitLengthNames.First();
+        if (aLenUnits == "millimetre")
+          Interface_Static::SetCVal("xstep.cascade.unit", "MM");
+        else if (aLenUnits == "centimetre")
+          Interface_Static::SetCVal("xstep.cascade.unit", "CM");
+        else if (aLenUnits == "metre" || aLenUnits.IsEmpty())
+          Interface_Static::SetCVal("xstep.cascade.unit", "M");
+        else if (aLenUnits == "INCH")
+          Interface_Static::SetCVal("xstep.cascade.unit", "INCH");
+        else {
+          // The file contains not supported units
+          return aResShape;
+        }
+      }
+        
+      Standard_Boolean failsonly = Standard_False;
+      aReader.PrintCheckLoad(failsonly, IFSelect_ItemsByEntity);
+
+      // Root transfers
+      Standard_Integer nbr = aReader.NbRootsForTransfer();
+      aReader.PrintCheckTransfer(failsonly, IFSelect_ItemsByEntity);
+
+      for (Standard_Integer n = 1; n <= nbr; n++) {
+        Standard_Boolean ok = aReader.TransferRoot(n);
+        // Collecting resulting entities
+        Standard_Integer nbs = aReader.NbShapes();
+        if (!ok || nbs == 0) {
+          continue; // skip empty root
+        } 
+        else if (nbr == 1 && nbs == 1) { // For a single entity
+          aResShape = aReader.Shape(1);
+          // 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;
+          }
+          // END workaround
+          break;
+        }
+
+        for (Standard_Integer i = 1; i <= nbs; i++) {
+          TopoDS_Shape aShape = aReader.Shape(i);
+          if (aShape.IsNull()) {
+            continue;
+          }
+          else {
+            B.Add(compound, aShape);
+          }
+        }
+      }
+  
+      if (aResShape.IsNull())
+        aResShape = compound;
+
+      // Check if any BRep entity has been read, there must be at least a vertex
+      if ( !TopExp_Explorer( aResShape, TopAbs_VERTEX ).More() ) {
+        // No geometrical data in the imported file
+        return TopoDS_Shape();
+      }
+    }
+    else {
+      aResShape.Nullify();
+    }
+  }
+  catch (Standard_Failure) {
+    aResShape.Nullify();
+  }
+
+  return aResShape;
+}
index 0a728c0acd872d39815ff18ba4c63781ebbaa078..66db4c38014608aeb4f06a83c054853ad5ca8768 100644 (file)
@@ -19,6 +19,8 @@ protected:
   enum DataTag
   {
     DataTag_First = HYDROData_ArtificialObject::DataTag_First + 100, ///< first tag, to reserve
+    DataTag_GeomObjectEntry, ///< study entry of the imported GEOM object
+    DataTag_FilePath ///< imported file path
   };
 
 public:
@@ -44,6 +46,41 @@ public:
    */
   HYDRODATA_EXPORT virtual TopoDS_Shape GetShape3D() const;
 
+  /**
+   * Imports shape from file containing geometrical object and sets this
+   * shape as the obstacle shape.
+   * The supported file types:
+   *  - BREP
+   *  - IGES
+   *  - STEP
+   *  - ACIS
+   * \param theFilePath the path to file
+   * \return \c true if file has been successfully read
+   */
+  HYDRODATA_EXPORT virtual bool ImportFromFile( const QString& theFilePath );
+
+  /**
+   * Stores the file path of the imported file.
+   * \param theFilePath file path
+   */
+  HYDRODATA_EXPORT void SetFilePath(const QString& theFilePath);
+
+  /**
+   * Returns the imported file path.
+   */
+  HYDRODATA_EXPORT QString GetFilePath() const;
+
+   /**
+   * Stores the study entry of the imported GEOM object.
+   * \param theEntry GEOM object entry
+   */
+  HYDRODATA_EXPORT void SetGeomObjectEntry(const QString& theEntry);
+
+  /**
+   * Returns the imported GEOM object entry.
+   */
+  HYDRODATA_EXPORT QString GetGeomObjectEntry() const;
+
 protected:
 
   friend class HYDROData_Iterator;
@@ -58,6 +95,28 @@ protected:
    * Destructs properties of the object and object itself, removes it from the document.
    */
   virtual HYDRODATA_EXPORT ~HYDROData_Obstacle();
+
+private:
+  /**
+   * Imports shape from the BREP file.
+   * \param theFilePath the path to file
+   * \return shape as TopoDS_Shape (null shape if import was failed)
+   */
+  TopoDS_Shape ImportBREP( const QString& theFilePath ) const;
+
+  /**
+   * Imports shape from the IGES file.
+   * \param theFilePath the path to file
+   * \return shape as TopoDS_Shape (null shape if import was failed)
+   */
+  TopoDS_Shape ImportIGES( const QString& theFilePath ) const;
+
+  /**
+   * Imports shape from the STEP file.
+   * \param theFilePath the path to file
+   * \return shape as TopoDS_Shape (null shape if import was failed)
+   */
+  TopoDS_Shape ImportSTEP( const QString& theFilePath ) const;
 };
 
 #endif
index 78f8736efaf44a97d8a7e7f8ccad45d298af2546..53395cd813cb79460818615884a6b57282fc68ac 100755 (executable)
@@ -13,7 +13,7 @@ class TopoDS_Wire;
 
 DEFINE_STANDARD_HANDLE(HYDROData_Polyline, HYDROData_Object)
 
-struct PolylineSection
+struct HYDRODATA_EXPORT PolylineSection
 {
 public:
   enum SectionType{ SECTION_POLYLINE=0, SECTION_SPLINE=1 };
@@ -138,12 +138,12 @@ protected:
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
    */
-  HYDROData_Polyline();
+  HYDRODATA_EXPORT HYDROData_Polyline();
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
-  ~HYDROData_Polyline();
+  HYDRODATA_EXPORT ~HYDROData_Polyline();
 };
 
 #endif
diff --git a/src/HYDROData/HYDROData_PolylineXY.cxx b/src/HYDROData/HYDROData_PolylineXY.cxx
new file mode 100755 (executable)
index 0000000..d2f9979
--- /dev/null
@@ -0,0 +1,659 @@
+
+#include "HYDROData_PolylineXY.h"
+
+#include "HYDROData_Tool.h"
+
+#include <NCollection_Map.hxx>
+
+#include <TCollection_ExtendedString.hxx>
+
+#include <TDataStd_ListIteratorOfListOfByte.hxx>
+#include <TDataStd_ListIteratorOfListOfExtendedString.hxx>
+#include <TColStd_ListIteratorOfListOfInteger.hxx>
+#include <TColStd_ListIteratorOfListOfReal.hxx>
+
+#include <TDataStd_BooleanList.hxx>
+#include <TDataStd_ExtStringList.hxx>
+#include <TDataStd_Integer.hxx>
+#include <TDataStd_IntegerList.hxx>
+#include <TDataStd_RealList.hxx>
+
+#include <TopoDS_Wire.hxx>
+
+
+IMPLEMENT_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
+IMPLEMENT_STANDARD_RTTIEXT(HYDROData_PolylineXY, HYDROData_IPolyline)
+
+HYDROData_PolylineXY::HYDROData_PolylineXY()
+: HYDROData_IPolyline()
+{
+}
+
+HYDROData_PolylineXY::~HYDROData_PolylineXY()
+{
+}
+
+CurveCreator_ICurve::ListAISObjects HYDROData_PolylineXY::constructWire() const
+{
+  // TODO
+  ListAISObjects aProfileObjects;
+  return aProfileObjects;
+}
+
+bool HYDROData_PolylineXY::clear()
+{
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
+
+  removeSectionsLists();
+  removePointsLists();
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return true;
+}
+
+bool HYDROData_PolylineXY::join( const int theISectionTo, 
+                                 const int theISectionFrom )
+{
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
+  if ( aNamesList.IsNull() || aNamesList->Extent() <= 1 )
+    return false;
+  
+  bool anIsOperation = myIsOperation;
+
+  if ( theISectionTo == -1 || theISectionFrom == -1 )
+  {
+    // Join all sections to one
+    if ( !anIsOperation )
+      startOperation();
+
+    TCollection_ExtendedString aSectName = aNamesList->First();
+    CurveCreator::SectionType aSectType = (CurveCreator::SectionType)aTypesList->First();
+    bool anIsClosed = aClosuresList->First();
+
+    aNamesList->Clear();
+    aTypesList->Clear();
+    aClosuresList->Clear();
+    
+    aNamesList->Append( aSectName );
+    aTypesList->Append( aSectType );
+    aClosuresList->Append( anIsClosed );
+
+    CurveCreator::Coordinates anAllPoints = getPoints();
+    removePointsLists();
+
+    addPoints( anAllPoints, 0 );
+  }
+  else
+  {
+    // Join selected range of sections to one
+    if ( theISectionFrom >= theISectionTo )
+      return false;
+
+    if ( !anIsOperation )
+      startOperation();
+
+    TDataStd_ListOfExtendedString anOldNamesList;
+    anOldNamesList = aNamesList->List();
+
+    TColStd_ListOfInteger anOldTypesList;
+    anOldTypesList = aTypesList->List();
+
+    TDataStd_ListOfByte anOldClosuresList;
+    anOldClosuresList = aClosuresList->List();
+
+    // Refill the existing lists
+    aNamesList->Clear();
+    aTypesList->Clear();
+    aClosuresList->Clear();
+
+    Handle(TDataStd_RealList) aJoinListX, aJoinListY;
+
+    TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
+    TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
+    TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
+
+    int aNbSect = 0;
+    for ( ; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
+            aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next(), ++aNbSect )
+    {
+      if ( aNbSect < theISectionFrom || aNbSect > theISectionTo )
+      {
+        aNamesList->Append( aNamesIter.Value() );
+        aTypesList->Append( aTypesIter.Value() );
+        aClosuresList->Append( (bool)aClosuresIter.Value() );
+      }
+      else
+      {
+        if ( aNbSect == theISectionFrom )
+        {
+          aNamesList->Append( aNamesIter.Value() );
+          aTypesList->Append( aTypesIter.Value() );
+          aClosuresList->Append( (bool)aClosuresIter.Value() );
+
+          getPointsLists( aNbSect, aJoinListX, aJoinListY );
+        }
+        else
+        {
+          Handle(TDataStd_RealList) aListX, aListY;
+          getPointsLists( aNbSect, aListX, aListY );
+
+          TColStd_ListIteratorOfListOfReal anIterX( aListX->List() );
+          TColStd_ListIteratorOfListOfReal anIterY( aListY->List() );
+          for ( ; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next() )
+          {
+            aJoinListX->Append( anIterX.Value() );
+            aJoinListY->Append( anIterY.Value() );
+          }
+  
+          removePointsLists( aNbSect );
+        }
+      }
+
+      // Move the list which are after theISectionTo to correct place
+      for ( int i = theISectionTo + 1, j = theISectionFrom + 1; i < aNbSect; ++i, j++ )
+      {
+        CurveCreator::Coordinates aPoints = getPoints( i );
+        removePointsLists( i );
+        addPoints( aPoints, j  );
+      }
+    }
+  }
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return true;
+}
+
+int HYDROData_PolylineXY::getNbSections() const
+{
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
+
+  return aNamesList.IsNull() ? 0 : aNamesList->Extent();
+}
+
+TCollection_ExtendedString getUniqueSectionName( const Handle(TDataStd_ExtStringList)& theNamesList )
+{
+  NCollection_Map<TCollection_ExtendedString> aNamesMap;
+
+  TDataStd_ListIteratorOfListOfExtendedString aNamesIter( theNamesList->List() );
+  for ( ; aNamesIter.More(); aNamesIter.Next() )
+    aNamesMap.Add( aNamesIter.Value() );
+
+  TCollection_ExtendedString aResName;
+
+  int aPrefIdx = 1;
+  do
+  {
+    aResName = "Section_" + aPrefIdx;
+    ++aPrefIdx;
+  }
+  while ( aNamesMap.Contains( aResName ) );
+
+  return aResName;
+}
+
+int HYDROData_PolylineXY::addSection( const std::string&              theName, 
+                                      const CurveCreator::SectionType theType,
+                                      const bool                      theIsClosed )
+{
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
+
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList );
+
+  TCollection_ExtendedString aSectName = theName.c_str();
+  if ( aSectName.Length() <= 0 )
+    aSectName = getUniqueSectionName( aNamesList );
+
+  aNamesList->Append( aSectName );
+  aTypesList->Append( theType );
+  aClosuresList->Append( theIsClosed );
+
+  int aSectId = aNamesList->Extent() - 1;
+
+  // Just to create empty data
+  Handle(TDataStd_RealList) aListX, aListY;
+  getPointsLists( aSectId, aListX, aListY );
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return aSectId;
+}
+
+bool HYDROData_PolylineXY::removeSection( const int theISection )
+{
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
+  if ( aNamesList.IsNull() || aNamesList->IsEmpty() )
+    return false;
+
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
+
+  if ( aNamesList->Extent() == 1 )
+  {
+    removeSectionsLists();
+    removePointsLists();
+  }
+  else
+  {
+    TDataStd_ListOfExtendedString anOldNamesList;
+    anOldNamesList = aNamesList->List();
+
+    TColStd_ListOfInteger anOldTypesList;
+    anOldTypesList = aTypesList->List();
+
+    TDataStd_ListOfByte anOldClosuresList;
+    anOldClosuresList = aClosuresList->List();
+
+    // Refill the existing lists
+    aNamesList->Clear();
+    aTypesList->Clear();
+    aClosuresList->Clear();
+
+    TDataStd_ListIteratorOfListOfExtendedString aNamesIter( anOldNamesList );
+    TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
+    TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
+    for ( int i = 0; aNamesIter.More() && aTypesIter.More() && aClosuresIter.More();
+                     aNamesIter.Next(), aTypesIter.Next(), aClosuresIter.Next(), ++i )
+    {
+      if ( i == theISection )
+        continue; // skip index to remove
+
+      aNamesList->Append( aNamesIter.Value() );
+      aTypesList->Append( aTypesIter.Value() );
+      aClosuresList->Append( (bool)aClosuresIter.Value() );
+    }
+
+    // Remove points that belong to removed section
+    removePointsLists( theISection );
+  }
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return true;
+}
+
+bool HYDROData_PolylineXY::isClosed( const int theISection ) const
+{
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
+  if ( aNamesList.IsNull() || theISection >= aNamesList->Extent() )
+    return false;
+
+  TDataStd_ListIteratorOfListOfByte aClosuresIter( aClosuresList->List() );
+  for ( int i = 0; aClosuresIter.More() && i != theISection; aClosuresIter.Next(), ++i );
+
+  return aClosuresIter.More() ? (bool)aClosuresIter.Value() : false;
+}
+
+bool HYDROData_PolylineXY::setClosed( const int  theISection, 
+                                      const bool theIsClosed )
+{
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
+  if ( aNamesList.IsNull() || theISection >= aNamesList->Extent() )
+    return false;
+
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
+
+  TDataStd_ListOfByte anOldClosuresList;
+  anOldClosuresList = aClosuresList->List();
+
+  // Refill the existing list
+  aClosuresList->Clear();
+
+  TDataStd_ListIteratorOfListOfByte aClosuresIter( anOldClosuresList );
+  for ( int i = 0; aClosuresIter.More(); aClosuresIter.Next(), ++i )
+    aClosuresList->Append( i == theISection ? theIsClosed : (bool)aClosuresIter.Value() );
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return true;
+}
+
+std::string HYDROData_PolylineXY::getSectionName( const int theISection ) const
+{
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
+  if ( aNamesList.IsNull() || theISection >= aNamesList->Extent() )
+    return "";
+
+  TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
+  for ( int i = 0; aNamesIter.More() && i != theISection; aNamesIter.Next(), ++i );
+
+  TCollection_AsciiString aResName;
+  if ( aNamesIter.More() )
+    aResName = aNamesIter.Value();
+
+  return aResName.ToCString();
+}
+
+bool HYDROData_PolylineXY::setSectionName( const int          theISection, 
+                                           const std::string& theName )
+{
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
+  if ( aNamesList.IsNull() || theISection >= aNamesList->Extent() )
+    return false;
+
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
+
+  TDataStd_ListOfExtendedString anOldNamesList;
+  anOldNamesList = aNamesList->List();
+
+  // Refill the existing list
+  aNamesList->Clear();
+
+  TDataStd_ListIteratorOfListOfExtendedString aNamesIter( aNamesList->List() );
+  for ( int i = 0; aNamesIter.More(); aNamesIter.Next(), ++i )
+    aNamesList->Append( i == theISection ? theName.c_str() : aNamesIter.Value() );
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return true;
+}
+
+CurveCreator::SectionType HYDROData_PolylineXY::getSectionType( const int theISection ) const
+{
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
+  if ( aNamesList.IsNull() || theISection >= aNamesList->Extent() )
+    return CurveCreator::Polyline;
+
+  TColStd_ListIteratorOfListOfInteger aTypesIter( aTypesList->List() );
+  for ( int i = 0; aTypesIter.More() && i != theISection; aTypesIter.Next(), ++i );
+
+  return aTypesIter.More() ? (CurveCreator::SectionType)aTypesIter.Value() : CurveCreator::Polyline;
+}
+
+bool HYDROData_PolylineXY::setSectionType( const int                       theISection, 
+                                           const CurveCreator::SectionType theType )
+{
+  Handle(TDataStd_ExtStringList) aNamesList;
+  Handle(TDataStd_IntegerList) aTypesList;
+  Handle(TDataStd_BooleanList) aClosuresList;
+  getSectionsLists( aNamesList, aTypesList, aClosuresList, false );
+  if ( aNamesList.IsNull() || theISection >= aNamesList->Extent() )
+    return false;
+
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
+
+  TColStd_ListOfInteger anOldTypesList;
+  anOldTypesList = aTypesList->List();
+
+  // Refill the existing list
+  aTypesList->Clear();
+
+  TColStd_ListIteratorOfListOfInteger aTypesIter( anOldTypesList );
+  for ( int i = 0; aTypesIter.More(); aTypesIter.Next(), ++i )
+    aTypesList->Append( i == theISection ? theType : aTypesIter.Value() );
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return true;
+}
+
+void addPointsToLists( const CurveCreator::Coordinates& theCoords,
+                       Handle(TDataStd_RealList)&       theListX,
+                       Handle(TDataStd_RealList)&       theListY,
+                       const bool                       theIsAppend )
+{
+  CurveCreator::Coordinates::const_iterator aBegIter = theCoords.begin();
+  CurveCreator::Coordinates::const_iterator anEndIter = theCoords.end();
+  while ( aBegIter != anEndIter )
+  {
+    const CurveCreator::TypeCoord& aCoordX = *aBegIter++;
+    if ( aBegIter == anEndIter )
+      break;
+
+    const CurveCreator::TypeCoord& aCoordY = *aBegIter++;
+
+    if ( theIsAppend )
+    {
+      theListX->Append( aCoordX );
+      theListY->Append( aCoordY );
+    }
+    else
+    {
+      theListX->Prepend( aCoordX );
+      theListY->Prepend( aCoordY );
+    }
+  }
+}
+
+bool HYDROData_PolylineXY::addPoints( const CurveCreator::Coordinates& theCoords,
+                                      const int                        theISection,
+                                      const int                        theIPnt )
+{
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
+
+  Handle(TDataStd_RealList) aListX, aListY;
+  getPointsLists( theISection, aListX, aListY );
+
+  if ( theIPnt < 0 || theIPnt >= aListX->Extent() )
+  {
+    addPointsToLists( theCoords, aListX, aListY, true );
+  }
+  else
+  {
+    TColStd_ListOfReal anOldListX;
+    anOldListX = aListX->List();
+
+    TColStd_ListOfReal anOldListY;
+    anOldListY = aListY->List();
+
+    // Refill the existing lists
+    aListX->Clear();
+    aListY->Clear();
+
+    TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
+    TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
+    for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
+    {
+      double aCoordX = anIterX.Value();
+      double aCoordY = anIterY.Value();
+
+      if ( i == theIPnt )
+      {
+        // Insert our new points
+        addPointsToLists( theCoords, aListX, aListY, true );
+      }
+
+      aListX->Append( aCoordX );
+      aListY->Append( aCoordY );
+    }
+  }
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return true;
+}
+
+bool HYDROData_PolylineXY::setPoint( const int                        theISection,
+                                     const int                        theIPnt,
+                                     const CurveCreator::Coordinates& theCoords )
+{
+  if ( theCoords.size() < 2 )
+    return false;
+
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
+
+  Handle(TDataStd_RealList) aListX, aListY;
+  getPointsLists( theISection, aListX, aListY );
+
+  if ( theIPnt < 0 )
+  {
+    addPointsToLists( theCoords, aListX, aListY, false );
+  }
+  else if ( theIPnt >= aListX->Extent() )
+  {
+    addPointsToLists( theCoords, aListX, aListY, true );
+  }
+  else
+  {
+    CurveCreator::Coordinates::const_iterator aBegIter = theCoords.begin();
+    const CurveCreator::TypeCoord& aNewCoordX = *aBegIter++;
+    const CurveCreator::TypeCoord& aNewCoordY = *aBegIter++;
+
+    TColStd_ListOfReal anOldListX;
+    anOldListX = aListX->List();
+
+    TColStd_ListOfReal anOldListY;
+    anOldListY = aListY->List();
+
+    // Refill the existing lists
+    aListX->Clear();
+    aListY->Clear();
+
+    TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
+    TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
+    for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
+    {
+      double aCoordX = anIterX.Value();
+      double aCoordY = anIterY.Value();
+
+      if ( i == theIPnt )
+      {
+        // Insert our new points instead of old one
+        aCoordX = aNewCoordX;
+        aCoordY = aNewCoordY;
+      }
+
+      aListX->Append( aCoordX );
+      aListY->Append( aCoordY );
+    }
+  }
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return true;
+}
+
+bool HYDROData_PolylineXY::removePoint( const int theISection,
+                                        const int theIPnt )
+{
+  Handle(TDataStd_RealList) aListX, aListY;
+  getPointsLists( theISection, aListX, aListY, false );
+  if ( aListX.IsNull() || aListY.IsNull() || aListX->IsEmpty() )
+    return false;
+
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
+
+  if ( aListX->Extent() == 1 )
+  {
+    removePointsLists( theISection );
+  }
+  else
+  {
+    TColStd_ListOfReal anOldListX;
+    anOldListX = aListX->List();
+
+    TColStd_ListOfReal anOldListY;
+    anOldListY = aListY->List();
+
+    // Refill the existing lists
+    aListX->Clear();
+    aListY->Clear();
+
+    TColStd_ListIteratorOfListOfReal anIterX( anOldListX );
+    TColStd_ListIteratorOfListOfReal anIterY( anOldListY );
+    for ( int i = 0; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next(), ++i )
+    {
+      if ( i == theIPnt )
+        continue; // skip index to remove
+
+      aListX->Append( anIterX.Value() );
+      aListY->Append( anIterY.Value() );
+    }
+  }
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return true;
+}
+
+CurveCreator::Coordinates HYDROData_PolylineXY::getPoints( const int theISection ) const
+{
+  CurveCreator::Coordinates aResList;
+
+  if ( theISection < 0 )
+  {
+    int aNbSections = getNbSections();
+    for ( int i = 0; i < aNbSections; ++i )
+    {
+      CurveCreator::Coordinates aSectCoords = getPoints( i );
+      aResList.insert( aResList.end(), aSectCoords.begin(), aSectCoords.end());
+    }
+  }
+  else
+  {
+    Handle(TDataStd_RealList) aListX, aListY;
+    getPointsLists( theISection, aListX, aListY, false );
+    if ( !aListX.IsNull() && !aListY.IsNull() )
+    {
+      TColStd_ListIteratorOfListOfReal anIterX( aListX->List() );
+      TColStd_ListIteratorOfListOfReal anIterY( aListY->List() );
+      for ( ; anIterX.More() && anIterY.More(); anIterX.Next(), anIterY.Next() )
+      {
+        const double& aCoordX = anIterX.Value();
+        const double& aCoordY = anIterY.Value();
+
+        aResList.push_back( aCoordX );
+        aResList.push_back( aCoordY );
+      }
+    }
+  }
+
+  return aResList;
+}
+
+
diff --git a/src/HYDROData/HYDROData_PolylineXY.h b/src/HYDROData/HYDROData_PolylineXY.h
new file mode 100644 (file)
index 0000000..93caac6
--- /dev/null
@@ -0,0 +1,140 @@
+
+#ifndef HYDROData_PolylineXY_HeaderFile
+#define HYDROData_PolylineXY_HeaderFile
+
+#include "HYDROData_IPolyline.h"
+
+DEFINE_STANDARD_HANDLE(HYDROData_PolylineXY, HYDROData_IPolyline)
+
+/**\class HYDROData_PolylineXY
+ * \brief Class that stores/retreives information about the 
+ *        parametric profile points.
+ */
+class HYDROData_PolylineXY : public HYDROData_IPolyline
+{
+protected:
+  /**
+   * Enumeration of tags corresponding to the persistent object parameters.
+   */
+  enum DataTag
+  {
+    DataTag_First = HYDROData_IPolyline::DataTag_First + 100, ///< first tag, to reserve
+  };
+
+public:
+  DEFINE_STANDARD_RTTI(HYDROData_PolylineXY);
+
+
+  /**
+   * Returns the kind of this object. Must be redefined in all objects of known type.
+   */
+  HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_POLYLINEXY;}
+
+
+public:
+
+  // Implementation of IPolyline interface
+
+  /**
+   * Returns the 3D presentation of all points.
+   */
+  HYDRODATA_EXPORT virtual ListAISObjects constructWire() const;
+
+public:
+
+  // Implementation of ICurve interface
+
+
+  /***********************************************/
+  /***           Section methods               ***/
+  /***********************************************/
+
+  //! Clear the polyline (remove all sections)
+  HYDRODATA_EXPORT virtual bool clear();
+
+  //! Join range of sections to one section (join all sections if -1 is passed in one of arguments)
+  HYDRODATA_EXPORT virtual bool join( const int theISectionTo = -1, 
+                                      const int theISectionFrom = -1 );
+
+  //! Get number of sections
+  HYDRODATA_EXPORT virtual int getNbSections() const;
+
+  //! Add a new section.
+  HYDRODATA_EXPORT virtual int addSection( const std::string&              theName, 
+                                           const CurveCreator::SectionType theType,
+                                           const bool                      theIsClosed );
+
+  //! Removes the given section.
+  HYDRODATA_EXPORT virtual bool removeSection( const int theISection );
+
+  //! Get "closed" flag of the specified section
+  HYDRODATA_EXPORT virtual bool isClosed( const int theISection ) const;
+
+  /**
+   *  Set "closed" flag of the specified section (all sections if
+   *  \a theISection is -1).
+   */
+  HYDRODATA_EXPORT virtual bool setClosed( const int  theISection, 
+                                           const bool theIsClosed );
+
+  //! Returns specifyed section name
+  HYDRODATA_EXPORT virtual std::string getSectionName( const int theISection ) const;
+
+  /** Set name of the specified section */
+  HYDRODATA_EXPORT virtual bool setSectionName( const int          theISection, 
+                                                const std::string& theName );
+
+  //! Get type of the specified section
+  HYDRODATA_EXPORT virtual CurveCreator::SectionType getSectionType( const int theISection ) const;
+
+  /**
+   *  Set type of the specified section (or all sections
+   *  if \a theISection is -1).
+   */
+  HYDRODATA_EXPORT virtual bool setSectionType( const int                       theISection, 
+                                                const CurveCreator::SectionType theType );
+
+
+  /***********************************************/
+  /***           Point methods                 ***/
+  /***********************************************/
+
+  /**
+   *  Insert one or several points to the specified section starting from the given theIPnt index
+   *  (or add these at the end of section points if \a theIPnt is -1).
+   */
+  HYDRODATA_EXPORT virtual bool addPoints( const CurveCreator::Coordinates& theCoords,
+                                           const int                        theISection,
+                                           const int                        theIPnt = -1 );
+
+  //! Set coordinates of specified point
+  HYDRODATA_EXPORT virtual bool setPoint( const int                        theISection,
+                                          const int                        theIPnt,
+                                          const CurveCreator::Coordinates& theCoords );
+
+  //! Remove point with given id
+  HYDRODATA_EXPORT virtual bool removePoint( const int theISection, const int theIPnt = -1 );
+
+  /**
+   * Get points of a section (the total points in Curve if theISection is equal to -1)..
+   */
+  HYDRODATA_EXPORT virtual CurveCreator::Coordinates getPoints( const int theISection = -1 ) const;
+
+protected:
+
+  friend class HYDROData_Profile;
+  friend class HYDROData_Iterator;
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDRODATA_EXPORT HYDROData_PolylineXY();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  HYDRODATA_EXPORT ~HYDROData_PolylineXY();
+};
+
+#endif
index 9832cadb3a4a47fa95a35795a1d2ec5da90c2af5..4374e043bdb59cfe61ceb3ad407242bebe7a3fd3 100755 (executable)
@@ -196,32 +196,40 @@ Handle(HYDROData_ProfileUZ) HYDROData_Profile::GetProfileUZ( const bool theIsCre
 int HYDROData_Profile::NbPoints() const
 {
   Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ( false );
-  return aProfileUZ.IsNull() ? 0 : aProfileUZ->NbPoints();
+  return aProfileUZ.IsNull() ? 0 : aProfileUZ->getNbPoints();
 }
 
 void HYDROData_Profile::RemovePoints()
 {
   Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ( false );
   if ( !aProfileUZ.IsNull() )
-    aProfileUZ->RemoveSections();
+    aProfileUZ->clear();
 }
 
-void HYDROData_Profile::SetParametricPoints( const HYDROData_ProfileUZ::PointsList& thePoints )
+void HYDROData_Profile::SetParametricPoints( const CurveCreator::Coordinates& theCoords )
 {
   RemovePoints();
 
   Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ();
-  for ( int i = 1, n = thePoints.Length(); i <= n ; ++i )
+
+  CurveCreator::Coordinates::const_iterator aBegIter = theCoords.begin();
+  CurveCreator::Coordinates::const_iterator anEndIter = theCoords.end();
+  while ( aBegIter != anEndIter )
   {
-    const HYDROData_ProfileUZ::Point& aPoint = thePoints.Value( i );
-    aProfileUZ->AddPoint( 0, aPoint );
+    const CurveCreator::TypeCoord& aCoordX = *aBegIter++;
+    if ( aBegIter == anEndIter )
+      break;
+
+    const CurveCreator::TypeCoord& aCoordY = *aBegIter++;
+
+    aProfileUZ->addPoint( aCoordX, aCoordY, 0 );
   }
 }
 
-HYDROData_ProfileUZ::PointsList HYDROData_Profile::GetParametricPoints() const
+CurveCreator::Coordinates HYDROData_Profile::GetParametricPoints() const
 {
   Handle(HYDROData_ProfileUZ) aProfileUZ = GetProfileUZ( false );
-  return aProfileUZ.IsNull() ? HYDROData_ProfileUZ::PointsList() : aProfileUZ->GetPoints();
+  return aProfileUZ.IsNull() ? CurveCreator::Coordinates() : aProfileUZ->getPoints();
 }
 
 void HYDROData_Profile::SetProfilePoints( const ProfilePoints& thePoints )
@@ -245,8 +253,7 @@ void HYDROData_Profile::SetProfilePoints( const ProfilePoints& thePoints )
 
     double aDistance = gp_Pnt2d( aFirstPoint ).Distance( aPointXY );
     
-    HYDROData_ProfileUZ::Point aParPoint( aDistance, aPoint.Z() );
-    aProfileUZ->AddPoint( 0, aParPoint );
+    aProfileUZ->addPoint( 0, aDistance, aPoint.Z() );
   }
 
   SetFirstPoint( aFirstPoint );
@@ -261,12 +268,15 @@ HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints() const
   if ( !GetFirstPoint( aFirstPoint ) || !GetLastPoint( aLastPoint ) )
     return aResPoints;
 
-  HYDROData_ProfileUZ::PointsList aParametricPoints = GetParametricPoints();
-  if ( aParametricPoints.Length() < 2 )
+  CurveCreator::Coordinates aParametricPoints = GetParametricPoints();
+  if ( aParametricPoints.size() < 4 )
     return aResPoints;
 
-  const HYDROData_ProfileUZ::Point& aFirstParPoint = aParametricPoints.First();
-  const HYDROData_ProfileUZ::Point& aLastParPoint = aParametricPoints.Last();
+  CurveCreator::Coordinates::const_iterator aBegIter = aParametricPoints.begin();
+  CurveCreator::Coordinates::const_iterator anEndIter = aParametricPoints.end()--;
+
+  gp_Pnt2d aFirstParPoint( *aBegIter++, *aBegIter++ );
+  gp_Pnt2d aLastParPoint( *anEndIter--, *anEndIter );
 
   double aGeoDistance = gp_Pnt2d( aFirstPoint ).Distance( aLastPoint );
   double aParCommonDist = gp_Pnt2d( aFirstParPoint.X(), 0 ).Distance( gp_Pnt2d( aLastParPoint.X(), 0 ) );
@@ -275,11 +285,13 @@ HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints() const
   aResPoints.Append( ProfilePoint( aFirstPoint.X(), aFirstPoint.Y(), aFirstParPoint.Y() ) );
 
   // Compute all other points
-  for ( int i = 2, n = aParametricPoints.Length(); i < n ; ++i )
+  while ( aBegIter != anEndIter )
   {
-    const HYDROData_ProfileUZ::Point& aParPoint = aParametricPoints.Value( i );
+    const CurveCreator::TypeCoord& aCoordU = *aBegIter++;
+    if ( aBegIter == anEndIter )
+      break;
 
-    double aParPointDist = gp_Pnt2d( aFirstParPoint.X(), 0 ).Distance( gp_Pnt2d( aParPoint.X(), 0 ) );
+    double aParPointDist = gp_Pnt2d( aFirstParPoint.X(), 0 ).Distance( gp_Pnt2d( aCoordU, 0 ) );
     
     double aParLen = ( aParPointDist / aParCommonDist ) * aGeoDistance;
 
@@ -288,7 +300,10 @@ HYDROData_Profile::ProfilePoints HYDROData_Profile::GetProfilePoints() const
     double aParX = ( aFirstPoint.X() + aRatio * aLastPoint.X() ) / ( 1 + aRatio );
     double aParY = ( aFirstPoint.Y() + aRatio * aLastPoint.Y() ) / ( 1 + aRatio );
 
-    ProfilePoint aCompPoint( aParX, aParY, aParPoint.Y() );
+
+    const CurveCreator::TypeCoord& aCoordZ = *aBegIter++;
+
+    ProfilePoint aCompPoint( aParX, aParY, aCoordZ );
     aResPoints.Append( aCompPoint );
   }
 
@@ -399,8 +414,8 @@ bool HYDROData_Profile::ImportFromFile( OSD_File& theFile )
   bool anIsParametric = false;
   bool anIsGeoref     = false;
 
-  HYDROData_ProfileUZ::PointsList aPointsUZ;
-  ProfilePoints                   aPointsXYZ;
+  CurveCreator::Coordinates aPointsUZ;
+  ProfilePoints             aPointsXYZ;
 
   double aPrevVal = -DBL_MAX;
   while ( !theFile.IsAtEnd() )
@@ -442,8 +457,8 @@ bool HYDROData_Profile::ImportFromFile( OSD_File& theFile )
         break;
       }
 
-      HYDROData_ProfileUZ::Point aPoint( aCoordX, aCoordY );
-      aPointsUZ.Append( aPoint );
+      aPointsUZ.push_back( aCoordX );
+      aPointsUZ.push_back( aCoordY );
 
       aPrevVal = aCoordX;
     }
@@ -462,7 +477,7 @@ bool HYDROData_Profile::ImportFromFile( OSD_File& theFile )
     }
   }
   
-  aRes = aRes && ( anIsParametric && !aPointsUZ.IsEmpty() || 
+  aRes = aRes && ( anIsParametric && !aPointsUZ.empty() || 
                    anIsGeoref && !aPointsXYZ.IsEmpty() );
   if ( aRes )
   {
index 775ced7a410def2ae3746877af482a5b27c00320..13c6f6198f0c96bd6ceeaa05d271d1c1415bcd7b 100644 (file)
@@ -8,6 +8,7 @@
 
 DEFINE_STANDARD_HANDLE(HYDROData_Profile, HYDROData_Object)
 
+class gp_XY;
 class gp_XYZ;
 class OSD_File;
 class Handle(HYDROData_Document);
@@ -128,13 +129,13 @@ public:
    * Replace current profile parametric points by new one.
    * \param thePoints the list with new points in parametric form
    */
-  HYDRODATA_EXPORT void SetParametricPoints( const HYDROData_ProfileUZ::PointsList& thePoints );
+  HYDRODATA_EXPORT void SetParametricPoints( const CurveCreator::Coordinates& theCoords );
 
   /**
    * Returns profile points in parametric form.
    * \return points list
    */
-  HYDRODATA_EXPORT HYDROData_ProfileUZ::PointsList GetParametricPoints() const;
+  HYDRODATA_EXPORT CurveCreator::Coordinates GetParametricPoints() const;
 
 
   /**
@@ -197,7 +198,7 @@ private:
    * Imports Profile data from parametric file.
    */
   bool importParametricFile( OSD_File&                        theFile,
-                             HYDROData_ProfileUZ::PointsList& thePoints );
+                             CurveCreator::Coordinates& thePoints );
 
   /**
    * Imports Profile data from Georeferenced file.
index 36ce31c6a528c9b03c6534072d23fa43c11e3c3d..98abdc8202afbb6aa3d17bac552f77978d7c7be6 100755 (executable)
@@ -24,42 +24,116 @@ HYDROData_ProfileUZ::~HYDROData_ProfileUZ()
 {
 }
 
-TopoDS_Wire HYDROData_ProfileUZ::GetWire() const
+CurveCreator_ICurve::ListAISObjects HYDROData_ProfileUZ::constructWire() const
 {
   // TODO
-  return TopoDS_Wire();
+  ListAISObjects aProfileObjects;
+  return aProfileObjects;
 }
 
-int HYDROData_ProfileUZ::NbSections() const
+bool HYDROData_ProfileUZ::clear()
+{
+  removePointsLists();
+  return true;
+}
+
+bool HYDROData_ProfileUZ::join( const int theISectionTo, 
+                                const int theISectionFrom )
+{
+  return false;
+}
+
+int HYDROData_ProfileUZ::getNbSections() const
 {
   return 1;
 }
 
-void HYDROData_ProfileUZ::AddSection( const bool /*theIsClosed*/ )
+int HYDROData_ProfileUZ::addSection( const std::string&              theName, 
+                                     const CurveCreator::SectionType theType,
+                                     const bool                      theIsClosed )
 {
+  return 0;
 }
 
-bool HYDROData_ProfileUZ::IsClosedSection( const int /*theSectionIndex*/ ) const
+bool HYDROData_ProfileUZ::removeSection( const int theISection )
+{
+  return clear();
+}
+
+bool HYDROData_ProfileUZ::isClosed( const int theISection ) const
+{
+  return false;
+}
+
+bool HYDROData_ProfileUZ::setClosed( const int  theISection, 
+                                     const bool theIsClosed )
 {
   return false;
 }
 
-void HYDROData_ProfileUZ::RemoveSection( const int /*theSectionIndex*/ )
+std::string HYDROData_ProfileUZ::getSectionName( const int theISection ) const
 {
-  RemoveSections();
+  return "Section_1";
 }
 
-void HYDROData_ProfileUZ::RemoveSections()
+bool HYDROData_ProfileUZ::setSectionName( const int          theISection, 
+                                          const std::string& theName )
 {
-  removePointsLists( 0 );
+  return false;
 }
 
-void HYDROData_ProfileUZ::AddPoint( const int    /*theSectionIndex*/,
-                                    const Point& thePoint,
-                                    const int    thePointIndex )
+CurveCreator::SectionType HYDROData_ProfileUZ::getSectionType( const int theISection ) const
 {
-  double aNewCoordU = thePoint.X();
-  double aNewCoordZ = thePoint.Y();
+  return CurveCreator::Polyline;
+}
+
+bool HYDROData_ProfileUZ::setSectionType( const int                       theISection, 
+                                          const CurveCreator::SectionType theType )
+{
+  return false;
+}
+
+bool HYDROData_ProfileUZ::addPoints( const CurveCreator::Coordinates& theCoords,
+                                     const int                        theISection,
+                                     const int                        theIPnt )
+{
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
+
+  bool aRes = true;
+
+  int anAfterPnt = theIPnt;
+
+  CurveCreator::Coordinates::const_iterator aBegIter = theCoords.begin();
+  CurveCreator::Coordinates::const_iterator anEndIter = theCoords.end();
+  while ( aBegIter != anEndIter )
+  {
+    const CurveCreator::TypeCoord& aCoordX = *aBegIter++;
+    if ( aBegIter == anEndIter )
+      break;
+
+    const CurveCreator::TypeCoord& aCoordY = *aBegIter++;
+
+    aRes = addPoint( aCoordX, aCoordY, theISection, anAfterPnt ) && aRes;
+    
+    if ( anAfterPnt != -1 )
+      ++anAfterPnt;
+  }
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return aRes;
+}
+
+bool HYDROData_ProfileUZ::addPoint( const CurveCreator::TypeCoord& theCoordX,
+                                    const CurveCreator::TypeCoord& theCoordY,
+                                    const int                      theISection,
+                                    const int                      theIPnt )
+{
+  CurveCreator::TypeCoord aNewCoordU = theCoordX;
+  CurveCreator::TypeCoord aNewCoordZ = theCoordY;
 
   Handle(TDataStd_RealList) aListU, aListZ;
   getPointsLists( 0, aListU, aListZ );
@@ -68,69 +142,69 @@ void HYDROData_ProfileUZ::AddPoint( const int    /*theSectionIndex*/,
   {
     aListU->Append( aNewCoordU );
     aListZ->Append( aNewCoordZ );
-    return;
   }
   else if ( aNewCoordU < aListU->First() )
   {
     aListU->Prepend( aNewCoordU );
     aListZ->Prepend( aNewCoordZ );
-    return;
   }
+  else 
+  {
+    TColStd_ListOfReal anOldListU;
+    anOldListU = aListU->List();
 
-  TColStd_ListOfReal anOldListU;
-  anOldListU = aListU->List();
-
-  TColStd_ListOfReal anOldListZ;
-  anOldListZ = aListZ->List();
-
-  // Crsat new lists
-  removePointsLists( 0 );
-  getPointsLists( 0, aListU, aListZ );
+    TColStd_ListOfReal anOldListZ;
+    anOldListZ = aListZ->List();
 
-  bool anIsInserted = false;
-  TColStd_ListIteratorOfListOfReal anIterU( anOldListU );
-  TColStd_ListIteratorOfListOfReal anIterZ( anOldListZ );
-  for ( ; anIterU.More() && anIterZ.More(); anIterU.Next(), anIterZ.Next() )
-  {
-    double aCoordU = anIterU.Value();
-    double aCoordZ = anIterZ.Value();
+    // Refill the existing lists
+    aListU->Clear();
+    aListZ->Clear();
 
-    if ( !anIsInserted )
+    bool anIsInserted = false;
+    TColStd_ListIteratorOfListOfReal anIterU( anOldListU );
+    TColStd_ListIteratorOfListOfReal anIterZ( anOldListZ );
+    for ( ; anIterU.More() && anIterZ.More(); anIterU.Next(), anIterZ.Next() )
     {
-      if ( ValuesEquals( aNewCoordU, aCoordU ) )
-      {
-        // Just update Z value
-        aCoordZ = aNewCoordZ;
-        anIsInserted = true;
-      }
-      else if ( aNewCoordU < aCoordU )
+      double aCoordU = anIterU.Value();
+      double aCoordZ = anIterZ.Value();
+
+      if ( !anIsInserted )
       {
-        // Insert new point
-        aListU->Append( aNewCoordU );
-        aListZ->Append( aNewCoordZ );
-        anIsInserted = true;
+        if ( ValuesEquals( aNewCoordU, aCoordU ) )
+        {
+          // Just update Z value
+          aCoordZ = aNewCoordZ;
+          anIsInserted = true;
+        }
+        else if ( aNewCoordU < aCoordU )
+        {
+          // Insert new point
+          aListU->Append( aNewCoordU );
+          aListZ->Append( aNewCoordZ );
+          anIsInserted = true;
+        }
       }
-    }
 
-    aListU->Append( aCoordU );
-    aListZ->Append( aCoordZ );
+      aListU->Append( aCoordU );
+      aListZ->Append( aCoordZ );
+    }
   }
-}
 
-void HYDROData_ProfileUZ::SetPoint( const int    theSectionIndex,
-                                    const int    /*thePointIndex*/,
-                                    const Point& thePoint )
-{
-  AddPoint( theSectionIndex, thePoint );
+  return true;
 }
 
-void HYDROData_ProfileUZ::RemovePoint( const int /*theSectionIndex*/,
-                                       const int thePointIndex )
+bool HYDROData_ProfileUZ::removePoint( const int /*theISection*/,
+                                       const int theIPnt )
 {
   Handle(TDataStd_RealList) aListU, aListZ;
   getPointsLists( 0, aListU, aListZ, false );
-  if ( aListU.IsNull() || aListZ.IsNull() || aListU->IsEmpty() )
-    return;
+  if ( aListU.IsNull() || aListZ.IsNull() || 
+       theIPnt < 0 || theIPnt >= aListU->Extent() )
+    return false;
+
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
 
   TColStd_ListOfReal anOldListU;
   anOldListU = aListU->List();
@@ -138,26 +212,50 @@ void HYDROData_ProfileUZ::RemovePoint( const int /*theSectionIndex*/,
   TColStd_ListOfReal anOldListZ;
   anOldListZ = aListZ->List();
 
-  // Creat new lists
-  removePointsLists( 0 );
-  getPointsLists( 0, aListU, aListZ );
+  // Refill the existing lists
+  aListU->Clear();
+  aListZ->Clear();
 
-  bool anIsInserted = false;
   TColStd_ListIteratorOfListOfReal anIterU( anOldListU );
   TColStd_ListIteratorOfListOfReal anIterZ( anOldListZ );
   for ( int i = 0; anIterU.More() && anIterZ.More(); anIterU.Next(), anIterZ.Next(), ++i )
   {
-    if ( i == thePointIndex )
+    if ( i == theIPnt )
       continue; // skip index to remove
 
     aListU->Append( anIterU.Value() );
     aListZ->Append( anIterZ.Value() );
   }
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return true;
 }
 
-HYDROData_ProfileUZ::PointsList HYDROData_ProfileUZ::GetPoints( const int /*theSectionIndex*/ ) const
+bool HYDROData_ProfileUZ::setPoint( const int                        /*theISection*/,
+                                    const int                        theIPoint,
+                                    const CurveCreator::Coordinates& theNewCoords )
 {
-  PointsList aResList;
+  bool anIsOperation = myIsOperation;
+  if ( !anIsOperation )
+    startOperation();
+
+  // At first we remove point
+  removePoint( 0, theIPoint );
+
+  // And then we insert it to correct place
+  bool aRes = addPoints( theNewCoords, 0 );
+
+  if ( !anIsOperation )
+    commitOperation();
+
+  return aRes;
+}
+
+CurveCreator::Coordinates HYDROData_ProfileUZ::getPoints( const int /*theISection*/ ) const
+{
+  CurveCreator::Coordinates aResList;
 
   Handle(TDataStd_RealList) aListU, aListZ;
   getPointsLists( 0, aListU, aListZ, false );
@@ -168,8 +266,11 @@ HYDROData_ProfileUZ::PointsList HYDROData_ProfileUZ::GetPoints( const int /*theS
   TColStd_ListIteratorOfListOfReal anIterZ( aListZ->List() );
   for ( ; anIterU.More() && anIterZ.More(); anIterU.Next(), anIterZ.Next() )
   {
-    Point aPoint( anIterU.Value(), anIterZ.Value() );
-    aResList.Append( aPoint );
+    const double& aCoordU = anIterU.Value();
+    const double& aCoordZ = anIterZ.Value();
+
+    aResList.push_back( aCoordU );
+    aResList.push_back( aCoordZ );
   }
 
   return aResList;
index 9b86029f1c83e6ad8be86cc7caee0109b506c361..fbb7eb0a9acbc511726fac5f9c718fefc84e6aa8 100644 (file)
@@ -30,94 +30,123 @@ public:
    */
   HYDRODATA_EXPORT virtual const ObjectKind GetKind() const {return KIND_PROFILEUZ;}
 
+
 public:
 
+  // Implementation of IPolyline interface
+
   /**
    * Returns the 3D presentation of all points.
    */
-  HYDRODATA_EXPORT virtual TopoDS_Wire GetWire() const;
+  HYDRODATA_EXPORT virtual ListAISObjects constructWire() const;
 
+public:
 
-  /**
-   * Returns number of sections.
-   */
-  HYDRODATA_EXPORT virtual int NbSections() const;
+  // Implementation of ICurve interface
 
-  /**
-   * Adds new one section.
-   * \param theIsClosed flag indicates type of polyline
-   */
-  HYDRODATA_EXPORT virtual void AddSection( const bool theIsClosed );
 
-  /**
-   * Returns true if section with given index is closed.
-   * \param theSectionIndex index of section
-   */
-  HYDRODATA_EXPORT virtual bool IsClosedSection( const int theSectionIndex ) const;
+  /***********************************************/
+  /***           Section methods               ***/
+  /***********************************************/
 
-  /**
-   * Removes section with given index.
-   * \param theSectionIndex index of section
-   */
-  HYDRODATA_EXPORT virtual void RemoveSection( const int theSectionIndex );
+  //! Clear the polyline (remove all sections)
+  HYDRODATA_EXPORT virtual bool clear();
+
+  //! Join range of sections to one section (join all sections if -1 is passed in one of arguments)
+  HYDRODATA_EXPORT virtual bool join( const int theISectionTo = -1, 
+                                      const int theISectionFrom = -1 );
+
+  //! Get number of sections
+  HYDRODATA_EXPORT virtual int getNbSections() const;
+
+  //! Add a new section.
+  HYDRODATA_EXPORT virtual int addSection( const std::string&              theName, 
+                                           const CurveCreator::SectionType theType,
+                                           const bool                      theIsClosed );
+
+  //! Removes the given sections.
+  HYDRODATA_EXPORT virtual bool removeSection( const int theISection );
+
+  //! Get "closed" flag of the specified section
+  HYDRODATA_EXPORT virtual bool isClosed( const int theISection ) const;
 
   /**
-   * Removes all sections.
+   *  Set "closed" flag of the specified section (all sections if
+   *  \a theISection is -1).
    */
-  HYDRODATA_EXPORT virtual void RemoveSections();
+  HYDRODATA_EXPORT virtual bool setClosed( const int  theISection, 
+                                           const bool theIsClosed );
+
+  //! Returns specifyed section name
+  HYDRODATA_EXPORT virtual std::string getSectionName( const int theISection ) const;
+
+  /** Set name of the specified section */
+  HYDRODATA_EXPORT virtual bool setSectionName( const int          theISection, 
+                                                const std::string& theName );
 
+  //! Get type of the specified section
+  HYDRODATA_EXPORT virtual CurveCreator::SectionType getSectionType( const int theISection ) const;
 
   /**
-   * Adds new point for section with index "theSectionIndex".
-   * \param theSectionIndex index of section
-   * \param thePoint point to add
-   * \param theBeforeIndex if not equal -1 then insert point in this pos
+   *  Set type of the specified section (or all sections
+   *  if \a theISection is -1).
    */
-  HYDRODATA_EXPORT virtual void AddPoint( const int    theSectionIndex,
-                                          const Point& thePoint,
-                                          const int    thePointIndex = -1 );
+  HYDRODATA_EXPORT virtual bool setSectionType( const int                       theISection, 
+                                                const CurveCreator::SectionType theType );
+
+
+  /***********************************************/
+  /***           Point methods                 ***/
+  /***********************************************/
 
   /**
-   * Replaces point for section with index "theSectionIndex".
-   * \param theSectionIndex index of section
-   * \param thePointIndex index of point to replace
-   * \param thePoint new point
+   *  Insert one or several points to the specified section starting from the given theIPnt index
+   *  (or add these at the end of section points if \a theIPnt is -1).
    */
-  HYDRODATA_EXPORT virtual void SetPoint( const int    theSectionIndex,
-                                          const int    thePointIndex,
-                                          const Point& thePoint );
+  HYDRODATA_EXPORT virtual bool addPoints( const CurveCreator::Coordinates& theCoords,
+                                           const int                        theISection,
+                                           const int                        theIPnt = -1 );
+
+  //! Set coordinates of specified point
+  HYDRODATA_EXPORT virtual bool setPoint( const int                        theISection,
+                                          const int                        theIPnt,
+                                          const CurveCreator::Coordinates& theCoords );
+
+  //! Remove point with given id
+  HYDRODATA_EXPORT virtual bool removePoint( const int theISection, const int theIPnt = -1 );
 
   /**
-   * Removes point from section with index "theSectionIndex".
-   * \param theSectionIndex index of section
-   * \param thePointIndex index of point
+   * Get points of a section (the total points in Curve if theISection is equal to -1)..
    */
-  HYDRODATA_EXPORT virtual void RemovePoint( const int theSectionIndex,
-                                             const int thePointIndex );
+  HYDRODATA_EXPORT virtual CurveCreator::Coordinates getPoints( const int theISection = -1 ) const;
 
+protected:
 
   /**
-   * Returns list of points.
-   * \param theSectionIndex if not equal -1 then list of points returned
-   *                        only for section with this index
-   * \return list of points
+   *  Insert point to the specified section after the given theIPnt index.
+   *  (or add these at the end of section points if \a theIPnt is -1).
    */
-  HYDRODATA_EXPORT virtual PointsList GetPoints( const int theSectionIndex = -1 ) const;
+  HYDRODATA_EXPORT virtual bool addPoint( 
+    const CurveCreator::TypeCoord& theCoordX,
+    const CurveCreator::TypeCoord& theCoordY,
+    const int                      theISection,
+    const int                      theIPnt = -1 );
 
 protected:
 
+  friend class HYDROData_Profile;
   friend class HYDROData_Iterator;
 
   /**
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
    */
-  HYDROData_ProfileUZ();
+  HYDRODATA_EXPORT HYDROData_ProfileUZ();
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
-  ~HYDROData_ProfileUZ();
+  HYDRODATA_EXPORT ~HYDROData_ProfileUZ();
 };
 
 #endif
index 82a3b7c86a3aa207f459c78749da2653bdc969e7..a4f68c331faeb01b7e24a27db665fc1bf4c3165d 100644 (file)
@@ -6,6 +6,17 @@
 #include "HYDROData_Iterator.h"
 #include "HYDROData_Zone.h"
 
+#include <TopoDS.hxx>
+#include <TopoDS_Shape.hxx>
+#include <TopoDS_Shell.hxx>
+#include <TopoDS_Face.hxx>
+#include <TopTools_ListOfShape.hxx>
+#include <TopTools_ListIteratorOfListOfShape.hxx>
+#include <TopExp_Explorer.hxx>
+#include <ShapeUpgrade_UnifySameDomain.hxx>
+#include <BRep_Builder.hxx>
+#include <BRepAlgoAPI_Fuse.hxx>
+
 #include <QStringList>
 
 #define PYTHON_REGION_ID "KIND_REGION"
@@ -134,3 +145,90 @@ Handle(HYDROData_Zone) HYDROData_Region::addNewZone()
   return aNewZone;
 }
 
+TopoDS_Shape HYDROData_Region::GetShape() const
+{
+  TopoDS_Shape aResShape;
+
+  // Unite the region zones (each zone is a face) into one face (united face)
+  // If the zones can't be united into the single face - unite them into shell
+
+  // Collect the list of region faces
+  TopTools_ListOfShape aRegionFacesList;
+
+  HYDROData_SequenceOfObjects aZones = GetZones();
+  HYDROData_SequenceOfObjects::Iterator aZoneIter( aZones );
+  for ( ; aZoneIter.More(); aZoneIter.Next() ) {
+    Handle(HYDROData_Zone) aZone =
+      Handle(HYDROData_Zone)::DownCast( aZoneIter.Value() );
+  
+    if ( aZone.IsNull() ) {
+      continue;
+    }
+
+    TopoDS_Face aFace = TopoDS::Face( aZone->GetShape() );
+    if ( !aFace.IsNull() ) {
+      aRegionFacesList.Append( aFace );
+    }
+  } // zones iterator
+  
+  // Check number of faces
+  int aNbFaces = aRegionFacesList.Extent();
+  if ( aNbFaces > 0 ) {
+    // The unite region face
+    TopoDS_Face aRegionFace;
+  
+    if ( aNbFaces == 1 ) {
+      aRegionFace = TopoDS::Face( aRegionFacesList.First() );
+    } else {
+      // Fuse faces into one
+      TopoDS_Shape aFuseShape;
+      TopTools_ListIteratorOfListOfShape aFaceIter( aRegionFacesList );
+      for ( ; aFaceIter.More(); aFaceIter.Next() ) {
+        if ( aFuseShape.IsNull() ) {
+          aFuseShape = aFaceIter.Value();
+        } else {
+          BRepAlgoAPI_Fuse aFuse(aFuseShape, aFaceIter.Value());
+          if ( !aFuse.IsDone() ) {
+            aFuseShape.Nullify();
+            break;
+          }
+          aFuseShape = aFuse.Shape();
+        }
+      } // faces iterator
+
+      if ( !aFuseShape.IsNull() ) {
+        ShapeUpgrade_UnifySameDomain aUnify;
+        aUnify.Initialize( aFuseShape );
+        aUnify.UnifyFacesAndEdges();
+        aUnify.Build();
+        TopoDS_Shape aUnitedShape = aUnify.Shape();
+
+        TopExp_Explorer anExp( aUnitedShape, TopAbs_FACE );
+        if ( anExp.More() ) {
+          aRegionFace = TopoDS::Face( anExp.Current() );
+          anExp.Next();
+          if ( anExp.More() ) {
+            aRegionFace.Nullify();
+          }
+        }
+      }
+    }
+
+    if ( !aRegionFace.IsNull() ) { // result shape is a face
+      aResShape = aRegionFace;
+    } else { // result shape is a shell
+      TopoDS_Shell aShell;
+      BRep_Builder aBuilder;
+      aBuilder.MakeShell( aShell );
+
+      TopTools_ListIteratorOfListOfShape aFaceIter( aRegionFacesList );
+      for ( ; aFaceIter.More(); aFaceIter.Next() ) {
+        aBuilder.Add( aShell, aFaceIter.Value() );
+      }
+
+      aResShape = aShell;
+    }
+  }
+  
+  return aResShape;
+}
\ No newline at end of file
index f0d2075f107d886181494ab89e77c17430882c49..cfaf931f7d6a494814d26c2ef361d7c007f93b11 100644 (file)
@@ -9,6 +9,8 @@ DEFINE_STANDARD_HANDLE(HYDROData_Region, HYDROData_Entity)
 
 class Handle(HYDROData_Zone);
 
+class TopoDS_Shape;
+
 /**\class HYDROData_Region
  * \brief Regions are groups (lists) of zones, they can include one or several zones.
  */
@@ -69,6 +71,14 @@ public:
    */
   HYDRODATA_EXPORT virtual void RemoveZones();
 
+  /**
+   * \brief Returns the shape of the region.
+   * Shape of the region could be:
+   * - a face which is the union of the region zones faces
+   * - a shell if the zones faces can't be united into one face
+   * \return shape as TopoDS_Shape
+   */
+  HYDRODATA_EXPORT virtual TopoDS_Shape GetShape() const;
 
 protected:
 
@@ -87,12 +97,12 @@ protected:
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
    */
-  HYDROData_Region();
+  HYDRODATA_EXPORT HYDROData_Region();
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
-  ~HYDROData_Region();
+  HYDRODATA_EXPORT ~HYDROData_Region();
 };
 
 #endif
index aba5d5ba8c3a8b60dd349ba0558c2cd84d509f35..c0472ea79906d6789cf1a9f6a1d658129750fd57 100644 (file)
@@ -126,12 +126,12 @@ protected:
    * Creates new object in the internal data structure. Use higher level objects 
    * to create objects with real content.
    */
-  HYDROData_Zone();
+  HYDRODATA_EXPORT HYDROData_Zone();
 
   /**
    * Destructs properties of the object and object itself, removes it from the document.
    */
-  ~HYDROData_Zone();
+  HYDRODATA_EXPORT ~HYDROData_Zone();
 
 };
 
index 7813790f88b5ee4a611e95730b395e355413f0a2..52bc47dbc0dd71f58ba74bce0b996677718ad100 100644 (file)
@@ -1,10 +1,9 @@
-include(../../CMake/Common.cmake)
+#include(../../CMake/Common.cmake)
 include(../../CMake/UseQT4EXT.cmake)
 
 set(PROJECT_HEADERS 
     HYDROGUI.h
     HYDROGUI_AbstractDisplayer.h
-    HYDROGUI_AISCurve.h
     HYDROGUI_CalculationDlg.h
     HYDROGUI_CalculationOp.h
     HYDROGUI_ColorWidget.h
@@ -54,12 +53,15 @@ set(PROJECT_HEADERS
     HYDROGUI_VisualStateOp.h
     HYDROGUI_Wizard.h
     HYDROGUI_Zone.h
+    HYDROGUI_ImportGeomObjectOp.h
+    HYDROGUI_ImportObstacleFromFileOp.h
+    HYDROGUI_ExportCalculationOp.h
+    HYDROGUI_ObstacleDlg.h
 )
 
 QT4_WRAP_CPP(PROJECT_HEADERS_MOC ${PROJECT_HEADERS})
 
 set(PROJECT_SOURCES 
-    HYDROGUI_AISCurve.cxx
     HYDROGUI_AbstractDisplayer.cxx
     HYDROGUI_CalculationDlg.cxx
     HYDROGUI_CalculationOp.cxx
@@ -109,20 +111,34 @@ set(PROJECT_SOURCES
     HYDROGUI_VisualStateOp.cxx
     HYDROGUI_Wizard.cxx
     HYDROGUI_Zone.cxx
+    HYDROGUI_ImportGeomObjectOp.cxx
+    HYDROGUI_ImportObstacleFromFileOp.cxx
+    HYDROGUI_ExportCalculationOp.cxx
+    HYDROGUI_ObstacleDlg.cxx
 )
 
 add_definitions(
   -DHYDROGUI_EXPORTS
+  -D__WIN32__
+  -D__x86__
+  -D_WIN32_WINNT=0x0400
+  -D__NT__
+  -D__OSVERSION__=4
   ${CAS_DEFINITIONS}
   ${QT_DEFINITIONS}
-  $(GUI_CXXFLAGS)
-  $(GEOM_CXXFLAGS)
+#  $(GUI_CXXFLAGS)
+  ${GUI_DEFINITIONS}
+#  $(GEOM_CXXFLAGS)
+  ${GEOM_DEFINITIONS}
 )
 
 include_directories(
   ${CAS_INCLUDE_DIRS}
   ${QT_INCLUDES}
-  ${GUI_ROOT_DIR}/include/salome
+#  ${GUI_ROOT_DIR}/include/salome
+  ${GUI_INCLUDE_DIRS}
+#  ${GEOM_ROOT_DIR}/include/salome
+  ${GEOM_INCLUDE_DIRS}
   ${CMAKE_CURRENT_SOURCE_DIR}
   ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROData
   ${CMAKE_CURRENT_SOURCE_DIR}/../HYDROCurveCreator
@@ -130,9 +146,11 @@ include_directories(
 
 add_library(HYDROGUI SHARED ${PROJECT_SOURCES} ${PROJECT_HEADERS} ${PROJECT_HEADERS_MOC})
 target_link_libraries(HYDROGUI HYDROData HYDROCurveCreator
-    ${CAS_TKV3d} ${CAS_TKTopAlgo} ${CAS_TKBO} ${CAS_TKService}
-    ${LightApp} ${CAM} ${suit} ${qtx} ${ObjBrowser} ${GraphicsView} ${std} ${Event} ${OCCViewer}
+    ${CAS_TKV3d} ${CAS_TKTopAlgo} ${CAS_TKBrep} ${CAS_TKBO}
+    ${GUI_LightApp} ${GUI_CAM} ${GUI_suit} ${GUI_qtx} ${GUI_ObjBrowser} ${GUI_GraphicsView} ${GUI_std} ${GUI_Event} ${GUI_OCCViewer}
+    ${GEOM_GEOM} ${GEOM_GEOMBase}
     )
+INSTALL(TARGETS HYDROGUI EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
 
 set(PROJECT_LIBRARIES HYDROGUI)
 
@@ -142,13 +160,13 @@ set(GUITS_SOURCES
   resources/HYDROGUI_msg_fr.ts
 )
 
-include(../../CMake/CommonInstall.cmake)
+#include(../../CMake/CommonInstall.cmake)
 
 # resources
-QT4_INSTALL_TS_RESOURCES("${GUITS_SOURCES}" "${HYDRO_salomeres_DATA}")
+QT4_INSTALL_TS_RESOURCES("${GUITS_SOURCES}" "${SALOME_HYDRO_INSTALL_RES_DATA}")
 
 FILE(GLOB GUIPNG_DATA "${CMAKE_CURRENT_SOURCE_DIR}/resources/*.png")
 FILE(GLOB GUIXML_DATA "${CMAKE_CURRENT_SOURCE_DIR}/resources/*.xml")
 SET(GUI_DATA ${GUIPNG_DATA} ${GUIXML_DATA})
-INSTALL(FILES ${GUI_DATA} DESTINATION ${HYDRO_salomeres_DATA})
+INSTALL(FILES ${GUI_DATA} DESTINATION ${SALOME_HYDRO_INSTALL_RES_DATA})
 
diff --git a/src/HYDROGUI/HYDROGUI_AISCurve.cxx b/src/HYDROGUI/HYDROGUI_AISCurve.cxx
deleted file mode 100755 (executable)
index 87a2d7d..0000000
+++ /dev/null
@@ -1,231 +0,0 @@
-#include "HYDROGUI_AISCurve.h"
-
-#include <HYDROData_BSplineOperation.h>
-
-#include <CurveCreator.hxx>
-#include <CurveCreator_Curve.hxx>
-
-#include <AIS_Point.hxx>
-#include <AIS_Line.hxx>
-#include <AIS_Shape.hxx>
-#include <BRepBuilderAPI_MakeEdge.hxx>
-#include <BRepBuilderAPI_MakeWire.hxx>
-#include <Geom_CartesianPoint.hxx>
-#include <gp_Pnt.hxx>
-#include <gp_Lin.hxx>
-#include <TopoDS_Edge.hxx>
-#include <TopoDS_Face.hxx>
-#include <TopoDS_Wire.hxx>
-
-HYDROGUI_AISCurveSection::HYDROGUI_AISCurveSection( Handle_AIS_InteractiveContext theContext, 
-                                                   CurveCreator_Curve* theCurve, int theSection) :
-  myCurve(theCurve), mySection(theSection), myContext(theContext), myIsHL(false)
-{
-  buildSection();
-}
-
-HYDROGUI_AISCurveSection::~HYDROGUI_AISCurveSection()
-{
-  Erase();
-  for( int i = 0 ; i < myObjects.size() ; i++ ){
-    myObjects[i].Nullify();
-  }
-  myObjects.clear();
-}
-
-Quantity_Color HYDROGUI_AISCurveSection::getActiveColor()
-{
-  if( myIsHL ){
-    return Quantity_Color( 1., 0., 0., Quantity_TOC_RGB );
-  }
-  return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );
-}
-
-void  HYDROGUI_AISCurveSection::highlight( bool isHL )
-{
-  myIsHL = isHL;
-  Quantity_Color aColor = getActiveColor();
-  for( int i = 0 ; i < myObjects.size() ; i++ ){
-    myObjects[i]->SetColor(aColor);
-    myContext->Display(myObjects[i], Standard_False);
-  }
-  myContext->UpdateCurrentViewer();
-}
-
-void HYDROGUI_AISCurveSection::Display()
-{
-  for( int i = 0 ; i < myObjects.size() ; i++ ){
-    myContext->Display(myObjects[i], Standard_False);
-  }
-  myContext->UpdateCurrentViewer();
-}
-
-void HYDROGUI_AISCurveSection::Erase()
-{
-  for( int i = 0 ; i < myObjects.size() ; i++ ){
-    myContext->Erase(myObjects[i], Standard_False);
-  }
-  myContext->UpdateCurrentViewer();
-}
-
-void HYDROGUI_AISCurveSection::buildSection()
-{
-  CurveCreator::SectionType aSectType = myCurve->getSectionType( mySection );
-  int aSectSize = myCurve->getNbPoints( mySection );
-  bool aSectIsClosed = myCurve->isClosed( mySection );
-
-  if( aSectType == CurveCreator::Polyline )
-  {
-    int i = 0; 
-    for( ; i < ( aSectSize - 1 ) ; i++ ){
-      Handle_AIS_Point anAISPnt = getAISPoint(i);
-      myObjects.push_back( anAISPnt );
-      Handle_AIS_Line aLine = getAISLine( i, i+1 );
-      myObjects.push_back( aLine );
-    }
-    if( aSectSize != 0 ){
-      Handle_AIS_Point anAISPnt = getAISPoint(i); 
-      myObjects.push_back( anAISPnt );
-      if( myCurve->isClosed(mySection) && ( aSectSize > 1 ) ){
-        Handle_AIS_Line aLine = getAISLine( i, 0 );
-        myObjects.push_back( aLine );
-      }
-    }
-  }
-  else if( aSectType == CurveCreator::Spline )
-  {
-    QList<double> aPoints;
-    for( int i = 0; i < aSectSize; i++ )
-    {
-      Handle_AIS_Point anAISPnt = getAISPoint( i );
-      myObjects.push_back( anAISPnt );
-
-      double aX = 0, aY = 0, aZ = 0;
-      getPoint( i, aX, aY, aZ );
-      aPoints << aX << aY;
-    }
-
-    if( aSectSize > 1 )
-    {
-      HYDROData_BSplineOperation aBSpline( aPoints, 0, aSectIsClosed );
-      TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSpline.Curve() ).Edge();
-
-      TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire();
-
-      Handle(AIS_Shape) aShape = new AIS_Shape( aWire );
-      myObjects.push_back( aShape );
-    }
-  }
-}
-
-Handle_AIS_Point HYDROGUI_AISCurveSection::getAISPoint( int theIndx )
-{
-  double anX;
-  double anY;
-  double aZ;
-  getPoint( theIndx, anX, anY, aZ );
-  gp_Pnt aPoint( anX, anY, aZ);
-
-  AIS_Point* aPnt = new AIS_Point( new Geom_CartesianPoint(aPoint));
-  return aPnt;
-}
-
-Handle_AIS_Line HYDROGUI_AISCurveSection::getAISLine( int theIndx1, int theIndx2 )
-{
-  double anX;
-  double anY;
-  double aZ;
-  getPoint( theIndx1, anX, anY, aZ );
-  gp_Pnt aPoint1( anX, anY, aZ);
-
-  double anX2;
-  double anY2;
-  double aZ2;
-  getPoint( theIndx2, anX2, anY2, aZ2 );
-//MTN to avoid crash during line construction
-  if( ( anX == anX2 ) && ( anY == anY2 ) && (aZ == aZ2 ) ){
-    aZ2 += 1e-7;
-  }
-
-  gp_Pnt aPoint2( anX2, anY2, aZ2 );
-
-  AIS_Line* aLine = new AIS_Line( new Geom_CartesianPoint(aPoint1), new Geom_CartesianPoint(aPoint2) );
-  return aLine;
-}
-
-void HYDROGUI_AISCurveSection::getPoint( int theIndx, double& theX, double& theY, double& theZ )
-{
-  CurveCreator::Dimension aDim = myCurve->getDimension();
-  const CurveCreator::Coordinates aCoords = myCurve->getPoint( mySection, theIndx );
-  theX = aCoords[0];
-  theY = aCoords[1];
-  theZ = 0.;
-  if( aDim == CurveCreator::Dim3d ){
-    theZ = aCoords[2];
-  }
-}
-
-/******************************* HYDROGUI_AISCurve ********************************************/
-HYDROGUI_AISCurve::HYDROGUI_AISCurve( CurveCreator_Curve* theCurve, Handle_AIS_InteractiveContext theContext ) :
-  CurveCreator_Listener(), myCurve(theCurve), myContext( theContext )
-{
-  myCurve->setListener(this);
-  buildCurve();
-}
-
-HYDROGUI_AISCurve::~HYDROGUI_AISCurve(void)
-{
-  myCurve->removeListener();
-}
-
-void HYDROGUI_AISCurve::setCurve( CurveCreator_Curve* theCurve )
-{
-  myCurve = theCurve;
-  buildCurve();
-}
-
-void HYDROGUI_AISCurve::Display()
-{
-  for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){
-    myCurveRepresentation[i]->Display();
-  }
-}
-
-void HYDROGUI_AISCurve::Erase()
-{
-  for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){
-    myCurveRepresentation[i]->Erase();
-  }
-}
-
-void HYDROGUI_AISCurve::buildCurve()
-{
-  for( int i = 0 ; i < myCurveRepresentation.size() ; i++ ){
-    myCurveRepresentation[i]->Erase();
-    delete myCurveRepresentation[i];
-  }
-  myCurveRepresentation.clear();
-
-  for( int i = 0 ; i < myCurve->getNbSections() ; i++ ){
-    HYDROGUI_AISCurveSection* aSection = new HYDROGUI_AISCurveSection( myContext, myCurve, i);
-    myCurveRepresentation.push_back( aSection );
-    myCurveRepresentation[i]->Display();
-  }
-}
-
-void HYDROGUI_AISCurve::pointChanged( int theSection, int thePoint )
-{
-  buildCurve();
-}
-
-void HYDROGUI_AISCurve::pointInserted( int theSection, int theIndx )
-{
-  buildCurve();
-}
-
-void HYDROGUI_AISCurve::highlightSection( int theSection, bool isHL )
-{
-  if( theSection >= myCurveRepresentation.size() )
-    return;
-  myCurveRepresentation[theSection]->highlight(isHL);
-}
diff --git a/src/HYDROGUI/HYDROGUI_AISCurve.h b/src/HYDROGUI/HYDROGUI_AISCurve.h
deleted file mode 100755 (executable)
index 325aa19..0000000
+++ /dev/null
@@ -1,78 +0,0 @@
-#ifndef HYDROGUI_AIS_CURVE_H
-#define HYDROGUI_AIS_CURVE_H
-
-#include <vector>
-#include <list>
-
-#include <AIS_InteractiveContext.hxx>
-#include <AIS_Point.hxx>
-#include <AIS_Line.hxx>
-
-#include <CurveCreator_Listener.hxx>
-
-class CurveCreator_Curve;
-
-class AIS_InteractiveObject;
-class AIS_Point;
-class AIS_Line;
-
-class HYDROGUI_AISCurveSection
-{
-public:
-  HYDROGUI_AISCurveSection(  Handle_AIS_InteractiveContext theContext, 
-    CurveCreator_Curve* theCurve, int theSection );
-  virtual ~HYDROGUI_AISCurveSection();
-
-  void Display();
-  void Erase();
-
-  void  highlight( bool isHL );
-
-protected:
-  virtual void buildSection();
-
-  void    getPoint( int theIndx, double& theX, double& theY, double& theZ );
-
-  Handle_AIS_Point getAISPoint( int theIndx );
-  Handle_AIS_Line  getAISLine( int theIndx1, int theIndx2 );
-
-  Quantity_Color getActiveColor();
-
-private:
-  CurveCreator_Curve*                                 myCurve;
-  int                                                 mySection;
-  std::vector< Handle_AIS_InteractiveObject >         myObjects;
-  Handle_AIS_InteractiveContext                       myContext;
-  bool                                                myIsHighlight;
-  bool                                                myIsHL;
-};
-
-class HYDROGUI_AISCurve : public CurveCreator_Listener
-{
-public:
-  HYDROGUI_AISCurve(CurveCreator_Curve* theCurve, Handle_AIS_InteractiveContext theContext );
-  ~HYDROGUI_AISCurve(void);
-
-  void setCurve( CurveCreator_Curve* theCurve );
-
-  void Display();
-  void Erase();
-
-  virtual void pointChanged( int theSection, int thePoint );
-  virtual void pointInserted( int theSection, int theIndx );
-
-  void  highlightSection( int theSection, bool isHL );
-
-  void  clearSelection();
-
-protected:
-  virtual void  buildCurve();
-  Quantity_Color getActiveColor();
-
-private:
-  CurveCreator_Curve*                                 myCurve;
-  Handle_AIS_InteractiveContext                       myContext;
-  std::vector< HYDROGUI_AISCurveSection* >            myCurveRepresentation; 
-};
-
-#endif
index 97ec16079ae1c5b00aca7e54d2057fdf79135634..05259c16e82dbe655945a87c6e067d754d6a644a 100644 (file)
@@ -38,6 +38,7 @@
 #include <HYDROData_VisualState.h>
 #include <HYDROData_Region.h>
 #include <HYDROData_Zone.h>
+#include <HYDROData_Obstacle.h>
 
 #include <CAM_Application.h>
 #include <CAM_DataObject.h>
@@ -268,6 +269,17 @@ void HYDROGUI_DataModel::update( const int theStudyId )
       createObject( aZonesRootObj, aZoneObj );
   }
 
+  LightApp_DataObject* anObstaclesRootObj = createObject( aRootObj, tr( partitionName( KIND_OBSTACLE ).toAscii() ) );
+
+  anIterator = HYDROData_Iterator( aDocument, KIND_OBSTACLE );
+  for( ; anIterator.More(); anIterator.Next() )
+  {
+    Handle(HYDROData_Obstacle) anObstacleObj =
+      Handle(HYDROData_Obstacle)::DownCast( anIterator.Current() );
+    if( !anObstacleObj.IsNull() )
+      createObject( anObstaclesRootObj, anObstacleObj );
+  }
+
   LightApp_DataObject* aCalculRootObj = createObject( aRootObj, tr( partitionName( KIND_CALCULATION ).toAscii() ) );
 
   anIterator = HYDROData_Iterator( aDocument, KIND_CALCULATION );
@@ -513,6 +525,7 @@ QString HYDROGUI_DataModel::partitionName( const ObjectKind theObjectKind )
     case KIND_BATHYMETRY:      return "BATHYMETRIES";
     case KIND_CALCULATION:     return "CALCULATION_CASES";
     case KIND_IMMERSIBLE_ZONE: return "IMMERSIBLE_ZONES";
+    case KIND_OBSTACLE:        return "OBSTACLES";
     default: break;
   }
   return QString();
diff --git a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.cxx
new file mode 100644 (file)
index 0000000..65b8641
--- /dev/null
@@ -0,0 +1,180 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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 "HYDROGUI_ExportCalculationOp.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
+
+#include <HYDROData_CalculationCase.h>
+
+#include <GeometryGUI.h>
+
+#include <SalomeApp_Study.h>
+
+#include <TopoDS_Shell.hxx>
+#include <BRepTools.hxx>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <SUIT_MessageBox.h>
+#include <SUIT_Desktop.h>
+
+#include <QApplication>
+
+HYDROGUI_ExportCalculationOp::HYDROGUI_ExportCalculationOp( HYDROGUI_Module* theModule )
+: HYDROGUI_Operation( theModule )
+{
+  setName( tr( "EXPORT_CALCULATION" ) );
+}
+
+HYDROGUI_ExportCalculationOp::~HYDROGUI_ExportCalculationOp()
+{
+}
+
+void HYDROGUI_ExportCalculationOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  onApply();
+}
+
+void HYDROGUI_ExportCalculationOp::abortOperation()
+{
+  HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_ExportCalculationOp::commitOperation()
+{
+  HYDROGUI_Operation::commitOperation();
+}
+
+bool HYDROGUI_ExportCalculationOp::processApply( int& theUpdateFlags,
+                                                QString& theErrorMsg )
+{
+  // Get the selected calculation case
+  Handle(HYDROData_CalculationCase) aCalculation = 
+    Handle(HYDROData_CalculationCase)::DownCast( 
+      HYDROGUI_Tool::GetSelectedObject( module() ) );
+
+  if ( aCalculation.IsNull() ) {
+    theErrorMsg = tr( "EXPORT_FAILED" );
+    return false;
+  }
+
+  bool anIsOk = false;
+
+  TopoDS_Shell aShell = aCalculation->GetShell();
+
+  if ( !aShell.IsNull() ) {
+    // TODO move this code to anothe place?
+    std::ostringstream aStreamShape;
+    // Write TopoDS_Shape in ASCII format to the stream
+    BRepTools::Write( aShell, aStreamShape );
+    // Returns the number of bytes that have been stored in the stream's buffer.
+    int aSize = aStreamShape.str().size();
+    // Allocate octect buffer of required size
+    CORBA::Octet* anOctetBuf = SALOMEDS::TMPFile::allocbuf( aSize );
+    // Copy ostrstream content to the octect buffer
+    memcpy( anOctetBuf, aStreamShape.str().c_str(), aSize );
+    // Create TMPFile
+    SALOMEDS::TMPFile_var aSeqFile = new SALOMEDS::TMPFile( aSize, aSize, anOctetBuf, 1 );
+
+    // Get active study
+    SalomeApp_Study* aStudy = 
+      dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
+
+    // Restore shape from the stream and get the GEOM object
+    GEOM::GEOM_Gen_var aGeomEngine = GeometryGUI::GetGeomGen(); // TODO: get GEOM engine in another way?
+    GEOM::GEOM_IInsertOperations_var anInsOp = aGeomEngine->GetIInsertOperations( module()->getStudyId() );
+    GEOM::GEOM_Object_var aGeomObj = anInsOp->RestoreShape( aSeqFile );
+
+    // Puplish the GEOM object
+    if ( !aGeomObj->_is_nil() ) {
+      QString aName = tr( "OBJ_PREFIX" ) + aCalculation->GetName();
+
+      SALOMEDS::Study_var aDSStudy = GeometryGUI::ClientStudyToStudy( aStudy->studyDS() );
+      SALOMEDS::SObject_var aResultSO = 
+        aGeomEngine->PublishInStudy( aDSStudy, SALOMEDS::SObject::_nil(), 
+                                     aGeomObj, qPrintable( aName ) );
+      if ( !aResultSO->_is_nil() ) {
+        theUpdateFlags = UF_ObjBrowser;
+        anIsOk = true;
+      } 
+    }
+  } else {
+    theErrorMsg = tr( "RESULT_SHAPE_NULL" );
+  }
+
+  if ( !anIsOk && theErrorMsg.isEmpty() ) {
+    theErrorMsg = tr( "EXPORT_FAILED" );
+  }
+
+  return anIsOk;
+}
+
+void HYDROGUI_ExportCalculationOp::onApply()
+{
+  QApplication::setOverrideCursor( Qt::WaitCursor );
+
+  int anUpdateFlags = 0;
+  QString anErrorMsg;
+
+  bool aResult = false;
+  
+  try {
+    aResult = processApply( anUpdateFlags, anErrorMsg );
+  }
+  catch ( Standard_Failure )
+  {
+    Handle(Standard_Failure) aFailure = Standard_Failure::Caught();
+    anErrorMsg = aFailure->GetMessageString();
+    aResult = false;
+  }
+  catch ( ... )
+  {
+    aResult = false;
+  }
+  
+  QApplication::restoreOverrideCursor();
+
+  if ( aResult ) {
+    module()->update( anUpdateFlags );
+    commit();
+
+    // Show message box
+    SUIT_MessageBox::information( module()->getApp()->desktop(),
+                                  tr( "EXPORT_STATUS" ),
+                                  tr( "EXPORT_FINISHED") ); 
+  } 
+  else {
+    abort();
+    QString aMsg = tr( "INPUT_VALID_DATA" );
+    if( !anErrorMsg.isEmpty() )
+      aMsg.prepend( anErrorMsg + "\n" );
+    SUIT_MessageBox::critical( module()->getApp()->desktop(),
+                               tr( "EXPORT_STATUS" ),
+                               aMsg ); 
+  }
+}
\ No newline at end of file
diff --git a/src/HYDROGUI/HYDROGUI_ExportCalculationOp.h b/src/HYDROGUI/HYDROGUI_ExportCalculationOp.h
new file mode 100644 (file)
index 0000000..1b42f3f
--- /dev/null
@@ -0,0 +1,45 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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
+//
+
+#ifndef HYDROGUI_EXPORTCALCULATIONOP_H
+#define HYDROGUI_EXPORTCALCULATIONOP_H
+
+#include "HYDROGUI_Operation.h"
+
+class HYDROGUI_ExportCalculationOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ExportCalculationOp( HYDROGUI_Module* theModule );
+  virtual ~HYDROGUI_ExportCalculationOp();
+
+protected:
+  virtual void               startOperation();
+  virtual void               abortOperation();
+  virtual void               commitOperation();
+
+  virtual bool               processApply( int& theUpdateFlags, QString& theErrorMsg );
+  virtual void               onApply();
+};
+
+#endif
\ No newline at end of file
diff --git a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.cxx
new file mode 100644 (file)
index 0000000..fd32dfa
--- /dev/null
@@ -0,0 +1,176 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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 "HYDROGUI_ImportGeomObjectOp.h"
+
+#include "HYDROGUI_ObstacleDlg.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
+
+#include <HYDROData_Obstacle.h>
+#include <HYDROData_Iterator.h>
+
+#include <GEOMBase.h>
+
+#include <SalomeApp_Study.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+HYDROGUI_ImportGeomObjectOp::HYDROGUI_ImportGeomObjectOp( HYDROGUI_Module* theModule,  
+                                                          const int theOpType, 
+                                                          const bool theIsToShowPanel )
+: HYDROGUI_Operation( theModule ),
+  myOpType ( theOpType ),
+  myIsToShowPanel ( theIsToShowPanel )
+{
+  setName( tr( "IMPORT_GEOM_OBJECT" ) );
+}
+
+HYDROGUI_ImportGeomObjectOp::~HYDROGUI_ImportGeomObjectOp()
+{
+}
+
+void HYDROGUI_ImportGeomObjectOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  // Get GEOM objects to import
+  myGeomObjects.clear();
+  if ( myOpType == ImportCreated ) {
+    myGeomObjects = module()->GetGeomObjectsToImport();
+  } else if ( myOpType == ImportSelected ) {
+    myGeomObjects = HYDROGUI_Tool::GetSelectedGeomObjects( module() );
+  }
+
+  HYDROGUI_ObstacleDlg* aPanel = 0;
+
+  if ( myGeomObjects.count() == 1 ) {
+    // Get panel
+    aPanel = ::qobject_cast<HYDROGUI_ObstacleDlg*>( inputPanel() );
+
+    if ( aPanel ) {
+      // Reset the panel state
+      aPanel->reset();
+
+      // Pass the existing obstacle names to the panel
+      QStringList anObstacles = 
+        HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_OBSTACLE );
+
+      aPanel->setObstacleNames( anObstacles );
+    }
+  }
+
+  if ( !aPanel ) {
+    onApply();
+  }
+}
+
+void HYDROGUI_ImportGeomObjectOp::abortOperation()
+{
+  HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_ImportGeomObjectOp::commitOperation()
+{
+  HYDROGUI_Operation::commitOperation();
+}
+
+bool HYDROGUI_ImportGeomObjectOp::processApply( int& theUpdateFlags,
+                                                QString& theErrorMsg )
+{
+  // Get active SalomeApp_Study
+  SalomeApp_Study* aStudy = 
+    dynamic_cast<SalomeApp_Study*>( module()->getApp()->activeStudy() );
+  if ( !aStudy ) {
+    return false;
+  }
+
+  QString anObstacleName;
+  Handle(HYDROData_Obstacle) anObstacleToEdit;  
+
+  // Get panel
+  HYDROGUI_ObstacleDlg* aPanel = ::qobject_cast<HYDROGUI_ObstacleDlg*>( inputPanel() );
+  if ( aPanel ) {
+    QString anEditedName = aPanel->getEditedObstacleName().simplified();
+
+    if ( !anEditedName.isEmpty() ) {
+      anObstacleToEdit = Handle(HYDROData_Obstacle)::DownCast(
+        HYDROGUI_Tool::FindObjectByName( module(), anEditedName, KIND_OBSTACLE ) );
+    }
+
+    anObstacleName = anEditedName; //TODO: aPanel->getObstacleName();
+  }
+
+  bool anIsOk = false;
+
+  // Get the created object as SObject
+  foreach ( const QString& anEntry, myGeomObjects ) {
+    _PTR(SObject) aSObject( aStudy->studyDS()->FindObjectID( qPrintable(anEntry)) );
+    if (aSObject) {
+      // Get the corresponding TopoDS_Shape
+      TopoDS_Shape aShape = GEOMBase::GetShapeFromIOR( aSObject->GetIOR().c_str() );
+      if ( !aShape.IsNull() ) {
+        // Create/edit an obstacle object
+        // TODO refactoring: get rid of obstacle from TopoDS_Shape creation code copy/paste
+        Handle(HYDROData_Obstacle) anObstacle; 
+
+        if ( anObstacleToEdit.IsNull() ) {
+          anObstacle = 
+            Handle(HYDROData_Obstacle)::DownCast( doc()->CreateObject(KIND_OBSTACLE) );
+        } else {
+          anObstacle = anObstacleToEdit;
+        }
+
+        // Set name
+        if ( anObstacleName.isEmpty() ) {
+          QString aName = QString::fromStdString( aSObject->GetName() );
+          anObstacleName = HYDROGUI_Tool::GenerateObjectName( module(), aName );
+        }
+        if ( anObstacle->GetName() != anObstacleName ) {
+          anObstacle->SetName( anObstacleName );
+        }
+
+        // Set shape
+        anObstacle->SetShape3D( aShape );
+
+        // Set operation status
+        anIsOk = true;
+        theUpdateFlags = UF_Model;
+      }
+    }
+  }
+
+  return anIsOk;
+}
+
+HYDROGUI_InputPanel* HYDROGUI_ImportGeomObjectOp::createInputPanel() const
+{
+  HYDROGUI_InputPanel* aPanel = 0;
+  if ( myIsToShowPanel ) {
+    aPanel = new HYDROGUI_ObstacleDlg( module(), getName() );
+  }
+
+  return aPanel;
+}
\ No newline at end of file
diff --git a/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.h b/src/HYDROGUI/HYDROGUI_ImportGeomObjectOp.h
new file mode 100644 (file)
index 0000000..6888d34
--- /dev/null
@@ -0,0 +1,60 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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
+//
+
+#ifndef HYDROGUI_IMPORTGEOMOBJECTOP_H
+#define HYDROGUI_IMPORTGEOMOBJECTOP_H
+
+#include "HYDROGUI_Operation.h"
+
+#include <QStringList>
+
+class HYDROGUI_InputPanel;
+
+class HYDROGUI_ImportGeomObjectOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  enum OperationType { ImportCreated, ImportSelected };
+
+public:
+  HYDROGUI_ImportGeomObjectOp( HYDROGUI_Module* theModule,
+                               const int theOpType,
+                               const bool theIsToShowPanel = true );
+  virtual ~HYDROGUI_ImportGeomObjectOp();
+
+protected:
+  virtual void               startOperation();
+  virtual void               abortOperation();
+  virtual void               commitOperation();
+
+  virtual HYDROGUI_InputPanel* createInputPanel() const;
+
+  virtual bool               processApply( int& theUpdateFlags, QString& theErrorMsg );
+
+private:
+  QStringList myGeomObjects; ///< the list of GEOM object entries
+  bool myIsToShowPanel; ///< indicates if obstacle panel to be shown
+  int  myOpType; ///< operation type (to import selected GEOM objects or the objects just created by GEOM )
+};
+
+#endif
\ No newline at end of file
diff --git a/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx b/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.cxx
new file mode 100644 (file)
index 0000000..8532081
--- /dev/null
@@ -0,0 +1,170 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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 "HYDROGUI_ImportObstacleFromFileOp.h"
+
+#include "HYDROGUI_ObstacleDlg.h"
+
+#include "HYDROGUI_DataModel.h"
+#include "HYDROGUI_Module.h"
+#include "HYDROGUI_Tool.h"
+
+#include <HYDROData_Obstacle.h>
+
+#include <GEOMBase.h>
+
+#include <SalomeApp_Study.h>
+
+#include <LightApp_Application.h>
+#include <LightApp_UpdateFlags.h>
+
+#include <SUIT_Desktop.h>
+#include <SUIT_FileDlg.h>
+
+static QString lastUsedFilter;
+
+HYDROGUI_ImportObstacleFromFileOp::HYDROGUI_ImportObstacleFromFileOp( HYDROGUI_Module* theModule, 
+                                                                      const bool theIsToShowPanel )
+: HYDROGUI_Operation( theModule ),
+  myIsToShowPanel ( theIsToShowPanel ),
+  myFileDlg( 0 )
+{
+  setName( tr( "IMPORT_OBSTACLE_FROM_FILE" ) );
+}
+
+HYDROGUI_ImportObstacleFromFileOp::~HYDROGUI_ImportObstacleFromFileOp()
+{
+}
+
+void HYDROGUI_ImportObstacleFromFileOp::startOperation()
+{
+  HYDROGUI_Operation::startOperation();
+
+  // Get panel
+  HYDROGUI_ObstacleDlg* aPanel = ::qobject_cast<HYDROGUI_ObstacleDlg*>( inputPanel() );
+
+  if ( aPanel ) {
+    // Reset the panel state
+    aPanel->reset();
+
+    // Pass the existing obstacle names to the panel
+    QStringList anObstacles = 
+      HYDROGUI_Tool::FindExistingObjectsNames( doc(), KIND_OBSTACLE );
+
+    aPanel->setObstacleNames( anObstacles );
+  } else {
+    myFileDlg = new SUIT_FileDlg( module()->application()->desktop(), true );
+    myFileDlg->setWindowTitle( getName() );
+    myFileDlg->setFilter( tr("OBSTACLE_FILTER") );
+    if ( !lastUsedFilter.isEmpty() ) {
+      myFileDlg->selectFilter( lastUsedFilter );
+    }
+
+    connect( myFileDlg, SIGNAL( accepted() ),      this, SLOT( onApply()  ) );
+    connect( myFileDlg, SIGNAL( rejected() ),      this, SLOT( onCancel() ) );
+
+    myFileDlg->exec();
+  }
+}
+
+void HYDROGUI_ImportObstacleFromFileOp::abortOperation()
+{
+  HYDROGUI_Operation::abortOperation();
+}
+
+void HYDROGUI_ImportObstacleFromFileOp::commitOperation()
+{
+  HYDROGUI_Operation::commitOperation();
+}
+
+bool HYDROGUI_ImportObstacleFromFileOp::processApply( int& theUpdateFlags,
+                                                      QString& theErrorMsg )
+{
+  QString aFileName;
+  QString anObstacleName;
+  Handle(HYDROData_Obstacle) anObstacle;
+
+  // Get panel
+  HYDROGUI_ObstacleDlg* aPanel = ::qobject_cast<HYDROGUI_ObstacleDlg*>( inputPanel() );
+  if ( aPanel ) {
+    // Get file name and obstacle name defined by the user
+    aFileName = aPanel->getFileName();
+      
+    QString anEditedName = aPanel->getEditedObstacleName().simplified();
+
+    // Get obstacle to edit
+    if ( !anEditedName.isEmpty() ) {
+      anObstacle = Handle(HYDROData_Obstacle)::DownCast(
+        HYDROGUI_Tool::FindObjectByName( module(), anEditedName, KIND_OBSTACLE ) );
+    }
+
+    anObstacleName = anEditedName; //TODO: aPanel->getObstacleName();
+  } else if ( myFileDlg ) {
+    // Get file name and file filter defined by the user
+    aFileName = myFileDlg->selectedFile();
+    lastUsedFilter = myFileDlg->selectedFilter();
+  }
+
+  // Check the file name
+  QFileInfo aFileInfo( aFileName );
+  if ( !aFileInfo.exists() || !aFileInfo.isReadable() ) {
+    theErrorMsg = tr( "FILE_NOT_EXISTS_OR_CANT_BE_READ" ).arg( aFileName );
+    return false;
+  }
+
+  bool anIsOk = false;
+  // If the obstacle for edit is null - create new obstacle object
+  if ( anObstacle.IsNull() ) {
+    anObstacle = Handle(HYDROData_Obstacle)::DownCast( doc()->CreateObject(KIND_OBSTACLE) );
+  }
+
+  if ( !anObstacle.IsNull() ) {
+    if ( anObstacle->ImportFromFile( aFileName ) ) {
+      // Set name
+      if ( anObstacleName.isEmpty() ) {
+        anObstacleName = HYDROGUI_Tool::GenerateObjectName( module(), aFileInfo.baseName() );
+      }
+      if ( anObstacle->GetName() != anObstacleName ) {
+        anObstacle->SetName( anObstacleName );
+      }
+
+      // Set operation status
+      anIsOk = true;
+      theUpdateFlags = UF_Model;
+    } else {
+      theErrorMsg = tr( "BAD_IMPORTED_OBSTACLE_FILE" ).arg( aFileName );
+    }
+  }
+  
+  return anIsOk;
+}
+
+HYDROGUI_InputPanel* HYDROGUI_ImportObstacleFromFileOp::createInputPanel() const
+{
+  HYDROGUI_InputPanel* aPanel = 0;
+  if ( myIsToShowPanel ) {
+    aPanel = new HYDROGUI_ObstacleDlg( module(), getName(), true );
+  }
+
+  return aPanel;
+}
\ No newline at end of file
diff --git a/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.h b/src/HYDROGUI/HYDROGUI_ImportObstacleFromFileOp.h
new file mode 100644 (file)
index 0000000..05b217f
--- /dev/null
@@ -0,0 +1,52 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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
+//
+
+#ifndef HYDROGUI_IMPORTOBSTACLEFROMFILE_H
+#define HYDROGUI_IMPORTOBSTACLEFROMFILE_H
+
+#include "HYDROGUI_Operation.h"
+
+class SUIT_FileDlg;
+
+class HYDROGUI_ImportObstacleFromFileOp : public HYDROGUI_Operation
+{
+  Q_OBJECT
+
+public:
+  HYDROGUI_ImportObstacleFromFileOp( HYDROGUI_Module* theModule, const bool theIsToShowPanel = true );
+  virtual ~HYDROGUI_ImportObstacleFromFileOp();
+
+protected:
+  virtual void startOperation();
+  virtual void abortOperation();
+  virtual void commitOperation();
+
+  virtual HYDROGUI_InputPanel* createInputPanel() const;
+
+  virtual bool processApply( int& theUpdateFlags, QString& theErrorMsg );
+
+private:
+  SUIT_FileDlg* myFileDlg;
+  bool myIsToShowPanel; ///< indicates if obstacle panel to be shown
+};
+
+#endif
\ No newline at end of file
index db43680470e477aaf2a6aea29d3ba5ae2f71195c..0733dcdc5917ab3dd56e088c349e1bb65578c9fa 100644 (file)
@@ -140,6 +140,9 @@ bool HYDROGUI_Module::activateModule( SUIT_Study* theStudy )
 
   updateCommandsStatus();
 
+  connect( anApp, SIGNAL( operationFinished( const QString&, const QString&, const QStringList& ) ), 
+           this, SLOT( onExternalOperationFinished( const QString&, const QString&, const QStringList& ) ) );
+
   return aRes;
 }
 
@@ -162,6 +165,9 @@ bool HYDROGUI_Module::deactivateModule( SUIT_Study* theStudy )
 
   getApp()->setEditEnabled( true ); // show SalomeApp copy/paste actions
 
+  disconnect( getApp(), SIGNAL( operationFinished( const QString&, const QString&, const QStringList& ) ), 
+              this, SLOT( onExternalOperationFinished( const QString&, const QString&, const QStringList& ) ) );
+
   return LightApp_Module::deactivateModule( theStudy );
 }
 
@@ -211,6 +217,13 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
   bool anIsVisualState = false;
   bool anIsRegion = false;
   bool anIsZone = false;
+  bool anIsObstacle = false;
+
+  // check the selected GEOM objects
+  if ( !HYDROGUI_Tool::GetSelectedGeomObjects( this ).isEmpty() ) {
+    theMenu->addAction( action( ImportGeomObjectId ) );
+    theMenu->addSeparator();
+  }
 
   // check the selected data model objects
   HYDROData_SequenceOfObjects aSeq = HYDROGUI_Tool::GetSelectedObjects( this );
@@ -264,6 +277,8 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         anIsRegion = true;
       else if( anObject->GetKind() == KIND_ZONE )
         anIsZone = true;
+      else if( anObject->GetKind() == KIND_OBSTACLE )
+        anIsObstacle = true;
     }
   }
 
@@ -293,6 +308,11 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
         case KIND_IMMERSIBLE_ZONE:
           theMenu->addAction( action( CreateImmersibleZoneId ) );
           break;
+        case KIND_OBSTACLE:
+          theMenu->addAction( action( ImportObstacleFromFileId ) );
+          theMenu->addAction( action( CreateBoxId ) );
+          theMenu->addAction( action( CreateCylinderId ) );
+          break;
       }
       theMenu->addSeparator();
     }
@@ -345,6 +365,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
       else if( anIsCalculation )
       {
         theMenu->addAction( action( EditCalculationId ) );
+        theMenu->addAction( action( ExportCalculationId ) );
         theMenu->addSeparator();
       }
       else if( anIsImmersibleZone )
@@ -363,7 +384,7 @@ void HYDROGUI_Module::contextMenuPopup( const QString& theClient,
     theMenu->addAction( action( DeleteId ) );
     theMenu->addSeparator();
 
-    if( anIsImage || anIsPolyline || anIsImmersibleZone || anIsZone || anIsRegion )
+    if( anIsImage || anIsPolyline || anIsImmersibleZone || anIsZone || anIsRegion || anIsObstacle )
     {
       if( anIsHiddenInSelection )
         theMenu->addAction( action( ShowId ) );
@@ -419,8 +440,8 @@ void HYDROGUI_Module::update( const int flags )
   }
 
   // Object browser is currently updated by using UF_Model flag
-  //if( ( flags & UF_ObjBrowser ) && getApp() )
-  //  getApp()->updateObjectBrowser( true );
+  if( ( flags & UF_ObjBrowser ) && ((flags & UF_Model) == 0) && getApp() )
+    getApp()->updateObjectBrowser( true );
 
   if( ( flags & UF_Controls ) && getApp() )
     getApp()->updateActions();
index b34dda4de30b2263390e9c892322602b2fd6a806..d2825208639d1e205a76060269f2fa6489a5767f 100644 (file)
@@ -125,6 +125,8 @@ public:
   void                            removeObjectShape( const int                       theViewId,
                                                      const Handle(HYDROData_Entity)& theObject );
 
+  QStringList                     GetGeomObjectsToImport();
+
 protected:
   CAM_DataModel*                  createDataModel();
 
@@ -134,6 +136,7 @@ public slots:
 
 protected:
   virtual LightApp_Operation*     createOperation( const int ) const;
+  virtual bool                    reusableOperation( const int id );
 
   virtual void                    customEvent( QEvent* );
   virtual bool                    eventFilter( QObject*, QEvent* );
@@ -149,6 +152,9 @@ protected slots:
   virtual void                    onViewCreated( SUIT_ViewWindow* );
 
   void                            onViewPortMouseEvent( QGraphicsSceneMouseEvent* );
+  
+  void                            onExternalOperationFinished( const QString&, const QString&, 
+                                                               const QStringList& );
 
 private:
   void                            updateGV( const bool theIsInit = false, 
@@ -192,6 +198,8 @@ private:
   ViewId2ListOfShapes             myShapesMap;
 
   bool                            myIsUpdateEnabled;
+
+  QStringList                     myGeomObjectsToImport; ///< entries of GEOM objects to be imported
 };
 
 #endif
index fe5fe68b6b82efa0adcbb5a7c5bce05eb5ec5cf7..9d3e2cf440986c5aa72e19768981dc736f377f0a 100644 (file)
@@ -104,7 +104,8 @@ HYDROGUI_Shape* HYDROGUI_OCCDisplayer::createShape( const int
        anObjectKind != KIND_POLYLINE &&
        anObjectKind != KIND_IMMERSIBLE_ZONE &&
        anObjectKind != KIND_REGION &&
-       anObjectKind != KIND_ZONE )
+       anObjectKind != KIND_ZONE &&
+       anObjectKind != KIND_OBSTACLE  )
     return aResShape;
 
   aResShape = new HYDROGUI_Shape( theContext, theObject );
diff --git a/src/HYDROGUI/HYDROGUI_ObstacleDlg.cxx b/src/HYDROGUI/HYDROGUI_ObstacleDlg.cxx
new file mode 100644 (file)
index 0000000..beb9f0d
--- /dev/null
@@ -0,0 +1,232 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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 "HYDROGUI_ObstacleDlg.h"
+
+#include "HYDROGUI_Tool.h"
+
+#include <SUIT_FileDlg.h>
+#include <SUIT_ResourceMgr.h>
+#include <SUIT_Session.h>
+
+#include <QLabel>
+#include <QLineEdit>
+#include <QComboBox>
+#include <QToolButton>
+#include <QRadioButton>
+#include <QButtonGroup>
+#include <QGroupBox>
+#include <QLayout>
+
+static QString lastUsedFilter;
+
+HYDROGUI_ObstacleDlg::HYDROGUI_ObstacleDlg( HYDROGUI_Module* theModule, const QString& theTitle,
+                                            const bool theIsToEnableFileSelection )
+: HYDROGUI_InputPanel( theModule, theTitle ),
+  myFileSelectionEnabled ( theIsToEnableFileSelection )
+{
+  // Get resource manager
+  SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
+
+  // File selector
+  QGroupBox* aFileNameGroup = 0;
+  myFileName = 0;
+  if ( myFileSelectionEnabled ) {
+    aFileNameGroup = new QGroupBox( tr( "GET_SHAPE_FROM_FILE" ), this );
+
+    QLabel* aFileNameLabel = new QLabel( tr( "FILE_NAME" ), aFileNameGroup );
+
+    myFileName = new QLineEdit( aFileNameGroup );
+    myFileName->setReadOnly( true );
+
+    QToolButton* aBrowseBtn = new QToolButton( aFileNameGroup );
+    aBrowseBtn->setIcon( aResMgr->loadPixmap( "HYDRO", tr( "BROWSE_ICO" ) ) );
+
+    QBoxLayout* aFileNameLayout = new QHBoxLayout( aFileNameGroup );
+    aFileNameLayout->setMargin( 5 );
+    aFileNameLayout->setSpacing( 5 );
+    aFileNameLayout->addWidget( aFileNameLabel );
+    aFileNameLayout->addWidget( myFileName );
+    aFileNameLayout->addWidget( aBrowseBtn );
+
+    connect( aBrowseBtn, SIGNAL( clicked() ), this, SLOT( onBrowse() ) );
+  }
+
+  // Obstacle name
+  myObstacleNameGroup = new QGroupBox( tr( "OBSTACLE_NAME" ), this );
+
+  QLabel* anObstacleNameLabel = new QLabel( tr( "NAME" ), myObstacleNameGroup );
+  myObstacleName = new QLineEdit( myObstacleNameGroup );
+
+  QBoxLayout* anObstacleNameLayout = new QHBoxLayout( myObstacleNameGroup );
+  anObstacleNameLayout->setMargin( 5 );
+  anObstacleNameLayout->setSpacing( 5 );
+  anObstacleNameLayout->addWidget( anObstacleNameLabel );
+  anObstacleNameLayout->addWidget( myObstacleName );
+
+  myObstacleNameGroup->hide(); //TODO to be enabled?
+
+  // Mode selector (create/edit)
+  myModeGroup = new QGroupBox( tr( "MODE" ), this );
+
+  QRadioButton* aNewObstacleRB = new QRadioButton( tr( "CREATE_NEW_OBSTACLE" ), mainFrame() );
+  QRadioButton* aModifyObstacleRB = new QRadioButton( tr( "MODIFY_OBSTACLE" ), mainFrame() );
+
+  myModeButtons = new QButtonGroup( mainFrame() );
+  myModeButtons->addButton( aNewObstacleRB, CreateNewId );
+  myModeButtons->addButton( aModifyObstacleRB, ModifyExistentId );
+
+  QBoxLayout* aModeSelectorLayout = new QHBoxLayout( myModeGroup );
+  aModeSelectorLayout->setMargin( 5 );
+  aModeSelectorLayout->setSpacing( 5 );
+  aModeSelectorLayout->addWidget( aNewObstacleRB );
+  aModeSelectorLayout->addWidget( aModifyObstacleRB );
+
+  // Existing obstacles selector
+  myObstaclesGroup = new QGroupBox( tr( "OBSTACLE_TO_EDIT" ), this );
+
+  QLabel* anObstacleLabel = new QLabel( tr( "OBSTACLE" ), myObstaclesGroup );
+
+  myObstacles = new QComboBox( mainFrame() );
+  myObstacles->setSizePolicy( QSizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed ) );
+  QBoxLayout* anObstaclesSelectorLayout = new QHBoxLayout( myObstaclesGroup );
+  anObstaclesSelectorLayout->setMargin( 5 );
+  anObstaclesSelectorLayout->setSpacing( 5 );
+  anObstaclesSelectorLayout->addWidget( anObstacleLabel );
+  anObstaclesSelectorLayout->addWidget( myObstacles );
+
+  // Layout
+  if ( aFileNameGroup ) {
+    addWidget( aFileNameGroup );
+  }
+  addWidget( myObstacleNameGroup );
+  addWidget( myModeGroup );
+  addWidget( myObstaclesGroup );
+  addStretch();
+
+  // Connect signals and slots
+  connect( myModeButtons, SIGNAL( buttonClicked( int ) ), this, SLOT( onModeActivated( int ) ) );
+  connect( myObstacles, SIGNAL( currentIndexChanged( int ) ), this, SLOT( onObstacleSelectionChanged( ) ) );
+}
+
+HYDROGUI_ObstacleDlg::~HYDROGUI_ObstacleDlg()
+{
+}
+
+void HYDROGUI_ObstacleDlg::setObstacleNames( const QStringList& theObstacles )
+{
+  myObstacles->clear();
+  myObstacles->addItems( theObstacles );
+
+  UpdateControls();
+}
+
+void HYDROGUI_ObstacleDlg::onModeActivated( int theMode )
+{
+  UpdateControls();
+}
+
+QString HYDROGUI_ObstacleDlg::getObstacleName() const
+{
+  return myObstacleName->text();
+
+
+  QString aName;
+
+  if ( myModeButtons->checkedId() == ModifyExistentId ) {
+    aName = myObstacles->currentText();
+  }
+
+  return aName;
+}
+
+QString HYDROGUI_ObstacleDlg::getEditedObstacleName() const
+{
+  QString aName;
+
+  if ( myModeButtons->checkedId() == ModifyExistentId ) {
+    aName = myObstacles->currentText();
+  }
+
+  return aName;
+}
+
+QString HYDROGUI_ObstacleDlg::getFileName() const
+{
+  return myFileName->text();
+}
+
+void HYDROGUI_ObstacleDlg::onBrowse()
+{
+  SUIT_FileDlg* aFileDlg = new SUIT_FileDlg( this, true );
+  aFileDlg->setWindowTitle( tr("IMPORT_OBSTACLE_FROM_FILE") );
+  aFileDlg->setFilter( tr("OBSTACLE_FILTER") );
+  if ( !lastUsedFilter.isEmpty() ) {
+    aFileDlg->selectFilter( lastUsedFilter );
+  }
+
+  if ( aFileDlg->exec() == QDialog::Accepted ) {
+    QString aFileName = aFileDlg->selectedFile();
+    lastUsedFilter = aFileDlg->selectedFilter();
+
+    if ( !aFileName.isEmpty() ) {
+      myFileName->setText( aFileName );
+
+      QFileInfo aFileInfo( aFileName );
+      QString aName = HYDROGUI_Tool::GenerateObjectName( module(), aFileInfo.baseName() );
+      myObstacleName->setText( aName );
+    }
+
+    UpdateControls();
+  }
+}
+
+void HYDROGUI_ObstacleDlg::reset()
+{
+  if ( myFileSelectionEnabled ) {
+    myFileName->clear();
+  }
+  myObstacleName->clear();
+
+  // Activate the creation mode
+  myModeButtons->button( CreateNewId )->setChecked( true );
+  onModeActivated( CreateNewId );
+
+  UpdateControls();
+}
+
+void HYDROGUI_ObstacleDlg::onObstacleSelectionChanged()
+{
+  if ( myObstacleName->text().isEmpty() ) {
+    myObstacleName->setText( myObstacles->currentText() );
+  }
+}
+
+void HYDROGUI_ObstacleDlg::UpdateControls()
+{
+  myObstacleNameGroup->setEnabled( !myFileSelectionEnabled || 
+                                   !myFileName->text().isEmpty() );
+  myModeGroup->setEnabled( myObstacleNameGroup->isEnabled() && 
+                           myObstacles->count() > 0 );
+  myObstaclesGroup->setEnabled( myModeButtons->checkedId() == ModifyExistentId );
+}
\ No newline at end of file
diff --git a/src/HYDROGUI/HYDROGUI_ObstacleDlg.h b/src/HYDROGUI/HYDROGUI_ObstacleDlg.h
new file mode 100644 (file)
index 0000000..af30309
--- /dev/null
@@ -0,0 +1,76 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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
+//
+
+#ifndef HYDROGUI_ObstacleDlg_H
+#define HYDROGUI_ObstacleDlg_H
+
+#include "HYDROGUI_InputPanel.h"
+
+class QLineEdit;
+class QGroupBox;
+class QComboBox;
+class QButtonGroup;
+
+class HYDROGUI_ObstacleDlg : public HYDROGUI_InputPanel
+{
+  Q_OBJECT
+
+  enum CreationMode { CreateNewId, ModifyExistentId };
+
+public:
+  HYDROGUI_ObstacleDlg( HYDROGUI_Module* theModule, const QString& theTitle, 
+                        const bool theIsToEnableFileSelection = false );
+  virtual ~HYDROGUI_ObstacleDlg();
+
+  void                       reset();
+
+  QString                    getObstacleName() const;
+
+  void                       setObstacleNames( const QStringList& theObstacles );
+  QString                    getEditedObstacleName() const;
+
+  QString                    getFileName() const;
+
+protected slots:
+  void                       onModeActivated( int );
+  void                       onObstacleSelectionChanged();
+  void                       onBrowse();
+
+private:
+  void                       UpdateControls();
+
+private:
+  QLineEdit*                 myFileName;
+  
+  QGroupBox*                 myObstacleNameGroup;
+  QLineEdit*                 myObstacleName;
+
+  QGroupBox*                 myModeGroup;
+  QButtonGroup*              myModeButtons;
+
+  QGroupBox*                 myObstaclesGroup;
+  QComboBox*                 myObstacles;
+
+  bool                       myFileSelectionEnabled;
+};
+
+#endif
index 08aa0d8fb8f6664d577d65c784dac5517cbf6bf6..0378857cad988d630d31302ab8ca41267e7eeaeb 100644 (file)
 #include "HYDROGUI_UpdateFlags.h"
 #include "HYDROGUI_UpdateImageOp.h"
 #include "HYDROGUI_VisualStateOp.h"
+#include "HYDROGUI_ImmersibleZoneOp.h"
+#include "HYDROGUI_ImportGeomObjectOp.h"
+#include "HYDROGUI_ImportObstacleFromFileOp.h"
+#include "HYDROGUI_ExportCalculationOp.h"
+
+#include "HYDROData_Document.h"
+#include "HYDROData_Obstacle.h"
+
+#include <GeometryGUI.h>
+#include <GeometryGUI_Operations.h>
+#include <GEOMBase.h>
+
+#include <SalomeApp_Study.h>
+
+#include <LightApp_Application.h>
 
 #include <CAM_Application.h>
 
@@ -65,8 +80,8 @@ QAction* HYDROGUI_Module::createAction( const int theId, const QString& theSuffi
   std::string aDesktop = ( "DSK_" + theSuffix ).toStdString();
   std::string aToolbar = ( "STB_" + theSuffix ).toStdString();
   std::string aSlotStr = aSlot.toStdString();
-  return LightApp_Module::createAction( theId, tr( aMenu.c_str() ), aPixmap,
-    tr( aDesktop.c_str() ), tr( aToolbar.c_str() ),
+  return LightApp_Module::createAction( theId, tr( aDesktop.c_str() ), aPixmap,
+    tr( aMenu.c_str() ), tr( aToolbar.c_str() ),
                theKey, application()->desktop(), isToggle, this, aSlotStr.c_str() );
 }
 
@@ -93,8 +108,14 @@ void HYDROGUI_Module::createActions()
   createAction( CreateImmersibleZoneId, "CREATE_IMMERSIBLE_ZONE" );
   createAction( EditImmersibleZoneId, "EDIT_IMMERSIBLE_ZONE" );
 
+  createAction( ImportObstacleFromFileId, "IMPORT_OBSTACLE_FROM_FILE" );
+  createAction( ImportGeomObjectId, "IMPORT_GEOM_OBJECT" );
+  createAction( CreateBoxId, "CREATE_BOX" );
+  createAction( CreateCylinderId, "CREATE_CYLINDER" );
+
   createAction( CreateCalculationId, "CREATE_CALCULATION" );
   createAction( EditCalculationId, "EDIT_CALCULATION" );
+  createAction( ExportCalculationId, "EXPORT_CALCULATION" );
 
   createAction( FuseImagesId, "FUSE_IMAGES" );
   createAction( EditFusedImageId, "EDIT_FUSED_IMAGE" );
@@ -134,11 +155,18 @@ void HYDROGUI_Module::createMenus()
   createMenu( ImportBathymetryId, aHydroId, -1, -1 );
   createMenu( CreatePolylineId, aHydroId, -1, -1 );
   createMenu( CreateImmersibleZoneId, aHydroId, -1, -1 );
+
+  int aNewObstacleId = createMenu( tr( "MEN_OBSTACLE" ), aHydroId, -1 );
+  createMenu( ImportObstacleFromFileId, aNewObstacleId, -1, -1 );
+  createMenu( CreateBoxId, aNewObstacleId, -1, -1 );
+  createMenu( CreateCylinderId, aNewObstacleId, -1, -1 );
+
   createMenu( CreateCalculationId, aHydroId, -1, -1 );
   createMenu( separator(), aHydroId );
   createMenu( FuseImagesId, aHydroId, -1, -1 );
   createMenu( CutImagesId, aHydroId, -1, -1 );
   createMenu( SplitImageId, aHydroId, -1, -1 );
+  createMenu( separator(), aHydroId );
 }
 
 void HYDROGUI_Module::createPopups()
@@ -290,6 +318,9 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case EditCalculationId:
     anOp = new HYDROGUI_CalculationOp( aModule, theId == EditCalculationId );
     break;
+  case ExportCalculationId:
+    anOp = new HYDROGUI_ExportCalculationOp( aModule );
+    break;
   case FuseImagesId:
   case EditFusedImageId:
     anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Fuse, theId == EditFusedImageId );
@@ -302,6 +333,21 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
   case EditSplittedImageId:
     anOp = new HYDROGUI_TwoImagesOp( aModule, HYDROGUI_TwoImagesOp::Split, theId == EditSplittedImageId );
     break;
+  case ImportObstacleFromFileId:
+    anOp = new HYDROGUI_ImportObstacleFromFileOp( aModule );
+    break;
+  case ImportCreatedPrimitiveId:
+    anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportCreated );
+    break;
+  case ImportGeomObjectId:
+    anOp = new HYDROGUI_ImportGeomObjectOp( aModule, HYDROGUI_ImportGeomObjectOp::ImportSelected );
+    break;
+  case CreateBoxId:
+    application()->activateOperation( "Geometry", GEOMOp::OpBox );
+    break;
+  case CreateCylinderId:
+    application()->activateOperation( "Geometry", GEOMOp::OpCylinder );
+    break;
   case DeleteId:
     anOp = new HYDROGUI_DeleteOp( aModule );
     break;
@@ -319,3 +365,41 @@ LightApp_Operation* HYDROGUI_Module::createOperation( const int theId ) const
 
   return anOp;
 }
+
+bool HYDROGUI_Module::reusableOperation( const int id )
+{
+  if ( id == ImportGeomObjectId ) {
+    return false;
+  }
+
+  return LightApp_Module::reusableOperation( id );
+}
+
+/**
+ * Called when the operation perfomed by another module is finished.
+ * \param theModuleName the name of the module which perfomed the operation
+ * \param theOperationName the operation name
+ * \param theEntryList the list of the created objects entries
+ */
+void HYDROGUI_Module::onExternalOperationFinished( const QString& theModuleName,
+                                                   const QString& theOperationName,
+                                                   const QStringList& theEntryList )
+{
+  // Process "Geometry" module operations with non-empty list of created objects only
+  if ( theModuleName != "Geometry" || theEntryList.isEmpty() ) {
+    return;
+  }
+  
+  // Start import GEOM object operation
+  myGeomObjectsToImport = theEntryList;
+  startOperation ( ImportCreatedPrimitiveId );
+  myGeomObjectsToImport.clear();
+}
+
+/**
+ * Returns the list of entries of GEOM objects to be imported.
+ */
+QStringList HYDROGUI_Module::GetGeomObjectsToImport()
+{
+  return myGeomObjectsToImport;
+}
index 1baabb87553af8bfed35ad3c25bee03b98fff98a..cdfe34d34eec820436e363606bc5d491d99a35b5 100644 (file)
@@ -54,6 +54,7 @@ enum OperationId
 
   CreateCalculationId,
   EditCalculationId,
+  ExportCalculationId,
 
   FuseImagesId,
   EditFusedImageId,
@@ -64,6 +65,12 @@ enum OperationId
   SplitImageId,
   EditSplittedImageId,
 
+  ImportObstacleFromFileId,
+  ImportGeomObjectId,
+  ImportCreatedPrimitiveId,
+  CreateBoxId,
+  CreateCylinderId,
+
   DeleteId,
 
   ShowId,
index e68a8f6743e1549eb2173c98e26e89ff9b114e61..88f11469527d03bfb9120402b60acd66e565c7d8 100755 (executable)
@@ -24,7 +24,9 @@
 
 #include "HYDROGUI_Module.h"
 #include <CurveCreator_Widget.h>
-#include <CurveCreator_Curve.hxx>
+#include <CurveCreator_ICurve.hxx>
+
+#include <OCCViewer_ViewModel.h>
 
 #include <QGroupBox>
 #include <QHBoxLayout>
@@ -63,6 +65,11 @@ HYDROGUI_PolylineDlg::~HYDROGUI_PolylineDlg()
 {
 }
 
+void HYDROGUI_PolylineDlg::setOCCViewer( OCCViewer_Viewer* theViewer )
+{
+  myEditorWidget->setOCCViewer( theViewer );
+}
+
 void HYDROGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget )
 {
   myEditorWidget->setEnabled( false );
@@ -99,7 +106,7 @@ QString HYDROGUI_PolylineDlg::getPolylineName() const
   return myName->text();
 }
 
-void HYDROGUI_PolylineDlg::setCurve( CurveCreator_Curve* theCurve )
+void HYDROGUI_PolylineDlg::setCurve( CurveCreator_ICurve* theCurve )
 {
   myEditorWidget->setCurve( theCurve );
 }
index 01d5a13cbe206cd06d63602f1c05c54cb305ac59..69c4b6cbd29954415218f934f1a7b88eb8952640 100755 (executable)
@@ -28,7 +28,8 @@
 class QGroupBox;
 class QLineEdit;
 class CurveCreator_Widget;
-class CurveCreator_Curve;
+class CurveCreator_ICurve;
+class OCCViewer_Viewer;
 
 class HYDROGUI_PolylineDlg : public HYDROGUI_InputPanel
 {
@@ -37,11 +38,13 @@ class HYDROGUI_PolylineDlg : public HYDROGUI_InputPanel
 public:
   HYDROGUI_PolylineDlg( HYDROGUI_Module* theModule, const QString& theTitle );
   virtual ~HYDROGUI_PolylineDlg();
-  
+
+  void setOCCViewer( OCCViewer_Viewer* theViewer );
+
   void  setPolylineName( const QString& theName );
   QString getPolylineName() const;
        
-  void  setCurve( CurveCreator_Curve* theCurve );
+  void  setCurve( CurveCreator_ICurve* theCurve );
 
   void  reset();
 
index dbf830babb78691b55e291cf043e52ceef55a68a..258c0f5b43a004a420f8a2fd590c06dff14544ee 100755 (executable)
 #include "HYDROGUI_PolylineOp.h"
 #include "HYDROGUI_PolylineDlg.h"
 #include "HYDROGUI_Tool.h"
-#include "HYDROGUI_AISCurve.h"
 #include "HYDROGUI_UpdateFlags.h"
 
-#include <HYDROData_Document.h>
-#include <HYDROData_Polyline.h>
-
-#include <CurveCreator_Curve.hxx>
+#include "HYDROData_Document.h"
+#include "HYDROData_Polyline.h"
+#include "CurveCreator_Curve.hxx"
+#include "CurveCreator_Displayer.h"
 
 #include <LightApp_Application.h>
 #include <LightApp_SelectionMgr.h>
@@ -47,7 +46,7 @@
 
 HYDROGUI_PolylineOp::HYDROGUI_PolylineOp( HYDROGUI_Module* theModule, bool theIsEdit )
 : HYDROGUI_Operation( theModule ), myIsEdit(theIsEdit), myCurve(NULL), 
-  myViewManager(NULL), myAISCurve(NULL)
+  myViewManager(NULL), myCurveDisplayer(NULL)
 {
   setName( theIsEdit ? tr( "EDIT_POLYLINE" ) : tr( "CREATE_POLYLINE" ) );
 }
@@ -70,6 +69,11 @@ void HYDROGUI_PolylineOp::startOperation()
   HYDROGUI_PolylineDlg* aPanel = (HYDROGUI_PolylineDlg*)inputPanel();
   aPanel->reset();
 
+  LightApp_Application* anApp = module()->getApp();
+  myViewManager =
+    dynamic_cast<OCCViewer_ViewManager*>( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
+  aPanel->setOCCViewer( myViewManager ? myViewManager->getOCCViewer() : 0 );
+
   if( myIsEdit )
     myEditedObject = Handle(HYDROData_Polyline)::DownCast( HYDROGUI_Tool::GetSelectedObject( module() ) );
   if( !myEditedObject.IsNull() )
@@ -105,9 +109,6 @@ void HYDROGUI_PolylineOp::startOperation()
   }
   aPanel->setCurve(myCurve);
 
-  if( myAISCurve )
-    myAISCurve->setCurve(myCurve);
-
   displayPreview();
 }
 
@@ -192,23 +193,19 @@ void HYDROGUI_PolylineOp::onEditorSelectionChanged()
     return;
   if( !myCurve )
     return;
-  if( !myAISCurve )
+  if( !myCurveDisplayer )
     return;
   QList<int> aSelSections = aPanel->getSelectedSections();
   for( int i = 0 ; i < myCurve->getNbSections() ; i++ ){
     bool aIsHl = false;
     if( aSelSections.contains(i) ){
-      myAISCurve->highlightSection(i, aIsHl);
+      myCurveDisplayer->highlight( myCurve->constructSection(i), aIsHl );
     }
   }
 }
 
 void HYDROGUI_PolylineOp::displayPreview()
 {
-  LightApp_Application* anApp = module()->getApp();
-
-  myViewManager =
-    dynamic_cast<OCCViewer_ViewManager*>( anApp->getViewManager( OCCViewer_Viewer::Type(), true ) );
   if( myViewManager )
   {
     if( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() )
@@ -216,8 +213,9 @@ void HYDROGUI_PolylineOp::displayPreview()
       Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
       if( !aCtx.IsNull() )
       {
-        myAISCurve = new HYDROGUI_AISCurve( myCurve, aCtx );
-        myAISCurve->Display();
+        myCurveDisplayer = new CurveCreator_Displayer( aCtx );
+        myCurve->setDisplayer( myCurveDisplayer );
+        myCurveDisplayer->display( myCurve->constructWire() );
       }
     }
   }
@@ -230,11 +228,11 @@ void HYDROGUI_PolylineOp::erasePreview()
     if( OCCViewer_Viewer* aViewer = myViewManager->getOCCViewer() )
     {
       Handle(AIS_InteractiveContext) aCtx = aViewer->getAISContext();
-      if( !aCtx.IsNull() && myAISCurve )
+      if( !aCtx.IsNull() && myCurveDisplayer )
       {
-        myAISCurve->Erase();
-        delete myAISCurve;
-        myAISCurve = 0;
+        myCurveDisplayer->erase();
+        delete myCurveDisplayer;
+        myCurveDisplayer = 0;
       }
     }
   }
index 614960dfecb719eeae3c0bc93ac8cc77b5b8c3d7..78c97a5b9b7459d556ad701627693ba9cde56a7f 100755 (executable)
@@ -29,7 +29,7 @@
 
 class OCCViewer_ViewManager;
 class CurveCreator_Curve;
-class HYDROGUI_AISCurve;
+class CurveCreator_Displayer;
 
 class HYDROGUI_PolylineOp : public HYDROGUI_Operation
 {
@@ -61,7 +61,7 @@ private:
   bool                       myIsEdit;
   Handle(HYDROData_Polyline) myEditedObject;
   CurveCreator_Curve*        myCurve;
-  HYDROGUI_AISCurve*         myAISCurve;
+  CurveCreator_Displayer*     myCurveDisplayer;
 };
 
 #endif
index 361a420cc42f5e1fb5e8b14256476b42e262708b..a54e7ccd92bd03bf79e855b0bad3de3c0bd6d99c 100644 (file)
@@ -43,6 +43,7 @@
 #include <HYDROData_Polyline.h>
 #include <HYDROData_Region.h>
 #include <HYDROData_Zone.h>
+#include <HYDROData_Obstacle.h>
 
 #include <TopoDS.hxx>
 #include <TopoDS_Wire.hxx>
@@ -219,8 +220,25 @@ void HYDROGUI_Shape::update( const bool theIsUpdateViewer )
       setTextureFileName( aTextureFileName, false, false );
       setFace( aWire, false, false );
     }
-  }
+    else if ( myObject->IsKind( STANDARD_TYPE(HYDROData_Obstacle) ) )
+    {
+      Handle(HYDROData_Obstacle) anObstacle =
+        Handle(HYDROData_Obstacle)::DownCast( myObject );
+
+      //TODO BEGIN of the block of code to be reimplemented
+      //TODO GetTopShape() to be used in future
+      myTopoShape = anObstacle->GetShape3D();
+      myDisplayMode = AIS_Shaded;
 
+      //TODO colors should be defined in another way
+      setFillingColor( Qt::green, false, false );
+
+      buildShape();
+      updateShape( false, false );
+      //TODO END of the block of code to be reimplemented
+    }
+  }
   if ( myShape.IsNull() || !isVisible() )
     return;
 
@@ -292,7 +310,9 @@ void HYDROGUI_Shape::setFace( const TopoDS_Face& theFace,
                               const bool         theIsUpdateViewer )
 {
   myTopoShape = theFace;
-  myDisplayMode = myTextureFileName.isEmpty() ? AIS_Shaded : AIS_ExactHLR;
+  myDisplayMode = myTextureFileName.isEmpty() ? AIS_Shaded : AIS_Shaded+2;
+  //Note: AIS_Shaded+2 is the same as AIS_ExactHLR
+  //TODO: it would be more suitable to use TexturedShape mode from GEOM_AISShape
 
   buildShape();
   updateShape( theToDisplay, theIsUpdateViewer );
index 51ce9f1d1d6c5fd1045b6014dc4cec39e71d1775..19d4e9c93b53c47aa71d1d76f5b54ae486fc1902 100644 (file)
 #include <HYDROData_ImmersibleZone.h>
 #include <HYDROData_Tool.h>
 
+#include <GEOMBase.h>
+
 #include <GraphicsView_Viewer.h>
 
+#include <SalomeApp_Study.h>
+
 #include <LightApp_Application.h>
 #include <LightApp_DataOwner.h>
 #include <LightApp_SelectionMgr.h>
@@ -49,6 +53,8 @@
 #include <SUIT_ViewManager.h>
 #include <SUIT_ViewWindow.h>
 
+#include <SALOMEDSClient.hxx>
+
 #include <QDir>
 #include <QFileInfo>
 #include <QDockWidget>
@@ -211,7 +217,8 @@ void HYDROGUI_Tool::GetPrsSubObjects( HYDROGUI_Module* theModule,
         ( anObject->GetKind() == KIND_POLYLINE ) ||
         ( anObject->GetKind() == KIND_IMMERSIBLE_ZONE ) ||
         ( anObject->GetKind() == KIND_REGION ) ||
-        ( anObject->GetKind() == KIND_ZONE ) ) )
+        ( anObject->GetKind() == KIND_ZONE ) ||
+        ( anObject->GetKind() == KIND_OBSTACLE ) ) )
       {
         theSeq.Append( anObject );
       }
@@ -335,6 +342,50 @@ ObjectKind HYDROGUI_Tool::GetSelectedPartition( HYDROGUI_Module* theModule )
   return KIND_UNKNOWN;
 }
 
+QStringList HYDROGUI_Tool::GetSelectedGeomObjects( HYDROGUI_Module* theModule )
+{
+  QStringList anEntryList;
+
+  // Get active SalomeApp_Study
+  SalomeApp_Study* aStudy = NULL;
+  if ( theModule && theModule->getApp() ) {
+    aStudy = dynamic_cast<SalomeApp_Study*>( theModule->getApp()->activeStudy() );
+  }
+  if ( !aStudy ) {
+    return anEntryList;
+  }
+
+  // Get selection
+  HYDROGUI_DataModel* aModel = theModule->getDataModel();
+
+  SUIT_SelectionMgr* aSelectionMgr = theModule->getApp()->selectionMgr();
+  SUIT_DataOwnerPtrList anOwners;
+  aSelectionMgr->selected( anOwners );
+
+  // Check if the selected objects belong to GEOM and have a shape
+  foreach( SUIT_DataOwner* aSUITOwner, anOwners )
+  {
+    if( LightApp_DataOwner* anOwner = dynamic_cast<LightApp_DataOwner*>( aSUITOwner ) )
+    {
+      QString anEntry = anOwner->entry();
+      _PTR(SObject) aSObject( aStudy->studyDS()->FindObjectID(qPrintable(anEntry)) );
+      if (aSObject) {
+         _PTR(SComponent) aSComponent = aSObject->GetFatherComponent();
+        if ( aSComponent && aSComponent->ComponentDataType() == "GEOM" ) {
+          GEOM::GEOM_Object_var aGeomObj = 
+            GEOMBase::GetObjectFromIOR( aSObject->GetIOR().c_str() );
+
+          if ( !aGeomObj->_is_nil() && aGeomObj->IsShape() ) {
+            anEntryList << anEntry;
+          }
+        }
+      }
+    }
+  }
+
+  return anEntryList;
+}
+
 Handle(HYDROData_Entity) HYDROGUI_Tool::FindObjectByName( HYDROGUI_Module* theModule,
                                                           const QString&   theName,
                                                           const ObjectKind theObjectKind )
@@ -525,3 +576,18 @@ QColor HYDROGUI_Tool::GenerateFillingColor( const Handle(HYDROData_Document)& th
   return aFillingColor;
 }
 
+QStringList HYDROGUI_Tool::FindExistingObjectsNames( const Handle(HYDROData_Document)& theDoc, 
+                                                     const ObjectKind theObjectKind )
+{
+  QStringList aNames;
+
+  HYDROData_Iterator anIter( theDoc, theObjectKind );
+  for ( ; anIter.More(); anIter.Next() ) {
+    Handle(HYDROData_Entity) anObject = anIter.Current();
+    if( !anObject.IsNull() ) {
+      aNames.append( anObject->GetName() );
+    }
+  }
+
+  return aNames;
+}
index 370021b5df0215f2697a0b5626e95453f6689124..5b5908657847dc7dfd2dc109afc665d87140564d 100644 (file)
@@ -162,6 +162,13 @@ public:
    */
   static ObjectKind GetSelectedPartition( HYDROGUI_Module* theModule );
 
+  /**
+   * \brief Get the selected GEOM objects.
+   * \param theModule module
+   * \return list of GEOM objects entries
+   */
+  static QStringList GetSelectedGeomObjects( HYDROGUI_Module* theModule );
+
   /**
    * \brief Find the data object with the specified name.
    * \param theModule module
@@ -269,7 +276,7 @@ public:
   static QColor                   GenerateFillingColor( HYDROGUI_Module*   theModule,
                                                         const QStringList& theZoneNames );
 
-  /*
+  /**
    * \brief Generates the filling color for intersected zone
    * \param theDoc model document
    * \param theZoneNames list of intersected zones
@@ -278,6 +285,14 @@ public:
   static QColor                   GenerateFillingColor( const Handle(HYDROData_Document)& theDoc,
                                                         const QStringList&                theZoneNames );
 
+  /**
+   * \brief Find names of existing objects of the given kind.
+   * \param theDoc model document
+   * \param theObjectKind kind of object
+   * \return list of names
+   */
+  static QStringList              FindExistingObjectsNames( const Handle(HYDROData_Document)& theDoc, 
+                                                            const ObjectKind theObjectKind );
 };
 
 #endif
index 56aa68926acf1406b6f6cb2197f473a6a1161980..d2b841a0cd957f9b23a93c156bbc13c086d915c5 100644 (file)
       <source>IMMERSIBLE_ZONES</source>
       <translation>IMMERSIBLE ZONES</translation>
     </message>
+    <message>
+      <source>OBSTACLES</source>
+      <translation>OBSTACLES</translation>
+    </message>
     <message>
       <source>BATHYMETRY_FILTER</source>
       <translation>Bathymetry files (*.xyz);;All files (*.* *)</translation>
@@ -128,6 +132,11 @@ does not exist or you have not enough permissions to open it.</translation>
       <source>NEW_REGION</source>
       <translation>&lt;New region&gt;</translation>
     </message>
+    <message>
+      <source>OBSTACLE_FILTER</source>
+      <translation>BREP files (*.brep);;IGES files (*.iges *.igs);;STEP files (*.step *.stp);;
+All supported formats (*.brep *.iges *.igs *.step *.stp)</translation>
+    </message>
   </context>
 
   <context>
@@ -164,6 +173,14 @@ does not exist or you have not enough permissions to open it.</translation>
       <source>EXCLUDE</source>
       <translation>Exclude &lt;&lt;</translation>
     </message>
+    <message>
+      <source>ADD</source>
+      <translation>Add</translation>
+    </message>
+    <message>
+      <source>REMOVE</source>
+      <translation>Remove</translation>
+    </message>
   </context>
 
   <context>
@@ -451,6 +468,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>DSK_EDIT_CALCULATION</source>
       <translation>Edit calculation case</translation>
     </message>
+    <message>
+      <source>DSK_EXPORT_CALCULATION</source>
+      <translation>Export calculation case to GEOM</translation>
+    </message>
     <message>
       <source>DSK_EDIT_CUT_IMAGE</source>
       <translation>Edit cut image</translation>
@@ -543,6 +564,22 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>DSK_UPDATE_IMAGE</source>
       <translation>Update image</translation>
     </message>
+    <message>
+      <source>DSK_IMPORT_OBSTACLE_FROM_FILE</source>
+      <translation>Import obstacle from file</translation>
+    </message>
+    <message>
+      <source>DSK_CREATE_BOX</source>
+      <translation>Create box obstacle</translation>
+    </message>
+    <message>
+      <source>DSK_IMPORT_GEOM_OBJECT</source>
+      <translation>Import GEOM object as an obstacle</translation>
+    </message>
+    <message>
+      <source>DSK_CREATE_CYLINDER</source>
+      <translation>Create cylinder obstacle</translation>
+    </message>
     <message>
       <source>MEN_CREATE_CALCULATION</source>
       <translation>Create new calculation case</translation>
@@ -579,6 +616,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>MEN_EDIT_CALCULATION</source>
       <translation>Edit calculation case</translation>
     </message>
+    <message>
+      <source>MEN_EXPORT_CALCULATION</source>
+      <translation>Export</translation>
+    </message>
     <message>
       <source>MEN_EDIT_CUT_IMAGE</source>
       <translation>Edit cut image</translation>
@@ -671,6 +712,26 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>MEN_UPDATE_IMAGE</source>
       <translation>Update image</translation>
     </message>
+    <message>
+      <source>MEN_OBSTACLE</source>
+      <translation>Obstacle</translation>
+    </message>
+    <message>
+      <source>MEN_IMPORT_OBSTACLE_FROM_FILE</source>
+      <translation>Import from file</translation>
+    </message>
+    <message>
+      <source>MEN_IMPORT_GEOM_OBJECT</source>
+      <translation>Import</translation>
+    </message>
+    <message>
+      <source>MEN_CREATE_BOX</source>
+      <translation>Box</translation>
+    </message>
+    <message>
+      <source>MEN_CREATE_CYLINDER</source>
+      <translation>Cylinder</translation>
+    </message>
     <message>
       <source>STB_CREATE_CALCULATION</source>
       <translation>Create new calculation case</translation>
@@ -703,6 +764,10 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>STB_EDIT_CALCULATION</source>
       <translation>Edit calculation case</translation>
     </message>
+    <message>
+      <source>STB_EXPORT_CALCULATION</source>
+      <translation>Export calculation case to GEOM</translation>
+    </message>
     <message>
       <source>STB_EDIT_CUT_IMAGE</source>
       <translation>Edit cut image</translation>
@@ -795,28 +860,24 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
       <source>STB_UPDATE_IMAGE</source>
       <translation>Update image</translation>
     </message>
-  </context>
-
-  <context>
-    <name>HYDROGUI_ObserveImageOp</name>
     <message>
-      <source>OBSERVE_IMAGE</source>
-      <translation>Observe image</translation>
+      <source>STB_IMPORT_OBSTACLE_FROM_FILE</source>
+      <translation>Import obstacle from file</translation>
     </message>
-  </context>
-
-  <context>
-    <name>HYDROGUI_PolylineDlg</name>
     <message>
-      <source>ADD_ELEMENT</source>
-      <translation>Add element</translation>
+      <source>STB_IMPORT_GEOM_OBJECT</source>
+      <translation>Import GEOM object as an obstacle</translation>
     </message>
     <message>
-      <source>CURVE_NAME_TLT</source>
-      <translation>Name</translation>
+      <source>STB_CREATE_BOX</source>
+      <translation>Create box obstacle</translation>
+    </message>
+    <message>
+      <source>STB_CREATE_CYLINDER</source>
+      <translation>Create cylinder obstacle</translation>
     </message>
   </context>
-
+  
   <context>
     <name>HYDROGUI_PolylineOp</name>
     <message>
@@ -861,6 +922,26 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
     </message>
   </context>
   
+  <context>
+    <name>HYDROGUI_ObserveImageOp</name>
+    <message>
+      <source>OBSERVE_IMAGE</source>
+      <translation>Observe image</translation>
+    </message>
+  </context>
+  
+  <context>
+    <name>HYDROGUI_PolylineDlg</name>
+    <message>
+      <source>ADD_ELEMENT</source>
+      <translation>Add element</translation>
+    </message>
+    <message>
+      <source>CURVE_NAME_TLT</source>
+      <translation>Name</translation>
+    </message>
+  </context>
+  
   <context>
     <name>HYDROGUI_TwoImagesDlg</name>
     <message>
@@ -1021,4 +1102,100 @@ file cannot be correctly imported for a Bathymetry definition.</translation>
     </message>
   </context>
 
+  <context>
+    <name>HYDROGUI_ImportGeomObjectOp</name>
+    <message>
+      <source>IMPORT_GEOM_OBJECT</source>
+      <translation>Import GEOM object</translation>
+    </message>
+  </context>
+
+  <context>
+    <name>HYDROGUI_ImportObstacleFromFileOp</name>
+    <message>
+      <source>IMPORT_OBSTACLE_FROM_FILE</source>
+      <translation>Import obstacle</translation>
+    </message>
+    <message>
+      <source>BAD_IMPORTED_OBSTACLE_FILE</source>
+      <translation>'%1'
+file cannot be correctly imported for an Obstacle definition.</translation>
+    </message>
+  </context>
+
+  <context>
+    <name>HYDROGUI_ExportCalculationOp</name>
+    <message>
+      <source>EXPORT_CALCULATION</source>
+      <translation>Export calculation case</translation>
+    </message>
+    <message>
+      <source>EXPORT_STATUS</source>
+      <translation>Export operation status</translation>
+    </message>
+    <message>
+      <source>EXPORT_FINISHED</source>
+      <translation>Export finished successfully.</translation>
+    </message>
+    <message>
+      <source>EXPORT_FAILED</source>
+      <translation>Export failed.</translation>
+    </message>
+    <message>
+      <source>RESULT_SHAPE_NULL</source>
+      <translation>Export failed: result shape is null.</translation>
+    </message>
+    <message>
+      <source>OBJ_PREFIX</source>
+      <translation>HYDRO_</translation>
+    </message>
+  </context>
+  <context>
+    <name>HYDROGUI_ObstacleDlg</name>
+    <message>
+      <source>GET_SHAPE_FROM_FILE</source>
+      <translation>Get shape from file</translation>
+    </message>
+    <message>
+      <source>IMPORT_OBSTACLE_FROM_FILE</source>
+      <translation>Import obstacle</translation>
+    </message>
+    <message>
+      <source></source>
+      <translation></translation>
+    </message>
+    <message>
+      <source>FILE_NAME</source>
+      <translation>File name</translation>
+    </message>
+    <message>
+      <source>OBSTACLE_NAME</source>
+      <translation>Obstacle name</translation>
+    </message>
+    <message>
+      <source>NAME</source>
+      <translation>Name</translation>
+    </message>
+    <message>
+      <source>MODE</source>
+      <translation>Mode</translation>
+    </message>
+    <message>
+      <source>CREATE_NEW_OBSTACLE</source>
+      <translation>Create new</translation>
+    </message>
+    <message>
+      <source>MODIFY_OBSTACLE</source>
+      <translation>Modify</translation>
+    </message>
+    <message>
+      <source>OBSTACLE_TO_EDIT</source>
+      <translation>Obstacle to edit</translation>
+    </message>
+    <message>
+      <source>OBSTACLE</source>
+      <translation>Obstacle</translation>
+    </message>
+  </context>
+
 </TS>
index 49772fd85e7c3cd5e882a69f4ba673403d7303de..a447b9e6ffd6cb512da5ff41f27130b8f5fa5269 100644 (file)
@@ -1,2 +1,88 @@
 
-ADD_CUSTOM_TARGET( HYDROData.py DEPENDS HYDROData.sip COMMAND ../../../HYDRO_SRC/src/HYDROPy/configure.py )
+include(../../CMake/UsePyQT4EXT.cmake)
+
+# --- options ---
+
+# additional include directories
+INCLUDE_DIRECTORIES(
+  ${CAS_INCLUDE_DIRS}
+  ${QT_INCLUDES}
+  ${SIP_INCLUDE_DIR}
+  ${PYTHON_INCLUDE_DIRS}
+  ${CMAKE_CURRENT_SOURCE_DIR}
+  ${PROJECT_SOURCE_DIR}/src/HYDROData
+)
+
+# additional preprocessor / compiler flags
+ADD_DEFINITIONS(
+  ${QT_DEFINITIONS}
+  ${CAS_DEFINITIONS}
+  ${PYTHON_DEFINITIONS}
+)
+
+# libraries to link to
+SET(_link_LIBRARIES
+  ${PYTHON_LIBRARIES}
+  HYDROData
+) 
+
+# --- resources ---
+
+# sip files / to be processed by sip
+
+# TODO: fix the PYQT4_WRAP_SIP and uncomment
+# SET(_sip_files
+#   HYDROData.sip
+#   HYDROData_Entity.sip
+#   HYDROData_Object.sip
+#   HYDROData_ArtificialObject.sip
+#   HYDROData_NaturalObject.sip
+#   HYDROData_Image.sip
+#   HYDROData_Polyline.sip
+#   HYDROData_Bathymetry.sip
+#   HYDROData_ImmersibleZone.sip
+#   HYDROData_Zone.sip
+#   HYDROData_Region.sip
+#   HYDROData_CalculationCase.sip
+#   HYDROData_Document.sip
+# )
+
+# workaround while PYQT4_WRAP_SIP is not corrected
+SET(_sip_files
+  HYDROData.sip
+)
+
+SET(_sip_files2
+  HYDROData_Entity.sip
+  HYDROData_Object.sip
+  HYDROData_ArtificialObject.sip
+  HYDROData_NaturalObject.sip
+  HYDROData_Image.sip
+  HYDROData_Polyline.sip
+  HYDROData_Bathymetry.sip
+  HYDROData_ImmersibleZone.sip
+  HYDROData_Zone.sip
+  HYDROData_Region.sip
+  HYDROData_CalculationCase.sip
+  HYDROData_Document.sip
+)
+
+# --- sources ---
+
+# sources / sip wrappings
+PYQT4_WRAP_SIP_EXT(_sip_SOURCES ${_sip_files})
+
+# sources / to compile
+SET(HYDROPy_SOURCES ${_sip_SOURCES} ${_sip_files2})
+
+# --- rules ---
+
+ADD_LIBRARY(HYDROPy ${HYDROPy_SOURCES})
+TARGET_LINK_LIBRARIES(HYDROPy ${_link_LIBRARIES})
+INSTALL(TARGETS HYDROPy EXPORT ${PROJECT_NAME}TargetGroup DESTINATION ${SALOME_INSTALL_LIBS})
+
+IF(WIN32)
+  SET_TARGET_PROPERTIES(HYDROPy PROPERTIES SUFFIX ".pyd" DEBUG_OUTPUT_NAME HYDROPy_d RELEASE_OUTPUT_NAME HYDROPy)
+ELSE()
+  SET_TARGET_PROPERTIES(HYDROPy PROPERTIES PREFIX "")
+ENDIF()
diff --git a/src/HYDROPy/HYDROData.py.in b/src/HYDROPy/HYDROData.py.in
deleted file mode 100644 (file)
index a5f37ad..0000000
+++ /dev/null
@@ -1,60 +0,0 @@
-# Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-#
-# 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.
-#
-# 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
-#
-
-from PyQt4 import pyqtconfig
-
-# These are installation specific values created when HYDROData was configured.
-# The following line will be replaced when this template is used to create
-# the final configuration module.
-# @SIP_CONFIGURATION@
-
-class Configuration(pyqtconfig.Configuration):
-    """The class that represents HYDROData configuration values.
-    """
-    def __init__(self, sub_cfg=None):
-        """Initialise an instance of the class.
-
-        sub_cfg is the list of sub-class configurations.  It should be None
-        when called normally.
-        """
-        # This is all standard code to be copied verbatim except for the
-        # name of the module containing the super-class.
-        if sub_cfg:
-            cfg = sub_cfg
-        else:
-            cfg = []
-
-        cfg.append(_pkg_config)
-
-        pyqtconfig.Configuration.__init__(self, cfg)
-
-class HYDRODataModuleMakefile(pyqtconfig.QtGuiModuleMakefile):
-    """The Makefile class for modules that %Import HYDROData.
-    """
-    def finalise(self):
-        """Finalise the macros.
-        """
-        # Make sure our C++ library is linked.
-        self.extra_libs.append("HYDROData")
-
-        # Let the super-class do what it needs to.
-        pyqtconfig.QtGuiModuleMakefile.finalise(self)
\ No newline at end of file
index c4c8ca3dc3bbc1a3316f04b6286dde71d6e9ed8a..3166f0504033079551c1281633b3c8cbbd2944e8 100644 (file)
@@ -24,8 +24,7 @@ CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
 //
 
 
-%Module(name=HYDROData, version=1)
-
+%Module HYDROPy
 
 %Copying
 Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
@@ -50,7 +49,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
 See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 %End
 
-%Import QtGui/QtGuimod.sip
+%Import QtGuimod.sip
 
 %Include HYDROData_Entity.sip
 %Include HYDROData_Object.sip
@@ -62,7 +61,7 @@ See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 %Include HYDROData_ImmersibleZone.sip
 %Include HYDROData_Zone.sip
 %Include HYDROData_Region.sip
-%Include HYDROData_Calculation.sip
+%Include HYDROData_CalculationCase.sip
 
 %Include HYDROData_Document.sip
 
index f26ec885a553c5b853f647e335073d58263659f5..abeab659e8840347ae336df4a66dcfe753993b97 100644 (file)
@@ -22,6 +22,7 @@
 
 %ExportedHeaderCode
 #include <HYDROData_Bathymetry.h>
+#include <gp_XY.hxx>
 #include <gp_XYZ.hxx>
 %End
 
@@ -160,6 +161,7 @@ public:
     sipRes = convertToPythonAltitudeList( aPoints );
     
   %End
+
   /**
    * Remove all altitude points.
    */
@@ -171,6 +173,16 @@ public:
    * \return altitude value
    */
   double           GetAltitudeForPoint( const QPointF& thePoint ) const;
+  %MethodCode
+  
+    // The C++ API gets the gp_XY object, we convert it from QPointF.
+    gp_XY aPoint( a0->x(), a0->y() );
+    
+    Py_BEGIN_ALLOW_THREADS
+    sipRes = sipSelfWasArg ? sipCpp->HYDROData_Bathymetry::GetAltitudeForPoint( aPoint ) : 
+                             sipCpp->GetAltitudeForPoint( aPoint );
+    Py_END_ALLOW_THREADS
+  %End
 
 
 public:
diff --git a/src/HYDROPy/HYDROData_Calculation.sip b/src/HYDROPy/HYDROData_Calculation.sip
deleted file mode 100644 (file)
index 18264de..0000000
+++ /dev/null
@@ -1,168 +0,0 @@
-// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-//
-// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-//
-// 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.
-//
-// 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
-//
-
-%ExportedHeaderCode
-#include <HYDROData_Calculation.h>
-%End
-
-class HYDROData_Calculation : HYDROData_Entity
-{
-
-%TypeHeaderCode
-#include <HYDROData_Calculation.h>
-%End
-
-%ConvertToSubClassCode
-    switch ( sipCpp->GetKind() )
-    {
-      case KIND_CALCULATION:
-        sipClass = sipClass_HYDROData_Calculation;
-        break;
-
-      default:
-        // We don't recognise the type.
-        sipClass = NULL;
-    }
-%End
-
-public:      
-
-  /**
-   * Split reference geometry objects to non-intersected regions.
-   */
-  void SplitGeometryObjects();
-
-  /**
-   * Returns number of geometry objects for calculation case.
-   */
-  int NbGeometryObjects() const;
-
-  /**
-   * dd new one geometry object for calculation case.
-   */
-  void AddGeometryObject( HYDROData_Object theRegion ) [void (const Handle_HYDROData_Object&)];
-  %MethodCode
-
-    Handle(HYDROData_Object) aGeomObj =
-      Handle(HYDROData_Object)::DownCast( createHandle( a0 ) );
-    if ( !aGeomObj.IsNull() )
-    {
-      Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Calculation::AddGeometryObject( aGeomObj ) : 
-                      sipCpp->AddGeometryObject( aGeomObj );
-      Py_END_ALLOW_THREADS
-    }
-
-  %End
-
-  /**
-   * Returns all geometry objects of calculation case.
-   */
-  //HYDROData_SequenceOfObjects GetGeometryObjects() const;
-
-  /**
-   * Removes all geometry objects from calculation case.
-   */
-  void RemoveGeometryObjects();
-
-
-  /**
-   * Add new one region for calculation case.
-   * The new region is added into the list of reference regions.
-   */
-  HYDROData_Region AddNewRegion() [Handle_HYDROData_Region ()];
-  %MethodCode
-
-    Handle(HYDROData_Region) aNewRegion;
-    
-    Py_BEGIN_ALLOW_THREADS
-    aNewRegion = sipSelfWasArg ? sipCpp->HYDROData_Calculation::AddNewRegion() : 
-                                 sipCpp->AddNewRegion();
-    Py_END_ALLOW_THREADS
-    
-    sipRes = (HYDROData_Region*)createPointer( aNewRegion );
-
-  %End
-
-
-  /**
-   * Add new one reference region for calculation case.
-   */
-  void AddRegion( HYDROData_Region theRegion ) [void (const Handle_HYDROData_Region&)];
-  %MethodCode
-
-    Handle(HYDROData_Region) aRegion =
-      Handle(HYDROData_Region)::DownCast( createHandle( a0 ) );
-    if ( !aRegion.IsNull() )
-    {
-      Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Calculation::AddRegion( aRegion ) : 
-                      sipCpp->AddRegion( aRegion );
-      Py_END_ALLOW_THREADS
-    }
-
-  %End
-
-  /**
-   * Returns all reference regions of calculation case.
-   */
-  //void HYDROData_SequenceOfObjects GetRegions() const;
-
-  /**
-   * Removes reference region from calculation case.
-   */
-  void RemoveRegion( HYDROData_Region theRegion ) [void (const Handle_HYDROData_Region&)];
-  %MethodCode
-
-    Handle(HYDROData_Region) aRegion =
-      Handle(HYDROData_Region)::DownCast( createHandle( a0 ) );
-    if ( !aRegion.IsNull() )
-    {
-      Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Calculation::RemoveRegion( aRegion ) : 
-                      sipCpp->RemoveRegion( aRegion );
-      Py_END_ALLOW_THREADS
-    }
-
-  %End
-
-  /**
-   * Removes all reference regions from calculation case.
-   */
-  void RemoveRegions();
-
-
-protected:
-
-  /**
-   * Creates new object in the internal data structure. Use higher level objects 
-   * to create objects with real content.
-   */
-  HYDROData_Calculation();
-
-  /**
-   * Destructs properties of the object and object itself, removes it from the document.
-   */
-  ~HYDROData_Calculation();
-};
-
-
diff --git a/src/HYDROPy/HYDROData_CalculationCase.sip b/src/HYDROPy/HYDROData_CalculationCase.sip
new file mode 100644 (file)
index 0000000..affe773
--- /dev/null
@@ -0,0 +1,64 @@
+// Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
+//
+// Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
+// CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
+//
+// 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.
+//
+// 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
+//
+
+%ExportedHeaderCode
+#include <HYDROData_CalculationCase.h>
+%End
+
+class HYDROData_CalculationCase : HYDROData_Entity
+{
+
+%TypeHeaderCode
+#include <HYDROData_CalculationCase.h>
+%End
+
+%ConvertToSubClassCode
+    switch ( sipCpp->GetKind() )
+    {
+      case KIND_CALCULATION:
+        sipClass = sipClass_HYDROData_CalculationCase;
+        break;
+
+      default:
+        // We don't recognise the type.
+        sipClass = NULL;
+    }
+%End
+
+public:      
+
+
+protected:
+
+  /**
+   * Creates new object in the internal data structure. Use higher level objects 
+   * to create objects with real content.
+   */
+  HYDROData_CalculationCase();
+
+  /**
+   * Destructs properties of the object and object itself, removes it from the document.
+   */
+  ~HYDROData_CalculationCase();
+};
+
+
index 539d91cb03d7c3ca93faf1fac213067b6fb7d2f1..2cbfbbc715def25c2dd6ddf53c540ed5799eaee1 100644 (file)
@@ -39,7 +39,7 @@ enum Data_DocError {
   DocError_UnknownProblem ///< problem has unknown nature
 };
 
-class HYDROData_Document
+class HYDROData_Document 
 {
 %TypeHeaderCode
 #include <HYDROData_Document.h>
@@ -84,7 +84,7 @@ class HYDROData_Document
       }
       case KIND_CALCULATION:
       {
-        aRes = new HYDROData_Calculation( *dynamic_cast<HYDROData_Calculation*>( theObject ) );
+        aRes = new HYDROData_CalculationCase( *dynamic_cast<HYDROData_CalculationCase*>( theObject ) );
         break;
       }
       case KIND_REGION:
index 20ab25cbe19efdff4dff711db6001e8d42669fad..e148402d38d1f60d1279feaefd2577fa8194adaa 100644 (file)
@@ -20,7 +20,6 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-
 %ExportedHeaderCode
 #include <HYDROData_Entity.h>
 %End
@@ -63,7 +62,7 @@ class HYDROData_Entity
         break;
         
       case KIND_CALCULATION:
-        sipClass = sipClass_HYDROData_Calculation;
+        sipClass = sipClass_HYDROData_CalculationCase;
         break;
 
       case KIND_REGION:
@@ -103,9 +102,8 @@ public:
 
   /**
    * Updates object state.
-   * \param theIsForce force reupdating of data object
    */
-  void Update(const bool theIsForce);
+  void Update();
 
   /**
    * Checks is object exists in the data structure.
index ca4ded28ee6a12c7223ea47dd03f6d688698a82d..33eceb9cdcc05829c0b6ce85455d30d65262a9b8 100644 (file)
@@ -63,188 +63,6 @@ public:
    */
   QImage                     Image();
 
-  /**
-   * Stores the image transformation
-   * \param theTrsf new transformation
-   */
-  void                       SetTrsf( const QTransform& theTrsf );
-
-  /**
-   * Returns the kept transformation, or "identity" if not yet stored
-   */
-  QTransform                 Trsf();
-
-  /**
-   * Stores the image transformation points (3 input + 3 output)
-   * \param thePointA input point A
-   * \param thePointB input point B
-   * \param thePointC input point C
-   * \param theLambertPointA output point A in Lambert93 coordinates
-   * \param theLambertPointB output point B in Lambert93 coordinates
-   * \param theLambertPointC output point C in Lambert93 coordinates
-   * \param theCartesianPointA output point A in Cartesian coordinates
-   * \param theCartesianPointB output point B in Cartesian coordinates
-   * \param theCartesianPointC output point C in Cartesian coordinates
-   */
-  void                       SetTrsfPoints( const QPoint& thePointA,
-                                            const QPoint& thePointB,
-                                            const QPoint& thePointC,
-                                            const QPointF& theLambertPointA,
-                                            const QPointF& theLambertPointB,
-                                            const QPointF& theLambertPointC,
-                                            const QPointF& theCartesianPointA,
-                                            const QPointF& theCartesianPointB,
-                                            const QPointF& theCartesianPointC );
-
-  /**
-   * Returns the image transformation points (3 input + 3 output)
-   * \param thePointA input point A
-   * \param thePointB input point B
-   * \param thePointC input point C
-   * \param theLambertPointA output point A in Lambert93 coordinates
-   * \param theLambertPointB output point B in Lambert93 coordinates
-   * \param theLambertPointC output point C in Lambert93 coordinates
-   * \param theCartesianPointA output point A in Cartesian coordinates
-   * \param theCartesianPointB output point B in Cartesian coordinates
-   * \param theCartesianPointC output point C in Cartesian coordinates
-   */
-  void                       TrsfPoints( QPoint& thePointA,
-                                         QPoint& thePointB,
-                                         QPoint& thePointC,
-                                         QPointF& theLambertPointA,
-                                         QPointF& theLambertPointB,
-                                         QPointF& theLambertPointC,
-                                         QPointF& theCartesianPointA,
-                                         QPointF& theCartesianPointB,
-                                         QPointF& theCartesianPointC ) const;
-
-  /**
-   * Returns true if the image has stored transformation points
-   */
-  bool                       HasTrsfPoints() const;
-
-  /**
-   * Stores the transformation mode (0 - Lambert93, 1 - Cartesian)
-   */
-  void                       SetTrsfMode(const int theMode);
-
-  /**
-   * Returns the transformation mode (0 - Lambert93, 1 - Cartesian)
-   */
-  int                        TrsfMode() const;
-
-
-  /**
-   * Returns the number of referenced images
-   * \return zero if there is no references
-   */
-  int                        NbReferences();
-
-  /**
-   * Appends reference to other image.
-   * \param theReferenced the image referenced by this
-   */
-  void AppendReference( HYDROData_Entity theReferenced ) [void (Handle_HYDROData_Entity)];
-  %MethodCode
-
-    Handle(HYDROData_Entity) aRefObj = createHandle( a0 );
-    if ( !aRefObj.IsNull() )
-    {
-      Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Image::AppendReference( aRefObj ) : 
-                      sipCpp->AppendReference( aRefObj );
-      Py_END_ALLOW_THREADS
-    }
-
-  %End
-
-  /**
-   * Returns reference by index.
-   * \param theIndex number of reference [0; NbReference)
-   * \returns the referenced image, or Null if index is invalid
-   */
-  HYDROData_Entity Reference( const int theIndex ) const [Handle_HYDROData_Entity (const int)];
-  %MethodCode
-
-    Handle(HYDROData_Entity) aRefObj;
-    
-    Py_BEGIN_ALLOW_THREADS
-    aRefObj = sipSelfWasArg ? sipCpp->HYDROData_Image::Reference( a0 ) : 
-                              sipCpp->Reference( a0 );
-    Py_END_ALLOW_THREADS
-    
-    sipRes = createPointer( aRefObj );
-  
-  %End
-
-  /**
-   * Updates reference by index. If index is one-bigger than \a NbReferences, 
-   * this method appends it to the end (NbReferences is incremented).
-   * \param theIndex number of reference [0; NbReference]
-   * \param theReferenced the image referenced by this
-   */
-  void ChangeReference( const int theIndex, HYDROData_Entity theReferenced ) [void (const int, Handle_HYDROData_Entity)];
-  %MethodCode
-
-    Handle(HYDROData_Entity) aRefObj = createHandle( a1 );
-    if ( !aRefObj.IsNull() )
-    {
-      Py_BEGIN_ALLOW_THREADS
-      sipSelfWasArg ? sipCpp->HYDROData_Image::ChangeReference( a0, aRefObj ) : 
-                      sipCpp->ChangeReference( a0, aRefObj );
-      Py_END_ALLOW_THREADS
-    }
-  
-  %End
-
-  /**
-   * Removes reference by index
-   * \param theIndex number of reference [0; NbReference)
-   */
-  void                       RemoveReference( const int theIndex );
-
-  /**
-   * Removes all references.
-   */
-  void                       ClearReferences();
-
-  /**
-   * Stores the operator name
-   * \param theOpName name of the operator that must be executed for image update
-   */
-  void                       SetOperatorName( const QString theOpName );
-
-  /**
-   * Returns the operator name
-   * \returns the name of the operator that must be executed for image update
-   */
-  QString                    OperatorName();
-
-  /**
-   * Stores the operator arguments
-   * \param theArgs array that stores the operator arguments, needed for execution
-   */
-  void                       SetArgs( const QByteArray& theArgs );
-
-  /**
-   * Returns the operator arguments
-   * \returns array that stores the operator arguments, needed for execution
-   */
-  QByteArray                 Args();
-  
-  /**
-   * Sets the "MustBeUpdated" flag: if image is depended on updated features.
-   * \param theFlag is true for images that must be updated, false for up-to-date
-   */
-  void                       MustBeUpdated( bool theFlag );
-
-  /**
-   * Returns the "MustBeUpdated" flag: is image must be recomputed or not
-   * \returns false if image is up to date
-   */
-  bool                       MustBeUpdated();
-
-
 protected:
 
   /**
index 85322fc900db3498964b16e5f869a69db469cb51..c93dd51d66f89e058a37377b3b0458512f4db81c 100644 (file)
@@ -20,7 +20,6 @@
 // See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
 //
 
-
 %ExportedHeaderCode
 #include <HYDROData_Object.h>
 %End
index 0798d97e8f5104f0e267a904945d92cc5b0c3cdb..6ab037879cf361cb25c5868ba32103e8a42be58b 100644 (file)
 #include <HYDROData_Polyline.h>
 %End
 
-struct PolylineSection
+class HYDROData_Polyline : HYDROData_Object
 {
+
 %TypeHeaderCode
 #include <HYDROData_Polyline.h>
 %End
 
-  enum SectionType{ SECTION_POLYLINE = 0, SECTION_SPLINE = 1 };
-
-  PolylineSection();
-  
-  SectionType                 myType;
-  bool                        myIsClosed;
-  QList<double>               myCoords;
-
-  QString                     mySectionName
-  {
-    %GetCode
-        sipPy = PyString_FromString( TCollection_AsciiString( sipCpp->mySectionName ).ToCString() );
-    %End
-
-    %SetCode
-        char* ptr;
-
-        if ( ( ptr = PyString_AsString( sipPy ) ) == NULL )
-        {
-          sipErr = 1;
-        }
-        else
-        {
-          sipCpp->mySectionName = TCollection_ExtendedString( ptr );
-        }
-    %End
-  };
-};
-
-class HYDROData_Polyline : HYDROData_Object
-{
-
 %ConvertToSubClassCode
     switch ( sipCpp->GetKind() )
     {
@@ -75,24 +44,8 @@ class HYDROData_Polyline : HYDROData_Object
     }
 %End
 
-public:
-
-  typedef QList<PolylineSection> PolylineData;
-
 public:      
 
-  /**
-   * Replace current polyline data by new sections list
-   * \param theSections the sections list
-   */
-  void SetPolylineData( const PolylineData& theSections );
-
-  /**
-   * Return polyline data
-   * \return polyline section list
-   */
-  PolylineData GetPolylineData();
-   
   /**
    * Return polyline dimension
    * \return polyline dimension (2 or 3)
diff --git a/src/HYDROPy/configure.py b/src/HYDROPy/configure.py
deleted file mode 100644 (file)
index 0bfa936..0000000
+++ /dev/null
@@ -1,111 +0,0 @@
-# Copyright (C) 2007-2013  CEA/DEN, EDF R&D, OPEN CASCADE
-#
-# Copyright (C) 2003-2007  OPEN CASCADE, EADS/CCR, LIP6, CEA/DEN,
-# CEDRAT, EDF R&D, LEG, PRINCIPIA R&D, BUREAU VERITAS
-#
-# 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.
-#
-# 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
-#
-
-import os
-import sipconfig
-from PyQt4 import pyqtconfig
-
-# Get the PyQt configuration information.
-config = pyqtconfig.Configuration()
-
-src_path = '.'
-installs_path = '.'
-
-# Set enviroment for make file
-
-if 'HYDRO_SRC_DIR' in os.environ :
-  config._macros[ 'INCDIR' ] += ' ' + os.path.join( os.environ[ 'HYDRO_SRC_DIR' ], 'src/HYDROData' )
-  src_path = os.path.join( os.environ[ 'HYDRO_SRC_DIR' ], 'src/HYDROPy' )
-
-if 'CASROOT' in os.environ :
-  config._macros[ 'INCDIR' ] += ' ' + os.path.join( os.environ[ 'CASROOT' ], 'inc' )
-
-if 'HYDRO_ROOT_DIR' in os.environ :
-  config._macros[ 'LIBDIR' ] += ' ' + os.path.join( os.environ[ 'HYDRO_ROOT_DIR' ], 'lib/salome' )
-  installs_path = os.path.join( os.environ[ 'HYDRO_ROOT_DIR' ], 'lib/python' + os.environ[ 'PYTHON_VERSION' ] + '/site-packages/salome' )
-  
-config._macros[ 'DEFINES' ] += ' HAVE_CONFIG_H HAVE_LIMITS_H HAVE_WOK_CONFIG_H OCC_CONVERT_SIGNALS'
-
-# The name of the SIP build file generated by SIP and used by the build
-# system.
-build_file = "HYDROData.sbf"
-
-# Get the extra SIP flags needed by the imported PyQt modules.  Note that
-# this normally only includes those flags (-x and -t) that relate to SIP's
-# versioning system.
-pyqt_sip_flags = config.pyqt_sip_flags
-
-# Run SIP to generate the code.  Note that we tell SIP where to find the qt
-# module's specification files using the -I flag.
-os.system( " ".join([
-    config.sip_bin,
-     '-s', '.cxx',
-     '-c', ".",
-     '-b', build_file,
-     '-I', config.pyqt_sip_dir,
-     pyqt_sip_flags,
-     os.path.join( src_path, 'HYDROData.sip' )
-     ]))
-
-
-# We are going to install the SIP specification file for this module and
-# its configuration module.
-installs = []
-installs.append( [ 'HYDROData.py', installs_path ] )
-
-# Create the Makefile.  The QtGuiModuleMakefile class provided by the
-# pyqtconfig module takes care of all the extra preprocessor, compiler and
-# linker flags needed by the Qt library.
-makefile = pyqtconfig.QtGuiModuleMakefile(
-    configuration=config,
-    build_file=build_file,
-    install_dir=installs_path,
-    installs=installs,
-    makefile='Makefile'
-)
-
-# Add the library we are wrapping.  The name doesn't include any platform
-# specific prefixes or extensions (e.g. the "lib" prefix on UNIX, or the
-# ".dll" extension on Windows).
-makefile.extra_libs = [ 'HYDROData' ]
-
-# Generate the Makefile itself.
-makefile.generate()
-
-# Now we create the configuration module.  This is done by merging a Python
-# dictionary (whose values are normally determined dynamically) with a
-# (static) template.
-content = {
-    # Publish where the SIP specifications for this module will be
-    # installed.
-    'HYDROData_sip_dir':    installs_path,
-
-    # Publish the set of SIP flags needed by this module.  As these are the
-    # same flags needed by the qt module we could leave it out, but this
-    # allows us to change the flags at a later date without breaking
-    # scripts that import the configuration module.
-    'HYDROData_sip_flags':  pyqt_sip_flags
-}
-
-# This creates the HYDROData.py module from the HYDROData.py.in
-# template and the dictionary.
-sipconfig.create_config_module( 'HYDROData.py', os.path.join( src_path, 'HYDROData.py.in' ), content )
\ No newline at end of file