ModuleBase_Operation* anOperation = createOperation(theCmdId.toStdString());
ModuleBase_ISelection* aSelection = myWorkshop->selection();
// Initialise operation with preliminary selection
- QList<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
- QList<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
- anOperation->initSelection(aSelected, aHighlighted);
+ anOperation->initSelection(aSelection);
sendOperation(anOperation);
}
/// Returns currently active widget
virtual ModuleBase_ModelWidget* activeWidget() const = 0;
+ /// Returns all property panel's widget created by WidgetFactory
+ virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const = 0;
+
signals:
/// The signal about key release on the control, that corresponds to the attribute
/// \param theEvent key release event
//! Returns data object by AIS
virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const = 0;
+ //! Select features clearing previous selection.
+ //! If the list is empty then selection will be cleared
+ virtual void setSelected(const QList<ObjectPtr>& theFeatures) = 0;
+
signals:
void selectionChanged();
#include "ModuleBase_WidgetValueFeature.h"
#include "ModuleBase_ViewerPrs.h"
#include "ModuleBase_IPropertyPanel.h"
+#include "ModuleBase_ISelection.h"
#include <ModelAPI_AttributeDouble.h>
#include <ModelAPI_Document.h>
}
}
-void ModuleBase_Operation::activateByPreselection()
+bool ModuleBase_Operation::activateByPreselection()
{
if (!myPropertyPanel)
- return;
- ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
- if ((myPreSelection.size() > 0) && aActiveWgt) {
- const ModuleBase_ViewerPrs& aPrs = myPreSelection.first();
+ return false;
+ if (myPreSelection.empty())
+ return false;
+ const QList<ModuleBase_ModelWidget*>& aWidgets = myPropertyPanel->modelWidgets();
+ if (aWidgets.empty())
+ return false;
+
+ ModuleBase_ModelWidget* aWgt;
+ ModuleBase_ViewerPrs aPrs;
+ QList<ModuleBase_ModelWidget*>::const_iterator aWIt;
+ QList<ModuleBase_ViewerPrs>::const_iterator aPIt;
+ for (aWIt = aWidgets.constBegin(), aPIt = myPreSelection.constBegin();
+ (aWIt != aWidgets.constEnd()) && (aPIt != myPreSelection.constEnd());
+ ++aWIt, ++aPIt) {
+ aWgt = (*aWIt);
+ aPrs = (*aPIt);
ModuleBase_WidgetValueFeature aValue;
aValue.setObject(aPrs.object());
- if (aActiveWgt->setValue(&aValue)) {
- myPreSelection.removeOne(aPrs);
- myPropertyPanel->activateNextWidget();
- }
- // If preselection is enough to make a valid feature - apply it immediately
+ if (!aWgt->setValue(&aValue))
+ break;
}
+ if (canBeCommitted()) {
+ // if all widgets are filled with selection
+ commit();
+ return true;
+ }
+
+ //ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
+ //if ((myPreSelection.size() > 0) && aActiveWgt) {
+ // const ModuleBase_ViewerPrs& aPrs = myPreSelection.first();
+ // ModuleBase_WidgetValueFeature aValue;
+ // aValue.setObject(aPrs.object());
+ // if (aActiveWgt->setValue(&aValue)) {
+ // myPreSelection.removeOne(aPrs);
+ // myPropertyPanel->activateNextWidget();
+ // }
+ // // If preselection is enough to make a valid feature - apply it immediately
+ //}
+ return false;
}
-void ModuleBase_Operation::initSelection(
- const QList<ModuleBase_ViewerPrs>& theSelected,
- const QList<ModuleBase_ViewerPrs>& /*theHighlighted*/)
+void ModuleBase_Operation::initSelection(ModuleBase_ISelection* theSelection)
{
- myPreSelection = theSelected;
+ myPreSelection = theSelection->getSelected();
}
void ModuleBase_Operation::onWidgetActivated(ModuleBase_ModelWidget* theWidget)
{
- activateByPreselection();
+ //activateByPreselection();
//if (theWidget && myPropertyPanel) {
// myPropertyPanel->activateNextWidget();
//// //emit activateNextWidget(myActiveWidget);
class ModuleBase_ModelWidget;
class ModuleBase_OperationDescription;
class ModuleBase_IPropertyPanel;
+class ModuleBase_ISelection;
class QKeyEvent;
/// Initialisation of operation with preliminary selection
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
- virtual void initSelection(const QList<ModuleBase_ViewerPrs>& theSelected,
- const QList<ModuleBase_ViewerPrs>& theHighlighted);
+ virtual void initSelection(ModuleBase_ISelection* theSelection);
virtual void setPropertyPanel(ModuleBase_IPropertyPanel* theProp);
ModuleBase_IPropertyPanel* propertyPanel() const { return myPropertyPanel; }
+ /// Activates widgets by preselection if it is accepted
+ virtual bool activateByPreselection();
+
signals:
void started(); /// the operation is started
void aborted(); /// the operation is aborted
/// Returns pointer to the root document.
boost::shared_ptr<ModelAPI_Document> document() const;
- /// Activates widgets by preselection if it is accepted
- virtual void activateByPreselection();
-
/// Set value to the active widget
/// \param theFeature the feature
/// \param theX the horizontal coordinate
}
ModuleBase_ISelection* aSelection = workshop()->selection();
// Initialise operation with preliminary selection
- QList<ModuleBase_ViewerPrs> aSelected = aSelection->getSelected();
- QList<ModuleBase_ViewerPrs> aHighlighted = aSelection->getHighlighted();
- aSketchOp->initSelection(aSelected, aHighlighted);
+ aSketchOp->initSelection(aSelection);
} //else if (aFeature) {
//anOperation->setFeature(aFeature);
////Deactivate result of current feature in order to avoid its selection
FeaturePtr aFeature = ModelAPI_Feature::feature(aObject);
if (!aFeature || aFeature != feature() || (aSelected.size() > 1)) {
if (commit()) {
+ theViewer->enableSelection(true);
emit featureConstructed(feature(), FM_Deactivation);
// If we have selection and prehilighting with shift pressed
}
//}
}
- }
+ }
}
void PartSet_OperationFeatureEdit::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer)
Handle(V3d_View) aView = theViewer->activeView();
gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
- if (theViewer->isSelectionEnabled())
- theViewer->enableSelection(false);
+ theViewer->enableSelection(false);
//blockSelection(true);
if (myCurPoint.myIsInitialized) {
QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
ModuleBase_ISelection* theSelection)
{
+ theViewer->enableSelection(true);
ModuleBase_ModelWidget* aActiveWgt = 0;
if (myPropertyPanel)
aActiveWgt = myPropertyPanel->activeWidget();
}// else {
//blockSelection(false);
//}
- if (!theViewer->isSelectionEnabled())
- theViewer->enableSelection(true);
}
void PartSet_OperationFeatureEdit::mouseDoubleClick(
#include <ModuleBase_OperationDescription.h>
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_IViewer.h>
+#include <ModuleBase_ISelection.h>
#include <ModelAPI_Events.h>
}
-void PartSet_OperationFeatureEditMulti::initSelection(
- const QList<ModuleBase_ViewerPrs>& theSelected,
- const QList<ModuleBase_ViewerPrs>& theHighlighted)
+void PartSet_OperationFeatureEditMulti::initSelection(ModuleBase_ISelection* theSelection)
{
//if (!theHighlighted.empty()) {
// // if there is highlighted object, we check whether it is in the list of selected objects
// else
// myFeatures = theSelected;
//} else
- myFeatures = theSelected;
+ myFeatures = theSelection->getSelected();
+ QList<ModuleBase_ViewerPrs> aHighlighted = theSelection->getHighlighted();
// add highlighted elements if they are not selected
- foreach (ModuleBase_ViewerPrs aPrs, theHighlighted) {
+ foreach (ModuleBase_ViewerPrs aPrs, aHighlighted) {
if (!isContains(myFeatures, aPrs))
myFeatures.append(aPrs);
}
return mySketch;
}
-void PartSet_OperationFeatureEditMulti::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection)
-{
-}
+//void PartSet_OperationFeatureEditMulti::mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection)
+//{
+//}
void PartSet_OperationFeatureEditMulti::mouseMoved(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer)
{
if (!(theEvent->buttons() & Qt::LeftButton))
return;
- Handle(V3d_View) aView = theViewer->activeView();
- gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
-
if (theViewer->isSelectionEnabled())
theViewer->enableSelection(false);
+ Handle(V3d_View) aView = theViewer->activeView();
+ gp_Pnt aPoint = PartSet_Tools::convertClickToPoint(theEvent->pos(), aView);
+
//blockSelection(true);
if (myCurPoint.myIsInitialized) {
double aCurX, aCurY;
QMouseEvent* theEvent, ModuleBase_IViewer* theViewer,
ModuleBase_ISelection* theSelection)
{
+ theViewer->enableSelection(true);
if (commit()) {
foreach (ModuleBase_ViewerPrs aPrs, myFeatures) {
ObjectPtr aFeature = aPrs.object();
}
}
}
- if (!theViewer->isSelectionEnabled())
- theViewer->enableSelection(true);
}
void PartSet_OperationFeatureEditMulti::startOperation()
/// Initialisation of operation with preliminary selection
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
- virtual void initSelection(const QList<ModuleBase_ViewerPrs>& theSelected,
- const QList<ModuleBase_ViewerPrs>& theHighlighted);
+ virtual void initSelection(ModuleBase_ISelection* theSelection);
/// Returns the operation sketch feature
/// \returns the sketch instance
/// \param theView a viewer to have the viewer the eye position
/// \param theSelected the list of selected presentations
/// \param theHighlighted the list of highlighted presentations
- virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
+ //virtual void mousePressed(QMouseEvent* theEvent, ModuleBase_IViewer* theViewer, ModuleBase_ISelection* theSelection);
/// Gives the current mouse point in the viewer
/// \param theEvent the mouse event
std::string anOperationType =
(aSelected.size() > 1) ?
PartSet_OperationFeatureEditMulti::Type() : PartSet_OperationFeatureEdit::Type();
- //theViewer->enableSelection(false);
restartOperation(anOperationType, aFeature);
}
} //else
}
-
-void PartSet_OperationSketchBase::activateByPreselection()
-{
- if (!myPropertyPanel)
- return;
- ModuleBase_ModelWidget* aActiveWgt = myPropertyPanel->activeWidget();
- if ((myPreSelection.size() > 0) && aActiveWgt) {
- const ModuleBase_ViewerPrs& aPrs = myPreSelection.first();
- ModuleBase_WidgetValueFeature aValue;
- aValue.setObject(aPrs.object());
- if (aActiveWgt->setValue(&aValue)) {
- myPreSelection.removeOne(aPrs);
- if(isValid()) {
- //myActiveWidget = NULL;
- commit();
- } else {
- myPropertyPanel->activateNextWidget();
- //emit activateNextWidget(myActiveWidget);
- }
- }
- // If preselection is enough to make a valid feature - apply it immediately
- }
-}
/// \param theFlushMessage the flag whether the create message should be flushed
/// \returns the created feature
virtual FeaturePtr createFeature(const bool theFlushMessage = true);
-
- /// Activates widgets by preselection if it is accepted
- virtual void activateByPreselection();
};
#endif
aContext->ClearSelected();
foreach(ObjectPtr aResult, theResults)
{
- if (myResult2AISObjectMap.find(aResult) == myResult2AISObjectMap.end())
- continue;
-
- AISObjectPtr anObj = myResult2AISObjectMap[aResult];
- if (anObj) {
+ if (isVisible(aResult)) {
+ AISObjectPtr anObj = myResult2AISObjectMap[aResult];
Handle(AIS_InteractiveObject) anAIS = anObj->impl<Handle(AIS_InteractiveObject)>();
if (!anAIS.IsNull())
aContext->SetSelected(anAIS, false);
{
XGUI_Displayer* aDisp = myWorkshop->displayer();
return aDisp->getObject(theAIS);
+}
+
+void XGUI_ModuleConnector::setSelected(const QList<ObjectPtr>& theFeatures)
+{
+ XGUI_Displayer* aDisp = myWorkshop->displayer();
+ aDisp->setSelected(theFeatures);
}
\ No newline at end of file
//! Returns data object by AIS
virtual ObjectPtr findPresentedObject(const AISObjectPtr& theAIS) const;
+ //! Select features clearing previous selection.
+ //! If the list is empty then selection will be cleared
+ virtual void setSelected(const QList<ObjectPtr>& theFeatures);
+
XGUI_Workshop* workshop() const { return myWorkshop; }
private:
/// Returns main widget of the property panel, which children will be created
/// by WidgetFactory using the XML definition
QWidget* contentWidget();
+
/// Brings back all widget created by widget factory for signal/slot
/// connections and further processing
void setModelWidgets(const QList<ModuleBase_ModelWidget*>& theWidgets);
+
/// Returns all property panel's widget created by WidgetFactory
- const QList<ModuleBase_ModelWidget*>& modelWidgets() const;
+ virtual const QList<ModuleBase_ModelWidget*>& modelWidgets() const;
+
/// Removes all widgets in the widget area of the property panel
void cleanContent();
ModuleBase_Tools::zeroMargins(myPropertyPanel->contentWidget());
QList<ModuleBase_ModelWidget*> aWidgets = aFactory.getModelWidgets();
- QList<ModuleBase_ModelWidget*>::const_iterator anIt = aWidgets.begin(), aLast = aWidgets.end();
- ModuleBase_ModelWidget* aWidget;
- for (; anIt != aLast; anIt++) {
- aWidget = *anIt;
+ foreach (ModuleBase_ModelWidget* aWidget, aWidgets) {
aWidget->setFeature(aOperation->feature());
aWidget->enableFocusProcessing();
QObject::connect(aWidget, SIGNAL(valuesChanged()), this, SLOT(onWidgetValuesChanged()));
aOperation->setPropertyPanel(myPropertyPanel);
myPropertyPanel->setModelWidgets(aWidgets);
- myPropertyPanel->activateNextWidget(NULL);
+ if (!aOperation->activateByPreselection())
+ myPropertyPanel->activateNextWidget(NULL);
// Widget activation (from the previous method) may commit the current operation
// if pre-selection is enougth for it. So we shouldn't update prop panel's title
if(myOperationMgr->isCurrentOperation(aOperation)) {