#include <QString>
-#define DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
+//#define DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
PartSet_OverconstraintListener::PartSet_OverconstraintListener(ModuleBase_IWorkshop* theWorkshop)
: myWorkshop(theWorkshop)
const std::set<ObjectPtr>& theConflictingObjects)
{
std::set<ObjectPtr> aModifiedObjects;
+ std::vector<int> aColor;
+ getConflictingColor(aColor);
+
// set error state for new objects and append them in the internal map of objects
std::set<ObjectPtr>::const_iterator anIt = theConflictingObjects.begin(), aLast = theConflictingObjects.end();
for (; anIt != aLast; anIt++) {
ObjectPtr anObject = *anIt;
if (myConflictingObjects.find(anObject) == myConflictingObjects.end()) { // it is not found
- setConflictingObject(anObject, true);
aModifiedObjects.insert(anObject);
myConflictingObjects.insert(anObject);
}
for (anIt = theConflictingObjects.begin(), aLast = theConflictingObjects.end() ; anIt != aLast; anIt++) {
ObjectPtr anObject = *anIt;
if (theConflictingObjects.find(anObject) != theConflictingObjects.end()) { // it is found
- setConflictingObject(anObject, false);
myConflictingObjects.erase(anObject);
aModifiedObjects.insert(anObject);
void PartSet_OverconstraintListener::redisplayObjects(
const std::set<ObjectPtr>& theObjects)
{
-/*static Events_Loop* aLoop = Events_Loop::loop();
- static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_UPDATED);
+ static Events_Loop* aLoop = Events_Loop::loop();
+ static Events_ID EVENT_DISP = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
static const ModelAPI_EventCreator* aECreator = ModelAPI_EventCreator::get();
std::set<ObjectPtr>::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
- for (; anIt != aLast; anIt++) {
+ for (; anIt != aLast; anIt++)
aECreator->sendUpdated(*anIt, EVENT_DISP);
- //#ifdef DEBUG_FEATURE_OVERCONSTRAINT_LISTENER
- // QString anInfoStr = ModuleBase_Tools::objectInfo(*anIt);
- // qDebug(QString("PartSet_OverconstraintListener::SEND UPDATED: %1").arg(anInfoStr).toStdString().c_str());
- //#endif
- }
- aLoop->flush(EVENT_DISP);*/
-
- XGUI_Displayer* aDisplayer = workshop()->displayer();
- bool aHidden;
- std::set<ObjectPtr>::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
- for (; anIt != aLast; anIt++) {
- ObjectPtr anObject = *anIt;
- aHidden = !anObject->data() || !anObject->data()->isValid() ||
- anObject->isDisabled() || (!anObject->isDisplayed());
- if (!aHidden)
- aDisplayer->redisplay(anObject, false);
- }
- aDisplayer->updateViewer();
-}
-
-void PartSet_OverconstraintListener::setConflictingObject(const ObjectPtr& theObject,
- const bool theConflicting)
-{
- if (!theObject.get() || !theObject->data()->isValid())
- return;
-
- AISObjectPtr anAISObject;
- GeomPresentablePtr aPrs = std::dynamic_pointer_cast<GeomAPI_IPresentable>(theObject);
-
- if (aPrs.get() != NULL) {
- XGUI_Workshop* aWorkshop = workshop();
- XGUI_Displayer* aDisplayer = aWorkshop->displayer();
-
- anAISObject = aPrs->getAISObject(aDisplayer->getAISObject(theObject));
- if (anAISObject.get()) {
- Handle(AIS_InteractiveObject) anAISIO = anAISObject->impl<Handle(AIS_InteractiveObject)>();
- 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);
- }
- }
- }
- }
+ aLoop->flush(EVENT_DISP);
}
XGUI_Workshop* PartSet_OverconstraintListener::workshop() const