mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2025-01-15 00:30:33 +05:00
Merge remote branch 'origin/SKV_CCreator_from_HYDRO' into asl/hydro_porting_741
This commit is contained in:
commit
8f9b04087c
@ -67,20 +67,7 @@ OPTION(SALOME_BUILD_TESTS "Build SALOME tests" ON)
|
||||
OPTION(SALOME_BUILD_GUI "Enable GUI" ON)
|
||||
CMAKE_DEPENDENT_OPTION(SALOME_GEOM_USE_OPENCV "Enable shape recognition from picture" OFF
|
||||
"SALOME_BUILD_GUI" OFF)
|
||||
CMAKE_DEPENDENT_OPTION(SALOME_GEOM_BUILD_CC "Enable curve creator (experimental)" OFF
|
||||
"SALOME_BUILD_GUI" OFF)
|
||||
MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_GEOM_USE_OPENCV SALOME_GEOM_BUILD_CC)
|
||||
|
||||
# Debug options (!!! FOR DEVELOPERS ONLY !!! TO BE REMOVED LATER !!!)
|
||||
IF(CMAKE_BUILD_TYPE MATCHES "^Debug$")
|
||||
CMAKE_DEPENDENT_OPTION(SALOME_GEOM_DEBUG_CC "Debug curve creator" OFF
|
||||
"SALOME_GEOM_BUILD_CC" OFF)
|
||||
MARK_AS_ADVANCED(SALOME_GEOM_DEBUG_CC)
|
||||
|
||||
IF(SALOME_GEOM_DEBUG_CC)
|
||||
ADD_DEFINITIONS(-DDEBUG_CURVE_CREATOR)
|
||||
ENDIF(SALOME_GEOM_DEBUG_CC)
|
||||
ENDIF()
|
||||
MARK_AS_ADVANCED(SALOME_BUILD_GUI SALOME_GEOM_USE_OPENCV)
|
||||
|
||||
# Prerequisites
|
||||
# =============
|
||||
@ -241,7 +228,7 @@ SET(_${PROJECT_NAME}_exposed_targets
|
||||
)
|
||||
IF(SALOME_BUILD_GUI)
|
||||
LIST(APPEND _${PROJECT_NAME}_exposed_targets
|
||||
AdvancedGUI BasicGUI BlocksGUI BooleanGUI BuildGUI DisplayGUI DlgRef EntityGUI GEOMBase
|
||||
AdvancedGUI BasicGUI BlocksGUI BooleanGUI BuildGUI DisplayGUI DlgRef CurveCreator EntityGUI GEOMBase
|
||||
GEOMFiltersSelection GEOM GEOMToolsGUI GenerationGUI GroupGUI Material MeasureGUI GEOMObject
|
||||
OperationGUI PrimitiveGUI RepairGUI TransformationGUI ImportExportGUI
|
||||
)
|
||||
@ -253,12 +240,6 @@ IF(SALOME_GEOM_USE_OPENCV)
|
||||
)
|
||||
ENDIF(SALOME_GEOM_USE_OPENCV)
|
||||
|
||||
IF(SALOME_GEOM_BUILD_CC)
|
||||
LIST(APPEND _${PROJECT_NAME}_exposed_targets
|
||||
CurveCreator
|
||||
)
|
||||
ENDIF(SALOME_GEOM_BUILD_CC)
|
||||
|
||||
# Add all targets to the build-tree export set
|
||||
EXPORT(TARGETS ${_${PROJECT_NAME}_exposed_targets}
|
||||
FILE ${PROJECT_BINARY_DIR}/${PROJECT_NAME}Targets.cmake)
|
||||
|
@ -27,15 +27,6 @@ SET(SUBDIRS_COMMON
|
||||
AdvancedEngine OCC2VTK VTKExport
|
||||
)
|
||||
|
||||
##
|
||||
# Curve creator
|
||||
##
|
||||
IF(SALOME_GEOM_BUILD_CC)
|
||||
SET(SUBDIRS_CC
|
||||
CurveCreator
|
||||
)
|
||||
ENDIF()
|
||||
|
||||
##
|
||||
# OPENCV
|
||||
##
|
||||
@ -52,7 +43,7 @@ IF(SALOME_BUILD_GUI)
|
||||
SET(SUBDIRS_GUI
|
||||
OBJECT DlgRef GEOMFiltersSelection Material GEOMGUI
|
||||
GEOMBase GEOMToolsGUI DisplayGUI BasicGUI PrimitiveGUI GenerationGUI
|
||||
EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI
|
||||
CurveCreator EntityGUI BuildGUI BooleanGUI TransformationGUI OperationGUI
|
||||
RepairGUI MeasureGUI GroupGUI BlocksGUI AdvancedGUI ImportExportGUI
|
||||
GEOM_SWIG_WITHIHM
|
||||
)
|
||||
|
@ -57,9 +57,8 @@ IF(SALOME_BUILD_GUI)
|
||||
# header files / to be processed by moc
|
||||
SET(_moc_HEADERS
|
||||
CurveCreator_NewSectionDlg.h
|
||||
CurveCreator_NewPointDlg.h
|
||||
CurveCreator_TableView.h
|
||||
CurveCreator_TreeView.h
|
||||
# CurveCreator_UndoOptsDlg.h
|
||||
CurveCreator_Widget.h
|
||||
)
|
||||
ENDIF(SALOME_BUILD_GUI)
|
||||
@ -68,13 +67,15 @@ ENDIF(SALOME_BUILD_GUI)
|
||||
SET(_other_HEADERS
|
||||
CurveCreator.hxx
|
||||
CurveCreator_Curve.hxx
|
||||
CurveCreator_CurveEditor.hxx
|
||||
CurveCreator_Diff.hxx
|
||||
CurveCreator_Displayer.hxx
|
||||
CurveCreator_ICurve.hxx
|
||||
CurveCreator_Listener.hxx
|
||||
CurveCreator_Macro.hxx
|
||||
CurveCreator_Operation.hxx
|
||||
CurveCreator_PosPoint.hxx
|
||||
CurveCreator_Section.hxx
|
||||
CurveCreator_UtilsICurve.hxx
|
||||
CurveCreator_Utils.hxx
|
||||
)
|
||||
|
||||
# header files / to install
|
||||
@ -90,17 +91,17 @@ ENDIF(SALOME_BUILD_GUI)
|
||||
# sources / static
|
||||
SET(_other_SOURCES
|
||||
CurveCreator_Curve.cxx
|
||||
CurveCreator_CurveEditor.cxx
|
||||
CurveCreator_Diff.cxx
|
||||
CurveCreator_ICurve.cxx
|
||||
CurveCreator_Displayer.cxx
|
||||
CurveCreator_Operation.cxx
|
||||
CurveCreator_Utils.cxx
|
||||
CurveCreator_UtilsICurve.cxx
|
||||
)
|
||||
IF(SALOME_BUILD_GUI)
|
||||
LIST(APPEND _other_SOURCES
|
||||
CurveCreator_NewPointDlg.cxx
|
||||
CurveCreator_NewSectionDlg.cxx
|
||||
CurveCreator_TableView.cxx
|
||||
CurveCreator_TreeView.cxx
|
||||
# CurveCreator_UndoOptsDlg.cxx
|
||||
CurveCreator_Widget.cxx
|
||||
)
|
||||
ENDIF(SALOME_BUILD_GUI)
|
||||
|
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -24,29 +24,30 @@
|
||||
#define _CurveCreator_HeaderFile
|
||||
|
||||
#include <deque>
|
||||
#include <map>
|
||||
#include <list>
|
||||
|
||||
struct CurveCreator_Section;
|
||||
struct CurveCreator_PosPoint;
|
||||
|
||||
namespace CurveCreator
|
||||
{
|
||||
|
||||
//! Dimension of the curve
|
||||
enum Dimension
|
||||
{
|
||||
Dim2d = 2,
|
||||
Dim3d = 3
|
||||
};
|
||||
|
||||
//! Type of the section
|
||||
enum Type
|
||||
{
|
||||
Polyline,
|
||||
BSpline
|
||||
};
|
||||
|
||||
//! Points coordinates
|
||||
typedef float TypeCoord;
|
||||
|
||||
/** List of coordinates in format depends on section dimension:
|
||||
* 2D: [x1, y1, x2, y2, x3, y3, ..]
|
||||
* 3D: [x1, y1, z1, x2, y2, z2, x3, y3, z3, ..]
|
||||
*/
|
||||
typedef std::deque<TypeCoord> Coordinates;
|
||||
|
||||
//! List of sections
|
||||
typedef std::deque<CurveCreator_Section *> Sections;
|
||||
|
||||
// List of positioned points (points with coordinates)
|
||||
typedef std::list<CurveCreator_PosPoint*> PosPointsList;
|
||||
//! Map of sections with positioned points
|
||||
typedef std::map<int,PosPointsList> SectionsMap;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -23,23 +23,32 @@
|
||||
#ifndef _CurveCreator_Curve_HeaderFile
|
||||
#define _CurveCreator_Curve_HeaderFile
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
#include "CurveCreator_ICurve.hxx"
|
||||
#include "CurveCreator_Macro.hxx"
|
||||
#include "CurveCreator_Operation.hxx"
|
||||
|
||||
class CurveCreator_Section;
|
||||
class CurveCreator_Listener;
|
||||
#include "CurveCreator_Macro.hxx"
|
||||
#include "CurveCreator.hxx"
|
||||
#include "CurveCreator_Diff.hxx"
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
|
||||
struct CurveCreator_Section;
|
||||
class CurveCreator_Displayer;
|
||||
class AIS_Shape;
|
||||
class Handle_AIS_InteractiveObject;
|
||||
|
||||
/**
|
||||
* The CurveCreator_Curve object is represented as one or more sets of
|
||||
* connected points; thus CurveCreator_Curve object can contain several
|
||||
* not connected curves (polylines or b-splines), each such curve has two
|
||||
* only ends <EFBFBD> start and end points <EFBFBD> in other words non-manifold curves
|
||||
* only ends "start and end points" in other words non-manifold curves
|
||||
* are not supported.
|
||||
*/
|
||||
class CURVECREATOR_EXPORT CurveCreator_Curve : public CurveCreator_ICurve
|
||||
{
|
||||
protected:
|
||||
typedef std::list<CurveCreator_Diff> ListDiff;
|
||||
|
||||
public:
|
||||
//! Constructor of the curve.
|
||||
/** The dimension is explicitly specified in the constructor
|
||||
@ -47,15 +56,273 @@ public:
|
||||
*/
|
||||
CurveCreator_Curve(const CurveCreator::Dimension theDimension);
|
||||
|
||||
/** Add points to the specified section (or last section
|
||||
//! Destructor.
|
||||
virtual ~CurveCreator_Curve();
|
||||
|
||||
//! Get the dimension.
|
||||
virtual CurveCreator::Dimension getDimension() const;
|
||||
|
||||
//! Return unique section name
|
||||
virtual std::string getUniqSectionName() const;
|
||||
|
||||
//! Set curve creator Displayer object
|
||||
virtual void setDisplayer( CurveCreator_Displayer* theDisplayer );
|
||||
|
||||
//! Return curve creator Displayer object
|
||||
CurveCreator_Displayer* getDisplayer();
|
||||
|
||||
//! 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)
|
||||
*/
|
||||
virtual void setUndoDepth(const int theDepth = -1);
|
||||
|
||||
//! Get depth of undo operations.
|
||||
virtual int getUndoDepth() const;
|
||||
|
||||
virtual void startOperation();
|
||||
virtual void finishOperation();
|
||||
|
||||
/**
|
||||
* This method converts the point index to the index in
|
||||
* an array of coordinates.
|
||||
*/
|
||||
virtual int toICoord(const int theIPnt) const;
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual bool moveSectionInternal(const int theISection,
|
||||
const int theNewIndex);
|
||||
//! Move section to new position in list
|
||||
virtual bool moveSection(const int theISection,
|
||||
const int theNewIndex);
|
||||
|
||||
protected:
|
||||
/** This method updates all undo/redo information required to be updated
|
||||
* after curve modification operation. It returns false if undo/redo
|
||||
* is disabled and true otherwise.
|
||||
*/
|
||||
virtual bool addEmptyDiff();
|
||||
|
||||
public: // TODO: remove public
|
||||
void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
|
||||
protected: // TODO: remove public
|
||||
void redisplayCurve();
|
||||
|
||||
public:
|
||||
/************ Implementation of INTERFACE methods ************/
|
||||
|
||||
/***********************************************/
|
||||
/*** Undo/Redo methods ***/
|
||||
/***********************************************/
|
||||
|
||||
//! Get number of available undo operations
|
||||
virtual int getNbUndo() const;
|
||||
|
||||
//! Undo previous operation
|
||||
virtual bool undo();
|
||||
|
||||
//! Get number of available redo operations
|
||||
virtual int getNbRedo() const;
|
||||
|
||||
//! Redo last previously "undone" operation
|
||||
virtual bool redo();
|
||||
|
||||
|
||||
/***********************************************/
|
||||
/*** Section methods ***/
|
||||
/***********************************************/
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual bool clearInternal();
|
||||
//! Clear the polyline (remove all sections)
|
||||
virtual bool clear();
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual bool joinInternal( const std::list<int>& theSections );
|
||||
|
||||
//! Join list of sections to one section (join all if the list is empty)
|
||||
// The first section in the list is a leader, another sections are joined to it
|
||||
virtual bool join( const std::list<int>& theSections );
|
||||
|
||||
//! Get number of sections
|
||||
virtual int getNbSections() const;
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual int addSectionInternal( const std::string &theName,
|
||||
const CurveCreator::SectionType theType,
|
||||
const bool theIsClosed,
|
||||
const CurveCreator::Coordinates &thePoints);
|
||||
//! Add a new section.
|
||||
virtual int addSection( const std::string &theName,
|
||||
const CurveCreator::SectionType theType,
|
||||
const bool theIsClosed );
|
||||
//! Add a new section.
|
||||
virtual int addSection( const std::string &theName,
|
||||
const CurveCreator::SectionType theType,
|
||||
const bool theIsClosed,
|
||||
const CurveCreator::Coordinates &thePoints);
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual bool removeSectionInternal( const int theISection );
|
||||
//! Removes the given sections.
|
||||
virtual bool removeSection( const int theISection );
|
||||
|
||||
//! Get "closed" flag of the specified section
|
||||
virtual bool isClosed( const int theISection ) const;
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual bool setClosedInternal( const int theISection,
|
||||
const bool theIsClosed );
|
||||
/**
|
||||
* Set "closed" flag of the specified section (all sections if
|
||||
* \a theISection is -1).
|
||||
*/
|
||||
virtual bool setClosed( const int theISection,
|
||||
const bool theIsClosed );
|
||||
|
||||
//! Returns specifyed section name
|
||||
virtual std::string getSectionName( const int theISection ) const;
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual bool setSectionNameInternal( const int theISection,
|
||||
const std::string& theName );
|
||||
/** Set name of the specified section */
|
||||
virtual bool setSectionName( const int theISection,
|
||||
const std::string& theName );
|
||||
|
||||
//! Get type of the specified section
|
||||
virtual CurveCreator::SectionType getSectionType( const int theISection ) const;
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual bool setSectionTypeInternal( const int theISection,
|
||||
const CurveCreator::SectionType theType );
|
||||
/**
|
||||
* Set type of the specified section (or all sections
|
||||
* if \a theISection is -1).
|
||||
*/
|
||||
virtual void addPoints
|
||||
(const CurveCreator::Coordinates &thePoints, const int theISection = -1);
|
||||
virtual bool setSectionType( const int theISection,
|
||||
const CurveCreator::SectionType theType );
|
||||
|
||||
friend class CurveCreator_CurveEditor;
|
||||
friend class CurveCreator_Operation;
|
||||
|
||||
/***********************************************/
|
||||
/*** Point methods ***/
|
||||
/***********************************************/
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual bool addPointsInternal( const CurveCreator::SectionsMap &theSectionsMap );
|
||||
/**
|
||||
* Add one point to the specified section starting from the given theIPnt index
|
||||
* (or at the end of points if \a theIPnt is -1).
|
||||
*/
|
||||
virtual bool addPoints( const CurveCreator::Coordinates &theCoords,
|
||||
const int theISection,
|
||||
const int theIPnt = -1 );
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual bool setPointInternal( const CurveCreator::SectionsMap &theSectionsMap );
|
||||
//! Set coordinates of specified point
|
||||
virtual bool setPoint( const int theISection,
|
||||
const int theIPnt,
|
||||
const CurveCreator::Coordinates& theNewCoords );
|
||||
|
||||
//! Set coordinates of specified points from different sections
|
||||
virtual bool setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
|
||||
const bool theIsToSaveDiff = true );
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual bool removePointsInternal( const SectionToPointList &thePoints );
|
||||
/** Remove point with given id */
|
||||
virtual bool removePoint( const int theISection, const int theIPnt = -1 );
|
||||
|
||||
//! Remove several points from different sections with given ids
|
||||
virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs);
|
||||
|
||||
//! Get coordinates of specified point
|
||||
virtual CurveCreator::Coordinates getPoint( const int theISection,
|
||||
const int theIPnt ) const;
|
||||
|
||||
/**
|
||||
* Get points of a section (the total points in Curve if theISection is equal to -1)..
|
||||
*/
|
||||
virtual CurveCreator::Coordinates getPoints( const int theISection = -1 ) const;
|
||||
|
||||
|
||||
/**
|
||||
* Get number of points in specified section or (the total number of points
|
||||
* in Curve if theISection is equal to -1).
|
||||
*/
|
||||
virtual int getNbPoints( const int theISection ) const;
|
||||
|
||||
/**
|
||||
* Set skip sorting flag. If the flag is true - points sorting will be skipped.
|
||||
*/
|
||||
virtual void setSkipSorting( const bool theIsToSkip );
|
||||
|
||||
/**
|
||||
* Indicates whether the points can be sorted.
|
||||
*/
|
||||
virtual bool canPointsBeSorted();
|
||||
|
||||
/**
|
||||
* Saves points coordinates difference.
|
||||
* \param theOldCoords the old points coordinates
|
||||
*/
|
||||
virtual void saveCoordDiff( const SectionToPointCoordsList &theOldCoords );
|
||||
|
||||
/***********************************************/
|
||||
/*** Presentation methods ***/
|
||||
/***********************************************/
|
||||
/**
|
||||
* Get the curve AIS object
|
||||
*/
|
||||
virtual Handle_AIS_InteractiveObject getAISObject( const bool theNeedToBuild = false ) const;
|
||||
|
||||
protected:
|
||||
/**
|
||||
* Removes the points from the section. It sortes the points and remove them
|
||||
* in the decreasing order
|
||||
* \param theSectionId a section index
|
||||
* \param thePointIds a list of section points
|
||||
*/
|
||||
bool removeSectionPoints( const int theSectionId,
|
||||
const std::list<int>& thePointIds );
|
||||
/**
|
||||
* Converts the list of pairs of section to point into map of a section to list of points
|
||||
* \param thePoints an source list
|
||||
* \param theConvPoints a converted map
|
||||
*/
|
||||
void convert( const SectionToPointList &thePoints,
|
||||
std::map<int, std::list<int> > &theConvPoints );
|
||||
|
||||
protected:
|
||||
virtual void constructAISObject();
|
||||
/**
|
||||
* Returns the section by the section index or NULL if the index is out of the section
|
||||
* list range
|
||||
* \param theSectionId the section index
|
||||
*/
|
||||
CurveCreator_Section* getSection( const int theSectionId ) const;
|
||||
|
||||
protected:
|
||||
bool mySkipSorting;
|
||||
|
||||
public:
|
||||
bool myIsLocked;
|
||||
CurveCreator::Sections mySections; //!< curve data
|
||||
CurveCreator::Dimension myDimension; //!< curve dimension
|
||||
CurveCreator_Displayer* myDisplayer; //!< curve displayer
|
||||
|
||||
private:
|
||||
|
||||
int myNbUndos;
|
||||
int myNbRedos;
|
||||
ListDiff::iterator myCurrenPos;
|
||||
ListDiff myListDiffs;
|
||||
int myUndoDepth;
|
||||
int myOpLevel;
|
||||
AIS_Shape* myAISShape; //!< AIS shape
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -1,511 +0,0 @@
|
||||
// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File: CurveCreator_CurveEditor.cxx
|
||||
// Author: Sergey KHROMOV
|
||||
|
||||
#include "CurveCreator_CurveEditor.hxx"
|
||||
|
||||
//=======================================================================
|
||||
// function: Constructor
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
CurveCreator_CurveEditor::CurveCreator_CurveEditor
|
||||
(CurveCreator_Curve* thePCurve)
|
||||
: myNbUndos (0),
|
||||
myNbRedos (0),
|
||||
myPCurve (thePCurve),
|
||||
myUndoDepth (-1),
|
||||
myOpLevel(0)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
if (myPCurve->isLocked()) {
|
||||
// This curve is locked by another editor. Invalid case.
|
||||
myPCurve = NULL;
|
||||
} else {
|
||||
// Lock the curve.
|
||||
myPCurve->myIsLocked = true;
|
||||
myCurrenPos = myListDiffs.end();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: Destructor
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
CurveCreator_CurveEditor::~CurveCreator_CurveEditor()
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Unlock the curve.
|
||||
myPCurve->myIsLocked = false;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getCurve
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
CurveCreator_Curve *CurveCreator_CurveEditor::getCurve() const
|
||||
{
|
||||
return myPCurve;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: isAttached
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
bool CurveCreator_CurveEditor::isAttached() const
|
||||
{
|
||||
return (myPCurve != NULL);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: undo
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::undo()
|
||||
{
|
||||
if (myNbUndos > 0) {
|
||||
myNbUndos--;
|
||||
myNbRedos++;
|
||||
myCurrenPos--;
|
||||
myCurrenPos->applyUndo(myPCurve);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: redo
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::redo()
|
||||
{
|
||||
if (myNbRedos > 0) {
|
||||
myCurrenPos->applyRedo(myPCurve);
|
||||
myCurrenPos++;
|
||||
myNbRedos--;
|
||||
myNbUndos++;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getNbUndo
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
int CurveCreator_CurveEditor::getNbUndo() const
|
||||
{
|
||||
return myNbUndos;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getNbRedo
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
int CurveCreator_CurveEditor::getNbRedo() const
|
||||
{
|
||||
return myNbRedos;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setUndoDepth
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::setUndoDepth(const int theDepth)
|
||||
{
|
||||
if (theDepth == 0) {
|
||||
// Reset all undo/redo data.
|
||||
myNbUndos = 0;
|
||||
myNbRedos = 0;
|
||||
myListDiffs.clear();
|
||||
myCurrenPos = myListDiffs.end();
|
||||
myUndoDepth = 0;
|
||||
} else if (theDepth == -1) {
|
||||
// There is nothing to do as the depth become unlimited.
|
||||
myUndoDepth = -1;
|
||||
} else if (theDepth > 0) {
|
||||
// The new "real" depth is set.
|
||||
if (theDepth < myNbRedos) {
|
||||
// The new depth is less then number of redos. Remove the latest redos.
|
||||
int aShift = (myNbRedos - theDepth);
|
||||
ListDiff::iterator aFromPos = myListDiffs.end();
|
||||
|
||||
while (aShift--) {
|
||||
aFromPos--;
|
||||
}
|
||||
|
||||
myListDiffs.erase(aFromPos, myListDiffs.end());
|
||||
myNbRedos = theDepth;
|
||||
}
|
||||
|
||||
if (theDepth < myNbUndos + myNbRedos) {
|
||||
// The new depth is less then the total number of differences.
|
||||
// Remove the first undos.
|
||||
int aShift = (myNbUndos + myNbRedos - theDepth);
|
||||
ListDiff::iterator aToPos = myListDiffs.begin();
|
||||
|
||||
while (aShift--) {
|
||||
aToPos++;
|
||||
}
|
||||
|
||||
myListDiffs.erase(myListDiffs.begin(), aToPos);
|
||||
myNbUndos = theDepth - myNbRedos;
|
||||
}
|
||||
|
||||
myUndoDepth = theDepth;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getUndoDepth
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
int CurveCreator_CurveEditor::getUndoDepth() const
|
||||
{
|
||||
return myUndoDepth;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setType
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::setType(const CurveCreator::Type theType,
|
||||
const int theISection)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
startOperation();
|
||||
// Set the difference.
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::SetType,
|
||||
theType, theISection);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->setType(theType, theISection);
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: addPoints
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::addPoints
|
||||
(const CurveCreator::Coordinates &thePoints,
|
||||
const int theISection)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::AddPoints,
|
||||
thePoints, theISection);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->addPoints(thePoints, theISection);
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: addSection
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::addSection
|
||||
(const std::string& theName, const CurveCreator::Type theType,
|
||||
const bool theIsClosed,
|
||||
const CurveCreator::Coordinates &thePoints)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::AddSection,
|
||||
theName, thePoints, theType, theIsClosed);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->addSection(theName, theType, theIsClosed, thePoints);
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: removeSection
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::removeSection(const int theISection)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::RemoveSection,
|
||||
theISection);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->removeSection(theISection);
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: insertPoints
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::insertPoints
|
||||
(const CurveCreator::Coordinates &thePoints,
|
||||
const int theISection,
|
||||
const int theIPnt)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::InsertPoints,
|
||||
thePoints, theISection, theIPnt);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->insertPoints(thePoints, theISection, theIPnt);
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: movePoints
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::movePoint(const int theISection,
|
||||
const int theOrigIPnt,
|
||||
const int theNewIPnt )
|
||||
{
|
||||
startOperation();
|
||||
myPCurve->movePoint(theISection, theOrigIPnt, theNewIPnt);
|
||||
finishOperation();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: removePoints
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::removePoints
|
||||
(const int theISection,
|
||||
const int theIPnt,
|
||||
const int theNbPoints)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::RemovePoints,
|
||||
theISection, theIPnt, theNbPoints);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->removePoints(theISection, theIPnt, theNbPoints);
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: clear
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::clear()
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
startOperation();
|
||||
// Set the difference.
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::Clear);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->clear();
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setCoordinates
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::setCoordinates
|
||||
(const CurveCreator::Coordinates &theCoords,
|
||||
const int theISection,
|
||||
const int theIPnt)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::SetCoordinates,
|
||||
theCoords, theISection, theIPnt);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->setCoordinates(theCoords, theISection, theIPnt);
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setClosed
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::setClosed(const bool theIsClosed,
|
||||
const int theISection)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::SetClosed,
|
||||
theIsClosed, theISection);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->setClosed(theIsClosed, theISection);
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setName
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::setName(const std::string& theName,
|
||||
const int theISection)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::RenameSection,
|
||||
theName, theISection);
|
||||
}
|
||||
myPCurve->setName( theName, theISection );
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: moveSection
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::moveSection(const int theISection,
|
||||
const int theNewIndex)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::MoveSection,
|
||||
theISection, theNewIndex);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->moveSection(theISection, theNewIndex);
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: join
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::join(const int theISectionTo,
|
||||
const int theISectionFrom)
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::Join,
|
||||
theISectionTo, theISectionFrom);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->join(theISectionTo, theISectionFrom);
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: join
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_CurveEditor::join()
|
||||
{
|
||||
if (myPCurve != NULL) {
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
if (addEmptyDiff()) {
|
||||
myListDiffs.back().init(myPCurve, CurveCreator_Operation::Join);
|
||||
}
|
||||
|
||||
// Update the curve.
|
||||
myPCurve->join();
|
||||
finishOperation();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: addDiff
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
bool CurveCreator_CurveEditor::addEmptyDiff()
|
||||
{
|
||||
bool isEnabled = false;
|
||||
|
||||
if (myUndoDepth != 0) {
|
||||
// Forget all Redos after the current one.
|
||||
if (myNbRedos > 0) {
|
||||
myNbRedos = 0;
|
||||
myListDiffs.erase(myCurrenPos, myListDiffs.end());
|
||||
}
|
||||
|
||||
if (myUndoDepth == -1 || myNbUndos < myUndoDepth) {
|
||||
// Increase the number of undos.
|
||||
myNbUndos++;
|
||||
} else {
|
||||
// If there are too many differences, remove the first one.
|
||||
myListDiffs.pop_front();
|
||||
}
|
||||
|
||||
// Add new difference.
|
||||
myListDiffs.push_back(CurveCreator_Diff());
|
||||
myCurrenPos = myListDiffs.end();
|
||||
isEnabled = true;
|
||||
}
|
||||
|
||||
return isEnabled;
|
||||
}
|
||||
|
||||
void CurveCreator_CurveEditor::startOperation()
|
||||
{
|
||||
myOpLevel++;
|
||||
}
|
||||
|
||||
void CurveCreator_CurveEditor::finishOperation()
|
||||
{
|
||||
myOpLevel--;
|
||||
}
|
@ -1,166 +0,0 @@
|
||||
// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File: CurveCreator_CurveEditor.hxx
|
||||
// Author: Sergey KHROMOV
|
||||
|
||||
#ifndef _CurveCreator_CurveEditor_HeaderFile
|
||||
#define _CurveCreator_CurveEditor_HeaderFile
|
||||
|
||||
#include "CurveCreator_Diff.hxx"
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
|
||||
#include <list>
|
||||
|
||||
/**
|
||||
* The CurveCreator_CurveEditor is designed to manage of
|
||||
* editing operations of CurveCreator_Curve class.
|
||||
*/
|
||||
class CURVECREATOR_EXPORT CurveCreator_CurveEditor
|
||||
{
|
||||
|
||||
private:
|
||||
|
||||
typedef std::list<CurveCreator_Diff> ListDiff;
|
||||
|
||||
public:
|
||||
|
||||
//! Constuctor, initialized by the curve object
|
||||
CurveCreator_CurveEditor(CurveCreator_Curve* thePCurve);
|
||||
|
||||
//! Destructor, detaches from the Curve
|
||||
~CurveCreator_CurveEditor();
|
||||
|
||||
//! Returns the curve.
|
||||
CurveCreator_Curve *getCurve() const;
|
||||
|
||||
//! This method returns true if this editor is attached to a valid curve.
|
||||
bool isAttached() const;
|
||||
|
||||
//! Undo previous operation
|
||||
void undo();
|
||||
|
||||
//! Redo last previously <20>undoed<65> operation
|
||||
void redo();
|
||||
|
||||
//! Get number of available undo operations
|
||||
int getNbUndo() const;
|
||||
|
||||
//! Get number of available redo operations
|
||||
int getNbRedo() const;
|
||||
|
||||
//! Set depth of undo operations (unlimited if \a theDepth is -1
|
||||
// or disabled if \a theDepth is 0)
|
||||
void setUndoDepth(const int theDepth = -1);
|
||||
|
||||
//! Get depth of undo operations.
|
||||
int getUndoDepth() const;
|
||||
|
||||
/** Set type of the specified section (or all sections
|
||||
* if \a theISection is -1).
|
||||
*/
|
||||
void setType(const CurveCreator::Type theType, const int theISection = -1);
|
||||
|
||||
/** Set section closed (or all sections
|
||||
* if \a theISection is -1).
|
||||
*/
|
||||
void setClosed(const bool theIsClosed, const int theISection);
|
||||
|
||||
/** Set section name (if theISection is invalid it is ignored).
|
||||
*/
|
||||
void setName(const std::string& theName, const int theISection);
|
||||
|
||||
/** Add points to the specified section (or last section
|
||||
* if \a theISection is -1).
|
||||
*/
|
||||
void addPoints(const CurveCreator::Coordinates &thePoints,
|
||||
const int theISection = -1);
|
||||
|
||||
//! Add a new section.
|
||||
void addSection(const std::string &theName, const CurveCreator::Type theType,
|
||||
const bool theIsClosed,
|
||||
const CurveCreator::Coordinates &thePoints);
|
||||
|
||||
//! Removes the section. If theISection equals -1, removes the last section.
|
||||
void removeSection(const int theISection = -1);
|
||||
|
||||
/** Insert points in the given position (add to the end of list
|
||||
* if \a theIPnt parameter is -1) of the specified section
|
||||
* (or last section if \a theISection parameter is -1).
|
||||
*/
|
||||
void insertPoints(const CurveCreator::Coordinates &thePoints,
|
||||
const int theISection = -1,
|
||||
const int theIPnt = -1);
|
||||
|
||||
/** Remove \a nbPoints points from given \a theISection,
|
||||
* starting from given \a theIPnt (of all points up to the end of
|
||||
* section if \a theNbPoints is -1).
|
||||
*/
|
||||
void removePoints(const int theISection,
|
||||
const int theIPnt,
|
||||
const int theNbPoints = -1);
|
||||
|
||||
/** Mobe point in \a theISection from given position \a theOrigIPnt
|
||||
* to new position \a theNewIPnt.
|
||||
*/
|
||||
void movePoint(const int theISection,
|
||||
const int theOrigIPnt,
|
||||
const int theNewIPnt );
|
||||
|
||||
//! Remove all sections.
|
||||
void clear();
|
||||
|
||||
//! Set coordinates of specified point
|
||||
void setCoordinates(const CurveCreator::Coordinates &theCoords,
|
||||
const int theISection,
|
||||
const int theIPnt);
|
||||
|
||||
/** Move specified \a theISection to the specified position
|
||||
* in the sections list.
|
||||
*/
|
||||
void moveSection(const int theISection, const int theNewIndex);
|
||||
|
||||
//! Join two sections to one section
|
||||
void join(const int theISectionTo, const int theISectionFrom);
|
||||
|
||||
//! Join all sections to the single curve
|
||||
void join();
|
||||
|
||||
void startOperation();
|
||||
void finishOperation();
|
||||
private:
|
||||
|
||||
/** This method updates all undo/redo information required to be updated
|
||||
* after curve modification operation. It returns false if undo/redo
|
||||
* is disabled and true otherwise.
|
||||
*/
|
||||
bool addEmptyDiff();
|
||||
|
||||
private:
|
||||
|
||||
int myNbUndos;
|
||||
int myNbRedos;
|
||||
ListDiff::iterator myCurrenPos;
|
||||
ListDiff myListDiffs;
|
||||
CurveCreator_Curve* myPCurve;
|
||||
int myUndoDepth;
|
||||
int myOpLevel;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -49,9 +49,9 @@ CurveCreator_Diff::~CurveCreator_Diff()
|
||||
// function: init
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType)
|
||||
bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve)
|
||||
{
|
||||
CurveCreator_Operation::Type aType = CurveCreator_Operation::Clear;
|
||||
bool isOK = false;
|
||||
|
||||
if (theCurve != NULL) {
|
||||
@ -60,36 +60,18 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
// Set redo.
|
||||
myPRedo = new CurveCreator_Operation;
|
||||
|
||||
if (myPRedo->init(theType)) {
|
||||
if (myPRedo->init(aType)) {
|
||||
isOK = true;
|
||||
|
||||
const int aNbSections = theCurve->getNbSections();
|
||||
|
||||
if (theType == CurveCreator_Operation::Clear) {
|
||||
// Construct undo for Clear command.
|
||||
if (aNbSections > 0) {
|
||||
setNbUndos(aNbSections);
|
||||
// Construct undo for Clear command.
|
||||
if (aNbSections > 0) {
|
||||
setNbUndos(aNbSections);
|
||||
|
||||
for (int i = 0; i < aNbSections && isOK; i++) {
|
||||
// Add AddSection command.
|
||||
isOK = addSectionToUndo(theCurve, i, myPUndo[i]);
|
||||
}
|
||||
}
|
||||
} else { // theType == CurveCreator_Operation::Join
|
||||
// Construct undo for Join command.
|
||||
if (aNbSections > 1) {
|
||||
// Add the RemovePoints command to remove points of
|
||||
// the second section fron the first one.
|
||||
const int aNbPoints = theCurve->getNbPoints(0);
|
||||
|
||||
setNbUndos(aNbSections);
|
||||
isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints,
|
||||
0, aNbPoints, -1);
|
||||
|
||||
for (int i = 1; i < aNbSections && isOK; i++) {
|
||||
// Add AddSection command.
|
||||
isOK = addSectionToUndo(theCurve, i, myPUndo[i]);
|
||||
}
|
||||
for (int i = 0; i < aNbSections && isOK; i++) {
|
||||
// Add AddSection command.
|
||||
isOK = addSectionToUndo(theCurve, i, myPUndo[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -176,33 +158,6 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
setNbUndos(1);
|
||||
isOK = myPUndo[0].init(theType, theIntParam2, theIntParam1);
|
||||
break;
|
||||
case CurveCreator_Operation::Join:
|
||||
{
|
||||
// If the last section is removed, one AddSection command is
|
||||
// enough. If not last section is removed, two commands are
|
||||
// requred: AddSection and MoveSection.
|
||||
const int aLastIndex = theCurve->getNbSections() - 1;
|
||||
const int aNbPoints = theCurve->getNbPoints(theIntParam1);
|
||||
|
||||
if (theIntParam2 == aLastIndex) {
|
||||
setNbUndos(2);
|
||||
} else {
|
||||
setNbUndos(3);
|
||||
}
|
||||
|
||||
isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints,
|
||||
theIntParam1, aNbPoints, -1);
|
||||
|
||||
if (isOK) {
|
||||
isOK = addSectionToUndo(theCurve, theIntParam2, myPUndo[1]);
|
||||
|
||||
if (isOK && theIntParam2 != aLastIndex) {
|
||||
isOK = myPUndo[2].init(CurveCreator_Operation::MoveSection,
|
||||
aLastIndex, theIntParam2);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
@ -222,77 +177,68 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
//=======================================================================
|
||||
bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const int theIntParam1,
|
||||
const int theIntParam2,
|
||||
const int theIntParam3)
|
||||
const std::list<int>& theParams)
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theCurve != NULL) {
|
||||
if (theCurve != NULL || theParams.empty()) {
|
||||
clear();
|
||||
|
||||
// Set redo.
|
||||
myPRedo = new CurveCreator_Operation;
|
||||
|
||||
if (myPRedo->init(theType, theIntParam1, theIntParam2, theIntParam3)) {
|
||||
// Construct undo for RemovePoints command.
|
||||
const CurveCreator::Dimension aDim = theCurve->getDimension();
|
||||
const CurveCreator::Coordinates &aPoints =
|
||||
theCurve->getPoints(theIntParam1);
|
||||
CurveCreator::Coordinates::const_iterator anIterBegin =
|
||||
aPoints.begin() + (aDim*theIntParam2);
|
||||
CurveCreator::Coordinates::const_iterator anIterEnd;
|
||||
if (myPRedo->init(theType, theParams)) {
|
||||
// Construct undo for different commands.
|
||||
switch (theType) {
|
||||
case CurveCreator_Operation::Join:
|
||||
{
|
||||
int aSectionMain = theParams.front();
|
||||
const int aNbPointsMain = theCurve->getNbPoints(aSectionMain);
|
||||
|
||||
if (theIntParam3 == -1) {
|
||||
anIterEnd = aPoints.end();
|
||||
} else {
|
||||
anIterEnd = anIterBegin + (aDim*theIntParam3);
|
||||
std::list<int> aSectionsToJoin = theParams;
|
||||
aSectionsToJoin.erase( aSectionsToJoin.begin() );
|
||||
// it is important to sort the section indices in order to correct perform undo
|
||||
// for the move sections to the previous positions
|
||||
aSectionsToJoin.sort();
|
||||
// 1rst undo for remove points from the main and n-1 undoes to contain joined sections
|
||||
int aSectionsToJoinNb = aSectionsToJoin.size();
|
||||
int aNbUndos = 2*aSectionsToJoinNb + 1;
|
||||
setNbUndos( aNbUndos );
|
||||
|
||||
// Add joined sections to undo
|
||||
std::list<int>::const_iterator anIt = aSectionsToJoin.begin(),
|
||||
aLast = aSectionsToJoin.end();
|
||||
anIt = aSectionsToJoin.begin();
|
||||
int aLastSectionId = -1;
|
||||
for (int i = 0; anIt != aLast && i < aSectionsToJoinNb; anIt++, i++) {
|
||||
int anISection = *anIt;
|
||||
isOK = addSectionToUndo( theCurve, anISection, myPUndo[i*2] );
|
||||
if (isOK) {
|
||||
isOK = myPUndo[i*2+1].init(CurveCreator_Operation::MoveSection,
|
||||
aLastSectionId, anISection);
|
||||
if (!isOK)
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Construct undo for RemovePoints command.
|
||||
if (isOK) {
|
||||
int aNbPointsInJoined = 0;
|
||||
anIt = aSectionsToJoin.begin();
|
||||
for ( ; anIt != aLast; anIt++ )
|
||||
aNbPointsInJoined += theCurve->getNbPoints( *anIt );
|
||||
|
||||
int aJoinedSize = aNbPointsMain + aNbPointsInJoined;
|
||||
CurveCreator_ICurve::SectionToPointList aSectionToPointList;
|
||||
for (int anIPoint = aNbPointsMain; anIPoint < aJoinedSize; anIPoint++)
|
||||
aSectionToPointList.push_back(std::make_pair(aSectionMain, anIPoint));
|
||||
|
||||
isOK = myPUndo[aNbUndos-1].init(CurveCreator_Operation::RemovePoints, aSectionToPointList);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
CurveCreator::Coordinates aPointsToAdd;
|
||||
|
||||
setNbUndos(1);
|
||||
aPointsToAdd.insert(aPointsToAdd.end(), anIterBegin, anIterEnd);
|
||||
isOK = myPUndo[0].init(CurveCreator_Operation::InsertPoints,
|
||||
aPointsToAdd, theIntParam1, theIntParam2);
|
||||
}
|
||||
|
||||
if (!isOK) {
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: init
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const CurveCreator::Coordinates &theCoords,
|
||||
const int theIntParam)
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theCurve != NULL) {
|
||||
clear();
|
||||
|
||||
// Set redo.
|
||||
myPRedo = new CurveCreator_Operation;
|
||||
|
||||
if (myPRedo->init(theType, theCoords, theIntParam)) {
|
||||
// Construct undo for AddPoints command.
|
||||
const int aSectionInd = getSectionIndex(theCurve, theIntParam);
|
||||
const CurveCreator::Dimension aDim = theCurve->getDimension();
|
||||
const CurveCreator::Coordinates &aPoints =
|
||||
theCurve->getPoints(aSectionInd);
|
||||
const int aNbPoints = (aPoints.size()/aDim);
|
||||
|
||||
setNbUndos(1);
|
||||
isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints,
|
||||
aSectionInd, aNbPoints, -1);
|
||||
}
|
||||
|
||||
if (!isOK) {
|
||||
@ -337,68 +283,6 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
return isOK;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: init
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const CurveCreator::Coordinates &theCoords,
|
||||
const int theIntParam1,
|
||||
const int theIntParam2)
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theCurve != NULL) {
|
||||
clear();
|
||||
|
||||
// Set redo.
|
||||
myPRedo = new CurveCreator_Operation;
|
||||
|
||||
if (myPRedo->init(theType, theCoords, theIntParam1, theIntParam2)) {
|
||||
// Construct undo for different commands.
|
||||
switch (theType) {
|
||||
case CurveCreator_Operation::InsertPoints:
|
||||
{
|
||||
const CurveCreator::Dimension aDim = theCurve->getDimension();
|
||||
const int aNbPoints = (theCoords.size()/aDim);
|
||||
const int aSectionInd = getSectionIndex(theCurve, theIntParam1);
|
||||
int aPointInd;
|
||||
|
||||
if (theIntParam2 == -1) {
|
||||
aPointInd = theCurve->getNbPoints(aSectionInd);
|
||||
} else {
|
||||
aPointInd = theIntParam2;
|
||||
}
|
||||
|
||||
setNbUndos(1);
|
||||
isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints,
|
||||
aSectionInd, aPointInd, aNbPoints);
|
||||
}
|
||||
break;
|
||||
case CurveCreator_Operation::SetCoordinates:
|
||||
{
|
||||
const CurveCreator::Coordinates anOldCoords =
|
||||
theCurve->getCoordinates(theIntParam1, theIntParam2);
|
||||
|
||||
setNbUndos(1);
|
||||
isOK = myPUndo[0].init(CurveCreator_Operation::SetCoordinates,
|
||||
anOldCoords, theIntParam1, theIntParam2);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isOK) {
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const std::string &theName,
|
||||
@ -423,6 +307,152 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
return isOK;
|
||||
}
|
||||
|
||||
bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const CurveCreator_ICurve::SectionToPointList &theParamList1)
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theCurve != NULL) {
|
||||
clear();
|
||||
|
||||
// Set redo.
|
||||
myPRedo = new CurveCreator_Operation;
|
||||
|
||||
if (myPRedo->init(theType, theParamList1)) {
|
||||
// Construct undo for different commands.
|
||||
switch (theType) {
|
||||
case CurveCreator_Operation::RemovePoints:
|
||||
{
|
||||
// Construct undo for RemovePoints command.
|
||||
CurveCreator_ICurve::SectionToPointCoordsList aSectionToPointCoords;
|
||||
CurveCreator::Coordinates aPointsToAdd;
|
||||
const CurveCreator::Dimension aDim = theCurve->getDimension();
|
||||
CurveCreator_ICurve::SectionToPointList::const_iterator anIt = theParamList1.begin(), aLast = theParamList1.end();
|
||||
std::list<int> aPoints;
|
||||
int aSectionId, aPointId;
|
||||
for ( ; anIt != aLast; anIt++ ) {
|
||||
aPointsToAdd.clear();
|
||||
aSectionId = anIt->first;
|
||||
aPointId = anIt->second;
|
||||
const CurveCreator::Coordinates &aPoints =
|
||||
theCurve->getPoints(aSectionId);
|
||||
CurveCreator::Coordinates::const_iterator anIterBegin =
|
||||
aPoints.begin() + (aDim*aPointId);
|
||||
CurveCreator::Coordinates::const_iterator anIterEnd =
|
||||
anIterBegin + aDim;
|
||||
aPointsToAdd.insert(aPointsToAdd.end(), anIterBegin, anIterEnd);
|
||||
aSectionToPointCoords.push_back(std::make_pair(*anIt, aPointsToAdd));
|
||||
}
|
||||
setNbUndos(1);
|
||||
isOK = myPUndo[0].init(CurveCreator_Operation::InsertPoints,
|
||||
aSectionToPointCoords);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isOK) {
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const CurveCreator_ICurve::SectionToPointCoordsList &theParamList1)
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theCurve != NULL) {
|
||||
clear();
|
||||
|
||||
// Set redo.
|
||||
myPRedo = new CurveCreator_Operation;
|
||||
|
||||
if (myPRedo->init(theType, theParamList1)) {
|
||||
// Construct undo for different commands.
|
||||
switch (theType) {
|
||||
case CurveCreator_Operation::InsertPoints:
|
||||
{
|
||||
// Construct undo for RemovePoints command.
|
||||
CurveCreator_ICurve::SectionToPointList aSectionToPointList;
|
||||
CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = theParamList1.begin(), aLast = theParamList1.end();
|
||||
for ( ; anIt != aLast; anIt++ ) {
|
||||
aSectionToPointList.push_back(anIt->first);
|
||||
}
|
||||
setNbUndos(1);
|
||||
isOK = myPUndo[0].init(CurveCreator_Operation::RemovePoints,
|
||||
aSectionToPointList);
|
||||
}
|
||||
break;
|
||||
case CurveCreator_Operation::SetCoordinates:
|
||||
{
|
||||
// Construct undo for SetCoordinates command.
|
||||
CurveCreator_ICurve::SectionToPointCoordsList aSectionToPointOldCoords;
|
||||
CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt = theParamList1.begin(), aLast = theParamList1.end();
|
||||
for ( ; anIt != aLast; anIt++ ) {
|
||||
CurveCreator::Coordinates anOldCoords = theCurve->getPoint(anIt->first.first, anIt->first.second);
|
||||
aSectionToPointOldCoords.push_back(std::make_pair(anIt->first, anOldCoords));
|
||||
}
|
||||
|
||||
setNbUndos(1);
|
||||
isOK = myPUndo[0].init(CurveCreator_Operation::SetCoordinates,
|
||||
aSectionToPointOldCoords);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!isOK) {
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_ICurve::SectionToPointCoordsList &theOldParamList)
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theCurve != NULL && theOldParamList.size() > 0) {
|
||||
clear();
|
||||
|
||||
// Set redo.
|
||||
myPRedo = new CurveCreator_Operation;
|
||||
|
||||
// Construct redo for SetCoordinates command.
|
||||
CurveCreator_ICurve::SectionToPointCoordsList aSectionToPointActualCoords;
|
||||
CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
|
||||
theOldParamList.begin(), aLast = theOldParamList.end();
|
||||
for ( ; anIt != aLast; anIt++ ) {
|
||||
CurveCreator::Coordinates anActualCoords = theCurve->getPoint(anIt->first.first, anIt->first.second);
|
||||
aSectionToPointActualCoords.push_back(std::make_pair(anIt->first, anActualCoords));
|
||||
}
|
||||
|
||||
if (myPRedo->init(CurveCreator_Operation::SetCoordinates, aSectionToPointActualCoords)) {
|
||||
// Undo for SetCoordinates command.
|
||||
setNbUndos(1);
|
||||
isOK = myPUndo[0].init(CurveCreator_Operation::SetCoordinates,
|
||||
theOldParamList);
|
||||
}
|
||||
|
||||
if (!isOK) {
|
||||
clear();
|
||||
}
|
||||
}
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: applyUndo
|
||||
// purpose:
|
||||
@ -495,12 +525,13 @@ bool CurveCreator_Diff::addSectionToUndo
|
||||
const int theIndex,
|
||||
CurveCreator_Operation &theOperation) const
|
||||
{
|
||||
const std::string aName = theCurve->getSectionName(theIndex);
|
||||
const CurveCreator::Coordinates &aPnts = theCurve->getPoints(theIndex);
|
||||
const CurveCreator::Type aType = theCurve->getType(theIndex);
|
||||
const CurveCreator::SectionType aType = theCurve->getSectionType(theIndex);
|
||||
const bool isClosed = theCurve->isClosed(theIndex);
|
||||
|
||||
bool isOK = theOperation.init(CurveCreator_Operation::AddSection,
|
||||
aPnts, aType, isClosed);
|
||||
aName, aPnts, aType, isClosed);
|
||||
|
||||
return isOK;
|
||||
}
|
||||
@ -533,7 +564,7 @@ bool CurveCreator_Diff::setTypeOrClosedToUndo
|
||||
// Get sections to be modified.
|
||||
for (i = 0; i < aNbSections; i++) {
|
||||
if (isSetType) {
|
||||
aValue = theCurve->getType(i);
|
||||
aValue = theCurve->getSectionType(i);
|
||||
} else {
|
||||
aValue = theCurve->isClosed(i);
|
||||
}
|
||||
@ -556,7 +587,7 @@ bool CurveCreator_Diff::setTypeOrClosedToUndo
|
||||
// There is only particular section modified.
|
||||
// Check if there is a real modification required.
|
||||
if (isSetType) {
|
||||
aValue = theCurve->getType(theIntParam2);
|
||||
aValue = theCurve->getSectionType(theIntParam2);
|
||||
} else {
|
||||
aValue = theCurve->isClosed(theIntParam2);
|
||||
}
|
||||
@ -572,7 +603,7 @@ bool CurveCreator_Diff::setTypeOrClosedToUndo
|
||||
std::list<int>::iterator anIter = aListOfInd.begin();
|
||||
|
||||
if (isSetType) {
|
||||
aValue = theCurve->getType(*anIter);
|
||||
aValue = theCurve->getSectionType(*anIter);
|
||||
} else {
|
||||
aValue = theCurve->isClosed(*anIter);
|
||||
}
|
||||
|
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -56,11 +56,9 @@ public:
|
||||
* parameters. It is applicable to the following operations:
|
||||
* <UL>
|
||||
* <LI>Clear</LI>
|
||||
* <LI>Join (without arguments)</LI>
|
||||
* </UL>
|
||||
*/
|
||||
bool init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType);
|
||||
bool init(const CurveCreator_Curve *theCurve);
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with one integer
|
||||
@ -80,7 +78,6 @@ public:
|
||||
* <LI>SetType</LI>
|
||||
* <LI>SetClosed</LI>
|
||||
* <LI>MoveSection</LI>
|
||||
* <LI>Join (with 2 int arguments)</LI>
|
||||
* </UL>
|
||||
*/
|
||||
bool init(const CurveCreator_Curve *theCurve,
|
||||
@ -88,46 +85,16 @@ public:
|
||||
const int theIntParam1,
|
||||
const int theIntParam2);
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with three
|
||||
* integer parameters. It is applicable to the following operations:
|
||||
/**
|
||||
* This method initializes the difference with an operation with two integer
|
||||
* parameters. It is applicable to the following operations:
|
||||
* <UL>
|
||||
* <LI>RemovePoints</LI>
|
||||
* <LI>Join (with a list of int arguments)</LI>
|
||||
* </UL>
|
||||
*/
|
||||
bool init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const int theIntParam1,
|
||||
const int theIntParam2,
|
||||
const int theIntParam3);
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with one
|
||||
* CurveCreator::Coordinates parameter and one integer parameter.
|
||||
* It is applicable to the following operations:
|
||||
* <UL>
|
||||
* <LI>AddPoints</LI>
|
||||
* </UL>
|
||||
*/
|
||||
bool init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const CurveCreator::Coordinates &theCoords,
|
||||
const int theIntParam);
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with one
|
||||
* CurveCreator::Coordinates parameter and two integer parameters.
|
||||
* It is applicable to the following operations:
|
||||
* <UL>
|
||||
* <LI>InsertPoints</LI>
|
||||
* <LI>SetCoordinates</LI>
|
||||
* </UL>
|
||||
*/
|
||||
bool init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const CurveCreator::Coordinates &theCoords,
|
||||
const int theIntParam1,
|
||||
const int theIntParam2);
|
||||
const std::list<int>& theParams);
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with one
|
||||
@ -157,6 +124,39 @@ public:
|
||||
const std::string &theName,
|
||||
const int theIntParam1 );
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with
|
||||
* list of pairs of integer parameters.
|
||||
* It is applicable to the following operations:
|
||||
* <UL>
|
||||
* <LI>RemovePoints</LI>
|
||||
* </UL>
|
||||
*/
|
||||
bool init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const CurveCreator_ICurve::SectionToPointList &theParamList);
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with
|
||||
* list of pairs of integer parameters with point coordinates.
|
||||
* It is applicable to the following operations:
|
||||
* <UL>
|
||||
* <LI>RemovePoints</LI>
|
||||
* </UL>
|
||||
*/
|
||||
bool init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const CurveCreator_ICurve::SectionToPointCoordsList &theParamList);
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with
|
||||
* list of pairs of integer parameters with point coordinates.
|
||||
* \param theCurve the modified curve
|
||||
* \param theOldParamList the old parameters (to be saved for undo)
|
||||
*/
|
||||
bool init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_ICurve::SectionToPointCoordsList &theOldParamList);
|
||||
|
||||
/**
|
||||
* This method applies undo operation to theCurve.
|
||||
*/
|
||||
|
64
src/CurveCreator/CurveCreator_Displayer.cxx
Normal file
64
src/CurveCreator/CurveCreator_Displayer.cxx
Normal file
@ -0,0 +1,64 @@
|
||||
#include "CurveCreator_Displayer.hxx"
|
||||
|
||||
CurveCreator_Displayer::CurveCreator_Displayer( Handle_AIS_InteractiveContext theContext,
|
||||
const int theZLayer ) :
|
||||
myContext( theContext ), myZLayer( theZLayer )
|
||||
{
|
||||
myObjects.clear();
|
||||
}
|
||||
|
||||
CurveCreator_Displayer::~CurveCreator_Displayer(void)
|
||||
{
|
||||
eraseAll( true );
|
||||
for( int i = 0 ; i < myObjects.size() ; i++ ){
|
||||
myObjects[i].Nullify();
|
||||
}
|
||||
myObjects.clear();
|
||||
}
|
||||
|
||||
void CurveCreator_Displayer::display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate )
|
||||
{
|
||||
if ( theObject.IsNull() )
|
||||
return;
|
||||
|
||||
myObjects.push_back( theObject );
|
||||
myContext->Display( theObject, Standard_False );
|
||||
|
||||
if ( myZLayer >= 0 )
|
||||
myContext->SetZLayer( theObject, myZLayer );
|
||||
|
||||
if( isUpdate )
|
||||
myContext->UpdateCurrentViewer();
|
||||
}
|
||||
|
||||
void CurveCreator_Displayer::eraseAll( bool isUpdate )
|
||||
{
|
||||
if(myObjects.empty())
|
||||
return;
|
||||
for( int i = 0 ; i < myObjects.size() ; i++ ){
|
||||
myContext->Erase(myObjects[i], Standard_False);
|
||||
}
|
||||
myObjects.clear();
|
||||
if( isUpdate )
|
||||
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();
|
||||
}*/
|
33
src/CurveCreator/CurveCreator_Displayer.hxx
Normal file
33
src/CurveCreator/CurveCreator_Displayer.hxx
Normal file
@ -0,0 +1,33 @@
|
||||
#ifndef CURVECREATOR_DISPLAYER_H
|
||||
#define CURVECREATOR_DISPLAYER_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,
|
||||
const int theZLayer = -1 );
|
||||
~CurveCreator_Displayer(void);
|
||||
|
||||
void display( const Handle_AIS_InteractiveObject& theObject, bool isUpdate );
|
||||
void eraseAll( bool isUpdate );
|
||||
//void highlight( const AISObjectsList& theObjects, bool isHL );
|
||||
|
||||
protected:
|
||||
Quantity_Color getActiveColor( bool isHL );
|
||||
|
||||
private:
|
||||
Handle_AIS_InteractiveContext myContext;
|
||||
AISObjectsList myObjects;
|
||||
int myZLayer;
|
||||
};
|
||||
|
||||
#endif
|
@ -1,459 +0,0 @@
|
||||
// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File: CurveCreator_ICurve.cxx
|
||||
// Author: Sergey KHROMOV
|
||||
|
||||
#include "CurveCreator_ICurve.hxx"
|
||||
#include "CurveCreator_Section.hxx"
|
||||
#include "CurveCreator_Listener.hxx"
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
//=======================================================================
|
||||
// function: Constructor
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
CurveCreator_ICurve::CurveCreator_ICurve
|
||||
(const CurveCreator::Dimension theDimension)
|
||||
: myIsLocked (false),
|
||||
myDimension (theDimension),
|
||||
myListener(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: Destructor
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
CurveCreator_ICurve::~CurveCreator_ICurve()
|
||||
{
|
||||
// Delete all allocated data.
|
||||
clear();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: isLocked
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
bool CurveCreator_ICurve::isLocked() const
|
||||
{
|
||||
return myIsLocked;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getDimension
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
CurveCreator::Dimension CurveCreator_ICurve::getDimension() const
|
||||
{
|
||||
return myDimension;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getNbPoints
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
int CurveCreator_ICurve::getNbPoints(const int theISection) const
|
||||
{
|
||||
int aNbCoords = 0;
|
||||
|
||||
if (theISection == -1) {
|
||||
int i = 0;
|
||||
const int aNbSections = getNbSections();
|
||||
|
||||
for (; i < aNbSections; i++) {
|
||||
aNbCoords += mySections[i]->myPoints.size();
|
||||
}
|
||||
} else {
|
||||
aNbCoords = mySections.at(theISection)->myPoints.size();
|
||||
}
|
||||
|
||||
return aNbCoords/myDimension;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getNbSections
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
int CurveCreator_ICurve::getNbSections() const
|
||||
{
|
||||
return mySections.size();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getCoordinates
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
CurveCreator::Coordinates CurveCreator_ICurve::getCoordinates
|
||||
(const int theISection, const int theIPnt) const
|
||||
{
|
||||
CurveCreator_Section *aSection = mySections.at(theISection);
|
||||
CurveCreator::Coordinates::const_iterator
|
||||
anIter = aSection->myPoints.begin() + toICoord(theIPnt);
|
||||
CurveCreator::Coordinates aResult(anIter, anIter + myDimension);
|
||||
|
||||
return aResult;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getType
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
CurveCreator::Type CurveCreator_ICurve::getType(const int theISection) const
|
||||
{
|
||||
return mySections.at(theISection)->myType;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getPoints
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
const CurveCreator::Coordinates &CurveCreator_ICurve::getPoints
|
||||
(const int theISection) const
|
||||
{
|
||||
return mySections.at(theISection)->myPoints;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: isClosed
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
bool CurveCreator_ICurve::isClosed(const int theISection) const
|
||||
{
|
||||
return mySections.at(theISection)->myIsClosed;
|
||||
}
|
||||
|
||||
std::string CurveCreator_ICurve::getSectionName(const int theISection) const
|
||||
{
|
||||
return mySections.at(theISection)->myName;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setType
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::setType
|
||||
(const CurveCreator::Type theType, const int theISection)
|
||||
{
|
||||
if (theISection == -1) {
|
||||
int i = 0;
|
||||
const int aNbSections = getNbSections();
|
||||
|
||||
for (; i < aNbSections; i++) {
|
||||
mySections[i]->myType = theType;
|
||||
}
|
||||
if( myListener )
|
||||
myListener->curveChanged();
|
||||
} else {
|
||||
if( mySections.at(theISection)->myType != theType ){
|
||||
mySections.at(theISection)->myType = theType;
|
||||
if( myListener )
|
||||
myListener->sectionTypeChanged(theISection);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: addSection
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::addSection
|
||||
(const std::string& theName,
|
||||
const CurveCreator::Type theType,
|
||||
const bool theIsClosed,
|
||||
const CurveCreator::Coordinates &thePoints)
|
||||
{
|
||||
CurveCreator_Section *aSection = new CurveCreator_Section;
|
||||
|
||||
std::string aName = theName;
|
||||
if( aName.empty() ){
|
||||
aName = getUnicSectionName();
|
||||
}
|
||||
aSection->myName = aName;
|
||||
aSection->myType = theType;
|
||||
aSection->myIsClosed = theIsClosed;
|
||||
aSection->myPoints = thePoints;
|
||||
mySections.push_back(aSection);
|
||||
if( myListener )
|
||||
myListener->sectionAdded( -1 );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: removeSection
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::removeSection(const int theISection)
|
||||
{
|
||||
if (theISection == -1) {
|
||||
delete mySections.back();
|
||||
mySections.pop_back();
|
||||
} else {
|
||||
Sections::iterator anIterRm = mySections.begin() + theISection;
|
||||
|
||||
delete *anIterRm;
|
||||
mySections.erase(anIterRm);
|
||||
}
|
||||
if( myListener )
|
||||
myListener->sectionRemoved(theISection);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: insertPoints
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::insertPoints
|
||||
(const CurveCreator::Coordinates &thePoints,
|
||||
const int theISection,
|
||||
const int theIPnt)
|
||||
{
|
||||
if (theIPnt == -1) {
|
||||
// Add points to the end of section points.
|
||||
addPoints(thePoints, theISection);
|
||||
} else {
|
||||
CurveCreator_Section *aSection =
|
||||
(theISection == -1 ? mySections.back() : mySections.at(theISection));
|
||||
|
||||
aSection->myPoints.insert(aSection->myPoints.begin() + toICoord(theIPnt),
|
||||
thePoints.begin(), thePoints.end());
|
||||
if( myListener )
|
||||
myListener->pointInserted( theISection, theIPnt );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_ICurve::movePoint(const int theISection, const int theIPointFrom, const int theNewIndex)
|
||||
{
|
||||
CurveCreator::Coordinates aCoords = getCoordinates(theISection, theIPointFrom );
|
||||
insertPoints(aCoords, theISection, theNewIndex+1);
|
||||
int aRemPntIndx = theIPointFrom;
|
||||
if( theNewIndex < theIPointFrom )
|
||||
aRemPntIndx++;
|
||||
removePoints(theISection, aRemPntIndx, 1 );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: removePoints
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::removePoints(const int theISection,
|
||||
const int theIPnt,
|
||||
const int theNbPoints)
|
||||
{
|
||||
CurveCreator_Section *aSection = mySections.at(theISection);
|
||||
CurveCreator::Coordinates::iterator anIterBegin =
|
||||
aSection->myPoints.begin() + toICoord(theIPnt);
|
||||
CurveCreator::Coordinates::iterator anIterEnd =
|
||||
(theNbPoints == -1 ?
|
||||
aSection->myPoints.end() : anIterBegin + toICoord(theNbPoints));
|
||||
|
||||
aSection->myPoints.erase(anIterBegin, anIterEnd);
|
||||
if( myListener )
|
||||
myListener->pointRemoved(theISection, theIPnt, theNbPoints );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: clear
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::clear()
|
||||
{
|
||||
// Delete all allocated data.
|
||||
int i = 0;
|
||||
const int aNbSections = getNbSections();
|
||||
|
||||
for (; i < aNbSections; i++) {
|
||||
delete mySections[i];
|
||||
}
|
||||
|
||||
mySections.clear();
|
||||
if( myListener )
|
||||
myListener->curveChanged();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setCoordinates
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::setCoordinates
|
||||
(const CurveCreator::Coordinates &theCoords,
|
||||
const int theISection,
|
||||
const int theIPnt)
|
||||
{
|
||||
if (theCoords.size() == myDimension) {
|
||||
CurveCreator_Section *aSection = mySections.at(theISection);
|
||||
int i;
|
||||
|
||||
for (i = 0; i < myDimension; i++) {
|
||||
aSection->myPoints.at(toICoord(theIPnt) + i) = theCoords[i];
|
||||
}
|
||||
|
||||
if( myListener )
|
||||
myListener->pointChanged( theISection, theIPnt );
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setClosed
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::setClosed(const bool theIsClosed,
|
||||
const int theISection)
|
||||
{
|
||||
if (theISection == -1) {
|
||||
int aSize = mySections.size();
|
||||
int i;
|
||||
|
||||
for (i = 0; i < aSize; i++) {
|
||||
mySections[i]->myIsClosed = theIsClosed;
|
||||
if( myListener ){
|
||||
myListener->sectionClosed( theISection, theIsClosed );
|
||||
}
|
||||
}
|
||||
} else {
|
||||
mySections.at(theISection)->myIsClosed = theIsClosed;
|
||||
if( myListener ){
|
||||
myListener->sectionClosed( theISection, theIsClosed );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/** Set name of the specified section.
|
||||
*/
|
||||
void CurveCreator_ICurve::setName( const std::string& theName, const int theISection )
|
||||
{
|
||||
if( ( theISection >= 0 ) && ( theISection < mySections.size() )){
|
||||
mySections.at(theISection)->myName = theName;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: moveSection
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::moveSection(const int theISection,
|
||||
const int theNewIndex)
|
||||
{
|
||||
if (theISection != theNewIndex) {
|
||||
CurveCreator_Section *aSection = mySections.at(theISection);
|
||||
|
||||
// Remove section
|
||||
Sections::iterator anIter = mySections.begin() + theISection;
|
||||
|
||||
mySections.erase(anIter);
|
||||
|
||||
// Insert section.
|
||||
anIter = mySections.begin() + theNewIndex;
|
||||
mySections.insert(anIter, aSection);
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: join
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::join(const int theISectionTo,
|
||||
const int theISectionFrom)
|
||||
{
|
||||
if (theISectionTo != theISectionFrom) {
|
||||
CurveCreator_Section *aSection1 = mySections.at(theISectionTo);
|
||||
CurveCreator_Section *aSection2 = mySections.at(theISectionFrom);
|
||||
|
||||
aSection1->myPoints.insert(aSection1->myPoints.end(),
|
||||
aSection2->myPoints.begin(), aSection2->myPoints.end());
|
||||
|
||||
removeSection(theISectionFrom);
|
||||
if( myListener )
|
||||
myListener->curveChanged();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: join
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::join()
|
||||
{
|
||||
const int aSize = mySections.size();
|
||||
|
||||
if (aSize > 1) {
|
||||
CurveCreator_Section *aSection1 = mySections[0];
|
||||
int i;
|
||||
|
||||
for (i = 1; i < aSize; i++) {
|
||||
CurveCreator_Section *aSection2 = mySections[i];
|
||||
|
||||
aSection1->myPoints.insert(aSection1->myPoints.end(),
|
||||
aSection2->myPoints.begin(), aSection2->myPoints.end());
|
||||
delete aSection2;
|
||||
}
|
||||
|
||||
// Just erace section pointers as they were deleted before.
|
||||
mySections.erase(mySections.begin() + 1, mySections.end());
|
||||
if( myListener )
|
||||
myListener->curveChanged();
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: toICoord
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
int CurveCreator_ICurve::toICoord(const int theIPnt) const
|
||||
{
|
||||
return theIPnt*myDimension;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getUnicSectionName
|
||||
// purpose: return unic section name
|
||||
//=======================================================================
|
||||
std::string CurveCreator_ICurve::getUnicSectionName()
|
||||
{
|
||||
for( int i = 0 ; i < 1000000 ; i++ ){
|
||||
char aBuffer[255];
|
||||
sprintf( aBuffer, "Section_%d", i+1 );
|
||||
std::string aName(aBuffer);
|
||||
int j;
|
||||
for( j = 0 ; j < mySections.size() ; j++ ){
|
||||
if( mySections[j]->myName == aName )
|
||||
break;
|
||||
}
|
||||
if( j == mySections.size() )
|
||||
return aName;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setListener
|
||||
// purpose: set curve changes listener
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::setListener( CurveCreator_Listener* theListener )
|
||||
{
|
||||
myListener = theListener;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setListener
|
||||
// purpose: set curve changes listener
|
||||
//=======================================================================
|
||||
void CurveCreator_ICurve::removeListener()
|
||||
{
|
||||
myListener = NULL;
|
||||
}
|
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -17,170 +17,189 @@
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File: CurveCreator_Curve.hxx
|
||||
// Author: Sergey KHROMOV
|
||||
// File: CurveCreator_ICurve.hxx
|
||||
// Author: Alexander KOVALEV and Alexander SOLOVYOV
|
||||
|
||||
#ifndef _CurveCreator_ICurve_HeaderFile
|
||||
#define _CurveCreator_ICurve_HeaderFile
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
#include "CurveCreator_Macro.hxx"
|
||||
#include "CurveCreator_Operation.hxx"
|
||||
#include <deque>
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <list>
|
||||
|
||||
class CurveCreator_Section;
|
||||
class CurveCreator_Listener;
|
||||
class Handle_AIS_InteractiveObject;
|
||||
|
||||
namespace CurveCreator
|
||||
{
|
||||
//! Type of the section
|
||||
enum SectionType
|
||||
{
|
||||
Polyline,
|
||||
Spline,
|
||||
};
|
||||
|
||||
//! Dimension of the curve
|
||||
enum Dimension
|
||||
{
|
||||
Dim2d = 2,
|
||||
Dim3d = 3
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
/**
|
||||
* The CurveCreator_ICurve object is represented as one or more sets of
|
||||
* connected points; thus CurveCreator_ICurve object can contain several
|
||||
* not connected curves (polylines or b-splines), each such curve has two
|
||||
* only ends <EFBFBD> start and end points <EFBFBD> in other words non-manifold curves
|
||||
* only ends "start and end points" in other words non-manifold curves
|
||||
* are not supported.
|
||||
*/
|
||||
class CURVECREATOR_EXPORT CurveCreator_ICurve
|
||||
{
|
||||
public:
|
||||
typedef std::pair<int,int> SectionToPoint;
|
||||
typedef std::deque<SectionToPoint> SectionToPointList;
|
||||
|
||||
//! List of curves
|
||||
typedef std::deque<CurveCreator_Section *> Sections;
|
||||
typedef std::deque< std::pair< SectionToPoint,std::deque< float > > > SectionToPointCoordsList;
|
||||
|
||||
public:
|
||||
//! Constructor of the curve.
|
||||
/** The dimension is explicitly specified in the constructor
|
||||
* and cannot be changed later.
|
||||
*/
|
||||
CurveCreator_ICurve(const CurveCreator::Dimension theDimension);
|
||||
/***********************************************/
|
||||
/*** Undo/Redo methods ***/
|
||||
/***********************************************/
|
||||
|
||||
//! Destructor.
|
||||
virtual ~CurveCreator_ICurve();
|
||||
//! Get number of available undo operations
|
||||
virtual int getNbUndo() const = 0;
|
||||
|
||||
//! Returns true if this curve is locked by a curve editor.
|
||||
virtual bool isLocked() const;
|
||||
//! Undo previous operation
|
||||
virtual bool undo() = 0;
|
||||
|
||||
//! Get the dimension.
|
||||
virtual CurveCreator::Dimension getDimension() const;
|
||||
//! Get number of available redo operations
|
||||
virtual int getNbRedo() const = 0;
|
||||
|
||||
//! Get number of sections.
|
||||
virtual int getNbSections() const;
|
||||
//! Redo last previously "undone" operation
|
||||
virtual bool redo() = 0;
|
||||
|
||||
/** Get number of points in specified section or (the total number of points
|
||||
* in Curve if theISection is equal to -1).
|
||||
*/
|
||||
virtual int getNbPoints(const int theISection = -1) const;
|
||||
|
||||
//! Get coordinates of specified point
|
||||
virtual CurveCreator::Coordinates getCoordinates
|
||||
(const int theISection, const int theIPnt) const;
|
||||
/***********************************************/
|
||||
/*** Section methods ***/
|
||||
/***********************************************/
|
||||
|
||||
//! Get points of a section.
|
||||
virtual const CurveCreator::Coordinates &getPoints(const int theISection) const;
|
||||
//! Clear the polyline (remove all sections)
|
||||
virtual bool clear() = 0;
|
||||
|
||||
//! Get type of the specified section
|
||||
virtual CurveCreator::Type getType(const int theISection) const;
|
||||
//! Join list of sections to one section (join all if the list is empty)
|
||||
// The first section in the list is a leader, another sections are joined to it
|
||||
virtual bool join( const std::list<int>& theSections ) = 0;
|
||||
|
||||
//! Get <20>closed<65> flag of the specified section
|
||||
virtual bool isClosed(const int theISection) const;
|
||||
|
||||
//! Returns specifyed section name
|
||||
virtual std::string getSectionName(const int theISection) const;
|
||||
|
||||
/**
|
||||
* Return unic section name
|
||||
*/
|
||||
virtual std::string getUnicSectionName();
|
||||
|
||||
/**
|
||||
* Set curve creator listener object
|
||||
*/
|
||||
virtual void setListener( CurveCreator_Listener* myWatcher );
|
||||
|
||||
/**
|
||||
* Remove curve creator listener object
|
||||
*/
|
||||
virtual void removeListener();
|
||||
|
||||
protected:
|
||||
|
||||
/** Set type of the specified section (or all sections
|
||||
* if \a theISection is -1).
|
||||
*/
|
||||
virtual void setType(const CurveCreator::Type theType, const int theISection = -1);
|
||||
|
||||
/** Add points to the specified section (or last section
|
||||
* if \a theISection is -1).
|
||||
*/
|
||||
virtual void addPoints
|
||||
(const CurveCreator::Coordinates &thePoints, const int theISection = -1) = 0;
|
||||
//! Get number of sections
|
||||
virtual int getNbSections() const = 0;
|
||||
|
||||
//! Add a new section.
|
||||
virtual void addSection (const std::string &theName, const CurveCreator::Type theType,
|
||||
const bool theIsClosed,
|
||||
const CurveCreator::Coordinates &thePoints);
|
||||
virtual int addSection( const std::string& theName,
|
||||
const CurveCreator::SectionType theType,
|
||||
const bool theIsClosed ) = 0;
|
||||
|
||||
//! Removes the section. If theISection equals -1, removes the last section.
|
||||
virtual void removeSection(const int theISection = -1);
|
||||
//! Removes the given sections.
|
||||
virtual bool removeSection( const int theISection ) = 0;
|
||||
|
||||
/** Insert points in the given position (add to the end of list
|
||||
* if \a theIPnt parameter is -1) of the specified section
|
||||
* (or last section if \a theISection parameter is -1).
|
||||
*/
|
||||
virtual void insertPoints(const CurveCreator::Coordinates &thePoints,
|
||||
const int theISection = -1,
|
||||
const int theIPnt = -1);
|
||||
|
||||
/** Remove \a nbPoints points from given \a theISection,
|
||||
* starting from given \a theIPnt (of all points up to the end of
|
||||
* section if \a theNbPoints is -1).
|
||||
*/
|
||||
virtual void removePoints(const int theISection,
|
||||
const int theIPnt,
|
||||
const int theNbPoints = -1);
|
||||
|
||||
/** Move specified point within section to new position
|
||||
*/
|
||||
virtual void movePoint(const int theISection,
|
||||
const int theIPointFrom,
|
||||
const int theNewIndex);
|
||||
|
||||
//! Remove all sections.
|
||||
virtual void clear();
|
||||
|
||||
//! Set coordinates of specified point
|
||||
virtual void setCoordinates(const CurveCreator::Coordinates &theCoords,
|
||||
const int theISection,
|
||||
const int theIPnt);
|
||||
|
||||
/** Set <20>closed<65> flag of the specified section (all sections if
|
||||
* \a theISection is -1).
|
||||
*/
|
||||
virtual void setClosed(const bool theIsClosed, const int theISection = -1);
|
||||
|
||||
/** Set name of the specified section.
|
||||
*/
|
||||
virtual void setName( const std::string& theName, const int theISection );
|
||||
|
||||
/** Move specified \a theISection to the specified position
|
||||
* in the sections list.
|
||||
*/
|
||||
virtual void moveSection(const int theISection, const int theNewIndex);
|
||||
|
||||
//! Join two sections to one section
|
||||
virtual void join(const int theISectionTo, const int theISectionFrom);
|
||||
|
||||
//! Join all sections to the single curve
|
||||
virtual void join();
|
||||
//! Get "closed" flag of the specified section
|
||||
virtual bool isClosed( const int theISection ) const = 0;
|
||||
|
||||
/**
|
||||
* This method converts the point index to the index in
|
||||
* an array of coordinates.
|
||||
* Set "closed" flag of the specified section (all sections if
|
||||
* \a theISection is -1).
|
||||
*/
|
||||
virtual int toICoord(const int theIPnt) const;
|
||||
virtual bool setClosed( const int theISection,
|
||||
const bool theIsClosed ) = 0;
|
||||
|
||||
public:
|
||||
//! Returns specifyed section name
|
||||
virtual std::string getSectionName( const int theISection ) const = 0;
|
||||
|
||||
bool myIsLocked;
|
||||
Sections mySections; //!< curve data
|
||||
CurveCreator::Dimension myDimension; //!< curve dimension
|
||||
CurveCreator_Listener* myListener; //!< listener
|
||||
/** Set name of the specified section */
|
||||
virtual bool setSectionName( const int theISection,
|
||||
const std::string& theName ) = 0;
|
||||
|
||||
//! Get type of the specified section
|
||||
virtual CurveCreator::SectionType getSectionType( const int theISection ) const = 0;
|
||||
|
||||
/**
|
||||
* Set type of the specified section (or all sections
|
||||
* if \a theISection is -1).
|
||||
*/
|
||||
virtual bool setSectionType( const int theISection,
|
||||
const CurveCreator::SectionType theType ) = 0;
|
||||
|
||||
|
||||
/***********************************************/
|
||||
/*** Point methods ***/
|
||||
/***********************************************/
|
||||
|
||||
//! Get the dimension.
|
||||
virtual CurveCreator::Dimension getDimension() const = 0;
|
||||
|
||||
/**
|
||||
* 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).
|
||||
*/
|
||||
virtual bool addPoints( const std::deque<float>& theCoords,
|
||||
const int theISection,
|
||||
const int theIPnt = -1 ) = 0;
|
||||
|
||||
//! Set coordinates of specified point
|
||||
virtual bool setPoint( const int theISection,
|
||||
const int theIPnt,
|
||||
const std::deque<float>& theNewCoords ) = 0;
|
||||
|
||||
//! Set coordinates of specified points from different sections
|
||||
virtual bool setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
|
||||
const bool theIsToSaveDiff = true ) = 0;
|
||||
|
||||
//! Remove point with given id
|
||||
virtual bool removePoint( const int theISection, const int theIPnt = -1 ) = 0;
|
||||
//! Remove several points from different sections
|
||||
virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs) = 0;
|
||||
|
||||
//! Get coordinates of specified point
|
||||
virtual std::deque<float> getPoint( const int theISection,
|
||||
const int theIPnt ) const = 0;
|
||||
|
||||
/**
|
||||
* Get points of a section (the total points in Curve if theISection is equal to -1)..
|
||||
*/
|
||||
virtual std::deque<float> getPoints( const int theISection = -1 ) const = 0;
|
||||
|
||||
/**
|
||||
* Get number of points in specified section or (the total number of points
|
||||
* in Curve if theISection is equal to -1).
|
||||
*/
|
||||
virtual int getNbPoints( const int theISection ) const = 0;
|
||||
|
||||
/**
|
||||
* Set skip sorting flag. If the flag is true - points sorting will be skipped.
|
||||
*/
|
||||
virtual void setSkipSorting( const bool ) = 0;
|
||||
|
||||
/**
|
||||
* Indicates whether the points can be sorted.
|
||||
*/
|
||||
virtual bool canPointsBeSorted() = 0;
|
||||
|
||||
/**
|
||||
* Saves points coordinates difference.
|
||||
* \param theOldCoords the old points coordinates
|
||||
*/
|
||||
virtual void saveCoordDiff( const SectionToPointCoordsList &theOldCoords ) = 0;
|
||||
|
||||
/***********************************************/
|
||||
/*** Presentation methods ***/
|
||||
/***********************************************/
|
||||
|
||||
virtual Handle_AIS_InteractiveObject getAISObject( const bool theNeedToBuild = false ) const = 0;
|
||||
|
||||
protected:
|
||||
virtual void constructAISObject() = 0;
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
|
@ -1,196 +0,0 @@
|
||||
// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
#include "CurveCreator_NewPointDlg.h"
|
||||
|
||||
#include <QGridLayout>
|
||||
#include <QVBoxLayout>
|
||||
#include <QLabel>
|
||||
#include <QDoubleSpinBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QDoubleValidator>
|
||||
#include <QRegExpValidator>
|
||||
#include <QAbstractButton>
|
||||
#include <QPushButton>
|
||||
#include <QLocale>
|
||||
|
||||
CurveCreator_NewPointDlg::CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent) :
|
||||
QWidget(parent), myX(NULL), myY(NULL), myZ(NULL), myIsEdit(false), myDim(theDim),
|
||||
myIsInstantSketchingEnabled(false)
|
||||
{
|
||||
QString aTitle = QString(tr("ADD_NEW_POINT"));
|
||||
setWindowTitle(aTitle);
|
||||
|
||||
QFrame* aFrame = new QFrame( this );
|
||||
QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
|
||||
|
||||
QFrame* aCoordFrame = new QFrame( aFrame );
|
||||
QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame );
|
||||
|
||||
QLabel* aLbl = new QLabel( tr("X_COORD"), this);
|
||||
myX = new QDoubleSpinBox(this);
|
||||
aCoordLayout->addWidget(aLbl, 0, 0);
|
||||
aCoordLayout->addWidget(myX, 0, 1 );
|
||||
|
||||
aLbl = new QLabel( tr("Y_COORD"), this);
|
||||
myY = new QDoubleSpinBox(this);
|
||||
aCoordLayout->addWidget(aLbl, 1, 0 );
|
||||
aCoordLayout->addWidget(myY, 1, 1 );
|
||||
|
||||
myZLabel = new QLabel( tr("Z_COORD"), this);
|
||||
myZ = new QDoubleSpinBox(this);
|
||||
aCoordLayout->addWidget(myZLabel, 2,0 );
|
||||
aCoordLayout->addWidget(myZ, 2,1 );
|
||||
|
||||
if( theDim != CurveCreator::Dim3d ){
|
||||
myZ->hide();
|
||||
myZLabel->hide();
|
||||
}
|
||||
|
||||
myBtnFrame = new QFrame( aFrame );
|
||||
QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
|
||||
|
||||
myAddBtn = new QPushButton( tr( "ADD_BTN" ), myBtnFrame );
|
||||
myCancelBtn = new QPushButton( tr( "CANCEL" ), myBtnFrame );
|
||||
|
||||
connect( myCancelBtn, SIGNAL( clicked() ), this, SIGNAL( cancelPoint() ) );
|
||||
|
||||
aBtnsLayout->addWidget( myAddBtn );
|
||||
aBtnsLayout->addStretch( 1 );
|
||||
aBtnsLayout->addWidget( myCancelBtn );
|
||||
|
||||
aLayout->addWidget( aCoordFrame, 0 );
|
||||
aLayout->addWidget( myBtnFrame, 1 );
|
||||
|
||||
clear();
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::setSectionName( const QString& theName )
|
||||
{
|
||||
mySectionName = theName;
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::setEditMode( bool isEdit )
|
||||
{
|
||||
myIsEdit = isEdit;
|
||||
if( myIsEdit ){
|
||||
myAddBtn->setText(tr("OK"));
|
||||
myAddBtn->disconnect( SIGNAL( clicked() ) );
|
||||
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( modifyPoint() ) );
|
||||
}
|
||||
else{
|
||||
myAddBtn->setText(tr("ADD_BTN"));
|
||||
myAddBtn->disconnect( SIGNAL( clicked() ) );
|
||||
connect( myAddBtn, SIGNAL( clicked() ), this, SIGNAL( addPoint() ) );
|
||||
}
|
||||
updateTitle();
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::updateTitle()
|
||||
{
|
||||
QString aTitle;
|
||||
if( !myIsEdit ){
|
||||
if( mySectionName.isEmpty() ){
|
||||
aTitle = tr("ADD_NEW_POINT");
|
||||
}
|
||||
else{
|
||||
aTitle = QString(tr("ADD_NEW_POINT_TO_%1")).arg(mySectionName);
|
||||
}
|
||||
}
|
||||
else{
|
||||
aTitle = tr("SET_POINT_COORDINATES");
|
||||
}
|
||||
setWindowTitle(aTitle);
|
||||
}
|
||||
|
||||
CurveCreator::Coordinates CurveCreator_NewPointDlg::getCoordinates() const
|
||||
{
|
||||
CurveCreator::Coordinates aCoords;
|
||||
double anX = myX->value();
|
||||
aCoords.push_back(anX);
|
||||
double anY = myY->value();
|
||||
aCoords.push_back(anY);
|
||||
if( myDim == CurveCreator::Dim3d ){
|
||||
double aZ = myZ->value();
|
||||
aCoords.push_back(aZ);
|
||||
}
|
||||
return aCoords;
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::clear()
|
||||
{
|
||||
initSpinBox(myX);
|
||||
initSpinBox(myY);
|
||||
initSpinBox(myZ);
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::setDimension(CurveCreator::Dimension theDim)
|
||||
{
|
||||
if( theDim == CurveCreator::Dim2d ){
|
||||
myZ->hide();
|
||||
myZLabel->hide();
|
||||
}
|
||||
else{
|
||||
myZ->show();
|
||||
myZLabel->show();
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::setCoordinates( const CurveCreator::Coordinates& theCoords )
|
||||
{
|
||||
double anX = theCoords[0];
|
||||
myX->setValue(anX);
|
||||
double anY = theCoords[1];
|
||||
myY->setValue(anY);
|
||||
if( theCoords.size() == 3 ){
|
||||
double aZ = theCoords[2];
|
||||
myZ->setValue(aZ);
|
||||
}
|
||||
if( isInstantSketchingEnabled() )
|
||||
emit addPoint();
|
||||
}
|
||||
|
||||
bool CurveCreator_NewPointDlg::isInstantSketchingEnabled() const
|
||||
{
|
||||
return myIsInstantSketchingEnabled;
|
||||
}
|
||||
|
||||
void CurveCreator_NewPointDlg::setInstantSketchingEnabled( const bool theState )
|
||||
{
|
||||
myIsInstantSketchingEnabled = theState;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: initSpinBox
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_NewPointDlg::initSpinBox(QDoubleSpinBox *theSpinBox)
|
||||
{
|
||||
const double aCoordMin = -1.e+15;
|
||||
const double aCoordMax = 1.e+15;
|
||||
const double aStep = 10;
|
||||
const int aPrecision = 6;
|
||||
|
||||
theSpinBox->setDecimals( qAbs( aPrecision ) );
|
||||
theSpinBox->setRange(aCoordMin, aCoordMax);
|
||||
theSpinBox->setSingleStep(aStep);
|
||||
theSpinBox->setValue(0.0);
|
||||
}
|
@ -1,70 +0,0 @@
|
||||
// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
#ifndef CURVECREATOR_NEWPOINTDLG_H
|
||||
#define CURVECREATOR_NEWPOINTDLG_H
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
class QDoubleSpinBox;
|
||||
class QDialogButtonBox;
|
||||
class QAbstractButton;
|
||||
class QPushButton;
|
||||
class QLabel;
|
||||
class QFrame;
|
||||
|
||||
class CurveCreator_NewPointDlg : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CurveCreator_NewPointDlg(CurveCreator::Dimension theDim, QWidget *parent = 0);
|
||||
CurveCreator::Coordinates getCoordinates() const;
|
||||
void clear();
|
||||
void setSectionName( const QString& theName );
|
||||
void setEditMode( bool isEdit );
|
||||
void setCoordinates( const CurveCreator::Coordinates& theCoords );
|
||||
void setDimension(CurveCreator::Dimension theDim);
|
||||
bool isInstantSketchingEnabled() const;
|
||||
void setInstantSketchingEnabled( const bool theState );
|
||||
signals:
|
||||
void addPoint();
|
||||
void modifyPoint();
|
||||
void cancelPoint();
|
||||
public slots:
|
||||
protected slots:
|
||||
protected:
|
||||
void updateTitle();
|
||||
void initSpinBox(QDoubleSpinBox *theSpinBox);
|
||||
private:
|
||||
QFrame* myBtnFrame;
|
||||
CurveCreator::Dimension myDim;
|
||||
QDoubleSpinBox* myX;
|
||||
QDoubleSpinBox* myY;
|
||||
QDoubleSpinBox* myZ;
|
||||
QLabel* myZLabel;
|
||||
QPushButton* myAddBtn;
|
||||
QPushButton* myCancelBtn;
|
||||
bool myIsEdit;
|
||||
QString mySectionName;
|
||||
bool myIsInstantSketchingEnabled;
|
||||
};
|
||||
|
||||
#endif // CURVECREATOR_NEWPOINTDLG_H
|
26
src/CurveCreator/CurveCreator_NewSectionDlg.cxx
Executable file → Normal file
26
src/CurveCreator/CurveCreator_NewSectionDlg.cxx
Executable file → Normal file
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -18,7 +18,7 @@
|
||||
//
|
||||
|
||||
#include "CurveCreator_NewSectionDlg.h"
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
//#include "CurveCreator_Curve.hxx"
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
@ -31,11 +31,17 @@
|
||||
#include <QDialogButtonBox>
|
||||
#include <QPushButton>
|
||||
|
||||
CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
|
||||
QWidget(parent)
|
||||
CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent, bool enableClosed ) :
|
||||
QWidget(parent), myIsEnableClosed( enableClosed )
|
||||
{
|
||||
QVBoxLayout* aMainLayout = new QVBoxLayout( this );
|
||||
aMainLayout->setMargin( 0 );
|
||||
|
||||
QFrame* aFrame = new QFrame( this );
|
||||
aMainLayout->addWidget( aFrame );
|
||||
|
||||
QVBoxLayout* aLayout = new QVBoxLayout( aFrame );
|
||||
aLayout->setMargin( 0 );
|
||||
|
||||
QFrame* aCoordFrame = new QFrame( aFrame );
|
||||
QGridLayout* aCoordLayout = new QGridLayout( aCoordFrame );
|
||||
@ -64,6 +70,10 @@ CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
|
||||
myIsClosed = new QCheckBox(this);
|
||||
aCoordLayout->addWidget(aLbl, 2, 0);
|
||||
aCoordLayout->addWidget(myIsClosed, 2, 1);
|
||||
if ( !myIsEnableClosed ) {
|
||||
aLbl->hide();
|
||||
myIsClosed->hide();
|
||||
}
|
||||
|
||||
myBtnFrame = new QFrame( aFrame );
|
||||
QHBoxLayout* aBtnsLayout = new QHBoxLayout( myBtnFrame );
|
||||
@ -82,7 +92,7 @@ CurveCreator_NewSectionDlg::CurveCreator_NewSectionDlg( QWidget *parent ) :
|
||||
aLayout->addWidget( myBtnFrame, 1 );
|
||||
}
|
||||
|
||||
void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType )
|
||||
void CurveCreator_NewSectionDlg::setSectionParameters( const QString& theName, bool isClosed, CurveCreator::SectionType theType )
|
||||
{
|
||||
myName->setText(theName);
|
||||
myIsClosed->setChecked(isClosed);
|
||||
@ -125,12 +135,12 @@ bool CurveCreator_NewSectionDlg::isClosed() const
|
||||
return myIsClosed->isChecked();
|
||||
}
|
||||
|
||||
CurveCreator::Type CurveCreator_NewSectionDlg::getSectionType() const
|
||||
CurveCreator::SectionType CurveCreator_NewSectionDlg::getSectionType() const
|
||||
{
|
||||
if( myLineType->currentIndex() == 0 )
|
||||
return CurveCreator::Polyline;
|
||||
else
|
||||
return CurveCreator::BSpline;
|
||||
return CurveCreator::Spline;
|
||||
}
|
||||
|
||||
void CurveCreator_NewSectionDlg::updateTitle()
|
||||
|
15
src/CurveCreator/CurveCreator_NewSectionDlg.h
Executable file → Normal file
15
src/CurveCreator/CurveCreator_NewSectionDlg.h
Executable file → Normal file
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -21,10 +21,11 @@
|
||||
#define CURVECREATOR_NEWSECTION_H
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
#include "CurveCreator_ICurve.hxx"
|
||||
|
||||
#include <QDockWidget>
|
||||
|
||||
class CurveCreator_Curve;
|
||||
//class CurveCreator_Curve;
|
||||
|
||||
class QLineEdit;
|
||||
class QComboBox;
|
||||
@ -38,16 +39,17 @@ class CurveCreator_NewSectionDlg : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit CurveCreator_NewSectionDlg(QWidget *parent = 0);
|
||||
explicit CurveCreator_NewSectionDlg(QWidget *parent = 0, bool enableClosed = true );
|
||||
|
||||
QString getName() const;
|
||||
bool isClosed() const;
|
||||
CurveCreator::Type getSectionType() const;
|
||||
CurveCreator::SectionType getSectionType() const;
|
||||
|
||||
void setSectionParameters( const QString& theName, bool isClosed, CurveCreator::Type theType );
|
||||
void setSectionParameters( const QString& theName, bool isClosed, CurveCreator::SectionType theType );
|
||||
void setSectionName(const QString& theName );
|
||||
void clear();
|
||||
void setEditMode( bool isEdit );
|
||||
bool isEnableClosed() const { return myIsEnableClosed; }
|
||||
|
||||
signals:
|
||||
void addSection();
|
||||
@ -63,6 +65,7 @@ private:
|
||||
QComboBox* myLineType;
|
||||
QCheckBox* myIsClosed;
|
||||
bool myIsEdit;
|
||||
bool myIsEnableClosed;
|
||||
QPushButton* myAddBtn;
|
||||
QPushButton* myCancelBtn;
|
||||
};
|
||||
|
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -22,6 +22,7 @@
|
||||
|
||||
#include "CurveCreator_Operation.hxx"
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
#include "CurveCreator.hxx"
|
||||
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
@ -46,6 +47,11 @@ CurveCreator_Operation::~CurveCreator_Operation()
|
||||
clear();
|
||||
}
|
||||
|
||||
bool compId(CurveCreator_PosPoint* p1, CurveCreator_PosPoint* p2)
|
||||
{
|
||||
return p1->myID < p2->myID;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: Constructor
|
||||
// purpose:
|
||||
@ -54,8 +60,7 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType)
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theType == CurveCreator_Operation::Clear ||
|
||||
theType == CurveCreator_Operation::Join) {
|
||||
if (theType == CurveCreator_Operation::Clear) {
|
||||
clear();
|
||||
myType = theType;
|
||||
isOK = true;
|
||||
@ -113,23 +118,28 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
// function: Constructor
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
const int theIntParam1,
|
||||
const int theIntParam2,
|
||||
const int theIntParam3)
|
||||
bool CurveCreator_Operation::init(const Type theType, const std::list<int> theParamList)
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theType == CurveCreator_Operation::RemovePoints) {
|
||||
int *pData = (int *)allocate(3*sizeof(int));
|
||||
if (theType == CurveCreator_Operation::Join)
|
||||
{
|
||||
const int aNbPoints = theParamList.size();
|
||||
|
||||
const size_t aSize =
|
||||
sizeof(aNbPoints) +
|
||||
aNbPoints * (sizeof(int));
|
||||
|
||||
int *pIntData = (int *)allocate(aSize);
|
||||
|
||||
*pIntData++ = aNbPoints;
|
||||
std::list<int>::const_iterator anIt = theParamList.begin(), aLast = theParamList.end();
|
||||
for ( ; anIt != aLast; anIt++ )
|
||||
*pIntData++ = *anIt;
|
||||
|
||||
pData[0] = theIntParam1;
|
||||
pData[1] = theIntParam2;
|
||||
pData[2] = theIntParam3;
|
||||
myType = theType;
|
||||
isOK = true;
|
||||
isOK = true;
|
||||
}
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
@ -166,43 +176,6 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
return isOK;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: Constructor
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
const CurveCreator::Coordinates &theCoords,
|
||||
const int theIntParam1,
|
||||
const int theIntParam2)
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theType == CurveCreator_Operation::AddSection ||
|
||||
theType == CurveCreator_Operation::InsertPoints ||
|
||||
theType == CurveCreator_Operation::SetCoordinates) {
|
||||
const int aNbCoords = theCoords.size();
|
||||
const size_t aSize =
|
||||
3*sizeof(theIntParam1) + aNbCoords*sizeof(CurveCreator::TypeCoord);
|
||||
int *pIntData = (int *)allocate(aSize);
|
||||
|
||||
*pIntData++ = theIntParam1;
|
||||
*pIntData++ = theIntParam2;
|
||||
*pIntData++ = aNbCoords;
|
||||
|
||||
CurveCreator::TypeCoord *pRealData = (CurveCreator::TypeCoord *)pIntData;
|
||||
int i = 0;
|
||||
|
||||
for (; i < aNbCoords; i++) {
|
||||
*pRealData++ = theCoords[i];
|
||||
}
|
||||
|
||||
myType = theType;
|
||||
isOK = true;
|
||||
}
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: Constructor
|
||||
// purpose:
|
||||
@ -234,7 +207,7 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
pIntData = (int*)aStrPtr;
|
||||
*pIntData++ = aNbCoords;
|
||||
|
||||
CurveCreator::TypeCoord *pRealData = (CurveCreator::TypeCoord *)aStrPtr;
|
||||
CurveCreator::TypeCoord *pRealData = (CurveCreator::TypeCoord *)pIntData;
|
||||
int i = 0;
|
||||
|
||||
for (; i < aNbCoords; i++) {
|
||||
@ -269,6 +242,84 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
const CurveCreator_ICurve::SectionToPointCoordsList &theParamList1)
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theType == CurveCreator_Operation::InsertPoints ||
|
||||
theType == CurveCreator_Operation::SetCoordinates ) {
|
||||
|
||||
const int aNbPoints = theParamList1.size();
|
||||
|
||||
CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
|
||||
theParamList1.begin();
|
||||
const int aNbCoords = anIt->second.size();
|
||||
|
||||
const size_t aSize =
|
||||
sizeof(aNbPoints) + sizeof(aNbCoords) +
|
||||
aNbPoints * (3*sizeof(int) + aNbCoords*sizeof(CurveCreator::TypeCoord));
|
||||
int *pIntData = (int *)allocate(aSize);
|
||||
|
||||
*pIntData++ = aNbPoints;
|
||||
*pIntData++ = aNbCoords;
|
||||
int aSectionId, aPointId;
|
||||
for ( ; anIt != theParamList1.end(); anIt++ ) {
|
||||
aSectionId = anIt->first.first;
|
||||
aPointId = anIt->first.second;
|
||||
|
||||
*pIntData++ = aSectionId;
|
||||
*pIntData++ = aPointId;
|
||||
*pIntData++ = aNbCoords;
|
||||
|
||||
const CurveCreator::Coordinates &aCoords = anIt->second;
|
||||
CurveCreator::TypeCoord *pRealData = (CurveCreator::TypeCoord *)pIntData;
|
||||
for (int i = 0; i < aNbCoords; i++) {
|
||||
*pRealData++ = aCoords[i];
|
||||
}
|
||||
pIntData = (int *)pRealData;
|
||||
}
|
||||
|
||||
myType = theType;
|
||||
isOK = true;
|
||||
}
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
const CurveCreator_ICurve::SectionToPointList &theParamList1)
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theType == CurveCreator_Operation::RemovePoints) {
|
||||
const int aNbPoints = theParamList1.size();
|
||||
|
||||
CurveCreator_ICurve::SectionToPointList::const_iterator anIt =
|
||||
theParamList1.begin();
|
||||
|
||||
const size_t aSize =
|
||||
sizeof(aNbPoints) +
|
||||
aNbPoints * (2*sizeof(int));
|
||||
int *pIntData = (int *)allocate(aSize);
|
||||
|
||||
*pIntData++ = aNbPoints;
|
||||
int aSectionId, aPointId;
|
||||
for ( ; anIt != theParamList1.end(); anIt++ ) {
|
||||
aSectionId = anIt->first;
|
||||
aPointId = anIt->second;
|
||||
|
||||
*pIntData++ = aSectionId;
|
||||
*pIntData++ = aPointId;
|
||||
}
|
||||
|
||||
myType = theType;
|
||||
isOK = true;
|
||||
}
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: apply
|
||||
// purpose:
|
||||
@ -280,58 +331,81 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve)
|
||||
|
||||
switch (myType) {
|
||||
case CurveCreator_Operation::AddPoints:
|
||||
case CurveCreator_Operation::InsertPoints:
|
||||
case CurveCreator_Operation::SetCoordinates:
|
||||
{
|
||||
int aSectionId, aPointId;
|
||||
CurveCreator::SectionsMap aSectionsMap;
|
||||
CurveCreator::PosPointsList aPoints;
|
||||
CurveCreator::Coordinates aCoords;
|
||||
|
||||
getCoords(&pInt[1], aCoords);
|
||||
theCurve->addPoints(aCoords, pInt[0]);
|
||||
int nbPoints = pInt[0];
|
||||
int nbCoords = pInt[1];
|
||||
int nbParams = 3+nbCoords;
|
||||
for (int i = 0; i < nbPoints*nbParams; i=i+nbParams) {
|
||||
aCoords.clear();
|
||||
aPoints.clear();
|
||||
getCoords(&pInt[4+i], aCoords);
|
||||
aSectionId = pInt[2+i];
|
||||
aPointId = pInt[3+i];
|
||||
if ( aSectionsMap.find( aSectionId ) != aSectionsMap.end() )
|
||||
aPoints = aSectionsMap[aSectionId];
|
||||
CurveCreator_PosPoint* aPosPoint = new CurveCreator_PosPoint( aPointId, aCoords );
|
||||
aPoints.push_back( aPosPoint );
|
||||
aPoints.sort(compId);
|
||||
aSectionsMap[aSectionId] = aPoints;
|
||||
}
|
||||
switch (myType) {
|
||||
case CurveCreator_Operation::AddPoints:
|
||||
case CurveCreator_Operation::InsertPoints:
|
||||
theCurve->addPointsInternal( aSectionsMap );
|
||||
break;
|
||||
case CurveCreator_Operation::SetCoordinates:
|
||||
theCurve->setPointInternal( aSectionsMap );
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case CurveCreator_Operation::RemovePoints:
|
||||
theCurve->removePoints(pInt[0], pInt[1], pInt[2]);
|
||||
break;
|
||||
case CurveCreator_Operation::InsertPoints:
|
||||
{
|
||||
CurveCreator::Coordinates aCoords;
|
||||
|
||||
getCoords(&pInt[2], aCoords);
|
||||
theCurve->insertPoints(aCoords, pInt[0], pInt[1]);
|
||||
CurveCreator_ICurve::SectionToPointList aListOfSectionsToPoints;
|
||||
int nbPoints = pInt[0];
|
||||
for (int i = 1; i < nbPoints*2; i=i+2) {
|
||||
aListOfSectionsToPoints.push_back(std::make_pair(pInt[i], pInt[i+1]));
|
||||
}
|
||||
theCurve->removePointsInternal(aListOfSectionsToPoints);
|
||||
}
|
||||
break;
|
||||
case CurveCreator_Operation::SetType:
|
||||
{
|
||||
const CurveCreator::Type aType = (CurveCreator::Type) pInt[0];
|
||||
const CurveCreator::SectionType aType = (CurveCreator::SectionType) pInt[0];
|
||||
|
||||
theCurve->setType(aType, pInt[1]);
|
||||
theCurve->setSectionTypeInternal( pInt[1], aType );
|
||||
}
|
||||
break;
|
||||
case CurveCreator_Operation::Clear:
|
||||
theCurve->clear();
|
||||
break;
|
||||
case CurveCreator_Operation::SetCoordinates:
|
||||
{
|
||||
CurveCreator::Coordinates aCoords;
|
||||
|
||||
getCoords(&pInt[2], aCoords);
|
||||
theCurve->setCoordinates(aCoords, pInt[0], pInt[1]);
|
||||
}
|
||||
theCurve->clearInternal();
|
||||
break;
|
||||
case CurveCreator_Operation::SetClosed:
|
||||
theCurve->setClosed((pInt[0] != 0), pInt[1]);
|
||||
theCurve->setClosedInternal(pInt[1], (pInt[0] != 0));
|
||||
break;
|
||||
case CurveCreator_Operation::MoveSection:
|
||||
theCurve->moveSection(pInt[0], pInt[1]);
|
||||
theCurve->moveSectionInternal(pInt[0], pInt[1]);
|
||||
break;
|
||||
case CurveCreator_Operation::Join:
|
||||
if (myPData == NULL) {
|
||||
theCurve->join();
|
||||
} else {
|
||||
theCurve->join(pInt[0], pInt[1]);
|
||||
if (myPData != NULL)
|
||||
{
|
||||
std::list<int> aListOfSections;
|
||||
int nbSections = pInt[0];
|
||||
for (int i = 1; i < nbSections+1; i++) {
|
||||
aListOfSections.push_back(pInt[i]);
|
||||
}
|
||||
theCurve->joinInternal(aListOfSections);
|
||||
}
|
||||
break;
|
||||
case CurveCreator_Operation::AddSection:
|
||||
{
|
||||
const CurveCreator::Type aType = (CurveCreator::Type) pInt[0];
|
||||
const CurveCreator::SectionType aType = (CurveCreator::SectionType) pInt[0];
|
||||
|
||||
std::string aName = std::string((char*)&pInt[2]);
|
||||
|
||||
@ -340,16 +414,16 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve)
|
||||
char* aPtr = ((char*)&pInt[2]);
|
||||
aPtr += (aName.length()) + 1;
|
||||
getCoords((int*)aPtr, aCoords);
|
||||
theCurve->addSection(aName, aType, (pInt[1] != 0), aCoords);
|
||||
theCurve->addSectionInternal(aName, aType, (pInt[1] != 0), aCoords);
|
||||
}
|
||||
break;
|
||||
case CurveCreator_Operation::RemoveSection:
|
||||
theCurve->removeSection(pInt[0]);
|
||||
theCurve->removeSectionInternal(pInt[0]);
|
||||
break;
|
||||
case CurveCreator_Operation::RenameSection:
|
||||
{
|
||||
std::string aName = std::string((char*)&pInt[1]);
|
||||
theCurve->setName(aName, pInt[0]);
|
||||
theCurve->setSectionNameInternal(pInt[0], aName);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
|
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -24,8 +24,11 @@
|
||||
#define _CurveCreator_Operation_HeaderFile
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
#include "CurveCreator_ICurve.hxx"
|
||||
#include "CurveCreator_PosPoint.hxx"
|
||||
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
class CurveCreator_Curve;
|
||||
|
||||
@ -74,7 +77,6 @@ public:
|
||||
* It is applicable to the following operations:
|
||||
* <UL>
|
||||
* <LI>Clear</LI>
|
||||
* <LI>Join (without arguments)</LI>
|
||||
* </UL>
|
||||
* @return true in case of success; false otherwise.
|
||||
*/
|
||||
@ -105,15 +107,26 @@ public:
|
||||
const int theIntParam2);
|
||||
|
||||
/**
|
||||
* This method initializes the object with an operation with three integer
|
||||
* This method initializes the object with an operation with two integer
|
||||
* parameters. It is applicable to the following operations:
|
||||
* <UL>
|
||||
* <LI>Join (with a list of int arguments)</LI>
|
||||
* </UL>
|
||||
* @return true in case of success; false otherwise.
|
||||
*/
|
||||
bool init(const Type theType, const std::list<int> theParamList);
|
||||
|
||||
/**
|
||||
* This method initializes the object with an operation with
|
||||
* list of pairs of integer parameters.
|
||||
* It is applicable to the following operations:
|
||||
* <UL>
|
||||
* <LI>RemovePoints</LI>
|
||||
* </UL>
|
||||
* @return true in case of success; false otherwise.
|
||||
*/
|
||||
bool init(const Type theType, const int theIntParam1,
|
||||
const int theIntParam2, const int theIntParam3);
|
||||
bool init(const Type theType,
|
||||
const CurveCreator_ICurve::SectionToPointList &theParamList1);
|
||||
|
||||
/**
|
||||
* This method initializes the object with an operation with one
|
||||
@ -128,18 +141,16 @@ public:
|
||||
const int theIntParam);
|
||||
|
||||
/**
|
||||
* This method initializes the object with an operation with one
|
||||
* CurveCreator::Coordinates parameter and two integer parameters.
|
||||
* This method initializes the object with an operation with
|
||||
* list of pairs of integer parameters and CurveCreator::Coordinates parameters.
|
||||
* It is applicable to the following operations:
|
||||
* <UL>
|
||||
* <LI>AddSection</LI>
|
||||
* <LI>InsertPoints</LI>
|
||||
* <LI>SetCoordinates</LI>
|
||||
* </UL>
|
||||
* @return true in case of success; false otherwise.
|
||||
*/
|
||||
bool init(const Type theType, const CurveCreator::Coordinates &theCoords,
|
||||
const int theIntParam1, const int theIntParam2);
|
||||
bool init(const Type theType,
|
||||
const CurveCreator_ICurve::SectionToPointCoordsList &theParamList1);
|
||||
|
||||
/**
|
||||
* This method initializes the object with an operation with one
|
||||
|
37
src/CurveCreator/CurveCreator_Listener.hxx → src/CurveCreator/CurveCreator_PosPoint.hxx
Executable file → Normal file
37
src/CurveCreator/CurveCreator_Listener.hxx → src/CurveCreator/CurveCreator_PosPoint.hxx
Executable file → Normal file
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -17,25 +17,30 @@
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
#ifndef CURVE_CREATOR_LISTENER_HXX
|
||||
#define CURVE_CREATOR_LISTENER_HXX
|
||||
// File: CurveCreator_PosPoint.hxx
|
||||
// Author: Alexander KOVALEV
|
||||
|
||||
class CurveCreator_Listener
|
||||
#ifndef _CurveCreator_PosPoint_HeaderFile
|
||||
#define _CurveCreator_PosPoint_HeaderFile
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
|
||||
struct CurveCreator_PosPoint
|
||||
{
|
||||
public:
|
||||
CurveCreator_Listener(void){};
|
||||
virtual ~CurveCreator_Listener(void){};
|
||||
CurveCreator_PosPoint( int theID, CurveCreator::Coordinates theCoords )
|
||||
: myID( theID ), myCoords( theCoords )
|
||||
{ };
|
||||
|
||||
virtual void pointChanged( int theSection, int thePoint ){}
|
||||
virtual void pointRemoved( int theSection, int theFirstPoint, int thePointCnt ){}
|
||||
virtual void pointInserted( int theSection, int theIndx ){}
|
||||
////! Overloaded operator to use sorting.
|
||||
//bool operator < (CurveCreator_PosPoint const & thePosPoint) const
|
||||
//{
|
||||
// return myID < thePosPoint.myID;
|
||||
//}
|
||||
|
||||
virtual void sectionClosed( int theSection, bool isClosed ){}
|
||||
virtual void sectionAdded( int theSection ){}
|
||||
virtual void sectionRemoved( int theSection ){}
|
||||
virtual void sectionTypeChanged( int theSection ){}
|
||||
int myID; // point ID
|
||||
CurveCreator::Coordinates myCoords; // point coordinates
|
||||
|
||||
virtual void curveChanged(){}
|
||||
};
|
||||
|
||||
#endif
|
||||
#endif
|
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -36,7 +36,7 @@ struct CurveCreator_Section
|
||||
|
||||
std::string myName; //!< section name
|
||||
CurveCreator::Coordinates myPoints; //!< points coordinates
|
||||
CurveCreator::Type myType; //!< type of the section
|
||||
CurveCreator::SectionType myType; //!< type of the section
|
||||
bool myIsClosed; //!< closed or not
|
||||
|
||||
};
|
||||
|
178
src/CurveCreator/CurveCreator_TableView.cxx
Normal file
178
src/CurveCreator/CurveCreator_TableView.cxx
Normal file
@ -0,0 +1,178 @@
|
||||
// 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_TableView.h"
|
||||
#include "CurveCreator_UtilsICurve.hxx"
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
#include <QTableWidget>
|
||||
#include <QTableWidgetItem>
|
||||
|
||||
#include <QtxDoubleSpinBox.h>
|
||||
|
||||
const double DBL_MINIMUM = -10000000.;
|
||||
const double DBL_MAXIMUM = 10000000.;
|
||||
|
||||
const int SECTION_NAME_COLUMN_WIDTH = 75;
|
||||
const int POINT_INDEX_COLUMN_WIDTH = 40;
|
||||
|
||||
const double LOCAL_SELECTION_TOLERANCE = 0.0001;
|
||||
|
||||
CurveCreator_TableItemDelegate::CurveCreator_TableItemDelegate( QObject* theParent )
|
||||
: QItemDelegate( theParent )
|
||||
{
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an editor for the cell
|
||||
*/
|
||||
QWidget* CurveCreator_TableItemDelegate::createEditor( QWidget* theParent,
|
||||
const QStyleOptionViewItem& theOption,
|
||||
const QModelIndex& theIndex ) const
|
||||
{
|
||||
QWidget* anEditor = 0;
|
||||
|
||||
int aColumnId = theIndex.column();
|
||||
if ( aColumnId == 2 || aColumnId == 3 ) {
|
||||
QDoubleSpinBox* aSpin = new QtxDoubleSpinBox( theParent );
|
||||
aSpin->setDecimals( 2 );
|
||||
aSpin->setRange( DBL_MINIMUM, DBL_MAXIMUM );
|
||||
anEditor = aSpin;
|
||||
}
|
||||
else
|
||||
anEditor = QItemDelegate::createEditor( theParent, theOption, theIndex );
|
||||
|
||||
return anEditor;
|
||||
}
|
||||
|
||||
void CurveCreator_TableItemDelegate::setEditorData( QWidget* theEditor,
|
||||
const QModelIndex& theIndex ) const
|
||||
{
|
||||
int aColumnId = theIndex.column();
|
||||
if ( aColumnId == 2 || aColumnId == 3 ) {
|
||||
QDoubleSpinBox* aDblSpin = dynamic_cast<QDoubleSpinBox*>( theEditor );
|
||||
if ( aDblSpin ) {
|
||||
double aValue = theIndex.model()->data( theIndex, Qt::EditRole ).toDouble();
|
||||
aDblSpin->setValue( aValue );
|
||||
}
|
||||
}
|
||||
else
|
||||
QItemDelegate::setEditorData( theEditor, theIndex );
|
||||
}
|
||||
|
||||
void CurveCreator_TableItemDelegate::setModelData( QWidget* theEditor,
|
||||
QAbstractItemModel* theModel,
|
||||
const QModelIndex& theIndex ) const
|
||||
{
|
||||
int aColumnId = theIndex.column();
|
||||
if ( aColumnId == 2 || aColumnId == 3 ) {
|
||||
QDoubleSpinBox* aDblSpin = dynamic_cast<QDoubleSpinBox*>( theEditor );
|
||||
if ( aDblSpin ) {
|
||||
double aValue = aDblSpin->value();
|
||||
theModel->setData( theIndex, aValue, Qt::UserRole);
|
||||
}
|
||||
}
|
||||
else
|
||||
QItemDelegate::setModelData( theEditor, theModel, theIndex );
|
||||
}
|
||||
|
||||
CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve,
|
||||
QWidget* theParent,
|
||||
const QStringList& theCoordTitles )
|
||||
: QTableWidget( theParent ), myCurve( theCurve )
|
||||
{
|
||||
setItemDelegate( new CurveCreator_TableItemDelegate( this ) );
|
||||
setVisible( false );
|
||||
setColumnCount( 4 );
|
||||
setColumnWidth( 0, SECTION_NAME_COLUMN_WIDTH );
|
||||
setColumnWidth( 1, POINT_INDEX_COLUMN_WIDTH );
|
||||
QStringList aLabels;
|
||||
QString aCoord1 = theCoordTitles.size() > 0 ? theCoordTitles[0] : tr( "X" ); // tr( "X_POSITION_LBL" )
|
||||
QString aCoord2 = theCoordTitles.size() > 1 ? theCoordTitles[1] : tr( "Y" ); // tr( "Y_POSITION_LBL" )
|
||||
//aLabels << tr( "SECTION_LABEL" ) << tr( "IDENTIFIER_LABEL" ) << aCoord1 << aCoord2;
|
||||
aLabels << tr( "Section" ) << "Index" << aCoord1 << aCoord2;
|
||||
setHorizontalHeaderLabels( aLabels );
|
||||
}
|
||||
|
||||
void CurveCreator_TableView::setCurve( CurveCreator_ICurve* theCurve )
|
||||
{
|
||||
myCurve = theCurve;
|
||||
}
|
||||
|
||||
void CurveCreator_TableView::setLocalPointsToTable(
|
||||
const CurveCreator_ICurve::SectionToPointList& thePoints )
|
||||
{
|
||||
setRowCount( thePoints.size() );
|
||||
|
||||
int aRowId = 0;
|
||||
CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(),
|
||||
aLast = thePoints.end();
|
||||
for ( ; anIt != aLast; anIt++ ) {
|
||||
CurveCreator_ICurve::SectionToPoint aSPoint = *anIt;
|
||||
int anISection = aSPoint.first;
|
||||
int anIPoint = aSPoint.second;
|
||||
|
||||
QTableWidgetItem* anItem;
|
||||
anItem = new QTableWidgetItem( myCurve->getSectionName( anISection ).c_str() );
|
||||
anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
|
||||
anItem->setData( Qt::UserRole, anISection );
|
||||
setItem( aRowId, 0, anItem );
|
||||
|
||||
anItem = new QTableWidgetItem( QString::number( anIPoint + 1 ) );
|
||||
anItem->setFlags( anItem->flags() & ~Qt::ItemIsEnabled );
|
||||
anItem->setData( Qt::UserRole, anIPoint );
|
||||
setItem( aRowId, 1, anItem );
|
||||
|
||||
gp_Pnt aPoint;
|
||||
CurveCreator_UtilsICurve::getPoint( myCurve, anISection, anIPoint, aPoint );
|
||||
|
||||
anItem = item( aRowId, 2 );
|
||||
if ( !anItem ) {
|
||||
anItem = new QTableWidgetItem();
|
||||
setItem( aRowId, 2, anItem );
|
||||
}
|
||||
anItem->setData( Qt::UserRole, aPoint.X() );
|
||||
anItem->setData( Qt::DisplayRole, QString::number( aPoint.X(), 'f', 2 ) );
|
||||
|
||||
anItem = item( aRowId, 3 );
|
||||
if ( !anItem ) {
|
||||
anItem = new QTableWidgetItem();
|
||||
setItem( aRowId, 3, anItem );
|
||||
}
|
||||
anItem->setData( Qt::UserRole, aPoint.Y() );
|
||||
anItem->setData( Qt::DisplayRole, QString::number( aPoint.Y(), 'f', 2 ) );
|
||||
|
||||
aRowId++;
|
||||
}
|
||||
}
|
||||
|
||||
int CurveCreator_TableView::getSectionId( const int theRowId ) const
|
||||
{
|
||||
return item( theRowId, 0 )->data( Qt::UserRole ).toInt();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a point index from the table
|
||||
* \param theRowId a table row
|
||||
*/
|
||||
int CurveCreator_TableView::getPointId( const int theRowId ) const
|
||||
{
|
||||
return item( theRowId, 1 )->data( Qt::UserRole ).toInt();
|
||||
}
|
69
src/CurveCreator/CurveCreator_TableView.h
Normal file
69
src/CurveCreator/CurveCreator_TableView.h
Normal file
@ -0,0 +1,69 @@
|
||||
// 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_TABLEVIEW_H
|
||||
#define CURVECREATOR_TABLEVIEW_H
|
||||
|
||||
#include "CurveCreator_ICurve.hxx"
|
||||
|
||||
#include <QItemDelegate>
|
||||
#include <QTableWidget>
|
||||
|
||||
class CurveCreator_TableItemDelegate : public QItemDelegate
|
||||
{
|
||||
public:
|
||||
CurveCreator_TableItemDelegate( QObject* theParent );
|
||||
~CurveCreator_TableItemDelegate() {}
|
||||
|
||||
virtual QWidget* createEditor( QWidget* theParent,
|
||||
const QStyleOptionViewItem& theOption,
|
||||
const QModelIndex& theIndex ) const;
|
||||
virtual void setEditorData( QWidget* theEditor, const QModelIndex& theIndex ) const;
|
||||
virtual void setModelData( QWidget* theEditor, QAbstractItemModel* theModel,
|
||||
const QModelIndex& theIndex ) const;
|
||||
};
|
||||
|
||||
class CurveCreator_TableView : public QTableWidget
|
||||
{
|
||||
public:
|
||||
CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent = 0,
|
||||
const QStringList& theCoordTitles = QStringList() );
|
||||
~CurveCreator_TableView() {};
|
||||
|
||||
void setCurve( CurveCreator_ICurve* theCurve );
|
||||
|
||||
void setLocalPointsToTable( const CurveCreator_ICurve::SectionToPointList& thePoints );
|
||||
|
||||
/**
|
||||
* Returns a section index from the table
|
||||
* \param theRowId a table row
|
||||
*/
|
||||
int getSectionId( const int theRowId ) const;
|
||||
/**
|
||||
* Returns a point index from the table
|
||||
* \param theRowId a table row
|
||||
*/
|
||||
int getPointId( const int theRowId ) const;
|
||||
|
||||
private:
|
||||
CurveCreator_ICurve* myCurve;
|
||||
|
||||
};
|
||||
|
||||
#endif // CURVECREATOR_TABLEVIEW_H
|
80
src/CurveCreator/CurveCreator_TreeView.cxx
Executable file → Normal file
80
src/CurveCreator/CurveCreator_TreeView.cxx
Executable file → Normal file
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -18,7 +18,7 @@
|
||||
//
|
||||
|
||||
#include "CurveCreator_TreeView.h"
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
#include "CurveCreator_ICurve.hxx"
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
#define ID_SECTION -1
|
||||
|
||||
CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent ) :
|
||||
CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent ) :
|
||||
QAbstractItemModel(parent), myCurve(theCurve)
|
||||
{
|
||||
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||
@ -86,7 +86,7 @@ QVariant CurveCreator_TreeViewModel::data(const QModelIndex & index, int role )
|
||||
}
|
||||
else if( role == Qt::DecorationRole ){
|
||||
if( aColumn == 0 ){
|
||||
CurveCreator::Type aSectionType = myCurve->getType(aRow);
|
||||
CurveCreator::SectionType aSectionType = myCurve->getSectionType(aRow);
|
||||
if( aSectionType == CurveCreator::Polyline ){
|
||||
if( myCurve->isClosed(aRow) ){
|
||||
return myCachedIcons[ICON_CLOSED_POLYLINE];
|
||||
@ -161,12 +161,12 @@ int CurveCreator_TreeViewModel::rowCount(const QModelIndex & parent ) const
|
||||
int aRowCnt = 0;
|
||||
if( myCurve != NULL ){
|
||||
if( !parent.isValid() ){
|
||||
//Points level
|
||||
//Section level
|
||||
aRowCnt = myCurve->getNbSections();
|
||||
}
|
||||
else{
|
||||
//Section level
|
||||
if( parent.internalId() == ID_SECTION ){
|
||||
//Points level
|
||||
aRowCnt = myCurve->getNbPoints(parent.row());
|
||||
}
|
||||
}
|
||||
@ -210,14 +210,14 @@ int CurveCreator_TreeViewModel::getPoint( const QModelIndex& theIndx ) const
|
||||
return theIndx.row();
|
||||
}
|
||||
|
||||
void CurveCreator_TreeViewModel::setCurve( CurveCreator_Curve* theCurve )
|
||||
void CurveCreator_TreeViewModel::setCurve( CurveCreator_ICurve* theCurve )
|
||||
{
|
||||
myCurve = theCurve;
|
||||
reset();
|
||||
}
|
||||
|
||||
/*****************************************************************************************/
|
||||
CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent) :
|
||||
CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent) :
|
||||
QTreeView(parent)
|
||||
{
|
||||
header()->hide();
|
||||
@ -249,7 +249,6 @@ QList<int> CurveCreator_TreeView::getSelectedSections() const
|
||||
aSect << aModel->getSection( anIndxs[i] );
|
||||
}
|
||||
}
|
||||
qSort(aSect.begin(), aSect.end());
|
||||
return aSect;
|
||||
}
|
||||
|
||||
@ -290,7 +289,11 @@ void CurveCreator_TreeView::sectionAdded( int theSection )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
rowsInserted(QModelIndex(), theSection, theSection );
|
||||
int nbRows = aModel->rowCount();
|
||||
int aSection = (theSection == -1 ? (nbRows==0 ? 0 : nbRows-1) : theSection);
|
||||
rowsInserted(QModelIndex(), aSection, aSection );
|
||||
QModelIndex aSectIndx = aModel->sectionIndex(aSection);
|
||||
selectionModel()->select(aSectIndx, QItemSelectionModel::Rows | QItemSelectionModel::ClearAndSelect);
|
||||
}
|
||||
}
|
||||
|
||||
@ -361,16 +364,6 @@ void CurveCreator_TreeView::sectionsSwapped( int theSection, int theOffset )
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::pointsSwapped( int theSection, int thePointNum, int theOffset )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
QModelIndex aFirstIndex = aModel->pointIndex( theSection, thePointNum );
|
||||
QModelIndex aSecondIndex = aModel->pointIndex( theSection, thePointNum + theOffset );
|
||||
swapIndexes( aFirstIndex, aSecondIndex );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::setSelectedSections( const QList<int>& theList )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
@ -378,19 +371,7 @@ void CurveCreator_TreeView::setSelectedSections( const QList<int>& theList )
|
||||
selectionModel()->clearSelection();
|
||||
for( int i = 0 ; i < theList.size() ; i++ ){
|
||||
QModelIndex aSectIndx = aModel->sectionIndex(theList[i]);
|
||||
selectionModel()->select(aSectIndx, QItemSelectionModel::Select );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::setSelectedPoints( const QList< QPair<int, int> >& thePointsList )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel ){
|
||||
selectionModel()->clearSelection();
|
||||
for( int i = 0 ; i < thePointsList.size() ; i++ ){
|
||||
QModelIndex aSectIndx = aModel->pointIndex( thePointsList[i].first, thePointsList[i].second );
|
||||
selectionModel()->select(aSectIndx, QItemSelectionModel::Select );
|
||||
selectionModel()->select(aSectIndx, QItemSelectionModel::Select | QItemSelectionModel::Rows );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -404,25 +385,6 @@ bool pointLessThan(const QPair<int,int> &s1, const QPair<int,int> &s2)
|
||||
return s1.second < s2.second;
|
||||
}
|
||||
|
||||
QList< QPair< int, int > > CurveCreator_TreeView::getSelectedPoints() const
|
||||
{
|
||||
QList< QPair< int, int > > aPoints;
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( !aModel )
|
||||
return aPoints;
|
||||
QModelIndexList anIndxs = selectionModel()->selectedIndexes();
|
||||
for( int i = 0 ; i < anIndxs.size() ; i++ ){
|
||||
if( !aModel->isSection( anIndxs[i] ) ){
|
||||
int aSect = aModel->getSection(anIndxs[i]);
|
||||
int aPointNum = aModel->getPoint(anIndxs[i]);
|
||||
QPair< int, int > aPoint = QPair<int,int>( aSect, aPointNum );
|
||||
aPoints.push_back( aPoint );
|
||||
}
|
||||
}
|
||||
qSort( aPoints.begin(), aPoints.end(), pointLessThan );
|
||||
return aPoints;
|
||||
}
|
||||
|
||||
CurveCreator_TreeView::SelectionType CurveCreator_TreeView::getSelectionType() const
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
@ -470,16 +432,20 @@ void CurveCreator_TreeView::onActivated( QModelIndex theIndx )
|
||||
int aSect = aModel->getSection(theIndx);
|
||||
if( aModel->isSection(theIndx) ){
|
||||
emit sectionEntered( aSect );
|
||||
return;
|
||||
}
|
||||
int aPointNum = aModel->getPoint( theIndx );
|
||||
emit pointEntered( aSect, aPointNum );
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::setCurve( CurveCreator_Curve* theCurve )
|
||||
void CurveCreator_TreeView::setCurve( CurveCreator_ICurve* theCurve )
|
||||
{
|
||||
CurveCreator_TreeViewModel* aModel = dynamic_cast<CurveCreator_TreeViewModel*>(model());
|
||||
if( aModel )
|
||||
aModel->setCurve(theCurve);
|
||||
reset();
|
||||
}
|
||||
|
||||
void CurveCreator_TreeView::reset()
|
||||
{
|
||||
QList<int> aSelSections = getSelectedSections();
|
||||
QTreeView::reset();
|
||||
setSelectedSections(aSelSections);
|
||||
}
|
||||
|
24
src/CurveCreator/CurveCreator_TreeView.h
Executable file → Normal file
24
src/CurveCreator/CurveCreator_TreeView.h
Executable file → Normal file
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -23,12 +23,12 @@
|
||||
#include <QTreeView>
|
||||
#include <QAbstractItemModel>
|
||||
|
||||
class CurveCreator_Curve;
|
||||
class CurveCreator_ICurve;
|
||||
|
||||
class CurveCreator_TreeViewModel : public QAbstractItemModel
|
||||
{
|
||||
public:
|
||||
CurveCreator_TreeViewModel( CurveCreator_Curve* theCurve, QObject* parent );
|
||||
CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent );
|
||||
virtual int columnCount(const QModelIndex & parent = QModelIndex()) const;
|
||||
virtual int rowCount(const QModelIndex & parent = QModelIndex()) const;
|
||||
virtual QVariant data(const QModelIndex & index, int role = Qt::DisplayRole) const;
|
||||
@ -44,12 +44,12 @@ public:
|
||||
int getSection( const QModelIndex& theIndx ) const;
|
||||
int getPoint( const QModelIndex& theIndx ) const;
|
||||
|
||||
void setCurve( CurveCreator_Curve* theCurve );
|
||||
void setCurve( CurveCreator_ICurve* theCurve );
|
||||
|
||||
private:
|
||||
enum IconType{ ICON_POLYLINE, ICON_SPLINE, ICON_CLOSED_SPLINE, ICON_CLOSED_POLYLINE, ICON_POINT };
|
||||
private:
|
||||
CurveCreator_Curve* myCurve;
|
||||
CurveCreator_ICurve* myCurve;
|
||||
QMap<IconType, QPixmap> myCachedIcons;
|
||||
};
|
||||
|
||||
@ -59,15 +59,13 @@ class CurveCreator_TreeView : public QTreeView
|
||||
public:
|
||||
enum SelectionType{ ST_NOSEL, ST_POINTS, ST_POINTS_ONE_SECTION, ST_SECTIONS, ST_MIXED };
|
||||
public:
|
||||
explicit CurveCreator_TreeView( CurveCreator_Curve* theCurve, QWidget *parent = 0);
|
||||
explicit CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent = 0);
|
||||
SelectionType getSelectionType() const;
|
||||
QList<int> getSelectedSections() const;
|
||||
QList< QPair< int, int > > getSelectedPoints() const;
|
||||
|
||||
void pointsAdded( int theSection, int thePoint, int thePointsCnt=1 );
|
||||
void pointDataChanged( int theSection, int thePoint );
|
||||
void pointsRemoved(int theSection, int thePoint, int thePointsCnt=1 );
|
||||
void pointsSwapped( int theSection, int thePointNum, int theOffset );
|
||||
|
||||
void sectionAdded( int theSection );
|
||||
void sectionChanged(int theSection , int aSectCnt = 1);
|
||||
@ -75,15 +73,15 @@ public:
|
||||
void sectionsSwapped( int theSection, int theOffset );
|
||||
|
||||
void setSelectedSections( const QList<int>& theList );
|
||||
void setSelectedPoints( const QList< QPair<int, int> >& thePointsList );
|
||||
|
||||
void setCurve( CurveCreator_Curve* theCurve );
|
||||
void setCurve( CurveCreator_ICurve* theCurve );
|
||||
|
||||
void reset();
|
||||
|
||||
signals:
|
||||
void selectionChanged();
|
||||
void sectionEntered(int);
|
||||
void pointEntered(int,int);
|
||||
public slots:
|
||||
|
||||
protected slots:
|
||||
void onActivated( QModelIndex theIndx );
|
||||
protected:
|
||||
|
@ -1,237 +0,0 @@
|
||||
// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File: CurveCreator_UndoOptsDlg.cxx
|
||||
// Author: Sergey KHROMOV
|
||||
|
||||
#include "CurveCreator_UndoOptsDlg.h"
|
||||
|
||||
#include <QButtonGroup>
|
||||
#include <QGridLayout>
|
||||
#include <QGroupBox>
|
||||
#include <QIntValidator>
|
||||
#include <QLineEdit>
|
||||
#include <QPushButton>
|
||||
#include <QRadioButton>
|
||||
|
||||
#define UNDO_DEPTH_UNLIMITED 0
|
||||
#define UNDO_DEPTH_DISABLED 1
|
||||
#define UNDO_DEPTH_FIX_SIZE 2
|
||||
|
||||
//=======================================================================
|
||||
// function: Constructor
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
CurveCreator_UndoOptsDlg::CurveCreator_UndoOptsDlg(QWidget* parent)
|
||||
: QDialog (parent),
|
||||
myUndoDepth (UNDO_DEPTH_UNLIMITED),
|
||||
myOptsBtnGrp (NULL),
|
||||
myBufferSizeEdit (NULL),
|
||||
myOkBtn (NULL),
|
||||
myCancelBtn (NULL)
|
||||
{
|
||||
setWindowTitle(tr("CC_UNDO_OPTIONS_TITLE"));
|
||||
|
||||
// Set Undo/Redo options group
|
||||
QGroupBox *anUndoOptsGrp =
|
||||
new QGroupBox(tr("CC_UNDO_OPTIONS_MODIFY"));
|
||||
QGridLayout *anUndoOptsLO = new QGridLayout(anUndoOptsGrp);
|
||||
QRadioButton *aDisabledRdBtn =
|
||||
new QRadioButton(tr("CC_UNDO_OPTIONS_DISABLED"), anUndoOptsGrp);
|
||||
QRadioButton *aFixSizeRdBtn =
|
||||
new QRadioButton(tr("CC_UNDO_OPTIONS_FIXED_SIZE"), anUndoOptsGrp);
|
||||
QRadioButton *anUnlimRdBtn =
|
||||
new QRadioButton(tr("CC_UNDO_OPTIONS_UNLIMITED"), anUndoOptsGrp);
|
||||
|
||||
myOptsBtnGrp = new QButtonGroup(anUndoOptsGrp);
|
||||
myBufferSizeEdit = new QLineEdit(anUndoOptsGrp);
|
||||
anUndoOptsLO->setMargin(9);
|
||||
anUndoOptsLO->setSpacing(6);
|
||||
anUndoOptsLO->addWidget(aDisabledRdBtn, 0, 0);
|
||||
anUndoOptsLO->addWidget(aFixSizeRdBtn, 1, 0);
|
||||
anUndoOptsLO->addWidget(anUnlimRdBtn, 2, 0);
|
||||
anUndoOptsLO->addWidget(myBufferSizeEdit, 1, 1);
|
||||
myOptsBtnGrp->addButton(anUnlimRdBtn, UNDO_DEPTH_UNLIMITED);
|
||||
myOptsBtnGrp->addButton(aDisabledRdBtn, UNDO_DEPTH_DISABLED);
|
||||
myOptsBtnGrp->addButton(aFixSizeRdBtn, UNDO_DEPTH_FIX_SIZE);
|
||||
|
||||
// Set OK/Cancel buttons group
|
||||
QGroupBox *anOkCancelGrp = new QGroupBox;
|
||||
QGridLayout *anOkCancelLO = new QGridLayout(anOkCancelGrp);
|
||||
|
||||
myOkBtn = new QPushButton(tr("GEOM_BUT_OK"), anOkCancelGrp);
|
||||
myCancelBtn = new QPushButton(tr("GEOM_BUT_CANCEL"), anOkCancelGrp);
|
||||
anOkCancelLO->setMargin(9);
|
||||
anOkCancelLO->setSpacing(6);
|
||||
anOkCancelLO->addWidget(myOkBtn, 0, 0);
|
||||
anOkCancelLO->addWidget(myCancelBtn, 0, 1);
|
||||
|
||||
// Set main group
|
||||
QGroupBox *aMainGrp = new QGroupBox;
|
||||
QVBoxLayout *aMainLO = new QVBoxLayout(aMainGrp);
|
||||
|
||||
aMainLO->addWidget(anUndoOptsGrp);
|
||||
aMainLO->addWidget(anOkCancelGrp);
|
||||
|
||||
setLayout(aMainLO);
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: Destructor
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
CurveCreator_UndoOptsDlg::~CurveCreator_UndoOptsDlg()
|
||||
{
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setUndoDepth
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_UndoOptsDlg::setUndoDepth(const int theDepth)
|
||||
{
|
||||
myUndoDepth = theDepth;
|
||||
|
||||
const int aDepthId = myUndoDepth + 1;
|
||||
int anId = UNDO_DEPTH_FIX_SIZE;
|
||||
|
||||
if (aDepthId == UNDO_DEPTH_UNLIMITED ||
|
||||
aDepthId == UNDO_DEPTH_DISABLED) {
|
||||
anId = aDepthId;
|
||||
} else if (myUndoDepth > 0) {
|
||||
myBufferSizeEdit->setText(QString::number(myUndoDepth));
|
||||
}
|
||||
|
||||
myOptsBtnGrp->button(anId)->setChecked(true);
|
||||
optionChanged(anId);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: getUndoDepth
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
int CurveCreator_UndoOptsDlg::getUndoDepth() const
|
||||
{
|
||||
return myUndoDepth;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: isEnabled
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
bool CurveCreator_UndoOptsDlg::isEnabled() const
|
||||
{
|
||||
return (myUndoDepth + 1 != UNDO_DEPTH_DISABLED);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: isUnlimited
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
bool CurveCreator_UndoOptsDlg::isUnlimited() const
|
||||
{
|
||||
return (myUndoDepth + 1 == UNDO_DEPTH_UNLIMITED);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: init
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_UndoOptsDlg::init()
|
||||
{
|
||||
// Initialize sections group.
|
||||
myOptsBtnGrp->setExclusive(true);
|
||||
myOptsBtnGrp->button(UNDO_DEPTH_UNLIMITED)->setChecked(true);
|
||||
connect(myOptsBtnGrp, SIGNAL(buttonClicked(int)),
|
||||
this, SLOT(optionChanged(int)));
|
||||
|
||||
// Initialize line edit.
|
||||
QIntValidator *aValidator = new QIntValidator(myBufferSizeEdit);
|
||||
|
||||
aValidator->setBottom(1);
|
||||
myBufferSizeEdit->setValidator(aValidator);
|
||||
optionChanged(UNDO_DEPTH_UNLIMITED);
|
||||
|
||||
// Init buttons.
|
||||
myOkBtn->setDefault(true);
|
||||
|
||||
connect(myOkBtn, SIGNAL(clicked()), this, SLOT(accept()));
|
||||
connect(myCancelBtn, SIGNAL(clicked()), this, SLOT(reject()));
|
||||
|
||||
setTabOrder();
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: setTabOrder
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_UndoOptsDlg::setTabOrder()
|
||||
{
|
||||
QWidget::setTabOrder(myOptsBtnGrp->button(UNDO_DEPTH_DISABLED),
|
||||
myOptsBtnGrp->button(UNDO_DEPTH_FIX_SIZE));
|
||||
QWidget::setTabOrder(myOptsBtnGrp->button(UNDO_DEPTH_FIX_SIZE),
|
||||
myBufferSizeEdit);
|
||||
QWidget::setTabOrder(myBufferSizeEdit,
|
||||
myOptsBtnGrp->button(UNDO_DEPTH_UNLIMITED));
|
||||
QWidget::setTabOrder(myOptsBtnGrp->button(UNDO_DEPTH_UNLIMITED), myOkBtn);
|
||||
QWidget::setTabOrder(myOkBtn, myCancelBtn);
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: optionChanged
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_UndoOptsDlg::optionChanged(int theId)
|
||||
{
|
||||
switch (theId) {
|
||||
case UNDO_DEPTH_FIX_SIZE:
|
||||
myBufferSizeEdit->setEnabled(true);
|
||||
break;
|
||||
case UNDO_DEPTH_UNLIMITED:
|
||||
case UNDO_DEPTH_DISABLED:
|
||||
default:
|
||||
myBufferSizeEdit->setEnabled(false);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: accept
|
||||
// purpose:
|
||||
//=======================================================================
|
||||
void CurveCreator_UndoOptsDlg::accept()
|
||||
{
|
||||
const int anId = myOptsBtnGrp->checkedId();
|
||||
|
||||
switch (anId) {
|
||||
case UNDO_DEPTH_FIX_SIZE:
|
||||
myUndoDepth = myBufferSizeEdit->text().toInt();
|
||||
break;
|
||||
case UNDO_DEPTH_UNLIMITED:
|
||||
case UNDO_DEPTH_DISABLED:
|
||||
myUndoDepth = anId - 1;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
QDialog::accept();
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
// Copyright (C) 2013-2014 CEA/DEN, EDF R&D, OPEN CASCADE
|
||||
//
|
||||
// This library is free software; you can redistribute it and/or
|
||||
// modify it under the terms of the GNU Lesser General Public
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
//
|
||||
// This library is distributed in the hope that it will be useful,
|
||||
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
// Lesser General Public License for more details.
|
||||
//
|
||||
// You should have received a copy of the GNU Lesser General Public
|
||||
// License along with this library; if not, write to the Free Software
|
||||
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
||||
//
|
||||
// See http://www.salome-platform.org/ or email : webmaster.salome@opencascade.com
|
||||
//
|
||||
|
||||
// File: CurveCreator_UndoOptsDlg.h
|
||||
// Author: Sergey KHROMOV
|
||||
|
||||
#ifndef _CurveCreator_UndoOptsDlg_HeaderFile
|
||||
#define _CurveCreator_UndoOptsDlg_HeaderFile
|
||||
|
||||
#include <QDialog>
|
||||
|
||||
class QButtonGroup;
|
||||
class QLineEdit;
|
||||
class QPushButton;
|
||||
|
||||
|
||||
class CurveCreator_UndoOptsDlg : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
CurveCreator_UndoOptsDlg(QWidget* parent);
|
||||
|
||||
~CurveCreator_UndoOptsDlg();
|
||||
|
||||
void setUndoDepth(const int theDepth);
|
||||
|
||||
int getUndoDepth() const;
|
||||
|
||||
bool isEnabled() const;
|
||||
|
||||
bool isUnlimited() const;
|
||||
|
||||
private:
|
||||
|
||||
void init();
|
||||
|
||||
void setTabOrder();
|
||||
|
||||
private slots:
|
||||
|
||||
void optionChanged(int theId);
|
||||
|
||||
void accept();
|
||||
|
||||
protected:
|
||||
|
||||
int myUndoDepth;
|
||||
QButtonGroup *myOptsBtnGrp;
|
||||
QLineEdit *myBufferSizeEdit;
|
||||
QPushButton *myOkBtn;
|
||||
QPushButton *myCancelBtn;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
537
src/CurveCreator/CurveCreator_Utils.cxx
Normal file
537
src/CurveCreator/CurveCreator_Utils.cxx
Normal file
@ -0,0 +1,537 @@
|
||||
// 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.hxx"
|
||||
#include "CurveCreator.hxx"
|
||||
#include "CurveCreator_UtilsICurve.hxx"
|
||||
|
||||
#include <GEOMUtils.hxx>
|
||||
|
||||
#include <gp_Pln.hxx>
|
||||
|
||||
#include <TopoDS.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Compound.hxx>
|
||||
|
||||
#include <AIS_ListOfInteractive.hxx>
|
||||
#include <AIS_ListIteratorOfListOfInteractive.hxx>
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <AIS_Line.hxx>
|
||||
#include <AIS_Trihedron.hxx>
|
||||
#include <AIS_LocalContext.hxx>
|
||||
|
||||
#include <Geom_Point.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <Geom_Line.hxx>
|
||||
|
||||
#include <TopExp.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <GeomAPI_ProjectPointOnCurve.hxx>
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <SelectMgr_Selection.hxx>
|
||||
#include <Select3D_SensitivePoint.hxx>
|
||||
|
||||
#include <BRep_Tool.hxx>
|
||||
#include <BRep_Builder.hxx>
|
||||
#include <BRepBuilderAPI_MakeVertex.hxx>
|
||||
#include <BRepBuilderAPI_MakeEdge.hxx>
|
||||
#include <BRepBuilderAPI_MakeWire.hxx>
|
||||
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <TColStd_HArray1OfBoolean.hxx>
|
||||
#include <TColgp_Array1OfVec.hxx>
|
||||
#include <GeomAPI_Interpolate.hxx>
|
||||
|
||||
#include <ProjLib.hxx>
|
||||
#include <ElSLib.hxx>
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include "CurveCreator_ICurve.hxx"
|
||||
|
||||
const double LOCAL_SELECTION_TOLERANCE = 0.0001;
|
||||
const int SCENE_PIXEL_PROJECTION_TOLERANCE = 10;
|
||||
const int SCENE_PIXEL_POINT_TOLERANCE = 5;
|
||||
|
||||
//=======================================================================
|
||||
// function : ConvertClickToPoint()
|
||||
// purpose : Returns the point clicked in 3D view
|
||||
//=======================================================================
|
||||
void CurveCreator_Utils::ConvertPointToClick( const gp_Pnt& thePoint,
|
||||
Handle(V3d_View) theView,
|
||||
int& x, int& y )
|
||||
{
|
||||
theView->Convert(thePoint.X(), thePoint.Y(), thePoint.Z(), x, y );
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
// function : ConvertClickToPoint()
|
||||
// purpose : Returns the point clicked in 3D view
|
||||
//=======================================================================
|
||||
gp_Pnt CurveCreator_Utils::ConvertClickToPoint( int x, int y, Handle(V3d_View) aView )
|
||||
{
|
||||
// the 3D point, that is a projection of the pixels to the XYZ view plane
|
||||
//return GEOMUtils::ConvertClickToPoint( x, y, aView );
|
||||
|
||||
// we need the projection to the XOY plane
|
||||
// 1. find a point in the plane of the eye and the normal to the plane
|
||||
Standard_Real X, Y, Z;
|
||||
Quantity_Parameter Vx, Vy, Vz;
|
||||
aView->ConvertWithProj( x, y, X, Y, Z, Vx, Vy, Vz );
|
||||
|
||||
// 2. build a ray from the point by the normal to the XOY plane and intersect it
|
||||
// The ray equation is the following : p(x,y,z) = p0(x,y,z) + t*V(x,y,z)
|
||||
// X,Y,Z - defines p0(x,y,z), Vx,Vy,Vz - defines V(x,y,z)
|
||||
// p(x,y,z) - is a searched point, t - should to be calculated by the condition of XOY plane
|
||||
// The system of equations is the following:
|
||||
// p(x) = p0(x)+t*V(x)
|
||||
// p(y) = p0(y)+t*V(y)
|
||||
// p(z) = p0(z)+t*V(z)
|
||||
// p(z) = 0
|
||||
|
||||
Standard_Real aXp, aYp, aZp;
|
||||
//It is not possible to use Precision::Confusion(), because it is e-0.8, but V is sometimes e-6
|
||||
Standard_Real aPrec = LOCAL_SELECTION_TOLERANCE;
|
||||
if ( fabs( Vz ) > aPrec ) {
|
||||
Standard_Real aT = -Z/Vz;
|
||||
aXp = X + aT*Vx;
|
||||
aYp = Y + aT*Vy;
|
||||
aZp = Z + aT*Vz;
|
||||
}
|
||||
else { // Vz = 0 - the eyed plane is orthogonal to Z plane - XOZ, or YOZ
|
||||
aXp = aYp = aZp = 0;
|
||||
if ( fabs( Vy ) < aPrec ) // Vy = 0 - the YOZ plane
|
||||
aYp = Y;
|
||||
else if ( fabs( Vx ) < aPrec ) // Vx = 0 - the XOZ plane
|
||||
aXp = X;
|
||||
}
|
||||
/*std::cout << "ConvertClickToPoint: " << std::endl
|
||||
<< "XYZ1 = (" << X << ", " << Y << ", " << Z << "); " << std::endl
|
||||
<< "Vxyz = (" << Vx << ", " << Vy << ", " << Vz << "); " << std::endl
|
||||
<< "Resp = (" << aXp << ", " << aYp << ", " << aZp << "); " << std::endl;*/
|
||||
|
||||
gp_Pnt ResultPoint( aXp, aYp, aZp );
|
||||
return ResultPoint;
|
||||
}
|
||||
|
||||
void CurveCreator_Utils::constructShape( const CurveCreator_ICurve* theCurve,
|
||||
TopoDS_Shape& theShape )
|
||||
{
|
||||
BRep_Builder aBuilder;
|
||||
TopoDS_Compound aComp;
|
||||
aBuilder.MakeCompound( aComp );
|
||||
for( int iSection = 0 ; iSection < theCurve->getNbSections() ; iSection++ )
|
||||
{
|
||||
int theISection = iSection;
|
||||
|
||||
CurveCreator::SectionType aSectType = theCurve->getSectionType( theISection );
|
||||
int aPointSize = theCurve->getNbPoints( theISection );
|
||||
if ( aPointSize == 0 )
|
||||
continue;
|
||||
|
||||
bool aSectIsClosed = theCurve->isClosed( theISection );
|
||||
bool isPolyline = aSectType == CurveCreator::Polyline;
|
||||
|
||||
int iPoint = 0;
|
||||
gp_Pnt aPrevPoint, aPoint;
|
||||
// filters the curve points to skip equal points
|
||||
std::vector<gp_Pnt> aPoints;
|
||||
CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint );
|
||||
aPoints.push_back( aPoint );
|
||||
aPrevPoint = aPoint;
|
||||
iPoint++;
|
||||
for( ; iPoint < aPointSize; iPoint++ ) {
|
||||
CurveCreator_UtilsICurve::getPoint( theCurve, theISection, iPoint, aPoint );
|
||||
if ( !isEqualPoints( aPrevPoint, aPoint ) )
|
||||
aPoints.push_back( aPoint );
|
||||
aPrevPoint = aPoint;
|
||||
}
|
||||
int aNbPoints = aPoints.size();
|
||||
|
||||
if ( aNbPoints == 1 ) {
|
||||
aPoint = aPoints.front();
|
||||
TopoDS_Vertex aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
|
||||
aBuilder.Add( aComp, aVertex );
|
||||
}
|
||||
else if ( aNbPoints > 1 ) {
|
||||
Handle(TColgp_HArray1OfPnt) aHCurvePoints = new TColgp_HArray1OfPnt(1, aNbPoints);
|
||||
TColgp_Array1OfVec aTangents(1, aNbPoints);
|
||||
Handle(TColStd_HArray1OfBoolean) aTangentFlags = new TColStd_HArray1OfBoolean(1, aNbPoints);
|
||||
gp_Vec aNullVec(0, 0, 0);
|
||||
|
||||
TopoDS_Edge aPointEdge;
|
||||
TopoDS_Vertex aVertex;
|
||||
|
||||
std::vector<gp_Pnt>::const_iterator aPointIt = aPoints.begin(), aPointLast = aPoints.end();
|
||||
aPoint = *aPointIt;
|
||||
|
||||
int aHIndex = 1;
|
||||
aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
|
||||
aBuilder.Add( aComp, aVertex );
|
||||
if ( !isPolyline ) {
|
||||
aHCurvePoints->SetValue( aHIndex, aPoint );
|
||||
aTangents.SetValue( aHIndex, aNullVec );
|
||||
aTangentFlags->SetValue( aHIndex, Standard_False );
|
||||
aHIndex++;
|
||||
}
|
||||
|
||||
aPrevPoint = aPoint;
|
||||
aPointIt++;
|
||||
for( ; aPointIt != aPointLast; aPointIt++ ) {
|
||||
aPoint = *aPointIt;
|
||||
aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
|
||||
aBuilder.Add( aComp, aVertex );
|
||||
if ( isPolyline ) {
|
||||
TopoDS_Edge aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge();
|
||||
aBuilder.Add( aComp, aPointEdge );
|
||||
}
|
||||
else {
|
||||
aHCurvePoints->SetValue( aHIndex, aPoint );
|
||||
aTangents.SetValue( aHIndex, aNullVec );
|
||||
aTangentFlags->SetValue( aHIndex, Standard_False );
|
||||
aHIndex++;
|
||||
}
|
||||
aPrevPoint = aPoint;
|
||||
}
|
||||
if( aSectIsClosed && ( aNbPoints > 2 ) ) {
|
||||
aPoint = aPoints.front();
|
||||
aVertex = BRepBuilderAPI_MakeVertex( aPoint ).Vertex();
|
||||
aBuilder.Add( aComp, aVertex );
|
||||
if ( isPolyline ) {
|
||||
aPointEdge = BRepBuilderAPI_MakeEdge( aPrevPoint, aPoint ).Edge();
|
||||
aBuilder.Add( aComp, aPointEdge );
|
||||
}
|
||||
}
|
||||
if( !isPolyline ) {
|
||||
// compute BSpline
|
||||
Handle(Geom_BSplineCurve) aBSplineCurve;
|
||||
GeomAPI_Interpolate aGBC(aHCurvePoints, aSectIsClosed, gp::Resolution());
|
||||
// correct the spline degree to be as 3 for non-periodic spline if number of points
|
||||
// less than 3. It is need to have a knot in each spline point. This knots are used
|
||||
// to found a neighbour points when a new point is inserted between two existing.
|
||||
if (!aSectIsClosed ) {
|
||||
if (aHCurvePoints->Length() == 3)
|
||||
aGBC.Load(aTangents, aTangentFlags);
|
||||
}
|
||||
|
||||
aGBC.Perform();
|
||||
if ( aGBC.IsDone() )
|
||||
aBSplineCurve = aGBC.Curve();
|
||||
TopoDS_Edge anEdge = BRepBuilderAPI_MakeEdge( aBSplineCurve ).Edge();
|
||||
TopoDS_Wire aWire = BRepBuilderAPI_MakeWire( anEdge ).Wire();
|
||||
aBuilder.Add( aComp, aWire );
|
||||
}
|
||||
}
|
||||
}
|
||||
theShape = aComp;
|
||||
}
|
||||
|
||||
class CompareSectionToPoint
|
||||
{
|
||||
public:
|
||||
CompareSectionToPoint( const int theISection = -1, const int theIPoint = -1 )
|
||||
: mySectionId( theISection ), myPointId( theIPoint ) {};
|
||||
~CompareSectionToPoint() {}
|
||||
|
||||
bool operator < ( const CompareSectionToPoint& theOther ) const
|
||||
{
|
||||
bool isLess = mySectionId < theOther.mySectionId;
|
||||
if ( !isLess && mySectionId == theOther.mySectionId )
|
||||
isLess = myPointId < theOther.myPointId;
|
||||
return isLess;
|
||||
}
|
||||
|
||||
private:
|
||||
int mySectionId;
|
||||
int myPointId;
|
||||
};
|
||||
|
||||
|
||||
void CurveCreator_Utils::getSelectedPoints( Handle(AIS_InteractiveContext) theContext,
|
||||
const CurveCreator_ICurve* theCurve,
|
||||
CurveCreator_ICurve::SectionToPointList& thePoints )
|
||||
{
|
||||
thePoints.clear();
|
||||
|
||||
std::list<float> aSelectedPoints;
|
||||
gp_Pnt aPnt;
|
||||
std::map<CompareSectionToPoint, int> aPointsMap;
|
||||
|
||||
CurveCreator_ICurve::SectionToPointList aPoints;
|
||||
for ( theContext->InitSelected(); theContext->MoreSelected(); theContext->NextSelected() ) {
|
||||
TopoDS_Vertex aVertex;
|
||||
TopoDS_Shape aShape = theContext->SelectedShape();
|
||||
if ( !aShape.IsNull() && aShape.ShapeType() == TopAbs_VERTEX )
|
||||
aVertex = TopoDS::Vertex( theContext->SelectedShape() );
|
||||
|
||||
if ( aVertex.IsNull() )
|
||||
continue;
|
||||
aPnt = BRep_Tool::Pnt( aVertex );
|
||||
|
||||
CurveCreator_UtilsICurve::findSectionsToPoints( theCurve, aPnt.X(), aPnt.Y(), aPoints );
|
||||
CurveCreator_ICurve::SectionToPointList::const_iterator anIt = aPoints.begin(),
|
||||
aLast = aPoints.end();
|
||||
CompareSectionToPoint aPoint;
|
||||
for ( ; anIt != aLast; anIt++ ) {
|
||||
aPoint = CompareSectionToPoint( (*anIt).first, (*anIt).second );
|
||||
if ( aPointsMap.find( aPoint ) != aPointsMap.end() )
|
||||
continue;
|
||||
aPointsMap[aPoint] = 0;
|
||||
|
||||
thePoints.push_back( *anIt );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Utils::setSelectedPoints( Handle(AIS_InteractiveContext) theContext,
|
||||
const CurveCreator_ICurve* theCurve,
|
||||
const CurveCreator_ICurve::SectionToPointList& thePoints )
|
||||
{
|
||||
if ( !theCurve )
|
||||
return;
|
||||
|
||||
Handle(AIS_InteractiveObject) anAIS = theCurve->getAISObject();
|
||||
if ( anAIS.IsNull() )
|
||||
return;
|
||||
Handle(AIS_Shape) anAISShape = Handle(AIS_Shape)::DownCast( anAIS );
|
||||
if ( anAISShape.IsNull() )
|
||||
return;
|
||||
|
||||
//ASL: we convert list of point indices to list of points coordinates
|
||||
int aSize = thePoints.size();
|
||||
std::vector<gp_Pnt> aPntsToSelect( aSize );
|
||||
|
||||
CurveCreator_ICurve::SectionToPointList::const_iterator
|
||||
aPIt = thePoints.begin(), aPLast = thePoints.end();
|
||||
CurveCreator_ICurve::SectionToPoint aSToPoint;
|
||||
for( int i=0; aPIt != aPLast; aPIt++, i++ )
|
||||
{
|
||||
gp_Pnt aPntToSelect;
|
||||
CurveCreator_UtilsICurve::getPoint( theCurve, aPIt->first, aPIt->second, aPntToSelect );
|
||||
aPntsToSelect[i] = aPntToSelect;
|
||||
}
|
||||
|
||||
theContext->ClearSelected( Standard_False );
|
||||
//ASL: we switch off automatic highlight to improve performance of selection
|
||||
theContext->SetAutomaticHilight( Standard_False );
|
||||
|
||||
Handle_SelectMgr_Selection aSelection = anAISShape->Selection( AIS_Shape::SelectionMode( TopAbs_VERTEX ) );
|
||||
for( aSelection->Init(); aSelection->More(); aSelection->Next() )
|
||||
{
|
||||
Handle_SelectBasics_SensitiveEntity aSenEntity = aSelection->Sensitive();
|
||||
Handle_Select3D_SensitivePoint aSenPnt = Handle_Select3D_SensitivePoint::DownCast( aSenEntity );
|
||||
|
||||
gp_Pnt anOwnerPnt = aSenPnt->Point();
|
||||
Handle_SelectMgr_EntityOwner anOwner = Handle_SelectMgr_EntityOwner::DownCast( aSenPnt->OwnerId() );
|
||||
|
||||
|
||||
CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(),
|
||||
aLast = thePoints.end();
|
||||
bool isFound = false;
|
||||
for( int i=0; i<aSize; i++ )
|
||||
{
|
||||
bool isIntersect = fabs( aPntsToSelect[i].X() - anOwnerPnt.X() ) < LOCAL_SELECTION_TOLERANCE &&
|
||||
fabs( aPntsToSelect[i].Y() - anOwnerPnt.Y() ) < LOCAL_SELECTION_TOLERANCE;
|
||||
if( isIntersect )
|
||||
{
|
||||
theContext->AddOrRemoveSelected( anOwner, Standard_False );
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//ASL: we switch on again automatic highlight (otherwise selection will not be shown)
|
||||
// and call HilightPicked to draw selected owners
|
||||
theContext->SetAutomaticHilight( Standard_True );
|
||||
theContext->LocalContext()->HilightPicked( Standard_True );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : setLocalPointContext
|
||||
// purpose : Open/close the viewer local context
|
||||
//=======================================================================
|
||||
void CurveCreator_Utils::setLocalPointContext( const CurveCreator_ICurve* theCurve,
|
||||
Handle(AIS_InteractiveContext) theContext,
|
||||
const bool theOpen )
|
||||
{
|
||||
if ( !theContext )
|
||||
return;
|
||||
|
||||
if ( theOpen ) {
|
||||
// Open local context if there is no one
|
||||
if ( !theContext->HasOpenedContext() ) {
|
||||
theContext->ClearCurrents( false );
|
||||
theContext->OpenLocalContext( false/*use displayed objects*/, true/*allow shape decomposition*/ );
|
||||
}
|
||||
// load the curve AIS object to the local context with the point selection
|
||||
Handle(AIS_InteractiveObject) anAIS = theCurve->getAISObject();
|
||||
if ( !anAIS.IsNull() )
|
||||
{
|
||||
if ( anAIS->IsKind( STANDARD_TYPE( AIS_Shape ) ) )
|
||||
{
|
||||
theContext->Load( anAIS, -1/*selection mode*/, true/*allow decomposition*/ );
|
||||
theContext->Activate( anAIS, AIS_Shape::SelectionMode( (TopAbs_ShapeEnum)TopAbs_VERTEX ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
if ( theContext->HasOpenedContext() )
|
||||
theContext->CloseAllContexts();
|
||||
}
|
||||
}
|
||||
|
||||
bool CurveCreator_Utils::pointOnObject( Handle(V3d_View) theView,
|
||||
Handle(AIS_InteractiveObject) theObject,
|
||||
const int theX, const int theY,
|
||||
gp_Pnt& thePoint,
|
||||
gp_Pnt& thePoint1, gp_Pnt& thePoint2 )
|
||||
{
|
||||
bool isFullFound = false;
|
||||
|
||||
if ( theObject.IsNull() || theView.IsNull() )
|
||||
return isFullFound;
|
||||
Handle(AIS_Shape) aShape = Handle(AIS_Shape)::DownCast( theObject );
|
||||
if ( aShape.IsNull() )
|
||||
return isFullFound;
|
||||
const TopoDS_Compound& aCompound = TopoDS::Compound( aShape->Shape() );
|
||||
if ( aCompound.IsNull() )
|
||||
return isFullFound;
|
||||
|
||||
gp_Pnt aCurPoint, aCurPoint1, aCurPoint2;
|
||||
gp_Pnt aFoundPoint, aFoundPnt1, aFoundPnt2;
|
||||
Standard_Real aParameter;
|
||||
bool isFound = false;
|
||||
int aDelta, aMinDelta = 2*SCENE_PIXEL_PROJECTION_TOLERANCE*SCENE_PIXEL_PROJECTION_TOLERANCE;
|
||||
TopExp_Explorer anExp( aCompound, TopAbs_EDGE );
|
||||
for ( ; anExp.More(); anExp.Next())
|
||||
{
|
||||
const TopoDS_Edge& anEdge = TopoDS::Edge(anExp.Current());
|
||||
if ( anEdge.IsNull() )
|
||||
continue;
|
||||
Standard_Real aFirst, aLast;
|
||||
Handle(Geom_Curve) aCurve = BRep_Tool::Curve( anEdge, aFirst, aLast );
|
||||
if ( aCurve->IsKind( STANDARD_TYPE(Geom_BSplineCurve) ) ) {
|
||||
Handle(Geom_BSplineCurve) aBSplineCurve =
|
||||
Handle(Geom_BSplineCurve)::DownCast( aCurve );
|
||||
if ( !aBSplineCurve.IsNull() ) {
|
||||
isFound = hasProjectPointOnCurve( theView, theX, theY, aBSplineCurve,
|
||||
aParameter, aDelta );
|
||||
if ( isFound ) {
|
||||
aCurPoint = aBSplineCurve->Value( aParameter );
|
||||
Standard_Integer anI1, anI2;
|
||||
aBSplineCurve->LocateU( aParameter, LOCAL_SELECTION_TOLERANCE, anI1, anI2 );
|
||||
aCurPoint1 = aBSplineCurve->Value( aBSplineCurve->Knot( anI1 ) );
|
||||
aCurPoint2 = aBSplineCurve->Value( aBSplineCurve->Knot( anI2 ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
else { // a curve built on a polyline edge
|
||||
Handle(Geom_Line) aGLine = Handle(Geom_Line)::DownCast( aCurve );
|
||||
if ( aGLine.IsNull() )
|
||||
continue;
|
||||
isFound = hasProjectPointOnCurve( theView, theX, theY, aGLine, aParameter,
|
||||
aDelta );
|
||||
if ( isFound ) {
|
||||
aCurPoint = aGLine->Value( aParameter );
|
||||
TopoDS_Vertex V1, V2;
|
||||
TopExp::Vertices( anEdge, V1, V2, Standard_True );
|
||||
if ( V1.IsNull() || V2.IsNull() )
|
||||
continue;
|
||||
aCurPoint1 = BRep_Tool::Pnt(V1);
|
||||
aCurPoint2 = BRep_Tool::Pnt(V2);
|
||||
|
||||
// check that the projected point is on the bounded curve
|
||||
gp_Vec aVec1( aCurPoint1, aCurPoint );
|
||||
gp_Vec aVec2( aCurPoint2, aCurPoint );
|
||||
isFound = fabs( aVec1.Angle( aVec2 ) - M_PI ) < LOCAL_SELECTION_TOLERANCE;
|
||||
}
|
||||
}
|
||||
if ( isFound && aMinDelta >= aDelta ) {
|
||||
aMinDelta = aDelta;
|
||||
|
||||
isFullFound = true;
|
||||
aFoundPnt1 = aCurPoint1;
|
||||
aFoundPnt2 = aCurPoint2;
|
||||
aFoundPoint = aCurPoint;
|
||||
}
|
||||
}
|
||||
if ( isFullFound ) {
|
||||
int aX, anY, aX1, anY1, aX2, anY2;
|
||||
int aDelta;
|
||||
CurveCreator_Utils::ConvertPointToClick( aFoundPoint, theView, aX, anY );
|
||||
CurveCreator_Utils::ConvertPointToClick( aFoundPnt1, theView, aX1, anY1 );
|
||||
CurveCreator_Utils::ConvertPointToClick( aFoundPnt2, theView, aX2, anY2 );
|
||||
|
||||
isFullFound = !isEqualPixels( aX, anY, aX1, anY1, SCENE_PIXEL_POINT_TOLERANCE, aDelta ) &&
|
||||
!isEqualPixels( aX, anY, aX2, anY2, SCENE_PIXEL_POINT_TOLERANCE, aDelta );
|
||||
if ( isFullFound ) {
|
||||
thePoint = aFoundPoint;
|
||||
thePoint1 = aFoundPnt1;
|
||||
thePoint2 = aFoundPnt2;
|
||||
}
|
||||
}
|
||||
return isFullFound;
|
||||
}
|
||||
|
||||
bool CurveCreator_Utils::hasProjectPointOnCurve( Handle(V3d_View) theView,
|
||||
const int theX, const int theY,
|
||||
const Handle(Geom_Curve)& theCurve,
|
||||
Standard_Real& theParameter,
|
||||
int& theDelta )
|
||||
{
|
||||
bool isFound = false;
|
||||
if ( theView.IsNull() )
|
||||
return isFound;
|
||||
|
||||
gp_Pnt aPoint = CurveCreator_Utils::ConvertClickToPoint( theX, theY, theView );
|
||||
|
||||
GeomAPI_ProjectPointOnCurve aProj( aPoint, theCurve );
|
||||
Standard_Integer aNbPoint = aProj.NbPoints();
|
||||
if (aNbPoint > 0) {
|
||||
for (Standard_Integer j = 1; j <= aNbPoint && !isFound; j++) {
|
||||
gp_Pnt aNewPoint = aProj.Point( j );
|
||||
theParameter = aProj.Parameter( j );
|
||||
|
||||
int aX, anY;
|
||||
CurveCreator_Utils::ConvertPointToClick( aNewPoint, theView, aX, anY );
|
||||
|
||||
isFound = isEqualPixels( aX, anY, theX, theY, SCENE_PIXEL_PROJECTION_TOLERANCE, theDelta );
|
||||
}
|
||||
}
|
||||
return isFound;
|
||||
}
|
||||
|
||||
bool CurveCreator_Utils::isEqualPixels( const int theX, const int theY, const int theOtherX,
|
||||
const int theOtherY, const double theTolerance, int& theDelta )
|
||||
{
|
||||
int aXDelta = abs( theX - theOtherX );
|
||||
int anYDelta = abs( theY - theOtherY );
|
||||
|
||||
theDelta = aXDelta*aXDelta + anYDelta*anYDelta;
|
||||
|
||||
return aXDelta < theTolerance && anYDelta < theTolerance;
|
||||
}
|
||||
|
||||
bool CurveCreator_Utils::isEqualPoints( const gp_Pnt& thePoint, const gp_Pnt& theOtherPoint )
|
||||
{
|
||||
return theOtherPoint.IsEqual( thePoint, LOCAL_SELECTION_TOLERANCE );
|
||||
}
|
159
src/CurveCreator/CurveCreator_Utils.hxx
Normal file
159
src/CurveCreator/CurveCreator_Utils.hxx
Normal file
@ -0,0 +1,159 @@
|
||||
// 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 "CurveCreator_ICurve.hxx"
|
||||
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
#include <AIS_InteractiveObject.hxx> // TODO: remove
|
||||
#include <V3d_View.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
#include <list>
|
||||
#include <vector> // TODO: remove
|
||||
|
||||
|
||||
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 void ConvertPointToClick( const gp_Pnt& thePoint,
|
||||
Handle(V3d_View) theView,
|
||||
int& x, int& y );
|
||||
|
||||
/*!
|
||||
* \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 );
|
||||
|
||||
/**
|
||||
* Generates shape on the curve
|
||||
* \param theCurve a curve object, that contains data
|
||||
* \param theShape a generated shape
|
||||
*/
|
||||
CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
|
||||
TopoDS_Shape& theShape );
|
||||
|
||||
/**
|
||||
* Find selected points in the context
|
||||
* \param theContext the viewer context
|
||||
* \param theCurve a curve object, that contains data
|
||||
*/
|
||||
CURVECREATOR_EXPORT static void getSelectedPoints( Handle(AIS_InteractiveContext) theContext,
|
||||
const CurveCreator_ICurve* theCurve,
|
||||
CurveCreator_ICurve::SectionToPointList& thePoints );
|
||||
|
||||
/**
|
||||
* Set selected points to the context
|
||||
* \param theContext the viewer context
|
||||
* \param theCurve a curve object, that contains data
|
||||
* \param thePoints the curve point indices to be selected in the context
|
||||
*/
|
||||
CURVECREATOR_EXPORT static void setSelectedPoints(
|
||||
Handle(AIS_InteractiveContext) theContext,
|
||||
const CurveCreator_ICurve* theCurve,
|
||||
const CurveCreator_ICurve::SectionToPointList& thePoints =
|
||||
CurveCreator_ICurve::SectionToPointList() );
|
||||
|
||||
/*!
|
||||
* \brief Sets the local point context for the 3D viewer.
|
||||
* \param theCurve a curve object, that contains data
|
||||
* \param theContext the viewer context
|
||||
* \param theOpen The flag to open or close the local context.
|
||||
*/
|
||||
CURVECREATOR_EXPORT static void setLocalPointContext(
|
||||
const CurveCreator_ICurve* theCurve,
|
||||
Handle(AIS_InteractiveContext) theContext,
|
||||
const bool theOpen );
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
CURVECREATOR_EXPORT static bool pointOnObject( Handle(V3d_View) theView,
|
||||
Handle(AIS_InteractiveObject) theObject,
|
||||
const int theX, const int theY,
|
||||
gp_Pnt& thePoint, gp_Pnt& thePoint1,
|
||||
gp_Pnt& thePoint2 );
|
||||
|
||||
protected:
|
||||
/*
|
||||
* Returns whether the clicked point belong to the curve or has a very near projection
|
||||
* \param theX the X coordinate of a point clicked in the OCC viewer
|
||||
* \param theY the Y coordinate of a point clicked in the OCC viewer
|
||||
* \param theCurve a geometry curve
|
||||
* \param theOutPoint a found projected point on the curve
|
||||
*/
|
||||
CURVECREATOR_EXPORT static bool hasProjectPointOnCurve(
|
||||
Handle(V3d_View) theView,
|
||||
const int theX, const int theY,
|
||||
const Handle(Geom_Curve)& theCurve,
|
||||
Standard_Real& theParameter,
|
||||
int& theDelta );
|
||||
|
||||
/*
|
||||
* Returns whether the X and Y coordinates is in the pixel tolerance
|
||||
* \param theX the X coordinate of the first point
|
||||
* \param theY the Y coordinate of the first point
|
||||
* \param theOtherX the X coordinate of the second point
|
||||
* \param theOtherY the Y coordinate of the second point
|
||||
* \param theTolerance the tolerance to compare
|
||||
* \param theDelta the sum of the a square of X and a square of Y
|
||||
* \returns whether the points are provide to the pixel tolerance
|
||||
*/
|
||||
CURVECREATOR_EXPORT static bool isEqualPixels( const int theX, const int theY,
|
||||
const int theOtherX, const int theOtherY,
|
||||
const double theTolerance, int& theDelta );
|
||||
|
||||
|
||||
/*
|
||||
* Returns whether the points are the same
|
||||
* \param thePoint the first point
|
||||
* \param theOtherPoint the second point
|
||||
* \returns whether the points are provide to the pixel tolerance
|
||||
*/
|
||||
CURVECREATOR_EXPORT static bool isEqualPoints( const gp_Pnt& thePoint,
|
||||
const gp_Pnt& theOtherPoint );
|
||||
};
|
||||
|
||||
#endif // CURVECREATOR_UTILS_H
|
126
src/CurveCreator/CurveCreator_UtilsICurve.cxx
Normal file
126
src/CurveCreator/CurveCreator_UtilsICurve.cxx
Normal file
@ -0,0 +1,126 @@
|
||||
// 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_UtilsICurve.hxx"
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
const double LOCAL_SELECTION_TOLERANCE = 0.0001;
|
||||
|
||||
int CurveCreator_UtilsICurve::findLocalPointIndex( const CurveCreator_ICurve* theCurve,
|
||||
int theSectionId, float theX, float theY )
|
||||
{
|
||||
int aPntIndex = -1;
|
||||
if ( !theCurve )
|
||||
return aPntIndex;
|
||||
|
||||
CurveCreator::Coordinates aCoords;
|
||||
for ( int i = 0, aNb = theCurve->getNbPoints( theSectionId ); i < aNb && aPntIndex < 0; i++ ) {
|
||||
aCoords = theCurve->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;
|
||||
}
|
||||
|
||||
void CurveCreator_UtilsICurve::findSectionsToPoints( const CurveCreator_ICurve* theCurve,
|
||||
const double theX, const double theY,
|
||||
CurveCreator_ICurve::SectionToPointList& thePoints )
|
||||
{
|
||||
thePoints.clear();
|
||||
|
||||
int aPointId = -1;
|
||||
for ( int i = 0, aNb = theCurve->getNbSections(); i < aNb; i++ ) {
|
||||
aPointId = CurveCreator_UtilsICurve::findLocalPointIndex( theCurve, i, theX, theY );
|
||||
if ( aPointId < 0 )
|
||||
continue;
|
||||
CurveCreator_ICurve::SectionToPoint aPoint = std::make_pair( i, aPointId );
|
||||
if ( !CurveCreator_UtilsICurve::contains( thePoints, aPoint ) )
|
||||
thePoints.push_back( aPoint );
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_UtilsICurve::convert( const CurveCreator_ICurve::SectionToPointList& thePoints,
|
||||
QMap<int, QList<int> >& theConvPoints )
|
||||
{
|
||||
theConvPoints.clear();
|
||||
|
||||
CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(),
|
||||
aLast = thePoints.end();
|
||||
QList<int> aPoints;
|
||||
int aSectionId, aPointId;
|
||||
for ( ; anIt != aLast; anIt++ ) {
|
||||
aSectionId = anIt->first;
|
||||
aPointId = anIt->second;
|
||||
aPoints.clear();
|
||||
if ( theConvPoints.contains( aSectionId ) )
|
||||
aPoints = theConvPoints[aSectionId];
|
||||
if ( aPoints.contains( aPointId ) )
|
||||
continue;
|
||||
aPoints.append( aPointId );
|
||||
theConvPoints[aSectionId] = aPoints;
|
||||
}
|
||||
}
|
||||
|
||||
#include "CurveCreator_Curve.hxx" // TODO
|
||||
void CurveCreator_UtilsICurve::getPoint( const CurveCreator_ICurve* theCurve, const int theISection,
|
||||
const int theIPoint, gp_Pnt& thePoint )
|
||||
{
|
||||
double anX, anY, aZ;
|
||||
// TODO
|
||||
const CurveCreator_Curve* aCurve = dynamic_cast<const CurveCreator_Curve*>( theCurve );
|
||||
if ( aCurve )
|
||||
aCurve->getCoordinates( theISection, theIPoint, anX, anY, aZ );
|
||||
thePoint = gp_Pnt( anX, anY, aZ);
|
||||
}
|
||||
|
||||
std::string CurveCreator_UtilsICurve::getUniqSectionName( CurveCreator_ICurve* theCurve )
|
||||
{
|
||||
for( int i = 0 ; i < 1000000 ; i++ ){
|
||||
char aBuffer[255];
|
||||
sprintf( aBuffer, "Section_%d", i+1 );
|
||||
std::string aName(aBuffer);
|
||||
int j;
|
||||
for( j = 0 ; j < theCurve->getNbSections() ; j++ ){
|
||||
if( theCurve->getSectionName(j) == aName )
|
||||
break;
|
||||
}
|
||||
if( j == theCurve->getNbSections() )
|
||||
return aName;
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
||||
bool CurveCreator_UtilsICurve::contains( const CurveCreator_ICurve::SectionToPointList& theList,
|
||||
const CurveCreator_ICurve::SectionToPoint& theValue )
|
||||
{
|
||||
bool isFound = false;
|
||||
|
||||
CurveCreator_ICurve::SectionToPointList::const_iterator anIt = theList.begin(),
|
||||
aLast = theList.end();
|
||||
for ( ; anIt != aLast && !isFound; anIt++ )
|
||||
isFound = anIt->first == theValue.first && anIt->second == theValue.second;
|
||||
|
||||
return isFound;
|
||||
}
|
69
src/CurveCreator/CurveCreator_UtilsICurve.hxx
Normal file
69
src/CurveCreator/CurveCreator_UtilsICurve.hxx
Normal file
@ -0,0 +1,69 @@
|
||||
// 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_ICURVE_H
|
||||
#define CURVECREATOR_UTILS_ICURVE_H
|
||||
|
||||
#include "CurveCreator_Macro.hxx"
|
||||
|
||||
#include "CurveCreator_ICurve.hxx"
|
||||
|
||||
#include <gp_Pnt.hxx>
|
||||
|
||||
#include <QMap>
|
||||
#include <QList>
|
||||
|
||||
class CurveCreator_UtilsICurve
|
||||
{
|
||||
public:
|
||||
|
||||
/*!
|
||||
* 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
|
||||
*/
|
||||
CURVECREATOR_EXPORT static int findLocalPointIndex( const CurveCreator_ICurve* theCurve,
|
||||
int theSectionId, float theX, float theY );
|
||||
|
||||
CURVECREATOR_EXPORT static void findSectionsToPoints( const CurveCreator_ICurve* theCurve,
|
||||
const double theX, const double theY,
|
||||
CurveCreator_ICurve::SectionToPointList& thePoints );
|
||||
CURVECREATOR_EXPORT static void convert( const CurveCreator_ICurve::SectionToPointList& thePoints,
|
||||
QMap<int, QList<int> >& theConvPoints );
|
||||
|
||||
CURVECREATOR_EXPORT static void getPoint( const CurveCreator_ICurve* theCurve, const int theISection,
|
||||
const int theIPoint, gp_Pnt& thePoint );
|
||||
|
||||
/*!
|
||||
* Returns a unique section name
|
||||
* \param theCurve a curve interface
|
||||
*/
|
||||
CURVECREATOR_EXPORT static std::string getUniqSectionName(
|
||||
CurveCreator_ICurve* theCurve );
|
||||
|
||||
/**
|
||||
* Returns whethe the container has the value
|
||||
* \param theList a container of values
|
||||
* \param theValue a value
|
||||
*/
|
||||
CURVECREATOR_EXPORT static bool contains( const CurveCreator_ICurve::SectionToPointList& theList,
|
||||
const CurveCreator_ICurve::SectionToPoint& theValue );
|
||||
};
|
||||
|
||||
#endif // CURVECREATOR_UTILS_ICURVE_H
|
File diff suppressed because it is too large
Load Diff
@ -1,9 +1,9 @@
|
||||
// Copyright (C) 2013-2014 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
|
||||
// License as published by the Free Software Foundation; either
|
||||
// version 2.1 of the License, or (at your option) any later version.
|
||||
// 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
|
||||
@ -20,101 +20,208 @@
|
||||
#ifndef CURVECREATOR_WIDGET_H
|
||||
#define CURVECREATOR_WIDGET_H
|
||||
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
#include "CurveCreator_Macro.hxx"
|
||||
#include "CurveCreator.hxx"
|
||||
#include "CurveCreator_ICurve.hxx"
|
||||
|
||||
#include <QWidget>
|
||||
#include <QMap>
|
||||
|
||||
#include <SUIT_ViewWindow.h>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <AIS_InteractiveContext.hxx>
|
||||
|
||||
#include <Geom_Curve.hxx>
|
||||
#include <V3d_View.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopoDS_Vertex.hxx> // TODO - remove
|
||||
|
||||
class OCCViewer_Viewer;
|
||||
class OCCViewer_ViewPort3d;
|
||||
|
||||
class AIS_ListOfInteractive;
|
||||
|
||||
class QAction;
|
||||
class QPixmap;
|
||||
class CurveCreator_CurveEditor;
|
||||
class CurveCreator_TableView;
|
||||
class CurveCreator_TreeView;
|
||||
class CurveCreator_NewPointDlg;
|
||||
class CurveCreator_NewSectionDlg;
|
||||
|
||||
class CURVECREATOR_EXPORT CurveCreator_Widget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CurveCreator_Widget( QWidget* parent,
|
||||
CurveCreator_Curve *theCurve,
|
||||
Qt::WindowFlags fl=0 );
|
||||
enum ActionFlags {
|
||||
NoFlags = 0x00000000,
|
||||
DisableDetectionMode = 0x00000001,
|
||||
DisableNewSection = 0x00000002,
|
||||
DisableClosedSection = 0x00000004
|
||||
};
|
||||
|
||||
void setCurve( CurveCreator_Curve* theCurve );
|
||||
enum ActionMode {
|
||||
NoneMode,
|
||||
AdditionMode,
|
||||
ModificationMode,
|
||||
DetectionMode
|
||||
};
|
||||
|
||||
QList<int> getSelectedSections();
|
||||
QList< QPair< int, int > > getSelectedPoints();
|
||||
public:
|
||||
explicit CurveCreator_Widget( QWidget* parent,
|
||||
CurveCreator_ICurve *theCurve,
|
||||
const int theActionFlags = NoFlags,
|
||||
const QStringList& theCoordTitles = QStringList(),
|
||||
Qt::WindowFlags fl=0,
|
||||
int theLocalPointRowLimit = 20);
|
||||
|
||||
bool isInstantSketchingEnabled() const;
|
||||
void setInstantSketchingEnabled( const bool theState );
|
||||
// OCC viewer manipulation
|
||||
void setOCCViewer( OCCViewer_Viewer* theViewer );
|
||||
|
||||
Handle(AIS_InteractiveContext) getAISContext();
|
||||
OCCViewer_ViewPort3d* getViewPort();
|
||||
int changeInteractionStyle( int theStyle );
|
||||
|
||||
void reset();
|
||||
void setCurve( CurveCreator_ICurve* theCurve );
|
||||
|
||||
QList<int> getSelectedSections();
|
||||
void setSelectedSections( const QList<int>& theSections );
|
||||
|
||||
void removeSelected();
|
||||
bool removeEnabled();
|
||||
|
||||
void setActionMode( const ActionMode& theMode );
|
||||
ActionMode getActionMode() const;
|
||||
|
||||
signals:
|
||||
void selectionChanged();
|
||||
void subOperationStarted( QWidget* );
|
||||
void subOperationFinished( QWidget* );
|
||||
void selectionChanged();
|
||||
void subOperationStarted( QWidget*, bool );
|
||||
void subOperationFinished( QWidget* );
|
||||
|
||||
public slots:
|
||||
|
||||
protected slots:
|
||||
void onAdditionMode(bool checked);
|
||||
void onModificationMode(bool checked);
|
||||
void onDetectPoints(bool checked);
|
||||
void onModeChanged(bool checked);
|
||||
void onNewSection();
|
||||
void onSelectionChanged();
|
||||
void onAddNewPoint(const CurveCreator::Coordinates& theCoords);
|
||||
void onAddNewSection();
|
||||
void onEditSection( int theSection );
|
||||
void onEditPoint( int theSection, int thePoint );
|
||||
void onModifyPoint();
|
||||
void onModifySection();
|
||||
void onCancelPoint();
|
||||
void onCancelSection();
|
||||
void onJoin();
|
||||
void onRemove();
|
||||
void onMoveUp();
|
||||
void onMoveDown();
|
||||
void onClearAll();
|
||||
void onJoinAll();
|
||||
void onInsertSectionBefore();
|
||||
void onInsertSectionAfter();
|
||||
void onSetSpline();
|
||||
void onSetPolyline();
|
||||
void onCloseSections();
|
||||
void onUncloseSections();
|
||||
void onInsertPointBefore();
|
||||
void onInsertPointAfter();
|
||||
void onUndo();
|
||||
void onRedo();
|
||||
void onUndoSettings();
|
||||
void onContextMenu(QPoint thePoint);
|
||||
void onGetPointByClick( SUIT_ViewWindow*, QMouseEvent* );
|
||||
// void onPointSelect( SUIT_ViewWindow*, QMouseEvent* );
|
||||
void onPointDrag( SUIT_ViewWindow*, QMouseEvent* );
|
||||
void onAdditionMode(bool checked);
|
||||
void onModificationMode(bool checked);
|
||||
void onDetectionMode(bool checked);
|
||||
void onModeChanged(bool checked);
|
||||
void onNewSection();
|
||||
void onSelectionChanged();
|
||||
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 onMousePress( SUIT_ViewWindow*, QMouseEvent* theEvent );
|
||||
void onMouseRelease( SUIT_ViewWindow*, QMouseEvent* theEvent );
|
||||
void onMouseMove( SUIT_ViewWindow*, QMouseEvent* theEvent );
|
||||
void onLastViewClosed( SUIT_ViewManager* theManager );
|
||||
|
||||
void onMousePress( QMouseEvent* theEvent );
|
||||
void onMouseRelease( QMouseEvent* theEvent );
|
||||
void onMouseMove( QMouseEvent* theEvent );
|
||||
|
||||
void onCellChanged( 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, UP_ID, DOWN_ID, INSERT_SECTION_BEFORE_ID, INSERT_SECTION_AFTER_ID,
|
||||
INSERT_POINT_BEFORE_ID, INSERT_POINT_AFTER_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 };
|
||||
void addCoordsByClick( QMouseEvent* );
|
||||
|
||||
protected:
|
||||
enum ActionId{ NONE_ID,
|
||||
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
|
||||
};
|
||||
|
||||
private:
|
||||
QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
|
||||
const QString& theToolTip, const QKeySequence& theShortcut );
|
||||
QAction* getAction(ActionId theId);
|
||||
void updateUndoRedo();
|
||||
OCCViewer_Viewer* getOCCViewer();
|
||||
|
||||
QAction* createAction( ActionId theId, const QString& theName, const QPixmap& theImage,
|
||||
const QString& theToolTip, const QKeySequence& theShortcut );
|
||||
QAction* getAction(ActionId theId);
|
||||
QAction* getAction(ActionMode theMode);
|
||||
|
||||
void updateActionsStates();
|
||||
void updateUndoRedo();
|
||||
|
||||
void removeSection();
|
||||
void removePoint();
|
||||
void addNewPoint(const CurveCreator::Coordinates& theCoords);
|
||||
void insertPointToSelectedSegment( const int theXPosition,
|
||||
const int theYPosition );
|
||||
void moveSelectedPoints( const int theXPosition, const int theYPosition );
|
||||
void updateLocalPointView();
|
||||
void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
|
||||
|
||||
void setDragStarted( const bool theState, const QPoint& thePoint = QPoint() );
|
||||
|
||||
void getSelectedPoints( CurveCreator_ICurve::SectionToPointList& thePoints );
|
||||
void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
|
||||
CurveCreator_ICurve::SectionToPointList() );
|
||||
|
||||
void stopActionMode();
|
||||
|
||||
void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints,
|
||||
const bool theFillPoints = true );
|
||||
void finishCurveModification( const CurveCreator_ICurve::SectionToPointList& thePoints =
|
||||
CurveCreator_ICurve::SectionToPointList() );
|
||||
|
||||
// curve algorithm
|
||||
int findLocalPointIndex( int theSectionId, float theX, float theY );
|
||||
void findSectionsToPoints( const double theX, const double theY,
|
||||
CurveCreator_ICurve::SectionToPointList& thePoints );
|
||||
void convert( const CurveCreator_ICurve::SectionToPointList& thePoints,
|
||||
QMap<int, QList<int> >& theConvPoints );
|
||||
|
||||
bool contains( const CurveCreator_ICurve::SectionToPointList& theList,
|
||||
const CurveCreator_ICurve::SectionToPoint& theValue ) const;
|
||||
|
||||
private:
|
||||
QMap<ActionId, QAction*> myActionMap;
|
||||
CurveCreator_Curve* myCurve;
|
||||
CurveCreator_CurveEditor* myEdit;
|
||||
CurveCreator_TreeView* mySectionView;
|
||||
CurveCreator_NewPointDlg* myNewPointEditor;
|
||||
CurveCreator_NewSectionDlg* myNewSectionEditor;
|
||||
int mySection;
|
||||
int myPointNum;
|
||||
QPoint myDragStartPosition;
|
||||
QMap<ActionId, QAction*> myActionMap;
|
||||
CurveCreator_ICurve* myCurve;
|
||||
CurveCreator_TreeView* mySectionView;
|
||||
CurveCreator_TableView* myLocalPointView;
|
||||
CurveCreator_ICurve::SectionToPointList myLocalPoints;
|
||||
CurveCreator_NewSectionDlg* myNewSectionEditor;
|
||||
OCCViewer_Viewer* myOCCViewer;
|
||||
int myLocalPointRowLimit;
|
||||
int mySection;
|
||||
int myPointNum;
|
||||
bool myDragStarted;
|
||||
QPoint myDragStartPosition;
|
||||
int myDragInteractionStyle;
|
||||
CurveCreator_ICurve::SectionToPointList myDragPoints;
|
||||
QMap<CurveCreator_ICurve::SectionToPoint, CurveCreator::Coordinates> myInitialDragPointsCoords;
|
||||
bool myDragged;
|
||||
QByteArray myGuiState;
|
||||
int myPressedX;
|
||||
int myPressedY;
|
||||
};
|
||||
|
||||
#endif // CURVECREATOR_WIDGET_H
|
||||
|
@ -40,6 +40,7 @@ INCLUDE_DIRECTORIES(
|
||||
${PROJECT_SOURCE_DIR}/src/GEOMGUI
|
||||
${PROJECT_SOURCE_DIR}/src/GEOMBase
|
||||
${PROJECT_SOURCE_DIR}/src/SKETCHER
|
||||
${PROJECT_SOURCE_DIR}/src/CurveCreator
|
||||
${PROJECT_SOURCE_DIR}/src/ShapeRecognition
|
||||
${PROJECT_SOURCE_DIR}/src/DlgRef
|
||||
${PROJECT_BINARY_DIR}/src/DlgRef
|
||||
@ -65,6 +66,7 @@ SET(_link_LIBRARIES
|
||||
GEOM
|
||||
DlgRef
|
||||
GEOMSketcher
|
||||
CurveCreator
|
||||
)
|
||||
|
||||
# optional sources
|
||||
@ -103,6 +105,7 @@ SET(EntityGUI_HEADERS
|
||||
EntityGUI.h
|
||||
EntityGUI_Widgets.h
|
||||
EntityGUI_SketcherDlg.h
|
||||
EntityGUI_PolylineDlg.h
|
||||
EntityGUI_3DSketcherDlg.h
|
||||
EntityGUI_IsolineDlg.h
|
||||
EntityGUI_SubShapeDlg.h
|
||||
@ -115,6 +118,7 @@ SET(_moc_HEADERS
|
||||
EntityGUI_Widgets.h
|
||||
EntityGUI_FieldDlg.h
|
||||
EntityGUI_SketcherDlg.h
|
||||
EntityGUI_PolylineDlg.h
|
||||
EntityGUI_3DSketcherDlg.h
|
||||
EntityGUI_IsolineDlg.h
|
||||
EntityGUI_SubShapeDlg.h
|
||||
@ -135,6 +139,7 @@ SET(EntityGUI_SOURCES
|
||||
EntityGUI_Widgets.cxx
|
||||
EntityGUI_FieldDlg.cxx
|
||||
EntityGUI_SketcherDlg.cxx
|
||||
EntityGUI_PolylineDlg.cxx
|
||||
EntityGUI_3DSketcherDlg.cxx
|
||||
EntityGUI_IsolineDlg.cxx
|
||||
EntityGUI_SubShapeDlg.cxx
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include "EntityGUI_FeatureDetectorDlg.h" // Feature Detection
|
||||
#include "EntityGUI_PictureImportDlg.h" // Import Picture in viewer
|
||||
#include "EntityGUI_FieldDlg.h" // Create/Edit Field
|
||||
#include "EntityGUI_PolylineDlg.h" // Create/Edit 2d polyline
|
||||
|
||||
#include "GEOMImpl_Types.hxx"
|
||||
|
||||
@ -188,6 +189,10 @@ bool EntityGUI::OnGUIEvent( int theCommandID, SUIT_Desktop* parent )
|
||||
SUIT_MessageBox::warning(parent, tr("WRN_WARNING"), tr("NO_FIELD"));
|
||||
break;
|
||||
}
|
||||
case GEOMOp::Op2dPolylineEditor: // POLYLINE EDITOR
|
||||
getGeometryGUI()->ActiveWorkingPlane();
|
||||
aDlg = new EntityGUI_PolylineDlg( getGeometryGUI(), parent );
|
||||
break;
|
||||
default:
|
||||
app->putInfo( tr( "GEOM_PRP_COMMAND" ).arg( theCommandID ) );
|
||||
break;
|
||||
|
173
src/EntityGUI/EntityGUI_PolylineDlg.cxx
Normal file
173
src/EntityGUI/EntityGUI_PolylineDlg.cxx
Normal file
@ -0,0 +1,173 @@
|
||||
// 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 "EntityGUI_PolylineDlg.h"
|
||||
#include <CurveCreator_Curve.hxx>
|
||||
#include <CurveCreator_Widget.h>
|
||||
#include <DlgRef.h>
|
||||
#include <GeometryGUI.h>
|
||||
|
||||
#include <OCCViewer_ViewManager.h>
|
||||
#include <SalomeApp_Application.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
#include <SUIT_Session.h>
|
||||
|
||||
#include <QGroupBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// function : Constructor
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
EntityGUI_PolylineDlg::EntityGUI_PolylineDlg
|
||||
(GeometryGUI* theGeometryGUI, QWidget* parent, bool modal, Qt::WindowFlags fl)
|
||||
: GEOMBase_Skeleton( theGeometryGUI, parent, modal, fl )
|
||||
{
|
||||
QPixmap image0( SUIT_Session::session()->resourceMgr()->loadPixmap( "GEOM", tr( "ICON_DLG_VECTOR_2P" ) ) );
|
||||
|
||||
/***************************************************************/
|
||||
mainFrame()->GroupConstructors->setTitle(tr("GEOM_VECTOR"));
|
||||
mainFrame()->RadioButton1->setIcon(image0);
|
||||
mainFrame()->RadioButton2->setAttribute( Qt::WA_DeleteOnClose );
|
||||
mainFrame()->RadioButton2->close();
|
||||
mainFrame()->RadioButton3->setAttribute( Qt::WA_DeleteOnClose );
|
||||
mainFrame()->RadioButton3->close();
|
||||
|
||||
myCurve = new CurveCreator_Curve( CurveCreator::Dim2d );
|
||||
myEditorWidget = new CurveCreator_Widget (centralWidget(), myCurve);
|
||||
myAddElementBox = new QGroupBox (tr("ADD_ELEMENT"), centralWidget());
|
||||
|
||||
QBoxLayout* anAddElementLayout = new QVBoxLayout( myAddElementBox );
|
||||
|
||||
anAddElementLayout->setMargin( 0 );
|
||||
anAddElementLayout->setSpacing( 6 );
|
||||
|
||||
QVBoxLayout* layout = new QVBoxLayout( centralWidget() );
|
||||
|
||||
layout->setMargin( 0 );
|
||||
layout->setSpacing( 6 );
|
||||
layout->addWidget( myEditorWidget );
|
||||
layout->addWidget( myAddElementBox );
|
||||
|
||||
/***************************************************************/
|
||||
|
||||
setHelpFileName( "create_vector_page.html" );
|
||||
|
||||
/* Initialisations */
|
||||
Init();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Destructor
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
EntityGUI_PolylineDlg::~EntityGUI_PolylineDlg()
|
||||
{
|
||||
delete myCurve;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : Init()
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
void EntityGUI_PolylineDlg::Init()
|
||||
{
|
||||
SalomeApp_Application *anApp = myGeomGUI->getApp();
|
||||
OCCViewer_ViewManager *aViewManager = dynamic_cast<OCCViewer_ViewManager*>
|
||||
(anApp->getViewManager(OCCViewer_Viewer::Type(), true));
|
||||
|
||||
myEditorWidget->setOCCViewer( aViewManager ? aViewManager->getOCCViewer() : 0 );
|
||||
|
||||
connect(myEditorWidget, SIGNAL(subOperationStarted(QWidget*, bool)),
|
||||
this, SLOT(processStartedSubOperation(QWidget*, bool)));
|
||||
connect(myEditorWidget, SIGNAL(subOperationFinished(QWidget*)),
|
||||
this, SLOT(processFinishedSubOperation(QWidget*)));
|
||||
|
||||
myAddElementBox->hide();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : createOperation
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
GEOM::GEOM_IOperations_ptr EntityGUI_PolylineDlg::createOperation()
|
||||
{
|
||||
return getGeomEngine()->GetICurvesOperations( getStudyId() );
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : isValid
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool EntityGUI_PolylineDlg::isValid( QString& msg )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
// function : execute
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
bool EntityGUI_PolylineDlg::execute( ObjectList& objects )
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
void EntityGUI_PolylineDlg::processStartedSubOperation( QWidget* theWidget, bool theIsEdit )
|
||||
{
|
||||
myEditorWidget->setEnabled( false );
|
||||
|
||||
myAddElementBox->setTitle( theIsEdit ? tr( "EDIT_ELEMENT" ) : tr( "ADD_ELEMENT" ) );
|
||||
QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
|
||||
anAddElementLayout->addWidget( theWidget );
|
||||
|
||||
theWidget->show();
|
||||
myAddElementBox->show();
|
||||
}
|
||||
|
||||
void EntityGUI_PolylineDlg::processFinishedSubOperation( QWidget* theWidget )
|
||||
{
|
||||
myEditorWidget->setEnabled( true );
|
||||
|
||||
QBoxLayout* anAddElementLayout = dynamic_cast<QBoxLayout*>( myAddElementBox->layout() );
|
||||
anAddElementLayout->removeWidget( theWidget );
|
||||
|
||||
theWidget->hide();
|
||||
myAddElementBox->hide();
|
||||
}
|
||||
|
||||
/**
|
||||
* Redirect the delete action to editor widget
|
||||
*/
|
||||
void EntityGUI_PolylineDlg::deleteSelected()
|
||||
{
|
||||
myEditorWidget->removeSelected();
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether there are some to delete
|
||||
*/
|
||||
bool EntityGUI_PolylineDlg::deleteEnabled()
|
||||
{
|
||||
return myEditorWidget->removeEnabled();
|
||||
}
|
77
src/EntityGUI/EntityGUI_PolylineDlg.h
Normal file
77
src/EntityGUI/EntityGUI_PolylineDlg.h
Normal file
@ -0,0 +1,77 @@
|
||||
// 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 ENTITYGUI_POLYLINEDLG_H
|
||||
#define ENTITYGUI_POLYLINEDLG_H
|
||||
|
||||
|
||||
#include <GEOMBase_Skeleton.h>
|
||||
|
||||
|
||||
class CurveCreator_Curve;
|
||||
class CurveCreator_Widget;
|
||||
class QGroupBox;
|
||||
|
||||
|
||||
//=================================================================================
|
||||
// class : EntityGUI_PolylineDlg
|
||||
// purpose :
|
||||
//=================================================================================
|
||||
class EntityGUI_PolylineDlg : public GEOMBase_Skeleton
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
|
||||
EntityGUI_PolylineDlg (GeometryGUI*, QWidget* = 0,
|
||||
bool = false, Qt::WindowFlags = 0);
|
||||
|
||||
virtual ~EntityGUI_PolylineDlg();
|
||||
|
||||
void deleteSelected();
|
||||
bool deleteEnabled();
|
||||
|
||||
protected:
|
||||
|
||||
// redefined from GEOMBase_Helper
|
||||
virtual GEOM::GEOM_IOperations_ptr createOperation();
|
||||
virtual bool isValid( QString& );
|
||||
virtual bool execute( ObjectList& );
|
||||
|
||||
private:
|
||||
|
||||
void Init();
|
||||
|
||||
protected slots:
|
||||
|
||||
void processStartedSubOperation( QWidget*, bool );
|
||||
void processFinishedSubOperation( QWidget* );
|
||||
|
||||
private:
|
||||
|
||||
CurveCreator_Curve *myCurve;
|
||||
CurveCreator_Widget *myEditorWidget;
|
||||
QGroupBox *myAddElementBox;
|
||||
|
||||
};
|
||||
|
||||
#endif // ENTITYGUI_POLYLINEDLG_H
|
@ -560,6 +560,7 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
|
||||
case GEOMOp::OpCreateField: // MENU FIELD - CREATE FIELD
|
||||
case GEOMOp::OpEditField: // MENU FIELD - EDIT FIELD
|
||||
case GEOMOp::OpEditFieldPopup: // POPUP MENU - EDIT FIELD
|
||||
case GEOMOp::Op2dPolylineEditor: // MENU BASIC - POLYLINE EDITOR
|
||||
libName = "EntityGUI";
|
||||
break;
|
||||
case GEOMOp::OpEdge: // MENU BUILD - EDGE
|
||||
@ -599,10 +600,6 @@ void GeometryGUI::OnGUIEvent( int id, const QVariant& theParam )
|
||||
case GEOMOp::OpSharedShapes: // MENU OPERATION - GET SHARED SHAPES
|
||||
case GEOMOp::OpExtrudedBoss: // MENU OPERATION - EXTRUDED BOSS
|
||||
case GEOMOp::OpExtrudedCut: // MENU OPERATION - EXTRUDED CUT
|
||||
#ifdef DEBUG_CURVE_CREATOR
|
||||
// for debug purposes, to be removed
|
||||
case GEOMOp::OpCurveCreator: // MENU OPERATION - CURVE CREATOR
|
||||
#endif
|
||||
libName = "OperationGUI";
|
||||
break;
|
||||
case GEOMOp::OpSewing: // MENU REPAIR - SEWING
|
||||
@ -947,6 +944,7 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createGeomAction( GEOMOp::OpFeatureDetect,"FEATURE_DETECTION" );
|
||||
#endif
|
||||
createGeomAction( GEOMOp::OpPictureImport,"PICTURE_IMPORT" );
|
||||
createGeomAction( GEOMOp::Op2dPolylineEditor, "CURVE_CREATOR" );
|
||||
|
||||
createGeomAction( GEOMOp::OpEdge, "EDGE" );
|
||||
createGeomAction( GEOMOp::OpWire, "WIRE" );
|
||||
@ -979,10 +977,6 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createGeomAction( GEOMOp::OpSharedShapes, "GET_SHARED_SHAPES" );
|
||||
createGeomAction( GEOMOp::OpExtrudedCut, "EXTRUDED_CUT" );
|
||||
createGeomAction( GEOMOp::OpExtrudedBoss, "EXTRUDED_BOSS" );
|
||||
#ifdef DEBUG_CURVE_CREATOR
|
||||
// for debug purposes, to be removed
|
||||
createGeomAction( GEOMOp::OpCurveCreator, "CURVE_CREATOR" );
|
||||
#endif
|
||||
createGeomAction( GEOMOp::OpFillet1d, "FILLET_1D" );
|
||||
createGeomAction( GEOMOp::OpFillet2d, "FILLET_2D" );
|
||||
|
||||
@ -1119,19 +1113,20 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
int newEntId = createMenu( tr( "MEN_NEW_ENTITY" ), -1, -1, 10 );
|
||||
|
||||
int basicId = createMenu( tr( "MEN_BASIC" ), newEntId, -1 );
|
||||
createMenu( GEOMOp::OpPoint, basicId, -1 );
|
||||
createMenu( GEOMOp::OpLine, basicId, -1 );
|
||||
createMenu( GEOMOp::OpCircle, basicId, -1 );
|
||||
createMenu( GEOMOp::OpEllipse, basicId, -1 );
|
||||
createMenu( GEOMOp::OpArc, basicId, -1 );
|
||||
createMenu( GEOMOp::OpCurve, basicId, -1 );
|
||||
createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
|
||||
createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
|
||||
createMenu( GEOMOp::OpIsoline, basicId, -1 );
|
||||
createMenu( separator(), basicId, -1 );
|
||||
createMenu( GEOMOp::OpVector, basicId, -1 );
|
||||
createMenu( GEOMOp::OpPlane, basicId, -1 );
|
||||
createMenu( GEOMOp::OpLCS, basicId, -1 );
|
||||
createMenu( GEOMOp::OpPoint, basicId, -1 );
|
||||
createMenu( GEOMOp::OpLine, basicId, -1 );
|
||||
createMenu( GEOMOp::OpCircle, basicId, -1 );
|
||||
createMenu( GEOMOp::OpEllipse, basicId, -1 );
|
||||
createMenu( GEOMOp::OpArc, basicId, -1 );
|
||||
createMenu( GEOMOp::OpCurve, basicId, -1 );
|
||||
createMenu( GEOMOp::Op2dSketcher, basicId, -1 );
|
||||
createMenu( GEOMOp::Op2dPolylineEditor, basicId, -1 );
|
||||
createMenu( GEOMOp::Op3dSketcher, basicId, -1 );
|
||||
createMenu( GEOMOp::OpIsoline, basicId, -1 );
|
||||
createMenu( separator(), basicId, -1 );
|
||||
createMenu( GEOMOp::OpVector, basicId, -1 );
|
||||
createMenu( GEOMOp::OpPlane, basicId, -1 );
|
||||
createMenu( GEOMOp::OpLCS, basicId, -1 );
|
||||
createMenu( GEOMOp::OpOriginAndVectors, basicId, -1 );
|
||||
|
||||
int primId = createMenu( tr( "MEN_PRIMITIVES" ), newEntId, -1 );
|
||||
@ -1239,11 +1234,6 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createMenu( GEOMOp::OpChamfer, operId, -1 );
|
||||
createMenu( GEOMOp::OpExtrudedBoss, operId, -1 );
|
||||
createMenu( GEOMOp::OpExtrudedCut, operId, -1 );
|
||||
#ifdef DEBUG_CURVE_CREATOR
|
||||
// for debug purposes, to be removed
|
||||
createMenu( separator(), operId, -1 );
|
||||
createMenu( GEOMOp::OpCurveCreator, operId, -1 );
|
||||
#endif
|
||||
//createMenu( GEOMOp::OpClipping, operId, -1 );
|
||||
|
||||
int repairId = createMenu( tr( "MEN_REPAIR" ), -1, -1, 10 );
|
||||
@ -1333,18 +1323,19 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
// ---- create toolbars --------------------------
|
||||
|
||||
int basicTbId = createTool( tr( "TOOL_BASIC" ) );
|
||||
createTool( GEOMOp::OpPoint, basicTbId );
|
||||
createTool( GEOMOp::OpLine, basicTbId );
|
||||
createTool( GEOMOp::OpCircle, basicTbId );
|
||||
createTool( GEOMOp::OpEllipse, basicTbId );
|
||||
createTool( GEOMOp::OpArc, basicTbId );
|
||||
createTool( GEOMOp::OpCurve, basicTbId );
|
||||
createTool( GEOMOp::OpVector, basicTbId );
|
||||
createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
|
||||
createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
|
||||
createTool( GEOMOp::OpIsoline, basicTbId );
|
||||
createTool( GEOMOp::OpPlane, basicTbId );
|
||||
createTool( GEOMOp::OpLCS, basicTbId );
|
||||
createTool( GEOMOp::OpPoint, basicTbId );
|
||||
createTool( GEOMOp::OpLine, basicTbId );
|
||||
createTool( GEOMOp::OpCircle, basicTbId );
|
||||
createTool( GEOMOp::OpEllipse, basicTbId );
|
||||
createTool( GEOMOp::OpArc, basicTbId );
|
||||
createTool( GEOMOp::OpCurve, basicTbId );
|
||||
createTool( GEOMOp::OpVector, basicTbId );
|
||||
createTool( GEOMOp::Op2dSketcher, basicTbId ); //rnc
|
||||
createTool( GEOMOp::Op2dPolylineEditor, basicTbId );
|
||||
createTool( GEOMOp::Op3dSketcher, basicTbId ); //rnc
|
||||
createTool( GEOMOp::OpIsoline, basicTbId );
|
||||
createTool( GEOMOp::OpPlane, basicTbId );
|
||||
createTool( GEOMOp::OpLCS, basicTbId );
|
||||
createTool( GEOMOp::OpOriginAndVectors, basicTbId );
|
||||
|
||||
// int sketchTbId = createTool( tr( "TOOL_SKETCH" ) );
|
||||
@ -1406,10 +1397,6 @@ void GeometryGUI::initialize( CAM_Application* app )
|
||||
createTool( GEOMOp::OpChamfer, featTbId );
|
||||
createTool( GEOMOp::OpExtrudedBoss, featTbId );
|
||||
createTool( GEOMOp::OpExtrudedCut, featTbId );
|
||||
#ifdef DEBUG_CURVE_CREATOR
|
||||
// for debug purposes, to be removed
|
||||
createTool( GEOMOp::OpCurveCreator, featTbId );
|
||||
#endif
|
||||
|
||||
int buildTbId = createTool( tr( "TOOL_BUILD" ) );
|
||||
createTool( GEOMOp::OpEdge, buildTbId );
|
||||
|
@ -117,6 +117,7 @@ namespace GEOMOp {
|
||||
OpCreateField = 3305, // MENU FIELD - CREATE FIELD
|
||||
OpEditField = 3306, // MENU FIELD - EDIT FIELD
|
||||
OpEditFieldPopup = 3307, // POPUP MENU - EDIT FIELD
|
||||
Op2dPolylineEditor = 3308, // MENU NEW ENTITY - BASIC - POLYLINE EDITOR
|
||||
// BuildGUI --------------------//--------------------------------
|
||||
OpEdge = 3400, // MENU NEW ENTITY - BUILD - EDGE
|
||||
OpWire = 3401, // MENU NEW ENTITY - BUILD - WIRE
|
||||
@ -152,10 +153,6 @@ namespace GEOMOp {
|
||||
OpSharedShapes = 3708, // MENU OPERATION - GET SHARED SHAPES
|
||||
OpExtrudedBoss = 3709, // MENU OPERATION - ETRUDED BOSS
|
||||
OpExtrudedCut = 3710, // MENU OPERATION - ETRUDED CUT
|
||||
#ifdef DEBUG_CURVE_CREATOR
|
||||
OpCurveCreator = 3799, // MENU OPERATION - CURVE CREATOR
|
||||
#endif
|
||||
// for debug purposes, to be removed
|
||||
// RepairGUI -------------------//--------------------------------
|
||||
OpSewing = 4000, // MENU REPAIR - SEWING
|
||||
OpSuppressFaces = 4001, // MENU REPAIR - SUPPRESS FACES
|
||||
|
@ -45,11 +45,6 @@ INCLUDE_DIRECTORIES(
|
||||
${CMAKE_CURRENT_BINARY_DIR}
|
||||
)
|
||||
|
||||
IF(SALOME_GEOM_DEBUG_CC)
|
||||
# for debug purposes, to be removed
|
||||
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/src/CurveCreator)
|
||||
ENDIF()
|
||||
|
||||
# additional preprocessor / compiler flags
|
||||
ADD_DEFINITIONS(
|
||||
${CAS_DEFINITIONS}
|
||||
@ -61,10 +56,6 @@ ADD_DEFINITIONS(
|
||||
SET(_link_LIBRARIES
|
||||
GEOMBase
|
||||
)
|
||||
IF(SALOME_GEOM_DEBUG_CC)
|
||||
# for debug purposes, to be removed
|
||||
LIST(APPEND _link_LIBRARIES CurveCreator)
|
||||
ENDIF()
|
||||
|
||||
# --- resources ---
|
||||
|
||||
|
@ -27,15 +27,8 @@
|
||||
#include <GeometryGUI.h>
|
||||
#include "GeometryGUI_Operations.h"
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_Desktop.h>
|
||||
#include <SUIT_ViewManager.h>
|
||||
#include <SalomeApp_Application.h>
|
||||
#include <OCCViewer_ViewWindow.h>
|
||||
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include <Precision.hxx>
|
||||
|
||||
#include "OperationGUI_PartitionDlg.h" // Method PARTITION
|
||||
#include "OperationGUI_ArchimedeDlg.h" // Method ARCHIMEDE
|
||||
@ -47,13 +40,6 @@
|
||||
#include "OperationGUI_GetSharedShapesDlg.h"
|
||||
#include "OperationGUI_ExtrudedFeatureDlg.h" // Methods EXTRUDED BOSS / CUT
|
||||
|
||||
#ifdef DEBUG_CURVE_CREATOR
|
||||
// for debug purposes, to be removed
|
||||
#include "CurveCreator_Widget.h"
|
||||
#include <QVBoxLayout>
|
||||
#include <QPushButton>
|
||||
#endif
|
||||
|
||||
//=======================================================================
|
||||
// function : OperationGUI()
|
||||
// purpose : Constructor
|
||||
@ -95,36 +81,6 @@ bool OperationGUI::OnGUIEvent (int theCommandID, SUIT_Desktop* parent)
|
||||
case GEOMOp::OpExtrudedCut: (new OperationGUI_ExtrudedFeatureDlg (CUT, getGeometryGUI(), parent))->show(); break;
|
||||
case GEOMOp::OpFillet1d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, true))->show(); break;
|
||||
case GEOMOp::OpFillet2d: (new OperationGUI_Fillet1d2dDlg (getGeometryGUI(), parent, false))->show(); break;
|
||||
#ifdef DEBUG_CURVE_CREATOR
|
||||
// for debug purposes, to be removed
|
||||
case GEOMOp::OpCurveCreator:
|
||||
{
|
||||
static CurveCreator_Curve *aStaticCurve = NULL;
|
||||
|
||||
if (aStaticCurve == NULL) {
|
||||
aStaticCurve = new CurveCreator_Curve(CurveCreator::Dim2d);
|
||||
}
|
||||
if (CurveCreator::Dim2d == aStaticCurve->getDimension()) {
|
||||
OCCViewer_ViewWindow* vw = (OCCViewer_ViewWindow*)getGeometryGUI()->getApp()->activeViewManager()->getActiveView();
|
||||
vw->onTopView();
|
||||
}
|
||||
|
||||
QDialog *aDialog = new QDialog(parent);
|
||||
QVBoxLayout *aMainLO = new QVBoxLayout;
|
||||
QPushButton *aQuitButton = new QPushButton(tr("Close"));
|
||||
CurveCreator_Widget *aWidget =
|
||||
new CurveCreator_Widget (aDialog, aStaticCurve);
|
||||
|
||||
connect(aQuitButton, SIGNAL(clicked()), aDialog, SLOT(close()));
|
||||
aMainLO->addWidget(aWidget);
|
||||
aMainLO->addWidget(aQuitButton);
|
||||
|
||||
aDialog->setLayout(aMainLO);
|
||||
aDialog->setAttribute(Qt::WA_DeleteOnClose);
|
||||
aDialog->show();
|
||||
}
|
||||
break;
|
||||
#endif
|
||||
default:
|
||||
app->putInfo(tr("GEOM_PRP_COMMAND").arg(theCommandID));
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user