Save/restore hidden state of feature/results.
return aValid && isDone;
}
+void ModuleBase_OperationFeature::startOperation()
+{
+ FeaturePtr aFeature = feature();
+ if (!aFeature.get() || !isEditOperation())
+ return;
+
+ // store hidden result features
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ ObjectPtr anObject = *aIt;
+ if (anObject.get() && !anObject->isDisplayed()) {
+ myVisualizedObjects.insert(*aIt);
+ anObject->setDisplayed(true);
+ }
+ }
+ if (!aFeature->isDisplayed()) {
+ myVisualizedObjects.insert(*aIt);
+ aFeature->setDisplayed(true);
+ }
+ Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+}
+
+void ModuleBase_OperationFeature::stopOperation()
+{
+ FeaturePtr aFeature = feature();
+ if (!aFeature.get() || !isEditOperation())
+ return;
+
+ // store hidden result features
+ std::list<ResultPtr> aResults = aFeature->results();
+ std::list<ResultPtr>::const_iterator aIt;
+ for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
+ ObjectPtr anObject = *aIt;
+ if (anObject.get() && myVisualizedObjects.find(anObject) != myVisualizedObjects.end()) {
+ anObject->setDisplayed(false);
+ }
+ }
+ if (myVisualizedObjects.find(aFeature) != myVisualizedObjects.end()) {
+ aFeature->setDisplayed(false);
+ }
+ if (myVisualizedObjects.size() > 0)
+ Events_Loop::loop()->flush(Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY));
+}
+
FeaturePtr ModuleBase_OperationFeature::createFeature(const bool theFlushMessage)
{
if (myParentFeature.get()) {
return false;
}
+bool ModuleBase_OperationFeature::isDisplayedOnStart(ObjectPtr theObject)
+{
+ return myVisualizedObjects.find(theObject) != myVisualizedObjects.end();
+}
+
void ModuleBase_OperationFeature::start()
{
setIsModified(false);
#include <ModuleBase_Operation.h>
#include <ModuleBase_ViewerPrs.h>
+#include <ModelAPI_Object.h>
#include <ModelAPI_CompositeFeature.h>
#include <QObject>
#include <QString>
#include <QStringList>
+#include <set>
+
class ModuleBase_ModelWidget;
class ModuleBase_ISelection;
class ModuleBase_IViewer;
/// Returns True if the current operation works with the given object (feature or result)
virtual bool hasObject(ObjectPtr theObj) const;
+ /// Returns true if the object is displayed when the operation was started
+ /// \param theObject a feature or result of the operation feature
+ /// \return boolean value whether the object display state was changed
+ virtual bool isDisplayedOnStart(ObjectPtr theObject);
+
/// Initialisation of operation with preliminary selection
/// \param theSelection an instance of Selection class
/// \param theViewer a viewer to have the viewer the eye position
bool commit();
protected:
+ /// Displays the feature/results if it is hidden. It will be hided in stopOperation
+ virtual void startOperation();
+
+ /// Hide feature/results if they were hided on start
+ virtual void stopOperation();
+
/// Creates an operation new feature
/// \param theFlushMessage the flag whether the create message should be flushed
/// \returns the created feature
/// The operation feature to be handled
FeaturePtr myFeature;
+ /// a list of hidden objects, whic are diplayed by operation start
+ /// and should be hidden by operation stop
+ std::set<ObjectPtr> myVisualizedObjects;
+
/// Editing feature flag
bool myIsEditing;
aConnector->activateModuleSelectionModes();
}
-void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* /* theOperation*/)
+void PartSet_SketcherMgr::stopSketch(ModuleBase_Operation* theOperation)
{
myIsMouseOverWindow = false;
myIsConstraintsShown = true;
std::list<ResultPtr>::const_iterator aIt;
Events_Loop* aLoop = Events_Loop::loop();
static Events_ID aDispEvent = aLoop->eventByName(EVENT_OBJECT_TO_REDISPLAY);
+
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (theOperation);
for (aIt = aResults.begin(); aIt != aResults.end(); ++aIt) {
- (*aIt)->setDisplayed(true);
- // this display event is needed because sketch already may have "displayed" state,
- // but not displayed while it is still active (issue 613, abort of existing sketch)
- ModelAPI_EventCreator::get()->sendUpdated(*aIt, aDispEvent);
+ if (!aFOperation->isDisplayedOnStart(*aIt)) {
+ (*aIt)->setDisplayed(true);
+ // this display event is needed because sketch already may have "displayed" state,
+ // but not displayed while it is still active (issue 613, abort of existing sketch)
+ ModelAPI_EventCreator::get()->sendUpdated(*aIt, aDispEvent);
+ }
}
- myCurrentSketch->setDisplayed(true);
+ if (!aFOperation->isDisplayedOnStart(myCurrentSketch))
+ myCurrentSketch->setDisplayed(true);
myCurrentSketch = CompositeFeaturePtr();
myModule->workshop()->viewer()->removeSelectionFilter(myPlaneFilter);
isObjectFound = true;
else {
std::list<ResultPtr>::const_iterator anIt = aResults.begin(), aLast = aResults.end();
- for (; anIt != aLast; anIt++) {
+ for (; anIt != aLast && !isObjectFound; anIt++) {
isObjectFound = *anIt == theObject;
}
}
//#define DEBUG_FEATURE_UPDATED
//#define DEBUG_RESULT_COMPSOLID
+#ifdef DEBUG_FEATURE_REDISPLAY
+const std::string DebugFeatureKind = "Extrusion";
+#endif
+
XGUI_WorkshopListener::XGUI_WorkshopListener(ModuleBase_IWorkshop* theWorkshop)
: myWorkshop(theWorkshop),
myUpdatePrefs(false)
XGUI_Workshop* aWorkshop = workshop();
XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+ bool aFirstVisualizedBody = false;
+
bool aRedisplayed = false;
for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
ObjectPtr aObj = (*aIt);
qDebug("COMPSOLID sub-object");
}
#endif
+ #ifdef DEBUG_FEATURE_REDISPLAY
+ QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aObj);
+ if (aFeature.get()) {
+ std::string aKind = aFeature->getKind();
+ if (aKind == DebugFeatureKind) {
+ qDebug(QString("visible=%1, hide=%2 : display= %2").arg(aDisplayer->isVisible(aObj))
+ .arg(aHide).arg(anObjInfo).toStdString().c_str());
+ }
+ }
+ #endif
if (aHide) {
aRedisplayed = aDisplayer->erase(aObj, false) || aRedisplayed;
#ifdef DEBUG_FEATURE_REDISPLAY
#ifdef DEBUG_FEATURE_REDISPLAY
QString anObjInfo = ModuleBase_Tools::objectInfo((aObj));
//qDebug(QString("visible=%1 : display= %2").arg(isVisibleObject).arg(anObjInfo).toStdString().c_str());
- /*FeaturePtr aFeature = std::dynamic_pointer_cast<ModelAPI_Feature>(aObj);
- if (aFeature.get()) {
- std::string aKind = aFeature->getKind();
- if (aKind == "SketchMultiRotation")
- bool aValue = true;
- }*/
#endif
if (isVisibleObject) { // redisplay visible object
aWorkshop->deactivateActiveObject(aObj, false);
}
} else { // display object if the current operation has it
- if (displayObject(aObj)) {
+ if (displayObject(aObj, aFirstVisualizedBody)) {
aRedisplayed = true;
// Deactivate object of current operation from selection
aWorkshop->deactivateActiveObject(aObj, false);
}
}
if (aRedisplayed) {
+ if (aFirstVisualizedBody)
+ myWorkshop->viewer()->fitAll();
customizeCurrentObject();
aDisplayer->updateViewer();
}
qDebug(QString("onFeatureCreatedMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str());
#endif
+ bool aFirstVisualizedBody = false;
+
//bool aHasPart = false;
bool aDisplayed = false;
for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
// with list of displayed objects
if (myWorkshop->module()->canDisplayObject(anObject)) {
anObject->setDisplayed(true);
- aDisplayed = displayObject(*aIt);
+ aDisplayed = displayObject(*aIt, aFirstVisualizedBody);
} else
anObject->setDisplayed(false);
}
//if (myObjectBrowser)
// myObjectBrowser->processEvent(theMsg);
if (aDisplayed) {
+ if (aFirstVisualizedBody)
+ myWorkshop->viewer()->fitAll();
customizeCurrentObject();
workshop()->displayer()->updateViewer();
}
//**************************************************************
-bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj)
+bool XGUI_WorkshopListener::displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody)
{
#ifdef DEBUG_RESULT_COMPSOLID
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(theObj);
int aNb = aDisplayer->objectsCount();
aDisplayed = aDisplayer->display(theObj, false);
if (aNb == 0)
- myWorkshop->viewer()->fitAll();
+ theFirstVisualizedBody = true;
} else
aDisplayed = aDisplayer->display(theObj, false);
/// Displaus object and fit all viewer if the object is first (update viewer will not be called)
/// Asks the module whether the object can be displayed
/// \param theObj an object
+ /// \param theFirstVisualizedBody an output state whether there are not object displayed in the view
+ /// and the displayed object is a body
/// \return true if the object is displayed
- bool displayObject(ObjectPtr theObj);
+ bool displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody);
/// Calls the module method of cusomize object for the feature of the current operation
/// \return true if the object is modified