return boost::shared_ptr<GeomAPI_Shape>();
}
- }
+//******************************************************************
+FeaturePtr feature(ObjectPtr theObject)
+{
+ FeaturePtr aFeature = boost::dynamic_pointer_cast<ModelAPI_Feature>(theObject);
+ if (!aFeature) {
+ ResultPtr aResult = boost::dynamic_pointer_cast<ModelAPI_Result>(theObject);
+ if (aResult) {
+ PluginManagerPtr aMgr = ModelAPI_PluginManager::get();
+ DocumentPtr aDoc = aMgr->rootDocument();
+ return aDoc->feature(aResult);
+ }
+ }
+ return aFeature;
+}
+
+ }
aDisplayer->closeLocalContexts();
}
--void PartSet_Module::onFeatureConstructed(FeaturePtr theFeature, int theMode)
++void PartSet_Module::onFeatureConstructed(ObjectPtr theFeature, int theMode)
{
// bool isDisplay = theMode != PartSet_OperationSketchBase::FM_Hide;
// if (isDisplay) {
// connect the operation
PartSet_OperationSketchBase* aPreviewOp = dynamic_cast<PartSet_OperationSketchBase*>(anOperation);
if (aPreviewOp) {
-- connect(aPreviewOp, SIGNAL(featureConstructed(FeaturePtr, int)),
-- this, SLOT(onFeatureConstructed(FeaturePtr, int)));
++ connect(aPreviewOp, SIGNAL(featureConstructed(ObjectPtr, int)),
++ this, SLOT(onFeatureConstructed(ObjectPtr, int)));
connect(aPreviewOp, SIGNAL(launchOperation(std::string, ObjectPtr)),
this, SLOT(onLaunchOperation(std::string, ObjectPtr)));
connect(aPreviewOp, SIGNAL(multiSelectionEnabled(bool)),
/// SLOT, to visualize the feature in another local context mode
/// \param theFeature the feature to be put in another local context mode
/// \param theMode the mode appeared on the feature
-- void onFeatureConstructed(FeaturePtr theFeature,
-- int theMode);
++ void onFeatureConstructed(ObjectPtr theFeature, int theMode);
/// Slot which reacts to the point 2d set to the feature. Creates a constraint
/// \param the feature
bool aHasShift = (theEvent->modifiers() & Qt::ShiftModifier);
if(aHasShift && !theHighlighted.empty()) {
QList<ObjectPtr> aSelected;
-- aSelected.push_back(feature());
-- aSelected.push_back(theHighlighted.front().object());
++ std::list<ModuleBase_ViewerPrs>::const_iterator aIt;
++ for (aIt = theSelected.cbegin(); aIt != theSelected.cend(); ++aIt)
++ aSelected.append((*aIt).object());
++ /*for (aIt = theHighlighted.cbegin(); aIt != theHighlighted.cend(); ++aIt) {
++ if (!aSelected.contains((*aIt).object()))
++ aSelected.append((*aIt).object());
++ }*/
++ //aSelected.push_back(feature());
++ //aSelected.push_back(theHighlighted.front().object());
emit setSelection(aSelected);
}
else if (aFeature) {
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_ViewerPrs.h>
++#include <ModuleBase_Tools.h>
#include <ModelAPI_Events.h>
// deselected in the viewer by blockSelection signal in the startOperation method.
bool isSelected = false;
std::list<ModuleBase_ViewerPrs>::const_iterator anIt = theSelected.begin(), aLast = theSelected.end();
-- // TODO
-- /*for (; anIt != aLast && !isSelected; anIt++) {
-- isSelected = (*anIt).feature() == feature();
-- }*/
++ for (; anIt != aLast && !isSelected; anIt++) {
++ isSelected = ModuleBase_Tools::feature((*anIt).object()) == feature();
++ }
if (!isSelected)
myFeatures = theHighlighted;
else
aSketchFeature->move(aDeltaX, aDeltaY);
std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
-- // TODO
-- /*for (; anIt != aLast; anIt++) {
-- FeaturePtr aFeature = (*anIt).feature();
-- if (!aFeature || aFeature == feature())
++ for (; anIt != aLast; anIt++) {
++ ObjectPtr aObject = (*anIt).object();
++ if (!aObject || aObject == feature())
continue;
-- aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
-- aSketchFeature->move(aDeltaX, aDeltaY);
-- }*/
++ FeaturePtr aFeature = ModuleBase_Tools::feature(aObject);
++ if (aFeature) {
++ aSketchFeature = boost::dynamic_pointer_cast<SketchPlugin_Feature>(aFeature);
++ if (aSketchFeature)
++ aSketchFeature->move(aDeltaX, aDeltaY);
++ }
++ }
}
sendFeatures();
std::list<ModuleBase_ViewerPrs> aFeatures = myFeatures;
commit();
std::list<ModuleBase_ViewerPrs>::const_iterator anIt = aFeatures.begin(), aLast = aFeatures.end();
-- // TODO
-- /*for (; anIt != aLast; anIt++) {
-- FeaturePtr aFeature = (*anIt).feature();
++ for (; anIt != aLast; anIt++) {
++ ObjectPtr aFeature = (*anIt).object();
if (aFeature) {
emit featureConstructed(aFeature, FM_Deactivation);
-- }
-- }*/
++ }
++ }
}
void PartSet_OperationFeatureEditMulti::startOperation()
std::list<FeaturePtr > aFeatures;
std::list<ModuleBase_ViewerPrs>::const_iterator anIt = myFeatures.begin(), aLast = myFeatures.end();
-- // TODO
-- /*for (; anIt != aLast; anIt++) {
-- FeaturePtr aFeature = (*anIt).feature();
++ for (; anIt != aLast; anIt++) {
++ ObjectPtr aFeature = (*anIt).object();
if (!aFeature)
continue;
ModelAPI_EventCreator::get()->sendUpdated(aFeature, anEvent);
-- }*/
++ }
Events_Loop::loop()->flush(anEvent);
flushUpdated();
}
/// theName the operation name
/// theFeature the operation argument
void launchOperation(std::string theName, ObjectPtr theFeature);
++
/// Signal about the feature construing is finished
/// \param theFeature the result feature
/// \param theMode the mode of the feature modification
-- void featureConstructed(FeaturePtr theFeature,
-- int theMode);
++ void featureConstructed(ObjectPtr theFeature, int theMode);
++
/// Signal about the features should be selected
/// \param theSelected the list of selected presentations
void featureSelected(const std::list<ModuleBase_ViewerPrs>& theSelected);
++
/// signal to enable/disable multi selection in the viewer
/// \param theEnabled the boolean state
void multiSelectionEnabled(bool theEnabled);
/// \param theFeatures a list of features to be disabled
/// \param theToStop the boolean state whether it it stopped or non stopped
void stopSelection(const QList<ObjectPtr>& theFeatures, const bool theToStop);
++
/// signal to set selection in the viewer
/// \param theFeatures a list of features to be disabled
void setSelection(const QList<ObjectPtr>& theFeatures);