bool isModified = false;
Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
- if (anOperationPrs->canActivate(theFeature)) {
- myIsActive = true;
- anOperationPrs->setFeature(theFeature);
- if (theFeature.get()) {
- displayPresentation(theUpdateViewer);
- isModified = true;
- }
+ myIsActive = true;
+ anOperationPrs->setFeature(theFeature);
+ if (theFeature.get()) {
+ displayPresentation(theUpdateViewer);
+ isModified = true;
}
return isModified;
}
return isModified;
}
-
-void PartSet_CustomPrs::displayPresentation(const bool theUpdateViewer)
+bool PartSet_CustomPrs::displayPresentation(const bool theUpdateViewer)
{
+ bool isModified = false;
Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
+ anOperationPrs->updateShapes();
Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
if (!aContext.IsNull() && !aContext->IsDisplayed(anOperationPrs)) {
XGUI_Workshop* aWorkshop = workshop();
aWorkshop->displayer()->displayAIS(myOperationPrs, false/*load object in selection*/, theUpdateViewer);
aContext->SetZLayer(anOperationPrs, aModule->getVisualLayerId());
+ isModified = true;
}
}
else {
- if (!anOperationPrs->hasShapes())
+ if (!anOperationPrs->hasShapes()) {
erasePresentation(theUpdateViewer);
+ isModified = true;
+ }
else {
anOperationPrs->Redisplay();
+ isModified = true;
if (theUpdateViewer)
workshop()->displayer()->updateViewer();
}
}
+ return isModified;
}
void PartSet_CustomPrs::erasePresentation(const bool theUpdateViewer)
#ifdef DO_NOT_VISUALIZE_CUSTOM_PRESENTATION
return false;
#endif
-
- bool isModified = false;
- // the presentation should be recomputed if the previous AIS depend on the result
- // [it should be hiddend] or the new AIS depend on it [it should be visualized]
- Handle(PartSet_OperationPrs) anOperationPrs = getPresentation();
- Handle(AIS_InteractiveContext) aContext = myWorkshop->viewer()->AISContext();
- if (!aContext.IsNull()) {
- if (aContext->IsDisplayed(anOperationPrs)) {
- // if there are performance poblems, to improve them, the necessity of redisplay can be checked
- //bool aChanged = anOperationPrs->dependOn(theObject);
- anOperationPrs->updateShapes();
- //aChanged = aChanged || anOperationPrs->dependOn(theObject);
- //if (aChanged)
- anOperationPrs->Redisplay();
- isModified = true;
- if (theUpdateViewer)
- workshop()->displayer()->updateViewer();
- }
- else {
- anOperationPrs->updateShapes();
- displayPresentation(theUpdateViewer);
- }
- }
- return isModified;
+ return displayPresentation(theUpdateViewer);
}
void PartSet_CustomPrs::clearPrs()
/// Displays the internal presentation in the viewer of workshop
/// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
- void displayPresentation(const bool theUpdateViewer);
+ bool displayPresentation(const bool theUpdateViewer);
/// Erases the internal presentation from the viewer of workshop
/// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
void erasePresentation(const bool theUpdateViewer);
- /// Sets color, point size and width of the presentation
- /// \param theUpdateViewer the parameter whether the viewer should be update immediatelly
- void customizePresentation(const bool theUpdateViewer);
-
private:
bool myIsActive;
ModuleBase_IWorkshop* myWorkshop; /// current workshop
myResultColor = ModuleBase_Tools::color("Visualization", "construction_plane_color", "0,1,0");
}
-bool PartSet_OperationPrs::canActivate(const FeaturePtr& theFeature)
-{
- bool aHasSelectionAttribute = false;
-
- std::list<AttributePtr> anAttributes = theFeature->data()->attributes("");
- std::list<AttributePtr>::const_iterator anIt = anAttributes.begin(), aLast = anAttributes.end();
- for (; anIt != aLast && !aHasSelectionAttribute; anIt++)
- aHasSelectionAttribute = isSelectionAttribute(*anIt);
-
- return aHasSelectionAttribute;
-}
-
void PartSet_OperationPrs::setFeature(const FeaturePtr& theFeature)
{
myFeature = theFeature;
- updateShapes();
}
-/*bool PartSet_OperationPrs::dependOn(const ObjectPtr& theResult)
-{
- return myFeatureShapes.contains(theResult);
-}*/
-
void PartSet_OperationPrs::updateShapes()
{
myFeatureShapes.clear();
bool PartSet_OperationPrs::hasShapes()
{
- return !myFeatureShapes.empty() || !myFeatureResults.empty();
+ bool aHasShapes = !myFeatureShapes.empty();
+
+ // find a result which contains a shape
+ if (!aHasShapes && !myFeatureResults.empty()) {
+ std::list<ResultPtr>::const_iterator aRIt = myFeatureResults.begin(),
+ aRLast = myFeatureResults.end();
+ XGUI_Displayer* aDisplayer = workshop()->displayer();
+ for (; aRIt != aRLast; aRIt++) {
+ ResultPtr aResult = *aRIt;
+ if (!isVisible(aDisplayer, aResult))
+ continue;
+ GeomShapePtr aGeomShape = aResult->shape();
+ if (!aGeomShape.get())
+ continue;
+ TopoDS_Shape aShape = aGeomShape->impl<TopoDS_Shape>();
+ if (!aShape.IsNull())
+ aHasShapes = true;
+ }
+ }
+
+ return aHasShapes;
}
void PartSet_OperationPrs::Compute(const Handle(PrsMgr_PresentationManager3d)& thePresentationManager,
{
std::string anAttrType = theAttribute->attributeType();
- /// workaround: start
- /// this is a TEMPORARY correction in order to avoid crash by parameter edit
- /// which is reproduced only on Linux Debian.
- /// The possible reason is an empty AIS presentation visualized in the viewer.
- /// The best solution is to analize whether the feature has shapes/results and only
- /// in this case visualize custom presentation and hide it as soon as they disappear.
- bool isAttributeArgument = theAttribute->isArgument();
- if (!isAttributeArgument)
- return false;
- /// workaround: end
-
return anAttrType == ModelAPI_AttributeSelectionList::typeId() ||
anAttrType == ModelAPI_AttributeRefList::typeId() ||
anAttrType == ModelAPI_AttributeRefAttr::typeId() ||
/// Constructor
Standard_EXPORT PartSet_OperationPrs(ModuleBase_IWorkshop* theWorkshop);
- /// Returns true if the feature contains attributes, which has references to other features
- /// \param theFeature a feature
- /// \return boolean result
- bool canActivate(const FeaturePtr& theFeature);
-
/// Sets the operation feature. It is used in Compute method to group the feature parameter shapes
/// theFeature a feature
void setFeature(const FeaturePtr& theFeature);
- /// Returns true if the presentation
- //bool dependOn(const ObjectPtr& theObject);
-
// Recompute internal list of shaped dependent on the current feature
void updateShapes();
} else if (theMessage->eventID() == Events_Loop::eventByName(EVENT_OBJECT_ERROR_CHANGED)) {
std::shared_ptr<ModelAPI_ObjectUpdatedMessage> aUpdMsg =
std::dynamic_pointer_cast<ModelAPI_ObjectUpdatedMessage>(theMessage);
- std::set<ObjectPtr> aObjects = aUpdMsg->objects();
+ std::set<ObjectPtr> anObjects = aUpdMsg->objects();
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(workshop()->operationMgr()->currentOperation());
FeaturePtr aFeature = aFOperation->feature();
if (aFeature.get()) {
std::set<ObjectPtr>::const_iterator aIt;
- for (aIt = aObjects.begin(); aIt != aObjects.end() && !aFeatureChanged; ++aIt) {
+ for (aIt = anObjects.begin(); aIt != anObjects.end() && !aFeatureChanged; ++aIt) {
aFeatureChanged = ModelAPI_Feature::feature(*aIt) == aFeature;
}
}
const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
{
#ifdef DEBUG_FEATURE_UPDATED
- std::set<ObjectPtr> aObjects = theMsg->objects();
+ std::set<ObjectPtr> anObjects = theMsg->objects();
std::set<ObjectPtr>::const_iterator aIt;
QStringList anInfo;
- for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
+ for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
}
QString anInfoStr = anInfo.join(";\t");
- qDebug(QString("onFeatureUpdatedMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str());
+ qDebug(QString("onFeatureUpdatedMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
#endif
std::set<ObjectPtr> aFeatures = theMsg->objects();
XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
//******************************************************
void XGUI_WorkshopListener::onFeatureRedisplayMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
{
- std::set<ObjectPtr> aObjects = theMsg->objects();
+ std::set<ObjectPtr> anObjects = theMsg->objects();
std::set<ObjectPtr>::const_iterator aIt;
#ifdef DEBUG_FEATURE_REDISPLAY
QStringList anInfo;
- for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
+ for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
}
QString anInfoStr = anInfo.join(";\t");
- qDebug(QString("onFeatureRedisplayMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str());
+ qDebug(QString("onFeatureRedisplayMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
#endif
XGUI_Workshop* aWorkshop = workshop();
bool aFirstVisualizedBody = false;
bool aRedisplayed = false;
- for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
+ for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
ObjectPtr aObj = (*aIt);
// Hide the object if it is invalid or concealed one
}
}
}
- if (aRedisplayed) {
- customizeCurrentObject();
+ bool isCustomized = customizeCurrentObject(anObjects, aRedisplayed);
+ if (aRedisplayed || isCustomized) {
//VSV FitAll updated viewer by it self
if (aFirstVisualizedBody)
myWorkshop->viewer()->fitAll();
//******************************************************
void XGUI_WorkshopListener::onFeatureCreatedMsg(const std::shared_ptr<ModelAPI_ObjectUpdatedMessage>& theMsg)
{
- std::set<ObjectPtr> aObjects = theMsg->objects();
+ std::set<ObjectPtr> anObjects = theMsg->objects();
std::set<ObjectPtr>::const_iterator aIt;
#ifdef DEBUG_FEATURE_CREATED
QStringList anInfo;
- for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
+ for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
anInfo.append(ModuleBase_Tools::objectInfo((*aIt)));
}
QString anInfoStr = anInfo.join(";\t");
- qDebug(QString("onFeatureCreatedMsg: %1, %2").arg(aObjects.size()).arg(anInfoStr).toStdString().c_str());
+ qDebug(QString("onFeatureCreatedMsg: %1, %2").arg(anObjects.size()).arg(anInfoStr).toStdString().c_str());
#endif
bool aFirstVisualizedBody = false;
//bool aHasPart = false;
bool aDisplayed = false;
- for (aIt = aObjects.begin(); aIt != aObjects.end(); ++aIt) {
+ for (aIt = anObjects.begin(); aIt != anObjects.end(); ++aIt) {
ObjectPtr anObject = *aIt;
#ifdef DEBUG_RESULT_COMPSOLID
}
}
+ bool isCustomized = customizeCurrentObject(anObjects, aDisplayed);
+
//if (myObjectBrowser)
// myObjectBrowser->processEvent(theMsg);
if (aDisplayed) {
- customizeCurrentObject();
//VSV FitAll updated viewer by it self
if (aFirstVisualizedBody)
myWorkshop->viewer()->fitAll();
return aDisplayed;
}
-bool XGUI_WorkshopListener::customizeCurrentObject()
+bool XGUI_WorkshopListener::customizeCurrentObject(const std::set<ObjectPtr>& theObjects,
+ bool theForceRedisplay)
{
- bool aCustomized = false;
XGUI_OperationMgr* anOperationMgr = workshop()->operationMgr();
+ FeaturePtr aCurrentFeature;
if (anOperationMgr->hasOperation()) {
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(anOperationMgr->currentOperation());
if (aFOperation) {
- FeaturePtr aCurrentFeature = aFOperation->feature();
- if (aCurrentFeature.get())
- aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
- ModuleBase_IModule::CustomizeAllObjects, false);
+ aCurrentFeature = aFOperation->feature();
}
}
+
+ bool aCustomized = false;
+ if (aCurrentFeature.get()) {
+ // the customize presentation should be redisplayed if force redislayed is true or
+ // if a list of message objects contains the operation feature for case when
+ // the feature is hidden, but arguments of the feature are modified
+ // e.g. extrusion is hidden(h=0) but sketch is chosen
+ if (theForceRedisplay || theObjects.find(aCurrentFeature) != theObjects.end())
+ aCustomized = myWorkshop->module()->customizeObject(aCurrentFeature,
+ ModuleBase_IModule::CustomizeAllObjects, false);
+ }
return aCustomized;
}
bool displayObject(ObjectPtr theObj, bool& theFirstVisualizedBody);
/// Calls the module method of cusomize object for the feature of the current operation
+ /// Perform cusomize if the force redisplay flag is true or the list of objects contains the
+ /// current operation feature
+ /// \param theObjects a list of objects to find current operation feature if forced redisplay is false
+ /// \param theForceRedisplay a flag to customize object even always
/// \return true if the object is modified
- bool customizeCurrentObject();
+ bool customizeCurrentObject(const std::set<ObjectPtr>& theObjects, bool theForceRedisplay);
/// Returns the workshop
XGUI_Workshop* workshop() const;