-// Copyright (C) 2013 CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2013-2016 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.
+// 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
#include <TopoDS_Face.hxx>
#include <TopoDS_Wire.hxx>
+#include <Prs3d_PointAspect.hxx>
+#include <iostream>
+#define DEBTRACE(msg) {std::cerr<<std::flush<<__FILE__<<" ["<<__LINE__<<"] : "<<msg<<std::endl<<std::flush;}
+
#include <stdio.h>
//=======================================================================
myNbRedos (0),
myUndoDepth (-1),
myOpLevel(0),
- mySkipSorting(false)
+ mySkipSorting(false),
+ myPointAspectColor (Quantity_NOC_ROYALBLUE4),
+ myCurveColor (Quantity_NOC_RED),
+ myEraseAll(true),
+ myLineWidth(1)
{
}
std::string aName(aBuffer);
int j;
for( j = 0 ; j < mySections.size() ; j++ ){
- aSection = getSection( j );
+ aSection = (CurveCreator_Section*)getSection( j );
if ( aSection && aSection->myName == aName )
break;
}
}
}
-void CurveCreator_Curve::redisplayCurve()
+void CurveCreator_Curve::redisplayCurve(bool preEraseAllObjects)
{
- if( myDisplayer ) {
- myDisplayer->eraseAll( false );
+ //DEBTRACE("redisplayCurve");
+ if( myDisplayer )
+ {
+ if (preEraseAllObjects)
+ myDisplayer->eraseAll( false );
+ else
+ myDisplayer->erase( myAISShape, false);
myAISShape = NULL;
-
myDisplayer->display( getAISObject( true ), true );
}
}
int aMovedSectionId = theISection >= 0 ? theISection : mySections.size()-1;
if (aMovedSectionId != theNewIndex) {
- CurveCreator_Section* aSection = getSection( aMovedSectionId );
+ CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( aMovedSectionId );
// Remove section
CurveCreator::Sections::iterator anIter = mySections.begin() + aMovedSectionId;
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.
CurveCreator_Section* aSection;
for (; i < aNbSections; i++) {
- aSection = getSection( i );
+ aSection = (CurveCreator_Section*)getSection( i );
if ( aSection )
delete aSection;
}
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 )
{
return res;
int anISectionMain = theSections.front();
- CurveCreator_Section* aSectionMain = getSection( anISectionMain );
+ CurveCreator_Section* aSectionMain =
+ (CurveCreator_Section*)getSection( anISectionMain );
std::list <int> aSectionsToJoin = theSections;
aSectionsToJoin.erase( aSectionsToJoin.begin() ); // skip the main section
std::list<int>::const_iterator anIt = aSectionsToJoin.begin(), aLast = aSectionsToJoin.end();
CurveCreator_Section* aSection;
for (; anIt != aLast; anIt++) {
- aSection = getSection( *anIt );
+ aSection = (CurveCreator_Section*)getSection( *anIt );
aSectionMain->myPoints.insert(aSectionMain->myPoints.end(), aSection->myPoints.begin(),
aSection->myPoints.end());
res = removeSectionInternal(*anIt);
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;
}
const int aNbSections = getNbSections();
for (; i < aNbSections; i++) {
- aSection = getSection( i );
+ aSection = (CurveCreator_Section*)getSection( i );
if ( aSection )
aNbCoords += aSection->myPoints.size();
}
} else {
- aSection = getSection( theISection );
+ aSection = (CurveCreator_Section*)getSection( theISection );
if ( aSection )
aNbCoords = aSection->myPoints.size();
}
//! Get "closed" flag of the specified section
bool CurveCreator_Curve::isClosed( const int theISection ) const
{
- CurveCreator_Section* aSection = getSection( theISection );
+ const CurveCreator_Section* aSection =
+ (CurveCreator_Section*)getSection( theISection );
return aSection ? aSection->myIsClosed : false;
}
int i;
for (i = 0; i < aSize; i++) {
- aSection = getSection( i );
+ aSection = (CurveCreator_Section*)getSection( i );
if( aSection ) {
aSection->myIsClosed = theIsClosed;
- redisplayCurve();
+ redisplayCurve(false);
}
}
} else {
- aSection = getSection( theISection );
+ aSection = (CurveCreator_Section*)getSection( theISection );
if ( aSection ) {
aSection->myIsClosed = theIsClosed;
- redisplayCurve();
+ redisplayCurve(false);
}
}
return true;
//! Returns specified section name
std::string CurveCreator_Curve::getSectionName( const int theISection ) const
{
- CurveCreator_Section* aSection = getSection( theISection );
+ CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
return aSection ? aSection->myName : "";
}
const std::string& theName )
{
bool res = false;
- CurveCreator_Section* aSection = getSection( theISection );
+ CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
if( aSection ) {
aSection->myName = theName;
res = true;
CurveCreator::SectionType CurveCreator_Curve::getSectionType
( const int theISection ) const
{
- CurveCreator_Section* aSection = getSection( theISection );
+ CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
return aSection ? aSection->myType : CurveCreator::Polyline;
}
const int aNbSections = getNbSections();
for (; i < aNbSections; i++) {
- aSection = getSection( i );
+ aSection = (CurveCreator_Section*)getSection( i );
if ( aSection )
aSection->myType = theType;
}
- redisplayCurve();
+ redisplayCurve(false);
} else {
- aSection = getSection( theISection );
+ aSection = (CurveCreator_Section*)getSection( theISection );
if ( aSection && aSection->myType != theType ){
aSection->myType = theType;
- redisplayCurve();
+ redisplayCurve(false);
}
}
return true;
CurveCreator_Section *aSection = 0;
for ( ; anIt != theSectionsMap.end(); anIt++ ) {
int anISection = anIt->first;
- aSection = getSection( anISection );
+ aSection = (CurveCreator_Section*)getSection( anISection );
if( aSection ) {
CurveCreator::PosPointsList aSectionPoints = anIt->second;
CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
}
}
if(res)
- redisplayCurve();
+ redisplayCurve(false);
return res;
}
const int theISection,
const int theIPnt )
{
+ //DEBTRACE("addPoints");
bool res = false;
CurveCreator::Coordinates aCoords = theCoords;
// Set the difference.
CurveCreator_Section *aSection = 0;
for ( ; anIt != theSectionsMap.end(); anIt++ ) {
int anISection = anIt->first;
- aSection = getSection( anISection );
+ aSection = (CurveCreator_Section*)getSection( anISection );
if( aSection ) {
CurveCreator::PosPointsList aSectionPoints = anIt->second;
CurveCreator::PosPointsList::const_iterator aPntIt = aSectionPoints.begin();
}
}
if(res)
- redisplayCurve();
+ redisplayCurve(false);
return res;
}
const int theIPnt,
const CurveCreator::Coordinates& theNewCoords )
{
+ //DEBTRACE("setPoint");
bool res = false;
// Set the difference.
startOperation();
bool CurveCreator_Curve::setSeveralPoints( const SectionToPointCoordsList &theSectionToPntCoords,
const bool theIsToSaveDiff )
{
+ //DEBTRACE("setSeveralPoints");
bool res = false;
// Set the difference.
startOperation();
aRes = removeSectionPoints(aSectionId, anIt->second);
}
if( aRes)
- redisplayCurve();
+ redisplayCurve(false);
return aRes;
}
CurveCreator::Coordinates CurveCreator_Curve::getPoint( const int theISection,
const int theIPnt) const
{
- CurveCreator_Section* aSection = getSection( theISection );
+ //DEBTRACE("getPoint");
+ CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
CurveCreator::Coordinates::const_iterator
anIter = aSection->myPoints.begin() + toICoord(theIPnt);
CurveCreator::Coordinates aResult(anIter, anIter + myDimension);
// function: getPoints
// purpose:
//=======================================================================
-CurveCreator::Coordinates CurveCreator_Curve::getPoints( const int theISection ) const
+CurveCreator::Coordinates CurveCreator_Curve::getCoords( int theISection ) const
{
- CurveCreator_Section* aSection = getSection( theISection );
+ CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
return aSection ? aSection->myPoints : CurveCreator::Coordinates();
}
-void CurveCreator_Curve::constructAISObject()
+Handle(TColgp_HArray1OfPnt) CurveCreator_Curve::GetDifferentPoints( int theISection ) const
{
- TopoDS_Shape aShape;
- CurveCreator_Utils::constructShape( this, aShape );
-
- myAISShape = new AIS_Shape( aShape );
+ //DEBTRACE("getPoints");
+ CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theISection );
+ return aSection ? aSection->GetDifferentPoints( (int)myDimension ) : Handle(TColgp_HArray1OfPnt)();
}
-CurveCreator_Section* CurveCreator_Curve::getSection( const int theSectionId ) const
+void CurveCreator_Curve::constructAISObject()
{
- CurveCreator_Section *aSection = 0;
- if ( theSectionId >= 0 && theSectionId < mySections.size() )
- aSection = mySections.at( theSectionId );
-
- return aSection;
+ //DEBTRACE("constructAISObject");
+ TopoDS_Shape aShape;
+ CurveCreator_Utils::constructShape( this, 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(myPointAspectColor);
+ myAISShape->Attributes()->SetPointAspect( anAspect );
}
Handle(AIS_InteractiveObject) CurveCreator_Curve::getAISObject( const bool theNeedToBuild ) const
{
- if ( !myAISShape && theNeedToBuild ) {
+ //DEBTRACE("getAISObject");
+ if ( !myAISShape && theNeedToBuild )
+ {
CurveCreator_Curve* aCurve = (CurveCreator_Curve*)this;
aCurve->constructAISObject();
}
{
bool aRes = false;
- CurveCreator_Section* aSection = getSection( theSectionId );
+ CurveCreator_Section* aSection = (CurveCreator_Section*)getSection( theSectionId );
if ( !aSection )
return aRes;