AttributeSelectionPtr aAttr = theList->value(i);
myListControl->addItem(aAttr->namingName().c_str());
}
- //QString aType;
- //if (myTypeCombo->currentText().toLower() == "vertices")
- // aType = "vertex";
- //else if (myTypeCombo->currentText().toLower() == "edges")
- // aType = "edge";
- //else if (myTypeCombo->currentText().toLower() == "faces")
- // aType = "face";
- //else if (myTypeCombo->currentText().toLower() == "solids")
- // aType = "solid";
-
- //myListControl->clear();
- //int i = 1;
- //foreach (GeomSelection aSel, mySelection) {
- // QString aName(aSel.first->data()->name().c_str());
- // aName += ":" + aType + QString("_%1").arg(i);
- // myListControl->addItem(aName);
- // i++;
- //}
- //myListControl->repaint();
}
void PartSet_Module::onSelectionChanged()
{
ModuleBase_Operation* aOperation = myWorkshop->currentOperation();
+ if (!aOperation)
+ return;
+
bool isSketcherOp = false;
// An edit operation is enable only if the current opeation is the sketch operation
- if (aOperation && mySketchMgr->activeSketch()) {
+ if (mySketchMgr->activeSketch()) {
if (PartSet_Tools::sketchPlane(mySketchMgr->activeSketch()))
isSketcherOp = (aOperation->id().toStdString() == SketchPlugin_Sketch::ID());
}
- if (!isSketcherOp)
- return;
-
- // Editing of constraints can be done on selection
- ModuleBase_ISelection* aSelect = myWorkshop->selection();
- QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
- if (aSelected.size() == 1) {
- ModuleBase_ViewerPrs aPrs = aSelected.first();
- ObjectPtr aObject = aPrs.object();
- FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
- if (aFeature) {
- std::string aId = aFeature->getKind();
- if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
- (aId == SketchPlugin_ConstraintLength::ID()) ||
- (aId == SketchPlugin_ConstraintDistance::ID())) {
- editFeature(aFeature);
+ if (isSketcherOp) {
+ // Editing of constraints can be done on selection
+ ModuleBase_ISelection* aSelect = myWorkshop->selection();
+ QList<ModuleBase_ViewerPrs> aSelected = aSelect->getSelected();
+ if (aSelected.size() == 1) {
+ ModuleBase_ViewerPrs aPrs = aSelected.first();
+ ObjectPtr aObject = aPrs.object();
+ FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
+ if (aFeature) {
+ std::string aId = aFeature->getKind();
+ if ((aId == SketchPlugin_ConstraintRadius::ID()) ||
+ (aId == SketchPlugin_ConstraintLength::ID()) ||
+ (aId == SketchPlugin_ConstraintDistance::ID())) {
+ editFeature(aFeature);
+ }
}
}
+ } else if (mySketchMgr->sketchOperationIdList().contains(aOperation->id()) &&
+ aOperation->isEditOperation()) {
+ // if this is sketch operation in edit mode
+
+ ModuleBase_ISelection* aSelect = myWorkshop->selection();
+ //aSelect->selectedShapes();
}
}
aMenu->addAction(action("EDIT_CMD"));
} else {
if (aDisplayer->isVisible(aObject)) {
- if (aDisplayer->displayMode(aObject) == XGUI_Displayer::Shading)
- aMenu->addAction(action("WIREFRAME_CMD"));
- else
- aMenu->addAction(action("SHADING_CMD"));
+ if (aDisplayer->canBeShaded(aObject)) {
+ if (aDisplayer->displayMode(aObject) == XGUI_Displayer::Shading)
+ aMenu->addAction(action("WIREFRAME_CMD"));
+ else
+ aMenu->addAction(action("SHADING_CMD"));
+ }
aMenu->addSeparator();
aMenu->addAction(action("HIDE_CMD"));
} else {
// theMenu->addAction(action("EDIT_CMD"));
bool isVisible = false;
bool isShading = false;
+ bool canBeShaded = false;
foreach(ObjectPtr aObject, aObjects)
{
ResultPtr aRes = std::dynamic_pointer_cast<ModelAPI_Result>(aObject);
if (aRes && myWorkshop->displayer()->isVisible(aRes)) {
isVisible = true;
+ canBeShaded = myWorkshop->displayer()->canBeShaded(aObject);
isShading = (myWorkshop->displayer()->displayMode(aObject) == XGUI_Displayer::Shading);
break;
}
}
if (isVisible) {
- if (isShading)
- theMenu->addAction(action("WIREFRAME_CMD"));
- else
- theMenu->addAction(action("SHADING_CMD"));
+ if (canBeShaded) {
+ if (isShading)
+ theMenu->addAction(action("WIREFRAME_CMD"));
+ else
+ theMenu->addAction(action("SHADING_CMD"));
+ }
theMenu->addSeparator();
theMenu->addAction(action("SHOW_ONLY_CMD"));
theMenu->addAction(action("HIDE_CMD"));
Handle(AIS_InteractiveObject) anAISIO = theAIS->impl<Handle(AIS_InteractiveObject)>();
if (!anAISIO.IsNull()) {
myResult2AISObjectMap[theObject] = theAIS;
- bool aCanBeShaded = canBeShaded(anAISIO);
+ bool aCanBeShaded = ::canBeShaded(anAISIO);
// In order to avoid extra closing/opening context
if (aCanBeShaded)
closeLocalContexts(false);
return;
Handle(AIS_InteractiveObject) aAISIO = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ bool aCanBeShaded = ::canBeShaded(aAISIO);
+ // In order to avoid extra closing/opening context
+ if (aCanBeShaded)
+ closeLocalContexts(false);
aContext->SetDisplayMode(aAISIO, theMode, toUpdate);
+ if (aCanBeShaded) {
+ openLocalContext();
+ activateObjects(myActiveSelectionModes);
+ }
}
XGUI_Displayer::DisplayMode XGUI_Displayer::displayMode(ObjectPtr theObject) const
}
updateViewer();
}
+
+bool XGUI_Displayer::canBeShaded(ObjectPtr theObject) const
+{
+ if (!isVisible(theObject))
+ return false;
+
+ AISObjectPtr aAISObj = getAISObject(theObject);
+ if (aAISObj.get() == NULL)
+ return false;
+
+ Handle(AIS_InteractiveObject) anAIS = aAISObj->impl<Handle(AIS_InteractiveObject)>();
+ return ::canBeShaded(anAIS);
+}
/// Returns number of displayed objects
int objectsCount() const { return myResult2AISObjectMap.size(); }
+ bool canBeShaded(ObjectPtr theObject) const;
+
protected:
/// Returns currently installed AIS_InteractiveContext
Handle(AIS_InteractiveContext) AISContext() const;