From 6bb214a346dbc1cf1b6f2607ef9415d2cba26a81 Mon Sep 17 00:00:00 2001 From: nds Date: Tue, 9 Feb 2016 11:46:47 +0300 Subject: [PATCH] 2.17. Improved management of overconstraint situation: temporary modification to show erroneous(tmp) icon for conflicting constraint. It is checked in case of making two lines parallel and perpendicular simultaneously --- .../PartSet_OverconstraintListener.cpp | 23 +++----------- src/PartSet/PartSet_icons.qrc | 1 + src/PartSet/icons/conflicting_icon.png | Bin 0 -> 291 bytes src/SketcherPrs/CMakeLists.txt | 1 + src/SketcherPrs/SketcherPrs_SymbolPrs.cpp | 29 +++++++++++++++++- src/SketcherPrs/SketcherPrs_SymbolPrs.h | 10 ++++++ src/SketcherPrs/icons/conflicting_icon.png | Bin 0 -> 291 bytes 7 files changed, 44 insertions(+), 20 deletions(-) create mode 100755 src/PartSet/icons/conflicting_icon.png create mode 100755 src/SketcherPrs/icons/conflicting_icon.png diff --git a/src/PartSet/PartSet_OverconstraintListener.cpp b/src/PartSet/PartSet_OverconstraintListener.cpp index a9c5dc2ad..b4468f395 100755 --- a/src/PartSet/PartSet_OverconstraintListener.cpp +++ b/src/PartSet/PartSet_OverconstraintListener.cpp @@ -51,16 +51,6 @@ void PartSet_OverconstraintListener::processEvent( { #ifdef DEBUG_FEATURE_OVERCONSTRAINT_LISTENER - - /* - anIt = theConflictingObjects.begin(); - aLast = theConflictingObjects.end(); - - QStringList anInfo; - for (; anIt != aLast; ++anIt) { - anInfo.append(ModuleBase_Tools::objectInfo((*anIt))); - } - QString anInfoStr = anInfo.join(";\n");*/ bool isRepaired = theMessage->eventID() == Events_Loop::eventByName(EVENT_SOLVER_REPAIRED); qDebug(QString("PartSet_OverconstraintListener::processEvent:\n %1").arg(isRepaired ? "REPAIRED" : "FAILED").toStdString().c_str()); #endif @@ -103,7 +93,7 @@ bool PartSet_OverconstraintListener::updateConflictingObjects( for (anIt = myConflictingObjects.begin(), aLast = myConflictingObjects.end() ; anIt != aLast; anIt++) { ObjectPtr anObject = *anIt; if (theConflictingObjects.find(anObject) == theConflictingObjects.end()) { // it is not found - //setConflictingObject(anObject, false); + setConflictingObject(anObject, false); aModifiedObjects.insert(anObject); } } @@ -117,7 +107,7 @@ bool PartSet_OverconstraintListener::updateConflictingObjects( for (anIt = theConflictingObjects.begin(), aLast = theConflictingObjects.end() ; anIt != aLast; anIt++) { ObjectPtr anObject = *anIt; if (myConflictingObjects.find(anObject) == myConflictingObjects.end()) { // it is not found - //setConflictingObject(anObject, true); + setConflictingObject(anObject, true); aModifiedObjects.insert(anObject); myConflictingObjects.insert(anObject); } @@ -149,13 +139,10 @@ void PartSet_OverconstraintListener::redisplayObjects( aLoop->flush(EVENT_DISP);*/ XGUI_Displayer* aDisplayer = workshop()->displayer(); - //QObjectPtrList aObjects = aDisplayer->displayedObjects(); bool aHidden; std::set::const_iterator anIt = theObjects.begin(), aLast = theObjects.end(); for (; anIt != aLast; anIt++) { ObjectPtr anObject = *anIt; - //foreach(ObjectPtr aObj, aObjects) { - //TODO: replace by redisplay event. aHidden = !anObject->data() || !anObject->data()->isValid() || anObject->isDisabled() || (!anObject->isDisplayed()); if (!aHidden) @@ -167,8 +154,6 @@ void PartSet_OverconstraintListener::redisplayObjects( void PartSet_OverconstraintListener::setConflictingObject(const ObjectPtr& theObject, const bool theConflicting) { - return; - AISObjectPtr anAISObject; GeomPresentablePtr aPrs = std::dynamic_pointer_cast(theObject); @@ -182,8 +167,8 @@ void PartSet_OverconstraintListener::setConflictingObject(const ObjectPtr& theOb if (!anAISIO.IsNull()) { if (!Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO).IsNull()) { Handle(SketcherPrs_SymbolPrs) aPrs = Handle(SketcherPrs_SymbolPrs)::DownCast(anAISIO); - //if (!aPrs.IsNull()) - // aPrs->setConflictingConstraint(theConflicting); + if (!aPrs.IsNull()) + aPrs->SetConflictingConstraint(theConflicting); } } } diff --git a/src/PartSet/PartSet_icons.qrc b/src/PartSet/PartSet_icons.qrc index 30e6b1b35..1741c8946 100644 --- a/src/PartSet/PartSet_icons.qrc +++ b/src/PartSet/PartSet_icons.qrc @@ -59,6 +59,7 @@ icons/tangent.png icons/fillet.png icons/coincedence.png + icons/conflicting_icon.png icons/mirror.png icons/translate.png icons/translate_32x32.png diff --git a/src/PartSet/icons/conflicting_icon.png b/src/PartSet/icons/conflicting_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..58a187e7d36c0e39a9780080d41155721e7f906d GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kmUKs7M+SzC{oH>NS%G}c0*}aI z1_r(ZAk3I`t&~%0Yu>JUl<}#+>!sdDo{qD%-Ae=QPqDn| hUcFG@-Zy!NFN~Y(+Wxj5Jqq$QgQu&X%Q~loCICvXaYz6F literal 0 HcmV?d00001 diff --git a/src/SketcherPrs/CMakeLists.txt b/src/SketcherPrs/CMakeLists.txt index 148f332ad..4d5692902 100644 --- a/src/SketcherPrs/CMakeLists.txt +++ b/src/SketcherPrs/CMakeLists.txt @@ -77,6 +77,7 @@ SET(PROJECT_PICTURES icons/equal.png icons/tangent.png icons/mirror.png + icons/conflicting_icon.png icons/rotate.png icons/translate.png ) diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp index b66ecbd03..d4d0df3ce 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.cpp @@ -249,7 +249,7 @@ std::map SketcherPrs_SymbolPrs::myIconsM SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(ModelAPI_Feature* theConstraint, const std::shared_ptr& thePlane) - : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane) + : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane), myIsConflicting(false) { SetAutoHilight(Standard_False); } @@ -267,6 +267,24 @@ SketcherPrs_SymbolPrs::~SketcherPrs_SymbolPrs() Handle(Image_AlienPixMap) SketcherPrs_SymbolPrs::icon() { + if (myIsConflicting) { + if (myErrorIcon.IsNull()) { + char* aEnv = getenv("NEWGEOM_ROOT_DIR"); + if (aEnv != NULL) { + TCollection_AsciiString aFile(aEnv); + aFile+=FSEP; + aFile+="resources"; + aFile += FSEP; + aFile += "conflicting_icon.png"; + Handle(Image_AlienPixMap) aPixMap = new Image_AlienPixMap(); + if (aPixMap->Load(aFile)) { + myErrorIcon = aPixMap; + } + } + } + return myErrorIcon; + } + if (myIconsMap.count(iconName()) == 1) { return myIconsMap[iconName()]; } @@ -412,6 +430,15 @@ void SketcherPrs_SymbolPrs::ComputeSelection(const Handle(SelectMgr_Selection)& } } +void SketcherPrs_SymbolPrs::SetConflictingConstraint(const bool& theConflicting) +{ + if (myIsConflicting != theConflicting) { + myIsConflicting = theConflicting; + Handle(Image_AlienPixMap) anIcon = icon(); + if (!anIcon.IsNull()) + myAspect->SetMarkerImage(new Graphic3d_MarkerImage(anIcon)); + } +} void SketcherPrs_SymbolPrs::Render(const Handle(OpenGl_Workspace)& theWorkspace) const { diff --git a/src/SketcherPrs/SketcherPrs_SymbolPrs.h b/src/SketcherPrs/SketcherPrs_SymbolPrs.h index ee88f55bc..56fc52770 100644 --- a/src/SketcherPrs/SketcherPrs_SymbolPrs.h +++ b/src/SketcherPrs/SketcherPrs_SymbolPrs.h @@ -62,6 +62,12 @@ public: /// Return array of points where symbols will be placed const Handle(Graphic3d_ArrayOfPoints)& pointsArray() const { return myPntArray; } + /// Set state of the presentation, in case of conflicting state, the icon of the presentation is + /// visualized in error color. The state is stored in an internal field, so should be changed when + /// constraint become not conflicting + /// \param theConflicting a state + Standard_EXPORT void SetConflictingConstraint(const bool& theConflicting); + /// Render of the presentation /// \param theWorkspace is OpenGl workspace void Render(const Handle(OpenGl_Workspace)& theWorkspace) const; @@ -146,6 +152,10 @@ private: mutable Handle(OpenGl_VertexBuffer) myVboAttribs; Select3D_EntitySequence mySPoints; + + bool myIsConflicting; /// state if the presentation is visualized in error state + Handle(Image_AlienPixMap) myErrorIcon; + Handle(Graphic3d_MarkerImage) myErrorImage; }; #endif \ No newline at end of file diff --git a/src/SketcherPrs/icons/conflicting_icon.png b/src/SketcherPrs/icons/conflicting_icon.png new file mode 100755 index 0000000000000000000000000000000000000000..58a187e7d36c0e39a9780080d41155721e7f906d GIT binary patch literal 291 zcmeAS@N?(olHy`uVBq!ia0vp^JRr=$1|-8uW1a&kmUKs7M+SzC{oH>NS%G}c0*}aI z1_r(ZAk3I`t&~%0Yu>JUl<}#+>!sdDo{qD%-Ae=QPqDn| hUcFG@-Zy!NFN~Y(+Wxj5Jqq$QgQu&X%Q~loCICvXaYz6F literal 0 HcmV?d00001 -- 2.39.2