aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
aLoop->registerListener(this, Events_LongOp::eventID());
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_PLUGIN_LOADED));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOSHOW));
- aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TOHIDE));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_SELFILTER_LOADED));
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_UPDATE_VIEWER_BLOCKED));
} else {
QApplication::restoreOverrideCursor();
}
- } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TOSHOW)) {
- std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
- std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
- const std::set<ObjectPtr>& aObjList = anUpdateMsg->objects();
- QObjectPtrList aList;
- std::set<ObjectPtr>::const_iterator aIt;
- for (aIt = aObjList.cbegin(); aIt != aObjList.cend(); ++aIt)
- aList.append(*aIt);
- showObjects(aList, true);
- } else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TOHIDE)) {
- std::shared_ptr<ModelAPI_ObjectUpdatedMessage> anUpdateMsg =
- std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
- const std::set<ObjectPtr>& aObjList = anUpdateMsg->objects();
- QObjectPtrList aList;
- std::set<ObjectPtr>::const_iterator aIt;
- for (aIt = aObjList.cbegin(); aIt != aObjList.cend(); ++aIt)
- aList.append(*aIt);
- showObjects(aList, false);
}
//An operation passed by message. Start it, process and commit.
else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OPERATION_LAUNCHED)) {
ObjectPtr aObj = (*aIt);
// Hide the object if it is invalid or concealed one
- bool aHide = !aObj->data() || !aObj->data()->isValid();
+ bool aHide = !aObj->data() || !aObj->data()->isValid() ||
+ aObj->isDisabled() || (!aObj->isDisplayed());
if (!aHide) { // check that this is not hidden result
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
aHide = aRes && aRes->isConcealed();
// of redisplay is called. This modification is made in order to have the line is updated
// by creation of a horizontal constraint on the line by preselection
myDisplayer->redisplay(aObj, false);
- if (myOperationMgr->hasOperation()) {
- ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
- if (!aOperation->isEditOperation() &&
- aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
+ //if (myOperationMgr->hasOperation()) {
+ // ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+ // if (!aOperation->isEditOperation() &&
+ // aOperation->hasObject(aObj) && myDisplayer->isActive(aObj))
+ if (!myModule->canActivateSelection(aObj)) {
+ if (myDisplayer->isActive(aObj))
myDisplayer->deactivate(aObj);
}
} else { // display object if the current operation has it
- ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
- if (aOperation && aOperation->hasObject(aObj)) {
- ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
- #ifdef DEBUG_FEATURE_REDISPLAY
- QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
- qDebug(QString(" display object = %1").arg(anObjInfo).toStdString().c_str());
- #endif
- if (displayObject(aObj)) {
+ if (displayObject(aObj)) {
+ //ModuleBase_Operation* aOperation = myOperationMgr->currentOperation();
+ //if (aOperation && aOperation->hasObject(aObj)) {
+ if (!myModule->canActivateSelection(aObj)) {
+ #ifdef DEBUG_FEATURE_REDISPLAY
+ QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
+ qDebug(QString(" display object = %1").arg(anObjInfo).toStdString().c_str());
+ #endif
// Deactivate object of current operation from selection
if (myDisplayer->isActive(aObj))
myDisplayer->deactivate(aObj);
ObjectPtr anObject = *aIt;
// the validity of the data should be checked here in order to avoid display of the objects,
// which were created, then deleted, but flush for the creation event happens after that
- if (!anObject->data() || !anObject->data()->isValid())
- continue;
- //ResultPartPtr aPart = std::dynamic_pointer_cast<ModelAPI_ResultPart>(*aIt);
- //if (aPart) {
- //aHasPart = true;
- // If a feature is created from the aplication's python console
- // it doesn't stored in the operation mgr and doesn't displayed
- //} else {
- isDisplayed = displayObject(*aIt);
- //}
+ // we should not display disabled objects
+ bool aHide = !anObject->data() || !anObject->data()->isValid() ||
+ anObject->isDisabled() || (!anObject->isDisplayed());
+ if (!aHide) {
+ // setDisplayed has to be called in order to synchronize internal state of the object
+ // with list of displayed objects
+ if (myModule->canDisplayObject(anObject)) {
+ anObject->setDisplayed(true);
+ isDisplayed = displayObject(*aIt);
+ } else
+ anObject->setDisplayed(false);
+ }
}
//if (myObjectBrowser)
// myObjectBrowser->processEvent(theMsg);
//myDisplayer->activateObjects(aModes);
myModule->operationStopped(theOperation);
- if (myOperationMgr->operationsCount() == 0) {
+ // if the operation is nested, do not deactivate objects
+ //if (myOperationMgr->operationsCount() == 0) {
// Activate selection mode for all objects
- QIntList aModes;
- myDisplayer->activateObjects(aModes);
- }
+ QIntList aModes;
+ // TODO: check on OCC_6.9.0
+ // the module current active modes should not be deactivated in order to save the objects selected
+ // the deactivate object in the mode of selection leads to the object is deselected in the viewer.
+ // But, in OCC_6.8.0 this deselection does not happened automatically. It is necessary to call
+ // ClearOutdatedSelection, but this method has an error in the realization, which should be fixed in
+ // the OCC_6.9.0 release. Moreother, it is possible that ClearOutdatedSelection will be called inside
+ // Deactivate method of AIS_InteractiveContext. In this case, we need not call it.
+ module()->activeSelectionModes(aModes);
+ myDisplayer->activateObjects(aModes);
+ //}
}
} else if (anAnswer == QMessageBox::Cancel) {
return;
}
- aSession->closeAll();
myCurrentDir = "";
}
}
QApplication::setOverrideCursor(Qt::WaitCursor);
myIsLoadingData = true;
+ aSession->closeAll();
aSession->load(myCurrentDir.toLatin1().constData());
myObjectBrowser->rebuildDataTree();
- displayAllResults();
+ //displayAllResults();
updateCommandStatus();
myIsLoadingData = false;
QApplication::restoreOverrideCursor();
"::title { position: relative; padding-left: 5px; text-align: left center }");
myObjectBrowser = new XGUI_ObjectsBrowser(aObjDock);
myObjectBrowser->setDataModel(myModule->dataModel());
- //connect(myObjectBrowser, SIGNAL(activePartChanged(ObjectPtr)), this,
- // SLOT(changeCurrentDocument(ObjectPtr)));
+ myModule->customizeObjectBrowser(myObjectBrowser);
aObjDock->setWidget(myObjectBrowser);
myContextMenuMgr->connectObjectBrowser();
setDisplayMode(aObjects, XGUI_Displayer::Shading);
else if (theId == "WIREFRAME_CMD")
setDisplayMode(aObjects, XGUI_Displayer::Wireframe);
- else if (theId == "HIDEALL_CMD")
- myDisplayer->eraseAll();
+ else if (theId == "HIDEALL_CMD") {
+ QObjectPtrList aList = myDisplayer->displayedObjects();
+ foreach (ObjectPtr aObj, aList)
+ aObj->setDisplayed(false);
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ }
}
//**************************************************************
aDescription += tr(" %1");
QStringList aObjectNames;
foreach (ObjectPtr aObj, anObjects) {
- if (!aObj->data().get())
+ if (!aObj->data()->isValid())
continue;
aObjectNames << QString::fromStdString(aObj->data()->name());
}
//**************************************************************
void XGUI_Workshop::showObjects(const QObjectPtrList& theList, bool isVisible)
{
- foreach (ObjectPtr aObj, theList)
- {
+ foreach (ObjectPtr aObj, theList) {
if (isVisible) {
- displayObject(aObj);
+ aObj->setDisplayed(true);
+ //displayObject(aObj);
} else {
- myDisplayer->erase(aObj, false);
+ aObj->setDisplayed(false);
+ //myDisplayer->erase(aObj, false);
}
}
- myDisplayer->updateViewer();
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+ //myDisplayer->updateViewer();
}
//**************************************************************
void XGUI_Workshop::showOnlyObjects(const QObjectPtrList& theList)
{
- myDisplayer->showOnly(theList);
+ QObjectPtrList aList = myDisplayer->displayedObjects();
+ foreach (ObjectPtr aObj, aList)
+ aObj->setDisplayed(false);
+ foreach (ObjectPtr aObj, theList)
+ aObj->setDisplayed(true);
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+
}
//**************************************************************
void XGUI_Workshop::displayGroupResults(DocumentPtr theDoc, std::string theGroup)
{
- for (int i = 0; i < theDoc->size(theGroup); i++)
- displayObject(theDoc->object(theGroup, i));
+ for (int i = 0; i < theDoc->size(theGroup); i++)
+ theDoc->object(theGroup, i)->setDisplayed(true);
+ //displayObject(theDoc->object(theGroup, i));
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
}
//**************************************************************
SessionPtr aMgr = ModelAPI_Session::get();
aMgr->closeAll();
- objectBrowser()->clearContent();
}
//**************************************************************