It is checked in case of making two lines parallel and perpendicular simultaneously
{
#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
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);
}
}
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);
}
aLoop->flush(EVENT_DISP);*/
XGUI_Displayer* aDisplayer = workshop()->displayer();
- //QObjectPtrList aObjects = aDisplayer->displayedObjects();
bool aHidden;
std::set<ObjectPtr>::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)
void PartSet_OverconstraintListener::setConflictingObject(const ObjectPtr& theObject,
const bool theConflicting)
{
- return;
-
AISObjectPtr anAISObject;
GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
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);
}
}
}
<file>icons/tangent.png</file>
<file>icons/fillet.png</file>
<file>icons/coincedence.png</file>
+ <file>icons/conflicting_icon.png</file>
<file>icons/mirror.png</file>
<file>icons/translate.png</file>
<file>icons/translate_32x32.png</file>
icons/equal.png
icons/tangent.png
icons/mirror.png
+ icons/conflicting_icon.png
icons/rotate.png
icons/translate.png
)
SketcherPrs_SymbolPrs::SketcherPrs_SymbolPrs(ModelAPI_Feature* theConstraint,
const std::shared_ptr<GeomAPI_Ax3>& thePlane)
- : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane)
+ : AIS_InteractiveObject(), myConstraint(theConstraint), myPlane(thePlane), myIsConflicting(false)
{
SetAutoHilight(Standard_False);
}
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()];
}
}
}
+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
{
/// 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;
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