myNbRedos (0),
myUndoDepth (-1),
myOpLevel(0),
- mySkipSorting(false)
+ mySkipSorting(false),
+ myPointAspectColor (Quantity_NOC_ROYALBLUE4),
+ myCurveColor (Quantity_NOC_RED),
+ myEraseAll(true),
+ myLineWidth(1)
{
}
}
}
-void CurveCreator_Curve::redisplayCurve()
+void CurveCreator_Curve::redisplayCurve(bool preEraseAllObjects)
{
//DEBTRACE("redisplayCurve");
- if( myDisplayer ) {
- myDisplayer->eraseAll( false );
+ if( myDisplayer )
+ {
+ if (preEraseAllObjects)
+ myDisplayer->eraseAll( false );
+ else
+ myDisplayer->erase( myAISShape, false);
myAISShape = NULL;
-
myDisplayer->display( getAISObject( true ), true );
}
}
bool CurveCreator_Curve::clearInternal()
{
// erase curve from the viewer
- if( myDisplayer ) {
- myDisplayer->eraseAll( true );
+ if( myDisplayer )
+ {
+ if (myEraseAll)
+ myDisplayer->eraseAll( true );
+ else
+ myDisplayer->erase(myAISShape, false);
myAISShape = NULL;
}
// Delete all allocated data.
return res;
}
+//=======================================================================
+// function: clear
+// purpose:
+//=======================================================================
+void CurveCreator_Curve::SetEraseAllState(bool toEraseAll)
+{
+ myEraseAll = toEraseAll;
+}
+//=======================================================================
+// function: clear
+// purpose:
+//=======================================================================
+bool CurveCreator_Curve::GetEraseAllState() const
+{
+ return myEraseAll;
+}
+
//! For internal use only! Undo/Redo are not used here.
bool CurveCreator_Curve::joinInternal( const std::list<int>& theSections )
{
break;
}
- redisplayCurve();
+ redisplayCurve(false);
return res;
}
aSection->myIsClosed = theIsClosed;
aSection->myPoints = thePoints;
mySections.push_back(aSection);
- redisplayCurve();
+ redisplayCurve(false);
return mySections.size()-1;
}
delete *anIterRm;
mySections.erase(anIterRm);
}
- redisplayCurve();
+ redisplayCurve(false);
return true;
}
aSection = (CurveCreator_Section*)getSection( i );
if( aSection ) {
aSection->myIsClosed = theIsClosed;
- redisplayCurve();
+ redisplayCurve(false);
}
}
} else {
aSection = (CurveCreator_Section*)getSection( theISection );
if ( aSection ) {
aSection->myIsClosed = theIsClosed;
- redisplayCurve();
+ redisplayCurve(false);
}
}
return true;
if ( aSection )
aSection->myType = theType;
}
- redisplayCurve();
+ redisplayCurve(false);
} else {
aSection = (CurveCreator_Section*)getSection( theISection );
if ( aSection && aSection->myType != theType ){
aSection->myType = theType;
- redisplayCurve();
+ redisplayCurve(false);
}
}
return true;
}
}
if(res)
- redisplayCurve();
+ redisplayCurve(false);
return res;
}
}
}
if(res)
- redisplayCurve();
+ redisplayCurve(false);
return res;
}
aRes = removeSectionPoints(aSectionId, anIt->second);
}
if( aRes)
- redisplayCurve();
+ redisplayCurve(false);
return aRes;
}
// function: getPoints
// purpose:
//=======================================================================
-CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) const
+CurveCreator::Coordinates CurveCreator_Curve::getCoords( int theISection ) const
{
- //DEBTRACE("getPoints");
CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
return aSection ? aSection->myPoints : CurveCreator::Coordinates();
}
+Handle(TColgp_HArray1OfPnt) CurveCreator_Curve::GetDifferentPoints( int theISection ) const
+{
+ //DEBTRACE("getPoints");
+ CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
+ return aSection ? aSection->GetDifferentPoints( (int)myDimension ) : Handle(TColgp_HArray1OfPnt)();
+}
+
void CurveCreator_Curve::constructAISObject()
{
//DEBTRACE("constructAISObject");
TopoDS_Shape aShape;
CurveCreator_Utils::constructShape( this, aShape );
-
- myAISShape = new AIS_Shape( aShape );
+ myAISShape = new AIS_Shape( aShape );
+ myAISShape->SetColor( myCurveColor );
+ myAISShape->SetWidth( myLineWidth );
Handle(Prs3d_PointAspect) anAspect = myAISShape->Attributes()->PointAspect();
anAspect->SetScale( 3.0 );
anAspect->SetTypeOfMarker(Aspect_TOM_O_POINT);
- anAspect->SetColor(Quantity_NOC_ROYALBLUE4);
+ anAspect->SetColor(myPointAspectColor);
myAISShape->Attributes()->SetPointAspect( anAspect );
-
}
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();
}
class CurveCreator_Displayer;
class AIS_Shape;
class AIS_InteractiveObject;
+class Quantity_Color;
/**
* The CurveCreator_Curve object is represented as one or more sets of
public: // TODO: remove public
void getCoordinates( int theISection, int theIPoint, double& theX, double& theY, double& theZ ) const;
protected: // TODO: remove public
- void redisplayCurve();
+ void redisplayCurve(bool preEraseAllObjects = true);
public:
/************ Implementation of INTERFACE methods ************/
//! Clear the polyline (remove all sections)
virtual bool clear();
+ //! set erase-all state
+ //! if true => erase all objects from viever, else remove only the current curve
+ void SetEraseAllState(bool toEraseAll);
+
+ //! get erase-all state
+ //! if true => erase all objects from viever, else remove only the current curve
+ bool GetEraseAllState() const;
+
//! For internal use only! Undo/Redo are not used here.
virtual bool joinInternal( const std::list<int>& theSections );
/**
* 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;
+ virtual Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theISection = -1 ) const;
+
+ CurveCreator::Coordinates getCoords( int theISection = -1 ) const;
/**
/**
* Get the curve AIS object
*/
- virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false ) const;
+ virtual Handle(AIS_InteractiveObject) getAISObject( const bool theNeedToBuild = false) const;
protected:
/**
CurveCreator::Sections mySections; //!< curve data
CurveCreator::Dimension myDimension; //!< curve dimension
CurveCreator_Displayer* myDisplayer; //!< curve displayer
+ Quantity_Color myPointAspectColor;
+ Quantity_Color myCurveColor;
+ double myLineWidth;
private:
int myUndoDepth;
int myOpLevel;
AIS_Shape* myAISShape; //!< AIS shape
+ bool myEraseAll;
};
#endif
aSectionId = anIt->first;
aPointId = anIt->second;
const CurveCreator::Coordinates &aPoints =
- theCurve->getPoints(aSectionId);
+ theCurve->getCoords(aSectionId);
CurveCreator::Coordinates::const_iterator anIterBegin =
aPoints.begin() + (aDim*aPointId);
CurveCreator::Coordinates::const_iterator anIterEnd =
CurveCreator_Operation &theOperation) const
{
const std::string aName = theCurve->getSectionName(theIndex);
- const CurveCreator::Coordinates &aPnts = theCurve->getPoints(theIndex);
+ const CurveCreator::Coordinates &aPnts = theCurve->getCoords(theIndex);
const CurveCreator::SectionType aType = theCurve->getSectionType(theIndex);
const bool isClosed = theCurve->isClosed(theIndex);
{
if(myObjects.empty())
return;
- for( int i = 0 ; i < myObjects.size() ; i++ ){
+ for( int i = 0 ; i < myObjects.size() ; i++ )
myContext->Erase(myObjects[i], Standard_False);
- }
myObjects.clear();
if( isUpdate )
myContext->UpdateCurrentViewer();
}
+void CurveCreator_Displayer::erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate )
+{
+ if(theObject.IsNull())
+ return;
+ myContext->Erase(theObject, Standard_False);
+ if( isUpdate )
+ myContext->UpdateCurrentViewer();
+}
+
Quantity_Color CurveCreator_Displayer::getActiveColor( bool isHL )
{
if( isHL ){
return Quantity_Color( 0., 1., 0., Quantity_TOC_RGB );
}
+void CurveCreator_Displayer::Update()
+{
+ for( int i = 0 ; i < myObjects.size() ; i++ )
+ myContext->Update(myObjects[i], Standard_True);
+ myContext->UpdateCurrentViewer();
+}
+
/*void CurveCreator_Displayer::highlight( const AISObjectsList& theObjects, bool isHL )
{
return;
void display( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate );
void eraseAll( bool isUpdate );
+ void erase( const Handle(AIS_InteractiveObject)& theObject, bool isUpdate );
+ void Update();
//void highlight( const AISObjectsList& theObjects, bool isHL );
protected:
virtual ~CurveCreator_ISection() {}
//! Calculates the different points of the section.
- virtual void GetDifferentPoints(
- const int theDimension, Handle(TColgp_HArray1OfPnt)& thePoints) const = 0;
+ virtual Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theDimension ) const = 0;
};
/**
/**
* 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 = 0;
+ virtual Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theISection = -1 ) const = 0;
/**
* Get number of points in specified section or (the total number of points
// function: GetDifferentPoints
// purpose:
//=======================================================================
-void CurveCreator_Section::GetDifferentPoints(
- const int theDimension, Handle(TColgp_HArray1OfPnt)& thePoints) const
+Handle(TColgp_HArray1OfPnt) CurveCreator_Section::GetDifferentPoints( int theDimension ) const
{
+ Handle(TColgp_HArray1OfPnt) points;
+
std::vector<gp_Pnt> aTmpPoints;
+
CurveCreator::Coordinates::const_iterator aPIt = myPoints.begin();
CurveCreator::Coordinates::const_iterator aPItLast = myPoints.end();
- const gp_Pnt aFirstPoint(
- *aPIt, *(aPIt + 1), (theDimension == 2) ? 0 : *(aPIt + 2));
- gp_Pnt aPoint = aFirstPoint;
- aTmpPoints.push_back(aPoint);
+
+ gp_Pnt aFirstPoint;
+ gp_Pnt aPoint;
+
+ if( myPoints.size() > 0 )
+ {
+ aFirstPoint = gp_Pnt(*aPIt, *(aPIt + 1), (theDimension == 2) ? 0 : *(aPIt + 2));
+ aPoint = aFirstPoint;
+ aTmpPoints.push_back(aPoint);
+ }
for (; aPIt != aPItLast; aPIt += theDimension)
{
}
}
- thePoints = new TColgp_HArray1OfPnt(1, aPointCount);
+ points = new TColgp_HArray1OfPnt(1, aPointCount);
for (int aPI = 0; aPI < aPointCount; ++aPI)
{
- thePoints->SetValue(aPI + 1, aTmpPoints[aPI]);
+ points->SetValue(aPI + 1, aTmpPoints[aPI]);
}
+
+ return points;
}
CurveCreator_Section() : myName("Section"),myType(CurveCreator::Polyline), myIsClosed(false)
{ }
- std::string myName; //!< section name
+ std::string myName; //!< section name
CurveCreator::Coordinates myPoints; //!< points coordinates
CurveCreator::SectionType myType; //!< type of the section
bool myIsClosed; //!< closed or not
//! A virtual method.
- void GetDifferentPoints(const int theDimension, Handle(TColgp_HArray1OfPnt)& thePoints) const;
+ Handle(TColgp_HArray1OfPnt) GetDifferentPoints( int theDimension ) const;
};
#endif
#include "CurveCreator_TableView.h"
#include "CurveCreator_UtilsICurve.hxx"
+#include "CurveCreator_Widget.h"
#include <gp_Pnt.hxx>
QItemDelegate::setModelData( theEditor, theModel, theIndex );
}
+
+
+
CurveCreator_TableView::CurveCreator_TableView( CurveCreator_ICurve* theCurve,
- QWidget* theParent,
+ CurveCreator_Widget* theParent,
const QStringList& theCoordTitles )
-: QTableWidget( theParent ), myCurve( theCurve )
+ : QTableWidget( theParent ), myWidget( theParent ),
+ myCurve( theCurve ), myCurrentSortId( -1 ), myCurrentSortOrder( Qt::AscendingOrder )
{
setItemDelegate( new CurveCreator_TableItemDelegate( this ) );
setVisible( false );
void CurveCreator_TableView::OnHeaderClick( int theLogicalId )
{
- sortByColumn( theLogicalId, Qt::AscendingOrder );
+ if( theLogicalId == myCurrentSortId )
+ if( myCurrentSortOrder == Qt::AscendingOrder )
+ myCurrentSortOrder = Qt::DescendingOrder;
+ else
+ myCurrentSortOrder = Qt::AscendingOrder;
+
+ sortByColumn( theLogicalId, myCurrentSortOrder );
+
+ CurveCreator_ICurve::SectionToPointList selected;
+ for( int r=0, n=rowCount(); r<n; r++ )
+ {
+ int section = item( r, 0 )->data( Qt::UserRole ).toInt();
+ int point = item( r, 1 )->data( Qt::UserRole ).toInt();
+ selected.push_back( CurveCreator_ICurve::SectionToPoint( section, point ) );
+ }
+ myWidget->setSelectedPoints( selected );
+
+ myCurrentSortId = theLogicalId;
}
#include <QItemDelegate>
#include <QTableWidget>
+class CurveCreator_Widget;
+
class CurveCreator_TableItemDelegate : public QItemDelegate
{
public:
const QModelIndex& theIndex ) const;
};
-class CurveCreator_TableView : public QTableWidget
+class CURVECREATOR_EXPORT CurveCreator_TableView : public QTableWidget
{
Q_OBJECT
public:
- CurveCreator_TableView( CurveCreator_ICurve* theCurve, QWidget* theParent = 0,
+ CurveCreator_TableView( CurveCreator_ICurve* theCurve, CurveCreator_Widget* theParent,
const QStringList& theCoordTitles = QStringList() );
~CurveCreator_TableView() {};
*/
int getPointId( const int theRowId ) const;
-private slots:
+public slots:
void OnHeaderClick( int );
private:
+ CurveCreator_Widget* myWidget;
CurveCreator_ICurve* myCurve;
+ int myCurrentSortId;
+ Qt::SortOrder myCurrentSortOrder;
};
#endif // CURVECREATOR_TABLEVIEW_H
void CurveCreator_TreeViewModel::setCurve( CurveCreator_ICurve* theCurve )
{
- myCurve = theCurve;
#if QT_VERSION < QT_VERSION_CHECK(5, 0, 0)
+ myCurve = theCurve;
reset();
+#else
+ beginResetModel();
+ myCurve = theCurve;
+ endResetModel();
#endif
}
}
// Get the different points.
- const CurveCreator_ISection* aSection = theCurve->getSection(aSectionI);
- Handle(TColgp_HArray1OfPnt) aPoints;
- aSection->GetDifferentPoints(theCurve->getDimension(), aPoints);
+ Handle(TColgp_HArray1OfPnt) aPoints = theCurve->GetDifferentPoints( aSectionI );
const int aPointCount = aPoints->Length();
const bool isClosed = theCurve->isClosed(aSectionI);
theContext->SetAutomaticHilight( Standard_False );
Handle(SelectMgr_Selection) aSelection = anAISShape->Selection( AIS_Shape::SelectionMode( TopAbs_VERTEX ) );
+
+ CurveCreator_ICurve::SectionToPointList::const_iterator anIt = thePoints.begin(),
+ aLast = thePoints.end();
+ bool isFound = false;
+ for( int i=0; i<aSize; i++ )
+ {
for( aSelection->Init(); aSelection->More(); aSelection->Next() )
{
const Handle(SelectMgr_SensitiveEntity) aHSenEntity = aSelection->Sensitive();
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 )
CurveCreator_ICurve *theCurve,
const int theActionFlags,
const QStringList& theCoordTitles,
- Qt::WindowFlags fl,
- int theLocalPointRowLimit )
+ Qt::WindowFlags fl )
: QWidget(parent), myNewSectionEditor(NULL), myCurve(theCurve), mySection(0),
myDragStarted( false ), myDragInteractionStyle( SUIT_ViewModel::STANDARD ),
- myOCCViewer( 0 ), myLocalPointRowLimit( theLocalPointRowLimit ),
+ myOCCViewer( 0 ),
myOld2DMode(OCCViewer_ViewWindow::No2dMode)
{
bool isToEnableClosed = !( theActionFlags & DisableClosedSection );
CurveCreator_Utils::getSelectedPoints( aContext, myCurve, myLocalPoints );
int aNbPoints = myLocalPoints.size();
- bool isRowLimit = aNbPoints > myLocalPointRowLimit;
- myLocalPointView->setVisible( getActionMode() == ModificationMode && !isRowLimit );
+ //bool isRowLimit = aNbPoints > myLocalPointRowLimit;
+ myLocalPointView->setVisible( getActionMode() == ModificationMode/* && !isRowLimit */);
- if ( !isRowLimit ) {
- bool isBlocked = myLocalPointView->blockSignals(true);
+ //if ( !isRowLimit ) {
+ bool isBlocked = myLocalPointView->blockSignals(true);
- myLocalPointView->setLocalPointsToTable( myLocalPoints );
+ myLocalPointView->setLocalPointsToTable( myLocalPoints );
- myLocalPointView->blockSignals( isBlocked );
- }
+ myLocalPointView->blockSignals( isBlocked );
+ //}
}
/**
CurveCreator_ICurve *theCurve,
const int theActionFlags = NoFlags,
const QStringList& theCoordTitles = QStringList(),
- Qt::WindowFlags fl=0,
- int theLocalPointRowLimit = 20);
+ Qt::WindowFlags fl=0);
// OCC viewer manipulation
void setOCCViewer( OCCViewer_Viewer* theViewer );
void SetViewer2DMode(const bool To2D);
+ void setSelectedPoints( const CurveCreator_ICurve::SectionToPointList& =
+ CurveCreator_ICurve::SectionToPointList() );
+
+ void updateLocalPointView();
+ void setLocalPointContext( const bool theOpen, const bool isUpdateTable = false );
+
signals:
void selectionChanged();
void subOperationStarted( QWidget*, bool );
void subOperationFinished( QWidget* );
public slots:
-
-protected slots:
void onAdditionMode(bool checked);
void onModificationMode(bool checked);
void onDetectionMode(bool checked);
BRING_TOGETHER_ID
};
+public:
+ QAction* getAction(ActionId theId);
+ QAction* getAction(ActionMode theMode);
+
private:
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 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();
for (i = 0; i < aNbSec; ++i) {
// Set coordinates
- CurveCreator::Coordinates aCoords = myCurve->getPoints(i);
+ CurveCreator::Coordinates aCoords = myCurve->getCoords(i);
const int aNbPoints = aCoords.size();
theCoords[i].length(aNbPoints);