virtual void updateAfterActivation() {}
/// The method called if widget should be activated always
- virtual bool needToBeActiated() { return false; }
+ virtual bool needToBeActivated() { return false; }
/// Returns list of widget controls
/// \return a control list
Events_Loop* aLoop = Events_Loop::loop();
aLoop->registerListener(this, Events_Loop::eventByName(EVENT_DOCUMENT_CHANGED));
+ aLoop->registerListener(this, Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
registerSelectionFilter(SF_GlobalFilter, new PartSet_GlobalFilter(myWorkshop));
registerSelectionFilter(SF_FilterInfinite, new PartSet_FilterInfinite(myWorkshop));
}
}
}
+ else if (theMessage->eventID() == Events_Loop::loop()->eventByName(EVENT_OBJECT_TO_REDISPLAY)) {
+ CompositeFeaturePtr aSketch = mySketchMgr->activeSketch();
+ if (aSketch.get()) {
+ mySketchMgr->previewSketchPlane()->createSketchPlane(aSketch, myWorkshop);
+ }
+ }
}
//******************************************************
void PartSet_PreviewSketchPlane::createSketchPlane(const CompositeFeaturePtr& theSketch,
ModuleBase_IWorkshop* theWorkshop)
{
- // the preview plane has been already created and displayed
- if (myPreviewIsDisplayed)
- return;
-
// plane is visualized only if sketch plane is filled
if (!PartSet_Tools::sketchPlane(theSketch).get())
return;
- if (!myPlane) { // If planes are not created
- // Create Preview
- // selected linear face parameters
- AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
- (theSketch->data()->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
- if (aSelAttr) {
- myShape = aSelAttr->value();
- // this case is needed by constructing sketch on a plane, where result shape is equal
- // to context result, therefore value() returns NULL and we should use shape of context.
- if (!myShape.get() && aSelAttr->context().get())
- myShape = aSelAttr->context()->shape();
- }
- if (!myShape.get()) {
- // Create Preview for default planes
- std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
- theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
- std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
- theSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
-
- double aFaceSize = myIsUseSizeOfView ? mySizeOfView
- : Config_PropManager::real(SKETCH_TAB_NAME, "planes_size");
- if (aFaceSize <= Precision::Confusion())
- aFaceSize = 200; // Set default value
-
- myShape = GeomAlgoAPI_FaceBuilder::squareFace(
- myViewCentralPoint.get() ? myViewCentralPoint : anOrigin->pnt(), aNormal->dir(), aFaceSize);
- }
- myPlane = createPreviewPlane();
+ XGUI_Displayer* aDisp = XGUI_Tools::workshop(theWorkshop)->displayer();
+ if (myPreviewIsDisplayed) {
+ aDisp->eraseAIS(myPlane, false);
}
- XGUI_Displayer* aDisp = XGUI_Tools::workshop(theWorkshop)->displayer();
+ // Create Preview
+ // selected linear face parameters
+ AttributeSelectionPtr aSelAttr = std::dynamic_pointer_cast<ModelAPI_AttributeSelection>
+ (theSketch->data()->attribute(SketchPlugin_SketchEntity::EXTERNAL_ID()));
+ if (aSelAttr) {
+ myShape = aSelAttr->value();
+ // this case is needed by constructing sketch on a plane, where result shape is equal
+ // to context result, therefore value() returns NULL and we should use shape of context.
+ if (!myShape.get() && aSelAttr->context().get())
+ myShape = aSelAttr->context()->shape();
+ }
+ if (!myShape.get()) {
+ // Create Preview for default planes
+ std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
+ theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ theSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+
+ double aFaceSize = myIsUseSizeOfView ? mySizeOfView
+ : Config_PropManager::real(SKETCH_TAB_NAME, "planes_size");
+ if (aFaceSize <= Precision::Confusion())
+ aFaceSize = 200; // Set default value
+
+ myShape = GeomAlgoAPI_FaceBuilder::squareFace(
+ myViewCentralPoint.get() ? myViewCentralPoint : anOrigin->pnt(), aNormal->dir(), aFaceSize);
+ }
+ myPlane = createPreviewPlane();
+
aDisp->displayAIS(myPlane, false/*load object in selection*/, 1/*shaded*/, false);
myPreviewIsDisplayed = true;
}
return aPlane;
}
+void PartSet_Tools::nullifySketchPlane(CompositeFeaturePtr theSketch)
+{
+ std::shared_ptr<GeomDataAPI_Point> anOrigin = std::dynamic_pointer_cast<GeomDataAPI_Point>(
+ theSketch->data()->attribute(SketchPlugin_Sketch::ORIGIN_ID()));
+ std::shared_ptr<GeomDataAPI_Dir> aNormal = std::dynamic_pointer_cast<GeomDataAPI_Dir>(
+ theSketch->data()->attribute(SketchPlugin_Sketch::NORM_ID()));
+
+ aNormal->reset();
+ anOrigin->reset();
+}
+
std::shared_ptr<GeomAPI_Pnt> PartSet_Tools::point3D(std::shared_ptr<GeomAPI_Pnt2d> thePoint2D,
CompositeFeaturePtr theSketch)
{
/// \return API object of geom plane
static std::shared_ptr<GeomAPI_Pln> sketchPlane(CompositeFeaturePtr theSketch);
+ /// Create a sketch plane instance
+ /// \param theSketch a sketch feature
+ /// \return API object of geom plane
+ static void nullifySketchPlane(CompositeFeaturePtr theSketch);
+
/// Create a point 3D on a basis of point 2D and sketch feature
/// \param thePoint2D a point on a sketch
/// \param theSketch a sketch feature
#include <ModuleBase_ViewerPrs.h>
#include <ModuleBase_Tools.h>
#include <ModuleBase_IModule.h>
+#include <ModuleBase_IPropertyPanel.h>
#include <GeomAlgoAPI_FaceBuilder.h>
#include <GeomAlgoAPI_ShapeTools.h>
ModuleBase_IWorkshop* theWorkshop,
const Config_WidgetAPI* theData,
const QMap<PartSet_Tools::ConstraintVisibleState, bool>& toShowConstraints)
-: ModuleBase_WidgetValidated(theParent, theWorkshop, theData)
+: ModuleBase_WidgetValidated(theParent, theWorkshop, theData), myOpenTransaction(false)
{
QVBoxLayout* aLayout = new QVBoxLayout(this);
ModuleBase_Tools::zeroMargins(aLayout);
aShowConstraints->setChecked(toShowConstraints[aState]);
}
+
+ QPushButton* aPlaneBtn = new QPushButton(tr("Change sketch plane"), aSecondWgt);
+ connect(aPlaneBtn, SIGNAL(clicked(bool)), SLOT(onChangePlane()));
+ aLayout->addWidget(aPlaneBtn);
+
myStackWidget->addWidget(aSecondWgt);
//setLayout(aLayout);
if (aModule)
aModule->onViewTransformed();
+ if (myOpenTransaction) {
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->finishOperation();
+ myOpenTransaction = false;
+ }
// 3. Clear text in the label
myStackWidget->setCurrentIndex(1);
//myLabel->setText("");
}
return aResult;
}
+
+//******************************************************
+void PartSet_WidgetSketchLabel::onChangePlane()
+{
+ PartSet_Module* aModule = dynamic_cast<PartSet_Module*>(myWorkshop->module());
+ if (aModule) {
+ mySizeOfViewWidget->setVisible(false);
+ myStackWidget->setCurrentIndex(0);
+
+ CompositeFeaturePtr aSketch = std::dynamic_pointer_cast<ModelAPI_CompositeFeature>(myFeature);
+ PartSet_Tools::nullifySketchPlane(aSketch);
+
+ Handle(SelectMgr_Filter) aFilter = aModule->selectionFilter(SF_SketchPlaneFilter);
+ if (!aFilter.IsNull()) {
+ std::shared_ptr<GeomAPI_Pln> aPln;
+ Handle(ModuleBase_ShapeInPlaneFilter)::DownCast(aFilter)->setPlane(aPln);
+ }
+ XGUI_Workshop* aWorkshop = aModule->getWorkshop();
+
+ aWorkshop->selectionActivate()->updateSelectionFilters();
+ aWorkshop->selectionActivate()->updateSelectionModes();
+
+ SessionPtr aMgr = ModelAPI_Session::get();
+ aMgr->startOperation();
+ myOpenTransaction = true;
+ }
+}
\ No newline at end of file
virtual void deactivate();
/// The method called if widget should be activated always
- virtual bool needToBeActiated() { return true; }
+ virtual bool needToBeActivated() { return true; }
/// Returns sketcher plane
std::shared_ptr<GeomAPI_Pln> plane() const;
/// \param theOn a flag show constraints or not
void onShowConstraint(bool theOn);
+ void onChangePlane();
+
private:
/// Set sketch plane by shape
/// \param theShape a planar face
QWidget* mySizeOfViewWidget; ///< Size of view widget, visualized if preview planes are shown
QLineEdit* mySizeOfView; ///< Value of square of size of View
QStackedWidget* myStackWidget;
+
+ bool myOpenTransaction;
};
#endif
XGUI_ActiveControlSelector* aSelectorToBeActivated = 0;
for (int i = 0, aCount = mySelectors.count(); i < aCount; i++)
{
- if (!mySelectors[i]->needToBeActiated())
+ if (!mySelectors[i]->needToBeActivated())
continue;
aSelectorToBeActivated = mySelectors[i];
break;
/// Returns whether the selector should be activated as soon as possible (by deactivatate other)
/// \return boolean result
- XGUI_EXPORT virtual bool needToBeActiated() const { return false; }
+ XGUI_EXPORT virtual bool needToBeActivated() const { return false; }
/// Processes current selection of workshop. Reaction to selection change in workshop.
XGUI_EXPORT virtual void processSelection() = 0;
if (!isActive) { // on deactivating, store previous active widget
ModuleBase_ModelWidget* aWidget = myPanel->activeWidget();
- if (aWidget && aWidget->needToBeActiated())
+ if (aWidget && aWidget->needToBeActivated())
{
myWidgetToBeActivated = aWidget;
}
}
//********************************************************************
-bool XGUI_PropertyPanelSelector::needToBeActiated() const
+bool XGUI_PropertyPanelSelector::needToBeActivated() const
{
return myWidgetToBeActivated != NULL;
}
/// Returns whether the selector should be activated as soon as possible (by deactivatate other)
/// \return boolean result
- XGUI_EXPORT virtual bool needToBeActiated() const;
+ XGUI_EXPORT virtual bool needToBeActivated() const;
/// Processes current selection of workshop. Reaction to selection change in workshop.
XGUI_EXPORT virtual void processSelection();