return res;
}
-void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent *theEvent)
+void ModuleBase_DoubleSpinBox::keyPressEvent(QKeyEvent* theEvent)
{
bool isEmitKeyRelease = false;
switch (theEvent->key()) {
QDoubleSpinBox::keyPressEvent(theEvent);
if (isEmitKeyRelease)
- emit keyReleased(theEvent);
+ emit enterPressed();
+}
+
+void ModuleBase_DoubleSpinBox::keyReleaseEvent(QKeyEvent* theEvent)
+{
+ switch (theEvent->key()) {
+ case Qt::Key_Enter:
+ case Qt::Key_Return: {
+ // the enter has already been processed when key is pressed,
+ // key release should not be processed in operation manager
+ if (myIsEmitKeyPressEvent) {
+ theEvent->accept();
+ emit enterReleased();
+ return;
+ }
+ }
+ break;
+ default:
+ break;
+ }
+ QDoubleSpinBox::keyReleaseEvent(theEvent);
}
/*!
signals:
/// The signal about key release on the control, that corresponds to the attribute
/// \param theEvent key release event
- void keyReleased(QKeyEvent* theEvent);
+ void enterPressed();
+ void enterReleased();
protected slots:
/// Called on text changed
protected:
/// Removes extra trailing zero symbols
QString removeTrailingZeroes(const QString&) const;
+ /// Called on key press event
+ virtual void keyReleaseEvent(QKeyEvent* theEvent);
+
/// Called on key press event
virtual void keyPressEvent(QKeyEvent* theEvent);
//! Returns Vsd_View object from currently active view window
virtual Handle(V3d_View) activeView() const = 0;
+ virtual QWidget* activeViewPort() const = 0;
+
//! Enable or disable selection in the viewer
//! \param isEnabled is enable or disable flag
virtual void enableSelection(bool isEnabled) = 0;
const Config_WidgetAPI* theData,
const std::string& theParentId)
: ModuleBase_WidgetDoubleValue(theParent, theData, theParentId),
- myIsKeyReleasedEmitted(false)
+ //myIsEnterPressedEmitted(false),
+ myXPosition(-1), myYPosition(-1)
{
}
ModuleBase_ParamSpinBox* anEditor = new ModuleBase_ParamSpinBox(&aDlg);
anEditor->enableKeyPressEvent(true);
- if (!myIsEditing) {
- connect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SLOT(onKeyReleased(QKeyEvent*)));
- }
+ //if (!myIsEditing) {
+ // connect(anEditor, SIGNAL(enterPressed()), this, SLOT(onEnterPressed()));
+ //}
anEditor->setMinimum(0);
anEditor->setMaximum(DBL_MAX);
ModuleBase_Tools::setFocus(anEditor, "ModuleBase_WidgetEditor::editedValue");
anEditor->selectAll();
- QObject::connect(anEditor, SIGNAL(editingFinished()), &aDlg, SLOT(accept()));
+ QObject::connect(anEditor, SIGNAL(enterReleased()), &aDlg, SLOT(accept()));
+
+ QPoint aPoint = QCursor::pos();
+ if (myXPosition >= 0 && myYPosition >= 0)
+ aPoint = QPoint(myXPosition, myYPosition);
- aDlg.move(QCursor::pos());
+ aDlg.move(aPoint);
aDlg.exec();
- if (!myIsEditing) {
- disconnect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SLOT(onKeyReleased(QKeyEvent*)));
- }
+ //if (!myIsEditing) {
+ // disconnect(anEditor, SIGNAL(keyReleased(QKeyEvent*)), this, SLOT(onEnterPressed()));
+ //}
outText = anEditor->text();
bool isDouble;
bool ModuleBase_WidgetEditor::focusTo()
{
- // nds: it seems, that the timer is not necessary anymore
-
- // We can not launch here modal process for value editing because
- // it can be called on other focusOutWidget event and will block it
- //QTimer::singleShot(1, this, SLOT(showPopupEditor()));
-
showPopupEditor();
-
return true;
}
-void ModuleBase_WidgetEditor::showPopupEditor()
+void ModuleBase_WidgetEditor::showPopupEditor(const bool theSendSignals)
{
- myIsKeyReleasedEmitted = false;
+ //myIsEnterPressedEmitted = false;
// we need to emit the focus in event manually in order to save the widget as an active
// in the property panel before the mouse leave event happens in the viewer. The module
// ask an active widget and change the feature visualization if the widget is not the current one.
- emit focusInWidget(this);
+ if (theSendSignals)
+ emit focusInWidget(this);
// nds: it seems, that the envents processing is not necessary anymore
// White while all events will be processed
} else {
ModuleBase_Tools::setSpinText(mySpinBox, aText);
}
- emit valuesChanged();
- // the focus leaves the control automatically by the Enter/Esc event
- // it is processed in operation manager
- //emit focusOutWidget(this);
-
- if (myIsKeyReleasedEmitted)
- emit enterClicked();
+ if (theSendSignals) {
+ emit valuesChanged();
+ // the focus leaves the control automatically by the Enter/Esc event
+ // it is processed in operation manager
+ //emit focusOutWidget(this);
+
+ //if (myIsEnterPressedEmitted)
+ if (!myIsEditing)
+ emit enterClicked();
+ }
+ else
+ storeValue();
}
-void ModuleBase_WidgetEditor::onKeyReleased(QKeyEvent* theEvent)
+/*void ModuleBase_WidgetEditor::onEnterPressed()
+{
+ myIsEnterPressedEmitted = true;
+}*/
+
+void ModuleBase_WidgetEditor::setCursorPosition(const int theX, const int theY)
{
- myIsKeyReleasedEmitted = true;
+ myXPosition = theX;
+ myYPosition = theY;
}
/// \return the state whether the widget can accept the focus
virtual bool focusTo();
- /// Shous popup window under cursor for data editing
- void showPopupEditor();
+ /// Shous popup window under cursor for data editing
+ /// \param theSendSignals a flag whether the signals should be sent or the value
+ /// is to be applyed directly
+ void showPopupEditor(const bool theSendSignals = true);
-protected slots:
- void onKeyReleased(QKeyEvent* theEvent);
+ void setCursorPosition(const int theX, const int theY);
+
+//protected slots:
+ //void onEnterPressed();
private:
void editedValue(double& outValue, QString& outText);
///< the kinds of possible features
QStringList myFeatureKinds;
- bool myIsKeyReleasedEmitted;
+ //bool myIsEnterPressedEmitted;
+
+ int myXPosition, myYPosition;
};
#endif
anOpMgr->onKeyReleased(theEvent);
}
+#include <XGUI_SalomeConnector.h>
void PartSet_Module::onOperationActivatedByPreselection()
{
if (!mySketchReentrantMgr->canBeCommittedByPreselection())
// Set final definitions if they are necessary
//propertyPanelDefined(aOperation);
/// Commit sketcher operations automatically
+ ModuleBase_OperationFeature* aFOperation = dynamic_cast<ModuleBase_OperationFeature*>
+ (anOperation);
+ if (aFOperation) {
+ if (PartSet_SketcherMgr::isDistanceOperation(aFOperation)) {
+ // Activate dimension value editing on double click
+ ModuleBase_IPropertyPanel* aPanel = aFOperation->propertyPanel();
+ QList<ModuleBase_ModelWidget*> aWidgets = aPanel->modelWidgets();
+ // Find corresponded widget to activate value editing
+ foreach (ModuleBase_ModelWidget* aWgt, aWidgets) {
+ if (aWgt->attributeID() == "ConstraintValue") {
+ FeaturePtr aFeature = aFOperation->feature();
+ // the featue should be displayed in order to find the AIS text position,
+ // the place where the editor will be shown
+ aFeature->setDisplayed(true);
+ /// the execute is necessary to perform in the feature compute for flyout position
+ aFeature->execute();
+
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_CREATED));
+ Events_Loop::loop()->flush(Events_Loop::eventByName(EVENT_OBJECT_TO_REDISPLAY));
+
+ PartSet_WidgetEditor* anEditor = dynamic_cast<PartSet_WidgetEditor*>(aWgt);
+ if (anEditor) {
+ int aX = 0, anY = 0;
+ XGUI_ModuleConnector* aConnector = dynamic_cast<XGUI_ModuleConnector*>(myWorkshop);
+ XGUI_Workshop* aWorkshop = aConnector->workshop();
+ XGUI_Displayer* aDisplayer = aWorkshop->displayer();
+ AISObjectPtr anAIS = aDisplayer->getAISObject(aFeature);
+ Handle(AIS_InteractiveObject) anAISIO;
+ if (anAIS.get() != NULL) {
+ anAISIO = anAIS->impl<Handle(AIS_InteractiveObject)>();
+ }
+ if (anAIS.get() != NULL) {
+ Handle(AIS_InteractiveObject) anAISIO = anAIS->impl<Handle(AIS_InteractiveObject)>();
+
+ if (!anAISIO.IsNull()) {
+ Handle(AIS_Dimension) aDim = Handle(AIS_Dimension)::DownCast(anAISIO);
+ if (!aDim.IsNull()) {
+ gp_Pnt aPosition = aDim->GetTextPosition();
+
+ ModuleBase_IViewer* aViewer = myWorkshop->viewer();
+ Handle(V3d_View) aView = aViewer->activeView();
+ int aCX, aCY;
+ aView->Convert(aPosition.X(), aPosition.Y(), aPosition.Z(), aCX, aCY);
+
+ QWidget* aViewPort = aViewer->activeViewPort();
+ QPoint aGlPoint = aViewPort->mapToGlobal(QPoint(aCX, aCY));
+ aX = aGlPoint.x();
+ anY = aGlPoint.y();
+ }
+ }
+ anEditor->setCursorPosition(aX, anY);
+ anEditor->showPopupEditor(false);
+ }
+ }
+ }
+ }
+ }
+ }
anOperation->commit();
}
}
#include "SketchPlugin.h"
#include <ModelAPI_CompositeFeature.h>
#include <GeomAPI_Shape.h>
-#include <GeomAPI_AISObject.h>
#include <ModelAPI_Document.h>
#include <ModelAPI_AttributeSelection.h>
#include <ModelAPI_AttributeBoolean.h>
#endif
}
+QWidget* XGUI_ViewerProxy::activeViewPort() const
+{
+#ifdef HAVE_SALOME
+ return myWorkshop->salomeConnector()->viewer()->activeView();
+#else
+ AppElements_Viewer* aViewer = myWorkshop->mainWindow()->viewer();
+ return (aViewer->activeViewWindow()) ?
+ aViewer->activeViewWindow()->viewPortApp(): 0;
+#endif
+}
+
void XGUI_ViewerProxy::setViewProjection(double theX, double theY, double theZ, double theTwist)
{
Handle(V3d_View) aView3d = activeView();
//! Returns Vsd_View object from currently active view window
virtual Handle(V3d_View) activeView() const;
+ virtual QWidget* activeViewPort() const;
+
//! Enable or disable selection in the viewer
virtual void enableSelection(bool isEnabled);