#include <QMouseEvent>
#include <QApplication>
#include <QCursor>
+#include <QMessageBox>
//#define DEBUG_DO_NOT_BY_ENTER
return aCanDisplay;
}
+void PartSet_SketcherMgr::processHiddenObject(const std::list<ObjectPtr>& theObjects)
+{
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (getCurrentOperation());
+ if (aFOperation && myCurrentSketch.get()) {
+ // find results of the current operation
+ // these results should not be proposed to be deleted
+ FeaturePtr anOperationFeature = aFOperation->feature();
+ std::list<ResultPtr> anOperationResultList = anOperationFeature->results();
+ std::set<ResultPtr> anOperationResults;
+ std::list<ResultPtr>::const_iterator aRIt = anOperationResultList.begin(),
+ aRLast = anOperationResultList.end();
+ for (; aRIt != aRLast; aRIt++)
+ anOperationResults.insert(*aRIt);
+
+ std::set<FeaturePtr> anObjectsToBeDeleted;
+ QStringList anObjectsToBeDeletedNames;
+ std::list<ObjectPtr>::const_iterator anIt = theObjects.begin(), aLast = theObjects.end();
+ for (; anIt != aLast; anIt++) {
+ ObjectPtr anObject = *anIt;
+ bool aCanErase = true;
+ // when the sketch operation is active, results of sketch sub-feature can not be hidden
+ ResultPtr aResult = std::dynamic_pointer_cast<ModelAPI_Result>(anObject);
+ // the result is found between current feature results
+ if (anOperationResults.find(aResult) != anOperationResults.end())
+ continue;
+
+ if (aResult.get()) {
+ // Display sketcher objects
+ for (int i = 0; i < myCurrentSketch->numberOfSubs() && aCanErase; i++) {
+ FeaturePtr aFeature = myCurrentSketch->subFeature(i);
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator anIt;
+ for (anIt = aResults.begin(); anIt != aResults.end() && aCanErase; ++anIt) {
+ aCanErase = *anIt != aResult;
+ }
+ }
+ }
+ if (!aCanErase) {
+ FeaturePtr aFeature = ModelAPI_Feature::feature(anObject);
+ if (aFeature.get() && anObjectsToBeDeleted.find(aFeature) == anObjectsToBeDeleted.end()) {
+ anObjectsToBeDeleted.insert(aFeature);
+ anObjectsToBeDeletedNames.append(aFeature->name().c_str());
+ }
+ }
+ }
+ if (!anObjectsToBeDeleted.empty()) {
+ QString aFeatureNames = anObjectsToBeDeletedNames.join(", ");
+ QString aMessage = tr("The following features have incorrect presentation and \
+will be hidden: %1. Would you like to delete them?")
+ .arg(aFeatureNames);
+ int anAnswer = QMessageBox::question(qApp->activeWindow(), tr("Features hide"),
+ aMessage, QMessageBox::Ok | QMessageBox::Cancel,
+ QMessageBox::Cancel);
+ if (anAnswer == QMessageBox::Ok) {
+ QObjectPtrList anObjects;
+ std::set<FeaturePtr>::const_iterator anIt = anObjectsToBeDeleted.begin(),
+ aLast = anObjectsToBeDeleted.end();
+ for (; anIt != aLast; anIt++)
+ anObjects.append(*anIt);
+ SessionPtr aMgr = ModelAPI_Session::get();
+ DocumentPtr aDoc = aMgr->activeDocument();
+ bool aIsOp = aMgr->isOperation();
+ if (!aIsOp)
+ aMgr->startOperation();
+ workshop()->deleteFeatures(anObjects);
+ //static Events_ID aDeletedEvent = Events_Loop::eventByName(EVENT_OBJECT_DELETED);
+ //static Events_ID aRedispEvent = Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY);
+ //Events_Loop::loop()->flush(aDeletedEvent);
+ //Events_Loop::loop()->flush(aRedispEvent);
+
+ if (!aIsOp)
+ aMgr->finishOperation();
+ }
+ }
+ }
+}
+
bool PartSet_SketcherMgr::canDisplayCurrentCreatedFeature() const
{
bool aCanDisplay = myIsMouseOverWindow;
Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
}
-XGUI_OperationMgr* PartSet_SketcherMgr::operationMgr() const
+XGUI_Workshop* PartSet_SketcherMgr::workshop() const
{
ModuleBase_IWorkshop* anIWorkshop = myModule->workshop();
XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(anIWorkshop);
- XGUI_Workshop* aWorkshop = aConnector->workshop();
+ return aConnector->workshop();
+}
- return aWorkshop->operationMgr();
+XGUI_OperationMgr* PartSet_SketcherMgr::operationMgr() const
+{
+ return workshop()->operationMgr();
}
class ModuleBase_ModelWidget;
class ModuleBase_Operation;
class XGUI_OperationMgr;
+class XGUI_Workshop;
+
class QMouseEvent;
/**
/// \param theObject a model object
bool canDisplayObject(const ObjectPtr& theObject) const;
+ /// Check the given objects either there are some results of the current sketch. If so,
+ /// it suggests to delete them as there are no functionality to show back hidden sketch objects
+ /// \param theObjects a list of hidden objects
+ virtual void processHiddenObject(const std::list<ObjectPtr>& theObjects);
+
/// Returns true if the mouse is over viewer or property panel value is changed
/// \return boolean result
bool canDisplayCurrentCreatedFeature() const;
const bool isToDisplay, const bool isFlushRedisplay = true);
private:
+ /// Returns current workshop
+ XGUI_Workshop* workshop() const;
+ /// Returns operation manager
XGUI_OperationMgr* operationMgr() const;
private:
bool aFirstVisualizedBody = false;
bool aRedisplayed = false;
+ //std::list<ObjectPtr> aHiddenObjects;
for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
ObjectPtr aObj = (*aIt);
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
aHide = aRes && aRes->isConcealed();
}
+
#ifdef DEBUG_RESULT_COMPSOLID
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObj);
if (aRes.get()) {
}
#endif
if (aHide) {
+ //we should provide objects which are hidden in the viewer, e.g. sketch always should visualizes
+ // all sub-features, if some features are to be hidden, sould be proposed may be to removed #1223
+ //aHiddenObjects.push_back(aObj);
aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
#ifdef DEBUG_FEATURE_REDISPLAY
// Redisplay the visible object or the object of the current operation
}
}
}
+ // this processing should be moved in another place in order to do not cause problems in
+ // flush messages chain
+ //if (aHiddenObjects.size() > 0)
+ // myWorkshop->module()->processHiddenObject(aHiddenObjects);
+
bool isCustomized = customizeCurrentObject(anObjects, aRedisplayed);
if (aRedisplayed || isCustomized) {
//VSV FitAll updated viewer by it self