virtual bool restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature) = 0;
- /// Set focus to the current widget if it corresponds to the given attribute
+ /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
/// \param theAttribute name
- virtual bool focusTo(const std::string& theAttributeName) = 0;
+ virtual bool canFocusTo(const std::string& theAttributeName) = 0;
+
+ /// Set focus to the current widget if it corresponds to the given attribute
+ virtual void focusTo() = 0;
/// Returns list of widget controls
/// \return a control list
return true;
}
-bool ModuleBase_WidgetPoint2D::focusTo(const std::string& theAttributeName)
+bool ModuleBase_WidgetPoint2D::canFocusTo(const std::string& theAttributeName)
{
- if (theAttributeName != myFeatureAttributeID)
- return false;
+ return theAttributeName == myFeatureAttributeID;
+}
- if (!myXSpin->hasFocus() && !myYSpin->hasFocus()) {
+void ModuleBase_WidgetPoint2D::focusTo()
+{
+ if (!myXSpin->hasFocus() && !myYSpin->hasFocus())
myXSpin->setFocus();
- }
-
- return true;
}
QWidget* ModuleBase_WidgetPoint2D::getControl() const
virtual bool restoreValue(boost::shared_ptr<ModelAPI_Feature> theFeature);
- /// Set focus to the current widget if it corresponds to the given attribute
+ /// Returns whether the widget can accept focus, or if it corresponds to the given attribute
/// \param theAttribute name
- virtual bool focusTo(const std::string& theAttributeName);
+ virtual bool canFocusTo(const std::string& theAttributeName);
+
+ /// Set focus to the current widget if it corresponds to the given attribute
+ virtual void focusTo();
/// Returns the internal parent wiget control, that can be shown anywhere
/// \returns the widget
//PartSet_TestOCC::testSelection(myWorkshop);
}
+void PartSet_Module::onFitAllView()
+{
+ myWorkshop->viewer()->fitAll();
+}
+
void PartSet_Module::onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature)
{
ModuleBase_Operation* anOperation = createOperation(theName.c_str());
if (aSketchOp) {
connect(aSketchOp, SIGNAL(planeSelected(double, double, double)),
this, SLOT(onPlaneSelected(double, double, double)));
+ connect(aSketchOp, SIGNAL(fitAllView()),
+ this, SLOT(onFitAllView()));
}
}
/// \param theZ the Z projection value
void onPlaneSelected(double theX, double theY, double theZ);
+ /// SLOT, to fit all current viewer
+ void onFitAllView();
+
void onLaunchOperation(std::string theName, boost::shared_ptr<ModelAPI_Feature> theFeature);
/// SLOT, to switch on/off the multi selection in the viewer
void PartSet_OperationSketch::startOperation()
{
- if (!feature())
+ if (!feature()) {
setFeature(createFeature());
+ emit fitAllView();
+ }
}
bool PartSet_OperationSketch::hasSketchPlane() const
/// \param theX the value in the Y direction value of the plane
/// \param theX the value in the Z direction of the plane
void planeSelected(double theX, double theY, double theZ);
+ // signal about the viewer fit all perform
+ void fitAllView();
protected:
/// Virtual method called when operation started (see start() method for more description)
void PartSet_OperationSketchLine::keyReleased(std::string theName, QKeyEvent* theEvent)
{
int aKeyType = theEvent->key();
- if (!theName.empty() && aKeyType == Qt::Key_Return) {
+ // the second point should be activated by any modification in the property panel
+ if (!theName.empty() /*&& aKeyType == Qt::Key_Return*/) {
if (theName == LINE_ATTR_START) {
setPointSelectionMode(SM_SecondPoint, false);
}
myWidgets = theWidgets;
if (!theWidgets.empty()) {
-
QList<ModuleBase_ModelWidget*>::const_iterator anIt = theWidgets.begin(), aLast = theWidgets.end();
for (; anIt != aLast; anIt++) {
connect(*anIt, SIGNAL(keyReleased(const std::string&, QKeyEvent*)),
setTabOrder(anOkBtn, aCancelBtn);
}
}
+ ModuleBase_ModelWidget* aWidget = theWidgets.first();
+ if (aWidget)
+ aWidget->focusTo();
}
}
}
else {
foreach(ModuleBase_ModelWidget* eachWidget, myWidgets) {
- if (eachWidget->focusTo(theAttributeName))
+ if (eachWidget->canFocusTo(theAttributeName)) {
+ eachWidget->focusTo();
break;
+ }
}
}
}
//! Returns true if multiselection is enabled
virtual bool isMultiSelectionEnabled() const = 0;
+ //! Perfroms the fit all for the active view
+ virtual void fitAll() = 0;
+
signals:
void lastViewClosed();
void tryCloseView();
}
}
+void XGUI_ViewerProxy::fitAll()
+{
+ if (myWorkshop->isSalomeMode()) {
+ myWorkshop->salomeConnector()->viewer()->fitAll();
+ }
+ else {
+ XGUI_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+ aViewer->activeViewWindow()->viewPort()->fitAll();
+ }
+}
void XGUI_ViewerProxy::connectToViewer()
{
/// \param theZ the Z projection value
void setViewProjection(double theX, double theY, double theZ);
+ //! Sets the view fitted all
+ void fitAll();
+
/// Connects to a viewer according to current environment
void connectToViewer();