create several lines, start point creation. Only first click on the line build a coincidence to the line.
#include <QHeaderView>\r
#include <QToolButton>\r
\r
+const int DEFAULT_NAME_COLUMN_WIDTH = 200;\r
+\r
ModuleBase_WidgetConcealedObjects::ModuleBase_WidgetConcealedObjects(QWidget* theParent,\r
const Config_WidgetAPI* theData)\r
: ModuleBase_ModelWidget(theParent, theData)\r
\r
myView->setCellWidget(anId, 0, aVisibilityBtn);\r
myView->setItem(anId, 1, new QTableWidgetItem(theResult->data()->name().c_str()));\r
+\r
+ if (anId == 1) {\r
+ myView->setColumnWidth(0, myView->verticalHeader()->defaultSectionSize());\r
+ myView->setColumnWidth(1, DEFAULT_NAME_COLUMN_WIDTH);\r
+ }\r
}\r
\r
void ModuleBase_WidgetConcealedObjects::onItemToggled(bool theState)\r
#include <ModuleBase_WidgetFactory.h>
#include <ModuleBase_OperationDescription.h>
#include "ModuleBase_ToolBox.h"
+#include "ModuleBase_ISelection.h"
#include <SketchPlugin_Feature.h>
#include <SketchPlugin_Line.h>
ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
(myWorkshop->currentOperation());
myPreviousFeature = aFOperation->feature();
+
+ /// selection should be obtained from workshop before ask if the operation can be started as
+ /// the canStartOperation method performs commit/abort of previous operation. Sometimes commit/abort
+ /// may cause selection clear(Sketch operation) as a result it will be lost and is not used for preselection.
+ ModuleBase_ISelection* aSelection = myWorkshop->selection();
+ QList<ModuleBase_ViewerPrsPtr> aPreSelected = aSelection->getSelected(ModuleBase_ISelection::AllControls);
+
restartOperation();
myPreviousFeature = FeaturePtr();
aProcessed = true;
PartSet_WidgetPoint2D* aPoint2DWdg = dynamic_cast<PartSet_WidgetPoint2D*>(module()->activeWidget());
ModuleBase_ModelWidget* aFirstWidget = aPanel->findFirstAcceptingValueWidget();
if (aPoint2DWdg && aPoint2DWdg == aFirstWidget) {
+ if (!aPreSelected.empty())
+ aPoint2DWdg->setPreSelection(aPreSelected.front());
aPoint2DWdg->mouseReleased(theWnd, theEvent);
+ if (!aPreSelected.empty())
+ aPoint2DWdg->setPreSelection(ModuleBase_ViewerPrsPtr());
}
// unblock viewer update
ModuleBase_Tools::blockUpdateViewer(false);
QList<ModuleBase_ViewerPrsPtr> aList = aSelection->getSelected(ModuleBase_ISelection::Viewer);
ModuleBase_ViewerPrsPtr aFirstValue = aList.size() > 0 ? aList.first() : ModuleBase_ViewerPrsPtr();
+ if (!aFirstValue.get() && myPreSelected.get()) {
+ aFirstValue = myPreSelected;
+ }
// if we have selection and use it
if (aFirstValue.get() && isValidSelectionCustom(aFirstValue)) {
GeomShapePtr aGeomShape = aFirstValue->shape();
}
}
+void PartSet_WidgetPoint2D::setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected)
+{
+ myPreSelected = thePreSelected;
+}
void PartSet_WidgetPoint2D::mouseMoved(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent)
{
/// \param theEvent a mouse event
virtual void mouseReleased(ModuleBase_IViewWindow* theWindow, QMouseEvent* theEvent);
+ /// Fill preselection used in mouseReleased
+ void setPreSelection(const std::shared_ptr<ModuleBase_ViewerPrs>& thePreSelected);
+
signals:
/// Signal about selection of an existing vertex from an object
void vertexSelected();
ModuleBase_ParamSpinBox* myXSpin; ///< the spin box for the X coordinate
ModuleBase_ParamSpinBox* myYSpin; ///< the spin box for the Y coordinate
+ std::shared_ptr<ModuleBase_ViewerPrs> myPreSelected; ///< value used as selection in mouse release method
+ ///< it is important during restart operation
CompositeFeaturePtr mySketch;
bool myValueIsCashed; /// boolean state if the value is cashed during value state change