mirror of
https://git.salome-platform.org/gitpub/modules/geom.git
synced 2024-11-11 16:19:17 +05:00
Old development made for salome Hydro:
To allow to move points on spline curve curveCreator :: allow selection of points of selected polyline(s) only
This commit is contained in:
parent
4048b73d92
commit
656de216bc
@ -267,6 +267,7 @@ SET( _res_files
|
||||
propagate.png
|
||||
redo.png
|
||||
undo.png
|
||||
setcolor.png
|
||||
glue2.png
|
||||
remove_webs.png
|
||||
remove_extra_edges.png
|
||||
|
BIN
resources/setcolor.png
Normal file
BIN
resources/setcolor.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 580 B |
@ -26,7 +26,7 @@ ENDIF(SALOME_BUILD_GUI)
|
||||
# additional include directories
|
||||
INCLUDE_DIRECTORIES(
|
||||
${PTHREAD_INCLUDE_DIR}
|
||||
${OpenCASCADE_INCLUDE_DIR}
|
||||
${CAS_INCLUDE_DIR}
|
||||
${KERNEL_INCLUDE_DIRS}
|
||||
${GUI_INCLUDE_DIRS}
|
||||
${PROJECT_SOURCE_DIR}/src/GEOMUtils
|
||||
@ -34,12 +34,15 @@ INCLUDE_DIRECTORIES(
|
||||
|
||||
# additional preprocessor / compiler flags
|
||||
ADD_DEFINITIONS(
|
||||
${CAS_DEFINITIONS}
|
||||
${OpenCASCADE_DEFINITIONS}
|
||||
${QT_DEFINITIONS}
|
||||
)
|
||||
|
||||
# libraries to link to
|
||||
SET(_link_LIBRARIES
|
||||
${CAS_KERNEL}
|
||||
${CAS_TKernel}
|
||||
GEOMUtils
|
||||
)
|
||||
IF(SALOME_BUILD_GUI)
|
||||
@ -66,6 +69,7 @@ ENDIF(SALOME_BUILD_GUI)
|
||||
SET(_other_HEADERS
|
||||
CurveCreator.hxx
|
||||
CurveCreator_Curve.hxx
|
||||
CurveCreator_ShapeFilter.hxx
|
||||
CurveCreator_Diff.hxx
|
||||
CurveCreator_Displayer.hxx
|
||||
CurveCreator_ICurve.hxx
|
||||
@ -92,6 +96,7 @@ SET(_other_SOURCES
|
||||
CurveCreator_Curve.cxx
|
||||
CurveCreator_Diff.cxx
|
||||
CurveCreator_Displayer.cxx
|
||||
CurveCreator_ShapeFilter.cxx
|
||||
CurveCreator_Operation.cxx
|
||||
CurveCreator_Section.cxx
|
||||
CurveCreator_Utils.cxx
|
||||
|
@ -31,11 +31,14 @@
|
||||
#include <AIS_Shape.hxx>
|
||||
#include <AIS_InteractiveObject.hxx>
|
||||
#include <Geom_CartesianPoint.hxx>
|
||||
#include <TopoDS_Iterator.hxx>
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <gp_Lin.hxx>
|
||||
#include <TopoDS_Edge.hxx>
|
||||
#include <TopoDS_Face.hxx>
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
#include <AIS_ColoredShape.hxx>
|
||||
|
||||
#include <Prs3d_PointAspect.hxx>
|
||||
#include <iostream>
|
||||
@ -52,8 +55,8 @@ CurveCreator_Curve::CurveCreator_Curve( const CurveCreator::Dimension theDimensi
|
||||
myIsLocked (false),
|
||||
myDimension (theDimension),
|
||||
myDisplayer (NULL),
|
||||
myPointAspectColor (Quantity_NOC_ROYALBLUE4),
|
||||
myCurveColor (Quantity_NOC_RED),
|
||||
myPointAspectColor (Quantity_NOC_ROYALBLUE4),
|
||||
//myCurveColor (Quantity_NOC_RED),
|
||||
myLineWidth (1),
|
||||
myNbUndos (0),
|
||||
myNbRedos (0),
|
||||
@ -256,7 +259,7 @@ void CurveCreator_Curve::getCoordinates( int theISection, int theIPoint, double&
|
||||
void CurveCreator_Curve::redisplayCurve(bool preEraseAllObjects)
|
||||
{
|
||||
//DEBTRACE("redisplayCurve");
|
||||
if( myDisplayer )
|
||||
if( myDisplayer )
|
||||
{
|
||||
if (preEraseAllObjects)
|
||||
myDisplayer->eraseAll( false );
|
||||
@ -384,7 +387,7 @@ bool CurveCreator_Curve::clearInternal()
|
||||
}
|
||||
|
||||
mySections.clear();
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -480,7 +483,8 @@ int CurveCreator_Curve::getNbSections() const
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
int CurveCreator_Curve::addSectionInternal
|
||||
(const std::string& theName, const CurveCreator::SectionType theType,
|
||||
const bool theIsClosed, const CurveCreator::Coordinates &thePoints)
|
||||
const bool theIsClosed, const CurveCreator::Coordinates &thePoints,
|
||||
const Quantity_Color& aColor)
|
||||
{
|
||||
CurveCreator_Section *aSection = new CurveCreator_Section;
|
||||
|
||||
@ -492,6 +496,7 @@ int CurveCreator_Curve::addSectionInternal
|
||||
aSection->myType = theType;
|
||||
aSection->myIsClosed = theIsClosed;
|
||||
aSection->myPoints = thePoints;
|
||||
aSection->myColor = aColor;//getRandColor(); //TODO temp
|
||||
mySections.push_back(aSection);
|
||||
redisplayCurve(false);
|
||||
return mySections.size()-1;
|
||||
@ -514,7 +519,9 @@ int CurveCreator_Curve::addSection
|
||||
theName, aCoords, theType, theIsClosed);
|
||||
}
|
||||
|
||||
resISection = addSectionInternal(theName, theType, theIsClosed, aCoords);
|
||||
Quantity_Color aRColor = CurveCreator_Utils::getRandColor();
|
||||
|
||||
resISection = addSectionInternal(theName, theType, theIsClosed, aCoords, aRColor);
|
||||
|
||||
finishOperation();
|
||||
return resISection;
|
||||
@ -535,7 +542,7 @@ int CurveCreator_Curve::addSection
|
||||
theName, thePoints, theType, theIsClosed);
|
||||
}
|
||||
|
||||
resISection = addSectionInternal(theName, theType, theIsClosed, thePoints);
|
||||
resISection = addSectionInternal(theName, theType, theIsClosed, thePoints, Quantity_NOC_YELLOW);
|
||||
|
||||
finishOperation();
|
||||
return resISection;
|
||||
@ -545,18 +552,21 @@ int CurveCreator_Curve::addSection
|
||||
bool CurveCreator_Curve::removeSectionInternal( const int theISection )
|
||||
{
|
||||
if (theISection == -1) {
|
||||
myRemColors.push_back(mySections.back()->myColor);
|
||||
delete mySections.back();
|
||||
mySections.pop_back();
|
||||
} else {
|
||||
CurveCreator::Sections::iterator anIterRm = mySections.begin() + theISection;
|
||||
|
||||
myRemColors.push_back((*anIterRm)->myColor);
|
||||
|
||||
delete *anIterRm;
|
||||
mySections.erase(anIterRm);
|
||||
}
|
||||
redisplayCurve(false);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
//! Removes the given sections.
|
||||
bool CurveCreator_Curve::removeSection( const int theISection )
|
||||
{
|
||||
@ -572,6 +582,49 @@ bool CurveCreator_Curve::removeSection( const int theISection )
|
||||
return res;
|
||||
}
|
||||
|
||||
bool CurveCreator_Curve::setColorSection( int SectInd, Quantity_Color theNewColor )
|
||||
{
|
||||
bool res = false;
|
||||
// Set the difference.
|
||||
startOperation();
|
||||
|
||||
int ColorParam[3] = { (int)( theNewColor.Red() * 255 ),
|
||||
(int)( theNewColor.Green() * 255 ),
|
||||
(int)( theNewColor.Blue() * 255 ) };
|
||||
|
||||
if (addEmptyDiff())
|
||||
myListDiffs.back().init(this, CurveCreator_Operation::SetColorSection, SectInd, ColorParam);
|
||||
|
||||
setColorSectionInternal(SectInd, theNewColor);
|
||||
|
||||
finishOperation();
|
||||
return res;
|
||||
}
|
||||
|
||||
void CurveCreator_Curve::setColorSectionInternal( int SectInd, Quantity_Color theNewColor )
|
||||
{
|
||||
CurveCreator_Section* aSec = (CurveCreator_Section*)(getSection(SectInd));
|
||||
aSec->myColor = theNewColor;
|
||||
|
||||
redisplayCurve(false);
|
||||
}
|
||||
|
||||
Quantity_Color CurveCreator_Curve::getColorSection( int SectInd ) const
|
||||
{
|
||||
CurveCreator_Section* aSec = (CurveCreator_Section*)(getSection(SectInd));
|
||||
return aSec->myColor;
|
||||
}
|
||||
|
||||
Quantity_Color CurveCreator_Curve::getLastRemovedColor() const
|
||||
{
|
||||
return myRemColors.empty() ? Quantity_NOC_BLACK : myRemColors.back();
|
||||
}
|
||||
|
||||
void CurveCreator_Curve::popLastRemovedColor()
|
||||
{
|
||||
myRemColors.pop_back();
|
||||
}
|
||||
|
||||
/**
|
||||
* Get number of points in specified section or (the total number of points
|
||||
* in Curve if theISection is equal to -1).
|
||||
@ -632,7 +685,7 @@ bool CurveCreator_Curve::isClosed( const int theISection ) const
|
||||
}
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
bool CurveCreator_Curve::setClosedInternal( const int theISection,
|
||||
bool CurveCreator_Curve::setClosedInternal( const int theISection,
|
||||
const bool theIsClosed )
|
||||
{
|
||||
CurveCreator_Section* aSection = 0;
|
||||
@ -661,7 +714,7 @@ bool CurveCreator_Curve::setClosedInternal( const int theISection,
|
||||
* Set "closed" flag of the specified section (all sections if
|
||||
* \a theISection is -1).
|
||||
*/
|
||||
bool CurveCreator_Curve::setClosed( const int theISection,
|
||||
bool CurveCreator_Curve::setClosed( const int theISection,
|
||||
const bool theIsClosed )
|
||||
{
|
||||
bool res = false;
|
||||
@ -684,7 +737,7 @@ std::string CurveCreator_Curve::getSectionName( const int theISection ) const
|
||||
}
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
bool CurveCreator_Curve::setSectionNameInternal( const int theISection,
|
||||
bool CurveCreator_Curve::setSectionNameInternal( const int theISection,
|
||||
const std::string& theName )
|
||||
{
|
||||
bool res = false;
|
||||
@ -697,7 +750,7 @@ bool CurveCreator_Curve::setSectionNameInternal( const int theISection,
|
||||
}
|
||||
|
||||
/** Set name of the specified section */
|
||||
bool CurveCreator_Curve::setSectionName( const int theISection,
|
||||
bool CurveCreator_Curve::setSectionName( const int theISection,
|
||||
const std::string& theName )
|
||||
{
|
||||
bool res = false;
|
||||
@ -721,7 +774,7 @@ CurveCreator::SectionType CurveCreator_Curve::getSectionType
|
||||
}
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
|
||||
bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
|
||||
const CurveCreator::SectionType theType )
|
||||
{
|
||||
CurveCreator_Section* aSection;
|
||||
@ -749,7 +802,7 @@ bool CurveCreator_Curve::setSectionTypeInternal( const int theISection,
|
||||
* Set type of the specified section (or all sections
|
||||
* if \a theISection is -1).
|
||||
*/
|
||||
bool CurveCreator_Curve::setSectionType( const int theISection,
|
||||
bool CurveCreator_Curve::setSectionType( const int theISection,
|
||||
const CurveCreator::SectionType theType )
|
||||
{
|
||||
bool res = false;
|
||||
@ -791,7 +844,7 @@ bool CurveCreator_Curve::addPointsInternal( const CurveCreator::SectionsMap &the
|
||||
anIterPosition = aSection->myPoints.end();
|
||||
else
|
||||
anIterPosition = aSection->myPoints.begin() + toICoord(anIPnt);
|
||||
/*CurveCreator::Coordinates::const_iterator aFirstPosition =
|
||||
/*CurveCreator::Coordinates::const_iterator aFirstPosition =
|
||||
aCoords.begin();*/
|
||||
aSection->myPoints.insert(anIterPosition,
|
||||
aCoords.begin(), aCoords.end());
|
||||
@ -845,7 +898,7 @@ bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theS
|
||||
for ( ; anIt != theSectionsMap.end(); anIt++ ) {
|
||||
int anISection = anIt->first;
|
||||
aSection = (CurveCreator_Section*)getSection( anISection );
|
||||
if( aSection ) {
|
||||
if( aSection ) {
|
||||
CurveCreator::PosPointsList aSectionPoints = anIt->second;
|
||||
CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
|
||||
for( ; aPntIt != aSectionPoints.end(); aPntIt++ ){
|
||||
@ -859,7 +912,7 @@ bool CurveCreator_Curve::setPointInternal( const CurveCreator::SectionsMap &theS
|
||||
}
|
||||
if(res)
|
||||
redisplayCurve(false);
|
||||
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -890,7 +943,7 @@ bool CurveCreator_Curve::setPoint( const int theISection,
|
||||
|
||||
finishOperation();
|
||||
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
//! Set coordinates of specified points from different sections
|
||||
@ -907,7 +960,7 @@ bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSe
|
||||
}
|
||||
CurveCreator::SectionsMap aSectionsMap;
|
||||
CurveCreator::PosPointsList aPosPoints;
|
||||
CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
|
||||
CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
|
||||
theSectionToPntCoords.begin(), aLast = theSectionToPntCoords.end();
|
||||
int aSectionId, aPointId;
|
||||
for ( ; anIt != aLast; anIt++ ) {
|
||||
@ -915,18 +968,18 @@ bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSe
|
||||
aSectionId = anIt->first.first;
|
||||
aPointId = anIt->first.second;
|
||||
CurveCreator::Coordinates aNewCoords = anIt->second;
|
||||
CurveCreator_PosPoint* aPosPoint =
|
||||
CurveCreator_PosPoint* aPosPoint =
|
||||
new CurveCreator_PosPoint( aPointId, aNewCoords );
|
||||
if( aSectionsMap.find(aSectionId) != aSectionsMap.end() )
|
||||
aPosPoints = aSectionsMap[aSectionId];
|
||||
aPosPoints.push_back( aPosPoint );
|
||||
aSectionsMap[aSectionId] = aPosPoints;
|
||||
|
||||
|
||||
}
|
||||
res = setPointInternal( aSectionsMap );
|
||||
finishOperation();
|
||||
|
||||
return res;
|
||||
return res;
|
||||
}
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
@ -1016,9 +1069,28 @@ void CurveCreator_Curve::constructAISObject()
|
||||
{
|
||||
//DEBTRACE("constructAISObject");
|
||||
TopoDS_Shape aShape;
|
||||
CurveCreator_Utils::constructShape( this, aShape );
|
||||
myAISShape = new AIS_Shape( aShape );
|
||||
myAISShape->SetColor( myCurveColor );
|
||||
mySect2Shape.Clear();
|
||||
CurveCreator_Utils::constructShape( this, aShape, &mySect2Shape );
|
||||
myAISShape = new AIS_ColoredShape( aShape );
|
||||
AIS_ColoredShape* AISColoredShape = dynamic_cast<AIS_ColoredShape*>(myAISShape);
|
||||
|
||||
std::map<int, TopoDS_Shape>::iterator it;
|
||||
|
||||
//for ( it = mySect2Shape.begin(); it != mySect2Shape.end(); it++ )
|
||||
for (int i = 1; i <= mySect2Shape.Extent(); i++ )
|
||||
{
|
||||
CurveCreator_Section* aSect = (CurveCreator_Section*)getSection(mySect2Shape.FindKey(i));
|
||||
Quantity_Color aColor = aSect->myColor;
|
||||
const TopoDS_Shape& aShape = mySect2Shape.FindFromIndex(i); //should contain: one wire + vertices
|
||||
TopoDS_Iterator it(aShape);
|
||||
for (;it.More();it.Next())
|
||||
{
|
||||
if (it.Value().ShapeType() == TopAbs_WIRE)
|
||||
AISColoredShape->SetCustomColor(it.Value(), aColor);
|
||||
}
|
||||
}
|
||||
|
||||
// myAISShape->SetColor( myCurveColor );
|
||||
myAISShape->SetWidth( myLineWidth );
|
||||
Handle(Prs3d_PointAspect) anAspect = myAISShape->Attributes()->PointAspect();
|
||||
anAspect->SetScale( 3.0 );
|
||||
@ -1030,7 +1102,7 @@ void CurveCreator_Curve::constructAISObject()
|
||||
Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const
|
||||
{
|
||||
//DEBTRACE("getAISObject");
|
||||
if ( !myAISShape && theNeedToBuild )
|
||||
if ( !myAISShape && theNeedToBuild )
|
||||
{
|
||||
CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this;
|
||||
aCurve->constructAISObject();
|
||||
|
@ -31,12 +31,14 @@
|
||||
|
||||
#include <list>
|
||||
#include <map>
|
||||
#include <NCollection_IndexedDataMap.hxx>
|
||||
|
||||
struct CurveCreator_Section;
|
||||
class CurveCreator_Displayer;
|
||||
class AIS_Shape;
|
||||
class AIS_InteractiveObject;
|
||||
class Quantity_Color;
|
||||
class TopoDS_Shape;
|
||||
|
||||
/**
|
||||
* The CurveCreator_Curve object is represented as one or more sets of
|
||||
@ -108,7 +110,7 @@ protected:
|
||||
|
||||
public: // TODO: remove public
|
||||
void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
|
||||
protected: // TODO: remove public
|
||||
protected: // TODO
|
||||
void redisplayCurve(bool preEraseAllObjects = true);
|
||||
|
||||
public:
|
||||
@ -159,20 +161,21 @@ public:
|
||||
virtual int getNbSections() const;
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual int addSectionInternal( const std::string &theName,
|
||||
virtual int addSectionInternal( const std::string &theName,
|
||||
const CurveCreator::SectionType theType,
|
||||
const bool theIsClosed,
|
||||
const CurveCreator::Coordinates &thePoints);
|
||||
const CurveCreator::Coordinates &thePoints,
|
||||
const Quantity_Color& aColor);
|
||||
//! Add a new section.
|
||||
virtual int addSection( const std::string &theName,
|
||||
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,
|
||||
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.
|
||||
@ -182,36 +185,49 @@ public:
|
||||
virtual bool isClosed( const int theISection ) const;
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual bool setClosedInternal( const int theISection,
|
||||
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,
|
||||
virtual bool setClosed( const int theISection,
|
||||
const bool theIsClosed );
|
||||
|
||||
//! Sets color of section by index
|
||||
virtual bool setColorSection( int SectInd, Quantity_Color theNewColor );
|
||||
|
||||
//! For internal use only! Undo/Redo are not used here.
|
||||
virtual void setColorSectionInternal( int SectInd, Quantity_Color theNewColor );
|
||||
|
||||
virtual Quantity_Color getLastRemovedColor() const;
|
||||
|
||||
virtual void popLastRemovedColor();
|
||||
|
||||
//! Gets color of section by index
|
||||
virtual Quantity_Color getColorSection( int SectInd ) const;
|
||||
|
||||
//! 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,
|
||||
virtual bool setSectionNameInternal( const int theISection,
|
||||
const std::string& theName );
|
||||
/** Set name of the specified section */
|
||||
virtual bool setSectionName( const int theISection,
|
||||
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,
|
||||
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 bool setSectionType( const int theISection,
|
||||
virtual bool setSectionType( const int theISection,
|
||||
const CurveCreator::SectionType theType );
|
||||
|
||||
//! A virtual method.
|
||||
@ -264,7 +280,7 @@ public:
|
||||
virtual bool removeSeveralPoints( const SectionToPointList &theSectionToPntIDs);
|
||||
|
||||
//! Get coordinates of specified point
|
||||
virtual CurveCreator::Coordinates getPoint( const int theISection,
|
||||
virtual CurveCreator::Coordinates getPoint( const int theISection,
|
||||
const int theIPnt ) const;
|
||||
|
||||
/**
|
||||
@ -327,6 +343,7 @@ protected:
|
||||
|
||||
protected:
|
||||
bool mySkipSorting;
|
||||
AIS_Shape* myAISShape; //!< AIS shape
|
||||
|
||||
public:
|
||||
bool myIsLocked;
|
||||
@ -334,8 +351,10 @@ public:
|
||||
CurveCreator::Dimension myDimension; //!< curve dimension
|
||||
CurveCreator_Displayer* myDisplayer; //!< curve displayer
|
||||
Quantity_Color myPointAspectColor;
|
||||
Quantity_Color myCurveColor;
|
||||
//Quantity_Color myCurveColor;
|
||||
double myLineWidth;
|
||||
NCollection_IndexedDataMap<int, TopoDS_Shape> mySect2Shape;
|
||||
std::vector<int> myCurSectInd;
|
||||
|
||||
private:
|
||||
|
||||
@ -345,8 +364,8 @@ private:
|
||||
ListDiff myListDiffs;
|
||||
int myUndoDepth;
|
||||
int myOpLevel;
|
||||
AIS_Shape* myAISShape; //!< AIS shape
|
||||
bool myEraseAll;
|
||||
std::vector<Quantity_Color> myRemColors;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
@ -22,6 +22,8 @@
|
||||
|
||||
#include "CurveCreator_Diff.hxx"
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
#include "CurveCreator_Section.hxx"
|
||||
#include "CurveCreator_Utils.hxx"
|
||||
|
||||
#include <list>
|
||||
|
||||
@ -171,6 +173,36 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
return isOK;
|
||||
}
|
||||
|
||||
bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const int theIntParam1,
|
||||
const int theIntParam2[3])
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theCurve != NULL)
|
||||
{
|
||||
clear();
|
||||
myPRedo = new CurveCreator_Operation;
|
||||
|
||||
if (myPRedo->init(theType, theIntParam1, theIntParam2))
|
||||
{
|
||||
Quantity_Color aColor = theCurve->getColorSection(theIntParam1);
|
||||
|
||||
setNbUndos(1);
|
||||
QColor aQColor = CurveCreator_Utils::colorConv(aColor);
|
||||
int colorArr[3] = {aQColor.red(),aQColor.green(), aQColor.blue()};
|
||||
|
||||
isOK = myPUndo[0].init(theType, theIntParam1, colorArr);
|
||||
}
|
||||
|
||||
if (!isOK)
|
||||
clear();
|
||||
}
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function: init
|
||||
// purpose:
|
||||
@ -343,7 +375,7 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
theCurve->getCoords(aSectionId);
|
||||
CurveCreator::Coordinates::const_iterator anIterBegin =
|
||||
aPoints.begin() + (aDim*aPointId);
|
||||
CurveCreator::Coordinates::const_iterator anIterEnd =
|
||||
CurveCreator::Coordinates::const_iterator anIterEnd =
|
||||
anIterBegin + aDim;
|
||||
aPointsToAdd.insert(aPointsToAdd.end(), anIterBegin, anIterEnd);
|
||||
aSectionToPointCoords.push_back(std::make_pair(*anIt, aPointsToAdd));
|
||||
@ -435,7 +467,7 @@ bool CurveCreator_Diff::init(const CurveCreator_Curve *theCurve,
|
||||
|
||||
// Construct redo for SetCoordinates command.
|
||||
CurveCreator_ICurve::SectionToPointCoordsList aSectionToPointActualCoords;
|
||||
CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
|
||||
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);
|
||||
|
@ -125,7 +125,7 @@ public:
|
||||
const int theIntParam1 );
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with
|
||||
* This method initializes the difference with an operation with
|
||||
* list of pairs of integer parameters.
|
||||
* It is applicable to the following operations:
|
||||
* <UL>
|
||||
@ -137,7 +137,7 @@ public:
|
||||
const CurveCreator_ICurve::SectionToPointList &theParamList);
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with
|
||||
* 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>
|
||||
@ -149,7 +149,7 @@ public:
|
||||
const CurveCreator_ICurve::SectionToPointCoordsList &theParamList);
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with
|
||||
* 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)
|
||||
@ -157,6 +157,20 @@ public:
|
||||
bool init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_ICurve::SectionToPointCoordsList &theOldParamList);
|
||||
|
||||
|
||||
/**
|
||||
* This method initializes the difference with an operation with one
|
||||
* integer and one array of integer[3] parameters.
|
||||
* It is applicable to the following operations:
|
||||
* <UL>
|
||||
* <LI>ColorSection</LI>
|
||||
* </UL>
|
||||
*/
|
||||
bool init(const CurveCreator_Curve *theCurve,
|
||||
const CurveCreator_Operation::Type theType,
|
||||
const int theIntParam1,
|
||||
const int theIntParam2[3]);
|
||||
|
||||
/**
|
||||
* This method applies undo operation to theCurve.
|
||||
*/
|
||||
|
@ -40,6 +40,12 @@ public:
|
||||
void eraseAll( bool isUpdate );
|
||||
void erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate );
|
||||
void Update();
|
||||
|
||||
Handle(AIS_InteractiveContext) getContext()
|
||||
{
|
||||
return myContext;
|
||||
}
|
||||
|
||||
//void highlight( const AISObjectsList& theObjects, bool isHL );
|
||||
|
||||
protected:
|
||||
|
@ -23,6 +23,9 @@
|
||||
#include "CurveCreator_Operation.hxx"
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
#include "CurveCreator.hxx"
|
||||
#include "CurveCreator_Section.hxx"
|
||||
#include "CurveCreator_Utils.hxx"
|
||||
#include <QColor>
|
||||
|
||||
#include <string>
|
||||
#include <stdlib.h>
|
||||
@ -114,6 +117,28 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
return isOK;
|
||||
}
|
||||
|
||||
bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
const int theIntParam1,
|
||||
const int theIntParam2[3])
|
||||
{
|
||||
bool isOK = false;
|
||||
|
||||
if (theType == CurveCreator_Operation::SetColorSection)
|
||||
{
|
||||
int *pData = (int *)allocate(4*sizeof(int));
|
||||
|
||||
pData[0] = theIntParam1;
|
||||
pData[1] = theIntParam2[0];
|
||||
pData[2] = theIntParam2[1];
|
||||
pData[3] = theIntParam2[2];
|
||||
myType = theType;
|
||||
isOK = true;
|
||||
}
|
||||
|
||||
return isOK;
|
||||
}
|
||||
|
||||
|
||||
//=======================================================================
|
||||
// function: Constructor
|
||||
// purpose:
|
||||
@ -252,12 +277,12 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
|
||||
const int aNbPoints = theParamList1.size();
|
||||
|
||||
CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
|
||||
CurveCreator_ICurve::SectionToPointCoordsList::const_iterator anIt =
|
||||
theParamList1.begin();
|
||||
const int aNbCoords = anIt->second.size();
|
||||
|
||||
const size_t aSize =
|
||||
sizeof(aNbPoints) + sizeof(aNbCoords) +
|
||||
sizeof(aNbPoints) + sizeof(aNbCoords) +
|
||||
aNbPoints * (3*sizeof(int) + aNbCoords*sizeof(CurveCreator::TypeCoord));
|
||||
int *pIntData = (int *)allocate(aSize);
|
||||
|
||||
@ -295,7 +320,7 @@ bool CurveCreator_Operation::init(const CurveCreator_Operation::Type theType,
|
||||
if (theType == CurveCreator_Operation::RemovePoints) {
|
||||
const int aNbPoints = theParamList1.size();
|
||||
|
||||
CurveCreator_ICurve::SectionToPointList::const_iterator anIt =
|
||||
CurveCreator_ICurve::SectionToPointList::const_iterator anIt =
|
||||
theParamList1.begin();
|
||||
|
||||
const size_t aSize =
|
||||
@ -416,7 +441,9 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve)
|
||||
char* aPtr = ((char*)&pInt[2]);
|
||||
aPtr += (aName.length()) + 1;
|
||||
getCoords((int*)aPtr, aCoords);
|
||||
theCurve->addSectionInternal(aName, aType, (pInt[1] != 0), aCoords);
|
||||
Quantity_Color aLastColor = theCurve->getLastRemovedColor();
|
||||
theCurve->popLastRemovedColor();
|
||||
theCurve->addSectionInternal(aName, aType, (pInt[1] != 0), aCoords, aLastColor);
|
||||
}
|
||||
break;
|
||||
case CurveCreator_Operation::RemoveSection:
|
||||
@ -428,6 +455,13 @@ void CurveCreator_Operation::apply(CurveCreator_Curve *theCurve)
|
||||
theCurve->setSectionNameInternal(pInt[0], aName);
|
||||
}
|
||||
break;
|
||||
case CurveCreator_Operation::SetColorSection:
|
||||
{
|
||||
Quantity_Color aColor = CurveCreator_Utils::colorConv(QColor(pInt[1], pInt[2], pInt[3]));
|
||||
theCurve->setColorSectionInternal(pInt[0], aColor);
|
||||
//theCurve->redisplayCurve(false);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -59,7 +59,8 @@ public:
|
||||
Join, //!< Method CurveCreator_Curve::join
|
||||
AddSection, //!< Method CurveCreator_Curve::addSection
|
||||
RemoveSection, //!< Method CurveCreator_Curve::removeSection
|
||||
RenameSection //!< Method CurveCreator_Curve::renameSection
|
||||
RenameSection, //!< Method CurveCreator_Curve::renameSection
|
||||
SetColorSection //!< Method CurveCreator_Curve::setColorSection
|
||||
};
|
||||
|
||||
/**
|
||||
@ -106,6 +107,14 @@ public:
|
||||
bool init(const Type theType, const int theIntParam1,
|
||||
const int theIntParam2);
|
||||
|
||||
/**
|
||||
* This method initializes the object with an operation with 4 integer
|
||||
* parameter (1 as first param + 3 as interger array)
|
||||
*/
|
||||
bool init(const Type theType, const int theIntParam1,
|
||||
const int theIntParam2[3]);
|
||||
|
||||
|
||||
/**
|
||||
* This method initializes the object with an operation with two integer
|
||||
* parameters. It is applicable to the following operations:
|
||||
@ -117,15 +126,15 @@ public:
|
||||
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.
|
||||
* 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,
|
||||
bool init(const Type theType,
|
||||
const CurveCreator_ICurve::SectionToPointList &theParamList1);
|
||||
|
||||
/**
|
||||
@ -149,7 +158,7 @@ public:
|
||||
* </UL>
|
||||
* @return true in case of success; false otherwise.
|
||||
*/
|
||||
bool init(const Type theType,
|
||||
bool init(const Type theType,
|
||||
const CurveCreator_ICurve::SectionToPointCoordsList &theParamList1);
|
||||
|
||||
/**
|
||||
|
@ -33,13 +33,15 @@ struct CURVECREATOR_EXPORT CurveCreator_Section :
|
||||
public CurveCreator_ISection
|
||||
{
|
||||
//! Constructor. Initializes object with default values.
|
||||
CurveCreator_Section() : myName("Section"),myType(CurveCreator::Polyline), myIsClosed(false)
|
||||
CurveCreator_Section() : myName("Section"),myType(CurveCreator::Polyline),
|
||||
myIsClosed(false), myColor (Quantity_NOC_RED)
|
||||
{ }
|
||||
|
||||
std::string myName; //!< section name
|
||||
CurveCreator::Coordinates myPoints; //!< points coordinates
|
||||
CurveCreator::SectionType myType; //!< type of the section
|
||||
bool myIsClosed; //!< closed or not
|
||||
Quantity_Color myColor; //!< color of section
|
||||
|
||||
//! A virtual method.
|
||||
Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theDimension ) const;
|
||||
|
74
src/CurveCreator/CurveCreator_ShapeFilter.cxx
Normal file
74
src/CurveCreator/CurveCreator_ShapeFilter.cxx
Normal file
@ -0,0 +1,74 @@
|
||||
// Copyright (C) 2013-2019 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_ShapeFilter.cxx
|
||||
// Author: Ilya Shchekin
|
||||
|
||||
|
||||
#include "CurveCreator_ShapeFilter.hxx"
|
||||
|
||||
#include <SelectMgr_EntityOwner.hxx>
|
||||
#include <StdSelect_BRepOwner.hxx>
|
||||
#include <TopoDS_Vertex.hxx>
|
||||
|
||||
IMPLEMENT_STANDARD_RTTIEXT(CurveCreator_ShapeFilter,SelectMgr_Filter)
|
||||
|
||||
CurveCreator_ShapeFilter::CurveCreator_ShapeFilter()
|
||||
: SelectMgr_Filter()
|
||||
{
|
||||
}
|
||||
|
||||
CurveCreator_ShapeFilter::~CurveCreator_ShapeFilter()
|
||||
{
|
||||
}
|
||||
|
||||
Standard_Boolean CurveCreator_ShapeFilter::ActsOn(const TopAbs_ShapeEnum aType) const
|
||||
{
|
||||
return (aType == TopAbs_VERTEX);
|
||||
}
|
||||
|
||||
Standard_Boolean CurveCreator_ShapeFilter::IsOk(const Handle(SelectMgr_EntityOwner)& EO) const
|
||||
{
|
||||
Handle(StdSelect_BRepOwner) aBO = Handle(StdSelect_BRepOwner)::DownCast(EO);
|
||||
if (aBO.IsNull())
|
||||
return Standard_False;
|
||||
|
||||
const TopoDS_Shape& aShape = aBO->Shape();
|
||||
|
||||
if(aShape.ShapeType()!= TopAbs_VERTEX)
|
||||
return Standard_False;
|
||||
|
||||
return myShapes.Contains(aShape);
|
||||
}
|
||||
|
||||
void CurveCreator_ShapeFilter::AddShape(const TopoDS_Shape& aShape)
|
||||
{
|
||||
myShapes.Add(aShape);
|
||||
}
|
||||
|
||||
void CurveCreator_ShapeFilter::RemoveShape(const TopoDS_Shape& aShape)
|
||||
{
|
||||
myShapes.Remove(aShape);
|
||||
}
|
||||
|
||||
void CurveCreator_ShapeFilter::ClearShapes()
|
||||
{
|
||||
myShapes.Clear();
|
||||
}
|
||||
|
73
src/CurveCreator/CurveCreator_ShapeFilter.hxx
Normal file
73
src/CurveCreator/CurveCreator_ShapeFilter.hxx
Normal file
@ -0,0 +1,73 @@
|
||||
// Copyright (C) 2013-2019 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_ShapeFilter.hxx
|
||||
// Author: Ilya Shchekin
|
||||
|
||||
|
||||
#ifndef _CurveCreator_ShapeFilter_HeaderFile
|
||||
#define _CurveCreator_ShapeFilter_HeaderFile
|
||||
|
||||
#include <Standard.hxx>
|
||||
#include <Standard_Type.hxx>
|
||||
#include <Basics_OCCTVersion.hxx>
|
||||
#include <Standard_DefineHandle.hxx>
|
||||
#include <SelectMgr_Filter.hxx>
|
||||
#include <TopAbs_ShapeEnum.hxx>
|
||||
#include <TopTools_MapOfShape.hxx>
|
||||
|
||||
class SelectMgr_EntityOwner;
|
||||
class TopoDS_Shape;
|
||||
|
||||
|
||||
class CurveCreator_ShapeFilter : public SelectMgr_Filter
|
||||
{
|
||||
|
||||
public:
|
||||
|
||||
|
||||
Standard_EXPORT CurveCreator_ShapeFilter();
|
||||
|
||||
Standard_EXPORT ~CurveCreator_ShapeFilter();
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean ActsOn (const TopAbs_ShapeEnum aType) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT virtual Standard_Boolean IsOk (const Handle(SelectMgr_EntityOwner)& EO) const Standard_OVERRIDE;
|
||||
|
||||
Standard_EXPORT void AddShape (const TopoDS_Shape& aShape);
|
||||
|
||||
Standard_EXPORT void RemoveShape (const TopoDS_Shape& aShape);
|
||||
|
||||
Standard_EXPORT void ClearShapes ();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
TopTools_MapOfShape myShapes;
|
||||
|
||||
public:
|
||||
|
||||
DEFINE_STANDARD_RTTIEXT(CurveCreator_ShapeFilter,SelectMgr_Filter)
|
||||
|
||||
};
|
||||
|
||||
DEFINE_STANDARD_HANDLE(CurveCreator_ShapeFilter, SelectMgr_Filter)
|
||||
|
||||
#endif
|
||||
|
@ -19,6 +19,8 @@
|
||||
|
||||
#include "CurveCreator_TreeView.h"
|
||||
#include "CurveCreator_ICurve.hxx"
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
#include "CurveCreator_Utils.hxx"
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
@ -28,8 +30,8 @@
|
||||
|
||||
#define ID_SECTION -1
|
||||
|
||||
CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent ) :
|
||||
QAbstractItemModel(parent), myCurve(theCurve)
|
||||
CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent, bool toDrawColorIcon ) :
|
||||
QAbstractItemModel(parent), myCurve(theCurve), myDrawColorIcon(toDrawColorIcon)
|
||||
{
|
||||
SUIT_ResourceMgr* aResMgr = SUIT_Session::session()->resourceMgr();
|
||||
QPixmap aSplineIcon(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SPLINE")));
|
||||
@ -65,8 +67,8 @@ CurveCreator_TreeViewModel::CurveCreator_TreeViewModel( CurveCreator_ICurve* the
|
||||
|
||||
int CurveCreator_TreeViewModel::columnCount(const QModelIndex & parent ) const
|
||||
{
|
||||
if( parent.internalId() == (quintptr)ID_SECTION )
|
||||
return 2;
|
||||
if( myDrawColorIcon )
|
||||
return 3;
|
||||
else
|
||||
return 2;
|
||||
}
|
||||
@ -104,6 +106,13 @@ QVariant CurveCreator_TreeViewModel::data(const QModelIndex & index, int role )
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (myDrawColorIcon && aColumn == 2)
|
||||
{
|
||||
Quantity_Color color = ((CurveCreator_Curve*)myCurve)->getColorSection(aRow);
|
||||
QPixmap pixmap(16,16);
|
||||
pixmap.fill( CurveCreator_Utils::colorConv(color));
|
||||
return pixmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
/* else{
|
||||
@ -218,14 +227,14 @@ void CurveCreator_TreeViewModel::setCurve( CurveCreator_ICurve* theCurve )
|
||||
}
|
||||
|
||||
/*****************************************************************************************/
|
||||
CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent) :
|
||||
CurveCreator_TreeView::CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent, bool toDrawColorIcon) :
|
||||
QTreeView(parent)
|
||||
{
|
||||
header()->hide();
|
||||
header()->setSectionResizeMode(QHeaderView::ResizeToContents);
|
||||
setUniformRowHeights(true);
|
||||
setContextMenuPolicy( Qt::CustomContextMenu );
|
||||
CurveCreator_TreeViewModel* aModel = new CurveCreator_TreeViewModel(theCurve, this);
|
||||
CurveCreator_TreeViewModel* aModel = new CurveCreator_TreeViewModel(theCurve, this, toDrawColorIcon);
|
||||
setModel(aModel);
|
||||
setSelectionBehavior(SelectRows);
|
||||
setSelectionMode(SingleSelection);
|
||||
|
@ -28,7 +28,7 @@ class CurveCreator_ICurve;
|
||||
class CurveCreator_TreeViewModel : public QAbstractItemModel
|
||||
{
|
||||
public:
|
||||
CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent );
|
||||
CurveCreator_TreeViewModel( CurveCreator_ICurve* theCurve, QObject* parent, bool toDrawColorIcon );
|
||||
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;
|
||||
@ -50,6 +50,7 @@ private:
|
||||
enum IconType{ ICON_POLYLINE, ICON_SPLINE, ICON_CLOSED_SPLINE, ICON_CLOSED_POLYLINE, ICON_POINT };
|
||||
private:
|
||||
CurveCreator_ICurve* myCurve;
|
||||
bool myDrawColorIcon;
|
||||
QMap<IconType, QPixmap> myCachedIcons;
|
||||
};
|
||||
|
||||
@ -59,7 +60,7 @@ 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_ICurve* theCurve, QWidget *parent = 0);
|
||||
explicit CurveCreator_TreeView( CurveCreator_ICurve* theCurve, QWidget *parent = 0, bool toDrawColorIcon = true);
|
||||
SelectionType getSelectionType() const;
|
||||
QList<int> getSelectedSections() const;
|
||||
|
||||
|
@ -295,11 +295,13 @@ TopoDS_Wire CurveCreator_Utils::ConstructWire(
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void CurveCreator_Utils::constructShape(
|
||||
const CurveCreator_ICurve* theCurve, TopoDS_Shape& theShape)
|
||||
const CurveCreator_ICurve* theCurve, TopoDS_Shape& theShape,
|
||||
NCollection_IndexedDataMap<int, TopoDS_Shape>* theSect2Shape )
|
||||
{
|
||||
BRep_Builder aBuilder;
|
||||
TopoDS_Compound aShape;
|
||||
aBuilder.MakeCompound(aShape);
|
||||
|
||||
const int aSectionCount = theCurve->getNbSections();
|
||||
for (int aSectionI = 0; aSectionI < aSectionCount; ++aSectionI)
|
||||
{
|
||||
@ -314,10 +316,18 @@ void CurveCreator_Utils::constructShape(
|
||||
const int aPointCount = aPoints->Length();
|
||||
const bool isClosed = theCurve->isClosed(aSectionI);
|
||||
|
||||
TopoDS_Compound ShapeWireWithV;
|
||||
if (theSect2Shape)
|
||||
aBuilder.MakeCompound(ShapeWireWithV);
|
||||
|
||||
// Add the vertices to the shape.
|
||||
for (Standard_Integer aPN = 1; aPN <= aPointCount; ++aPN)
|
||||
{
|
||||
aBuilder.Add(aShape, BRepBuilderAPI_MakeVertex(aPoints->Value(aPN)));
|
||||
TopoDS_Vertex V;
|
||||
aBuilder.MakeVertex(V,aPoints->Value(aPN),Precision::Confusion());
|
||||
aBuilder.Add(aShape, V);
|
||||
if (theSect2Shape)
|
||||
aBuilder.Add(ShapeWireWithV, V);
|
||||
}
|
||||
|
||||
// Add the wire to the shape.
|
||||
@ -327,6 +337,11 @@ void CurveCreator_Utils::constructShape(
|
||||
if (!aWire.IsNull())
|
||||
{
|
||||
aBuilder.Add(aShape, aWire);
|
||||
if (theSect2Shape)
|
||||
{
|
||||
aBuilder.Add(ShapeWireWithV, aWire);
|
||||
(*theSect2Shape).Add(aSectionI, ShapeWireWithV);
|
||||
}
|
||||
}
|
||||
}
|
||||
theShape = aShape;
|
||||
@ -345,9 +360,36 @@ struct Section3D
|
||||
Handle(TColgp_HArray1OfPnt) myPoints;
|
||||
};
|
||||
|
||||
Quantity_Color CurveCreator_Utils::getRandColor()
|
||||
{
|
||||
float aHue = ( rand()%1000 ) * 0.001f;
|
||||
|
||||
QColor aColor;
|
||||
aColor.setHsl( (int)(aHue*255.), 200, 128 );
|
||||
int r = aColor.red();
|
||||
int g = aColor.green();
|
||||
int b = aColor.blue();
|
||||
|
||||
double r1 = r / 255.0;
|
||||
double g1 = g / 255.0;
|
||||
double b1 = b / 255.0;
|
||||
return Quantity_Color( r1, g1, b1, Quantity_TOC_RGB );
|
||||
}
|
||||
|
||||
Quantity_Color CurveCreator_Utils::colorConv(QColor color)
|
||||
{
|
||||
return Quantity_Color( color.red() / 255.,
|
||||
color.green() / 255., color.blue() / 255., Quantity_TOC_RGB );
|
||||
}
|
||||
|
||||
QColor CurveCreator_Utils::colorConv(Quantity_Color color)
|
||||
{
|
||||
return QColor( (int)( color.Red() * 255 ), (int)( color.Green() * 255 ), (int)( color.Blue() * 255 ) );
|
||||
}
|
||||
|
||||
//=======================================================================
|
||||
// function : constructCurve
|
||||
// purpose :
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
bool CurveCreator_Utils::constructCurve
|
||||
(const TopoDS_Shape theShape,
|
||||
@ -517,7 +559,7 @@ bool CurveCreator_Utils::constructCurve
|
||||
CurveCreator::Spline : CurveCreator::Polyline;
|
||||
|
||||
theCurve->addSectionInternal(aSecName, aSecType,
|
||||
aSecIt->myIsClosed, aCoords);
|
||||
aSecIt->myIsClosed, aCoords, Quantity_NOC_RED);
|
||||
}
|
||||
|
||||
// Set the local coordinate system.
|
||||
@ -625,7 +667,7 @@ void CurveCreator_Utils::setSelectedPoints( Handle(AIS_InteractiveContext) theCo
|
||||
{
|
||||
for ( NCollection_Vector<Handle(SelectMgr_SensitiveEntity)>::Iterator selIter( selected );
|
||||
selIter.More(); selIter.Next() )
|
||||
{
|
||||
{
|
||||
const Handle(SelectMgr_SensitiveEntity) aHSenEntity = selIter.Value();
|
||||
if( aHSenEntity.IsNull() )
|
||||
continue;
|
||||
@ -820,7 +862,7 @@ bool CurveCreator_Utils::isEqualPoints( const gp_Pnt& thePoint, const gp_Pnt& th
|
||||
|
||||
//=======================================================================
|
||||
// function : getPoints
|
||||
// purpose :
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
Handle(TColgp_HArray1OfPnt) CurveCreator_Utils::getPoints
|
||||
(const TopoDS_Shape &theShape,
|
||||
@ -909,7 +951,7 @@ Handle(TColgp_HArray1OfPnt) CurveCreator_Utils::getPoints
|
||||
}
|
||||
|
||||
IsClosed = aV[0].IsSame(aV[1]) ? true : false;
|
||||
|
||||
|
||||
Standard_Integer aNbPoints = aBSplCurve->NbKnots();
|
||||
TColStd_Array1OfReal aKnots(1, aNbPoints);
|
||||
aBSplCurve->Knots(aKnots);
|
||||
@ -979,7 +1021,7 @@ Handle(TColgp_HArray1OfPnt) CurveCreator_Utils::getPoints
|
||||
}
|
||||
//=======================================================================
|
||||
// function : FindPlane
|
||||
// purpose :
|
||||
// purpose :
|
||||
//=======================================================================
|
||||
void CurveCreator_Utils::FindPlane
|
||||
(const Handle(TColgp_HArray1OfPnt) &thePoints,
|
||||
|
@ -32,9 +32,11 @@
|
||||
#include <TopoDS_Wire.hxx>
|
||||
#include <TColgp_HArray1OfPnt.hxx>
|
||||
#include <Geom_BSplineCurve.hxx>
|
||||
#include <QColor>
|
||||
|
||||
#include <list>
|
||||
#include <vector> // TODO: remove
|
||||
#include <NCollection_IndexedDataMap.hxx>
|
||||
|
||||
class CurveCreator_Curve;
|
||||
|
||||
@ -55,6 +57,21 @@ public:
|
||||
Handle(V3d_View) theView,
|
||||
int& x, int& y );
|
||||
|
||||
/**
|
||||
* Generates a random color
|
||||
*/
|
||||
CURVECREATOR_EXPORT static Quantity_Color getRandColor();
|
||||
|
||||
/**
|
||||
* Convert QColor to Quantity_Color
|
||||
*/
|
||||
CURVECREATOR_EXPORT static Quantity_Color colorConv(QColor color);
|
||||
|
||||
/**
|
||||
* Convert Quantity_Color to QColor
|
||||
*/
|
||||
CURVECREATOR_EXPORT static QColor colorConv(Quantity_Color color);
|
||||
|
||||
/*!
|
||||
* \brief Returns the point clicked in 3D view.
|
||||
*
|
||||
@ -70,9 +87,11 @@ public:
|
||||
* Generates shape on the curve
|
||||
* \param theCurve a curve object, that contains data
|
||||
* \param theShape a generated shape
|
||||
* \param Sect2Shape optional out map: section to constructed shape (wire+vertices)
|
||||
*/
|
||||
CURVECREATOR_EXPORT static void constructShape( const CurveCreator_ICurve* theCurve,
|
||||
TopoDS_Shape& theShape );
|
||||
TopoDS_Shape& theShape,
|
||||
NCollection_IndexedDataMap<int, TopoDS_Shape>* Sect2Shape = NULL);
|
||||
|
||||
/**
|
||||
* Generates a curve from a shape.
|
||||
|
@ -21,6 +21,7 @@
|
||||
|
||||
#include "CurveCreator.hxx"
|
||||
#include <gp_Pnt.hxx>
|
||||
#include <TopoDS_Shape.hxx>
|
||||
|
||||
const double LOCAL_SELECTION_TOLERANCE = 0.0001;
|
||||
|
||||
|
@ -26,11 +26,18 @@
|
||||
#include "CurveCreator_UtilsICurve.hxx"
|
||||
#include "CurveCreator_TableView.h"
|
||||
|
||||
#include "CurveCreator_Curve.hxx"
|
||||
#include "CurveCreator_Section.hxx"
|
||||
#include <QColorDialog>
|
||||
|
||||
#include <SUIT_Session.h>
|
||||
#include <SUIT_Desktop.h>
|
||||
#include <SUIT_ResourceMgr.h>
|
||||
#include <SUIT_ViewManager.h>
|
||||
|
||||
#include <TopExp_Explorer.hxx>
|
||||
#include "CurveCreator_ShapeFilter.hxx"
|
||||
|
||||
#include <OCCViewer_ViewManager.h>
|
||||
#include <OCCViewer_ViewPort3d.h>
|
||||
#include <OCCViewer_Utilities.h>
|
||||
@ -97,7 +104,10 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
||||
|
||||
QGroupBox* aSectionGroup = new QGroupBox(tr("SECTION_GROUP_TITLE"),this);
|
||||
|
||||
mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup);
|
||||
|
||||
bool toDrawSectColor = !(theActionFlags & DisableSetColor);
|
||||
|
||||
mySectionView = new CurveCreator_TreeView(myCurve, aSectionGroup, toDrawSectColor);
|
||||
mySectionView->setSelectionMode( QTreeView::ExtendedSelection );
|
||||
connect( mySectionView, SIGNAL(selectionChanged()), this, SLOT( onSelectionChanged() ) );
|
||||
connect( mySectionView, SIGNAL(sectionEntered(int)), this, SLOT(onEditSection(int)) );
|
||||
@ -124,20 +134,21 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
||||
QPixmap aBringTogetherPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_BRING_TOGETHER")));
|
||||
QPixmap aStepUpPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_UP")));
|
||||
QPixmap aStepDownPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_ARROW_DOWN")));
|
||||
QPixmap aSetColorPixmap(aResMgr->loadPixmap("GEOM", tr("ICON_CC_SETCOLOR")));
|
||||
|
||||
QAction* anAct = createAction( UNDO_ID, tr("UNDO"), anUndoPixmap, tr("UNDO_TLT"),
|
||||
QAction* anAct = createAction( UNDO_ID, tr("UNDO"), anUndoPixmap, tr("UNDO_TLT"),
|
||||
QKeySequence(Qt::ControlModifier|Qt::Key_Z) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onUndo()) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
anAct = createAction( REDO_ID, tr("REDO"), aRedoPixmap, tr("REDO_TLT"),
|
||||
anAct = createAction( REDO_ID, tr("REDO"), aRedoPixmap, tr("REDO_TLT"),
|
||||
QKeySequence(Qt::ControlModifier|Qt::Key_Y) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onRedo()) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
aTB->addSeparator();
|
||||
|
||||
anAct = createAction( NEW_SECTION_ID, tr("NEW_SECTION"), aNewSectionPixmap, tr("NEW_SECTION_TLT"),
|
||||
|
||||
anAct = createAction( NEW_SECTION_ID, tr("NEW_SECTION"), aNewSectionPixmap, tr("NEW_SECTION_TLT"),
|
||||
QKeySequence(Qt::ControlModifier|Qt::Key_N) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onNewSection()) );
|
||||
if ( !(theActionFlags & DisableNewSection) ) {
|
||||
@ -145,21 +156,21 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
||||
aTB->addSeparator();
|
||||
}
|
||||
|
||||
anAct = createAction( ADDITION_MODE_ID, tr("ADDITION_MODE"), aNewPointPixmap, tr("ADDITION_MODE_TLT"),
|
||||
anAct = createAction( ADDITION_MODE_ID, tr("ADDITION_MODE"), aNewPointPixmap, tr("ADDITION_MODE_TLT"),
|
||||
QKeySequence() );
|
||||
anAct->setCheckable(true);
|
||||
connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onAdditionMode(bool)) );
|
||||
connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
anAct = createAction( MODIFICATION_MODE_ID, tr("MODIFICATION_MODE"), anEditPointsPixmap, tr("MODIFICATION_MODE_TLT"),
|
||||
|
||||
anAct = createAction( MODIFICATION_MODE_ID, tr("MODIFICATION_MODE"), anEditPointsPixmap, tr("MODIFICATION_MODE_TLT"),
|
||||
QKeySequence() );
|
||||
anAct->setCheckable(true);
|
||||
connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onModificationMode(bool)) );
|
||||
connect(anAct, SIGNAL(toggled(bool)), this, SLOT(onModeChanged(bool)) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
anAct = createAction( DETECTION_MODE_ID, tr("DETECTION_MODE"), aDetectPointsPixmap, tr("DETECTION_MODE_TLT"),
|
||||
anAct = createAction( DETECTION_MODE_ID, tr("DETECTION_MODE"), aDetectPointsPixmap, tr("DETECTION_MODE_TLT"),
|
||||
QKeySequence() );
|
||||
anAct->setCheckable(true);
|
||||
connect(anAct, SIGNAL(triggered(bool)), this, SLOT(onDetectionMode(bool)) );
|
||||
@ -167,32 +178,39 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
||||
// if ( !(theActionFlags & DisableDetectionMode) ) {
|
||||
// aTB->addAction(anAct);
|
||||
// }
|
||||
|
||||
anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), QPixmap(), tr("CLOSE_SECTIONS_TLT"),
|
||||
|
||||
anAct = createAction( CLOSE_SECTIONS_ID, tr("CLOSE_SECTIONS"), QPixmap(), tr("CLOSE_SECTIONS_TLT"),
|
||||
QKeySequence(Qt::ControlModifier|Qt::Key_W) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onCloseSections()) );
|
||||
|
||||
anAct = createAction( UNCLOSE_SECTIONS_ID, tr("UNCLOSE_SECTIONS"), QPixmap(),
|
||||
anAct = createAction( UNCLOSE_SECTIONS_ID, tr("UNCLOSE_SECTIONS"), QPixmap(),
|
||||
tr("UNCLOSE_SECTIONS_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_S) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onUncloseSections()) );
|
||||
|
||||
anAct = createAction( SET_SECTIONS_POLYLINE_ID, tr("SET_SECTIONS_POLYLINE"),
|
||||
aPolylinePixmap, tr("SET_SECTIONS_POLYLINE_TLT"),
|
||||
anAct = createAction( SET_SECTIONS_POLYLINE_ID, tr("SET_SECTIONS_POLYLINE"),
|
||||
aPolylinePixmap, tr("SET_SECTIONS_POLYLINE_TLT"),
|
||||
QKeySequence(Qt::ControlModifier|Qt::Key_E) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetPolyline()) );
|
||||
|
||||
anAct = createAction( SET_SECTIONS_SPLINE_ID, tr("SET_SECTIONS_SPLINE"), aSplinePixmap,
|
||||
anAct = createAction( SET_SECTIONS_SPLINE_ID, tr("SET_SECTIONS_SPLINE"), aSplinePixmap,
|
||||
tr("SET_SECTIONS_SPLINE_TLT"), QKeySequence(Qt::ControlModifier|Qt::Key_R) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetSpline()) );
|
||||
|
||||
aTB->addSeparator();
|
||||
|
||||
anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, tr("REMOVE_TLT"),
|
||||
anAct = createAction( REMOVE_ID, tr("REMOVE"), aRemovePixmap, tr("REMOVE_TLT"),
|
||||
QKeySequence(Qt::ControlModifier|Qt::Key_Delete ) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onRemove()) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"),
|
||||
|
||||
anAct = createAction( SETCOLOR_ID, tr("SETCOLOR"), aSetColorPixmap, tr("SETCOLOR_TLT"),
|
||||
QKeySequence(Qt::ControlModifier|Qt::Key_C ) );
|
||||
connect(anAct, SIGNAL(triggered()), this, SLOT(onSetColor()) );
|
||||
|
||||
if ( !(theActionFlags & DisableSetColor) )
|
||||
aTB->addAction(anAct);
|
||||
|
||||
anAct = createAction( JOIN_ID, tr("JOIN"), aJoinPixmap, tr("JOIN_TLT"),
|
||||
QKeySequence(Qt::ControlModifier|Qt::Key_Plus ) );
|
||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoin()) );
|
||||
aTB->addAction(anAct);
|
||||
@ -202,11 +220,11 @@ CurveCreator_Widget::CurveCreator_Widget(QWidget* parent,
|
||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onBringTogether()) );
|
||||
aTB->addAction(anAct);
|
||||
|
||||
anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"),
|
||||
anAct = createAction( CLEAR_ALL_ID, tr("CLEAR_ALL"), QPixmap(), tr("CLEAR_ALL_TLT"),
|
||||
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Delete ) );
|
||||
connect( anAct, SIGNAL(triggered()), this, SLOT( onClearAll()) );
|
||||
|
||||
anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"),
|
||||
anAct = createAction( JOIN_ALL_ID, tr("JOIN_ALL"), QPixmap(), tr("JOIN_ALL_TLT"),
|
||||
QKeySequence(Qt::ControlModifier | Qt::ShiftModifier | Qt::Key_Plus ) );
|
||||
connect( anAct, SIGNAL(triggered()), this, SLOT(onJoinAll()) );
|
||||
|
||||
@ -305,7 +323,7 @@ OCCViewer_ViewPort3d* CurveCreator_Widget::getViewPort()
|
||||
OCCViewer_Viewer* aViewer = getOCCViewer();
|
||||
if ( aViewer )
|
||||
aViewPort = ((OCCViewer_ViewWindow*)aViewer->getViewManager()->getActiveView())->getViewPort();
|
||||
|
||||
|
||||
return aViewPort;
|
||||
}
|
||||
|
||||
@ -349,6 +367,11 @@ void CurveCreator_Widget::onSelectionChanged()
|
||||
updateActionsStates();
|
||||
updateUndoRedo();
|
||||
emit selectionChanged();
|
||||
QList<int> selectedSections = mySectionView->getSelectedSections();
|
||||
CurveCreator_Curve* Curve = ((CurveCreator_Curve*)myCurve);
|
||||
Curve->myCurSectInd.clear();
|
||||
foreach (int sectInd, selectedSections)
|
||||
Curve->myCurSectInd.push_back(sectInd);
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::updateActionsStates()
|
||||
@ -359,6 +382,8 @@ void CurveCreator_Widget::updateActionsStates()
|
||||
if ( removeEnabled() )
|
||||
anEnabledAct << REMOVE_ID;
|
||||
QList<int> aSelSections = mySectionView->getSelectedSections();
|
||||
if (aSelSections.size() == 1)
|
||||
anEnabledAct << SETCOLOR_ID;
|
||||
CurveCreator_TreeView::SelectionType aSelType = mySectionView->getSelectionType();
|
||||
switch( aSelType ){
|
||||
case CurveCreator_TreeView::ST_NOSEL:{
|
||||
@ -434,7 +459,7 @@ void CurveCreator_Widget::updateActionsStates()
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
/*int aSelObjsCnt = aSelPoints.size() + aSelSections.size();
|
||||
if( aSelObjsCnt > 0 ){
|
||||
anEnabledAct << REMOVE_ID;
|
||||
@ -601,7 +626,7 @@ void CurveCreator_Widget::onEditSection( int theSection )
|
||||
{
|
||||
if( !myCurve )
|
||||
return;
|
||||
|
||||
|
||||
stopActionMode();
|
||||
mySection = theSection;
|
||||
QString aSectName = QString::fromStdString( myCurve->getSectionName(theSection));
|
||||
@ -689,6 +714,31 @@ void CurveCreator_Widget::onRemove()
|
||||
}
|
||||
}
|
||||
|
||||
void CurveCreator_Widget::onSetColor()
|
||||
{
|
||||
if( !myCurve )
|
||||
return;
|
||||
|
||||
QList<int> aSections = mySectionView->getSelectedSections();
|
||||
if (aSections.size() != 1)
|
||||
return;
|
||||
|
||||
int aSectNum = aSections[0];
|
||||
Quantity_Color aColor = ((CurveCreator_Curve*)myCurve)->getColorSection( aSectNum );;
|
||||
|
||||
QColor aQColor = CurveCreator_Utils::colorConv(aColor);
|
||||
QColor aNewQColor = QColorDialog::getColor( aQColor, this );
|
||||
if( !aNewQColor.isValid() )
|
||||
return;
|
||||
|
||||
Quantity_Color aNewColor = CurveCreator_Utils::colorConv(aNewQColor);
|
||||
|
||||
((CurveCreator_Curve*)myCurve)->setColorSection( aSectNum, aNewColor);
|
||||
|
||||
updateUndoRedo();
|
||||
}
|
||||
|
||||
|
||||
void CurveCreator_Widget::onClearAll()
|
||||
{
|
||||
if( !myCurve )
|
||||
@ -971,7 +1021,7 @@ void CurveCreator_Widget::addCoordsByClick( QMouseEvent* pe )
|
||||
if ( ic.IsNull() )
|
||||
return;
|
||||
|
||||
gp_Pnt aPnt;
|
||||
gp_Pnt aPnt;
|
||||
OCCViewer_ViewPort3d* vp = getViewPort();
|
||||
|
||||
aPnt = CurveCreator_Utils::ConvertClickToPoint( pe->x(), pe->y(), vp->getView() );
|
||||
@ -1098,7 +1148,7 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven
|
||||
aCtx->ClearSelected( Standard_True );
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (theEvent->button() != Qt::LeftButton) return;
|
||||
if (!theWindow->inherits("OCCViewer_ViewWindow")) return;
|
||||
|
||||
@ -1122,6 +1172,32 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven
|
||||
Handle(V3d_View) aView3d = aView->getViewPort()->getView();
|
||||
if ( !aView3d.IsNull() )
|
||||
{
|
||||
CurveCreator_Curve* Curve = ((CurveCreator_Curve*)myCurve);
|
||||
//if (!Curve->myCurSectInd.empty())
|
||||
//{
|
||||
aCtx->RemoveFilters();
|
||||
Handle(CurveCreator_ShapeFilter) filter = new CurveCreator_ShapeFilter();
|
||||
for (int i=0; i<Curve->myCurSectInd.size(); i++)
|
||||
{
|
||||
int sectInd = Curve->myCurSectInd[i];
|
||||
const TopoDS_Shape& W = Curve->mySect2Shape(sectInd+1);
|
||||
TopExp_Explorer exp(W, TopAbs_VERTEX);
|
||||
for (;exp.More();exp.Next())
|
||||
filter->AddShape(exp.Current());
|
||||
}
|
||||
aCtx->AddFilter(filter);
|
||||
#if OCC_VERSION_LARGE <= 0x07030000
|
||||
if (aCtx->HasOpenedContext())
|
||||
{
|
||||
Handle(AIS_LocalContext) aLctx = aCtx->LocalContext();
|
||||
aLctx->Filter()->Clear();
|
||||
aLctx->AddFilter(filter);
|
||||
}
|
||||
#else
|
||||
// TODO: check if something required
|
||||
#endif
|
||||
//}
|
||||
|
||||
// Initialize the single selection if start and end points are equal,
|
||||
// otherwise a rectangular selection.
|
||||
if ( myStartPoint == myEndPoint )
|
||||
@ -1171,7 +1247,7 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven
|
||||
if ( aCoords.size() < 2 ) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
CurveCreator_ICurve::SectionToPoint aSectionToPoint = std::make_pair( aSectionId, aPointId );
|
||||
|
||||
if ( !anInitialDragPointsCoords.contains( aSectionToPoint ) ) {
|
||||
@ -1179,7 +1255,7 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// Apply points sorting
|
||||
CurveCreator_ICurve::SectionToPointList aPoints;
|
||||
startCurveModification( aPoints, false );
|
||||
@ -1199,7 +1275,7 @@ void CurveCreator_Widget::onMouseRelease( SUIT_ViewWindow* theWindow, QMouseEven
|
||||
}
|
||||
|
||||
myCurve->setSeveralPoints( aCoordList, false );
|
||||
|
||||
|
||||
finishCurveModification( aDraggedPoints );
|
||||
} else {
|
||||
// if the drag of some points has happened, restore the drag selection
|
||||
@ -1391,7 +1467,7 @@ void CurveCreator_Widget::insertPointToSelectedSegment( const int theX,
|
||||
}
|
||||
|
||||
int anInsertPos = -1;
|
||||
int aLastPoint = myCurve->getNbPoints( aSectionId )-1;
|
||||
int aLastPoint = myCurve->getNbPoints( aSectionId )-1;
|
||||
if ( ( aPoint1Id == aLastPoint && aPoint2Id == 0 ) ||
|
||||
( aPoint2Id == aLastPoint && aPoint1Id == 0 ) )
|
||||
anInsertPos = -1; // if the section happens between first and last points
|
||||
@ -1442,9 +1518,9 @@ void CurveCreator_Widget::moveSelectedPoints( const int theXPosition,
|
||||
|
||||
aChangedPos[0] = aChangedPos[0] - aXDelta;
|
||||
aChangedPos[1] = aChangedPos[1] - anYDelta;
|
||||
|
||||
|
||||
aCoordList.push_back(
|
||||
std::make_pair(std::make_pair( aSectionId, aPointId ),
|
||||
std::make_pair(std::make_pair( aSectionId, aPointId ),
|
||||
aChangedPos ));
|
||||
}
|
||||
myCurve->setSeveralPoints( aCoordList, false );
|
||||
@ -1477,7 +1553,7 @@ void CurveCreator_Widget::updateLocalPointView()
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
void CurveCreator_Widget::setLocalPointContext( const bool theOpen, const bool isUpdateTable )
|
||||
{
|
||||
|
@ -56,7 +56,8 @@ public:
|
||||
NoFlags = 0x00000000,
|
||||
DisableDetectionMode = 0x00000001,
|
||||
DisableNewSection = 0x00000002,
|
||||
DisableClosedSection = 0x00000004
|
||||
DisableClosedSection = 0x00000004,
|
||||
DisableSetColor = 0x00000008
|
||||
};
|
||||
|
||||
enum ActionMode {
|
||||
@ -119,6 +120,7 @@ public slots:
|
||||
void onJoin();
|
||||
void onBringTogether();
|
||||
void onRemove();
|
||||
void onSetColor();
|
||||
void onClearAll();
|
||||
void onJoinAll();
|
||||
void onSetSpline();
|
||||
@ -146,23 +148,24 @@ protected:
|
||||
|
||||
protected:
|
||||
enum ActionId{ NONE_ID,
|
||||
UNDO_ID,
|
||||
REDO_ID,
|
||||
NEW_SECTION_ID,
|
||||
ADDITION_MODE_ID,
|
||||
REMOVE_ID,
|
||||
REMOVE_ALL_ID,
|
||||
UNDO_ID,
|
||||
REDO_ID,
|
||||
NEW_SECTION_ID,
|
||||
ADDITION_MODE_ID,
|
||||
REMOVE_ID,
|
||||
REMOVE_ALL_ID,
|
||||
JOIN_ID,
|
||||
JOIN_ALL_ID,
|
||||
CLOSE_SECTIONS_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,
|
||||
SET_SECTIONS_POLYLINE_ID,
|
||||
SET_SECTIONS_SPLINE_ID,
|
||||
CLEAR_ALL_ID,
|
||||
SEPARATOR_ID,
|
||||
MODIFICATION_MODE_ID,
|
||||
DETECTION_MODE_ID,
|
||||
BRING_TOGETHER_ID
|
||||
BRING_TOGETHER_ID,
|
||||
SETCOLOR_ID
|
||||
};
|
||||
|
||||
public:
|
||||
@ -193,7 +196,7 @@ private:
|
||||
|
||||
void startCurveModification( CurveCreator_ICurve::SectionToPointList& thePoints,
|
||||
const bool theFillPoints = true );
|
||||
void finishCurveModification( const CurveCreator_ICurve::SectionToPointList& thePoints =
|
||||
void finishCurveModification( const CurveCreator_ICurve::SectionToPointList& thePoints =
|
||||
CurveCreator_ICurve::SectionToPointList() );
|
||||
|
||||
// curve algorithm
|
||||
|
@ -63,6 +63,10 @@
|
||||
<source>ICON_CC_UNDO</source>
|
||||
<translation>undo.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICON_CC_SETCOLOR</source>
|
||||
<translation>setcolor.png</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>ICON_FOLDER</source>
|
||||
<translation>folder.png</translation>
|
||||
|
@ -6103,6 +6103,14 @@ shells and solids on the other hand.</translation>
|
||||
<source>SET_SECTIONS_SPLINE_TLT</source>
|
||||
<translation>Set selected section type to spline</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>SETCOLOR</source>
|
||||
<translation>Set color</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>SETCOLOR_TLT</source>
|
||||
<translation>Set color</translation>
|
||||
</message>
|
||||
<message>
|
||||
<source>REMOVE</source>
|
||||
<translation>Remove</translation>
|
||||
|
Loading…
Reference in New Issue
Block a user