From 07ccb73fe7dd7b737e361545482d16ba99bd1e18 Mon Sep 17 00:00:00 2001 From: wmayer Date: Sun, 17 Jul 2022 11:54:55 +0200 Subject: [PATCH] Partially revert "Remove unused code into GUI" --- src/Gui/CallTips.cpp | 7 +++ src/Gui/DlgDisplayPropertiesImp.cpp | 13 +++++ src/Gui/DlgParameterImp.cpp | 5 ++ src/Gui/DlgSettingsUnitsImp.cpp | 13 +++++ src/Gui/PythonWrapper.cpp | 14 ++++++ src/Gui/SoFCDB.cpp | 1 + src/Gui/SoFCSelection.cpp | 2 +- src/Gui/SoTextLabel.cpp | 27 +++++++++- src/Gui/View3DInventorViewer.cpp | 30 ++++++++++-- src/Gui/ViewProviderPythonFeature.cpp | 1 + src/Gui/Workbench.cpp | 49 +++++++++++++++++++ .../propertyeditor/PropertyItemDelegate.cpp | 8 ++- src/Gui/propertyeditor/PropertyModel.cpp | 2 + 13 files changed, 164 insertions(+), 8 deletions(-) diff --git a/src/Gui/CallTips.cpp b/src/Gui/CallTips.cpp index 6c87d410ed..fb51c3ff5c 100644 --- a/src/Gui/CallTips.cpp +++ b/src/Gui/CallTips.cpp @@ -232,6 +232,13 @@ QMap CallTipsList::extractTips(const QString& context) const } Py::Object obj(eval, true); + // Checks whether the type is a subclass of PyObjectBase because to get the doc string + // of a member we must get it by its type instead of its instance otherwise we get the + // wrong string, namely that of the type of the member. + // Note: 3rd party libraries may use their own type object classes so that we cannot + // reliably use Py::Type. To be on the safe side we should use Py::Object to assign + // the used type object to. + //Py::Object type = obj.type(); Py::Object type(PyObject_Type(obj.ptr()), true); Py::Object inst = obj; // the object instance PyObject* typeobj = Base::getTypeAsObject(&Base::PyObjectBase::Type); diff --git a/src/Gui/DlgDisplayPropertiesImp.cpp b/src/Gui/DlgDisplayPropertiesImp.cpp index 61ebf3ab8b..e15aab0484 100644 --- a/src/Gui/DlgDisplayPropertiesImp.cpp +++ b/src/Gui/DlgDisplayPropertiesImp.cpp @@ -45,6 +45,12 @@ using namespace std; namespace bp = boost::placeholders; +/* TRANSLATOR Gui::Dialog::DlgDisplayPropertiesImp */ + +#if 0 // needed for Qt's lupdate utility + qApp->translate("QDockWidget", "Display properties"); +#endif + class DlgDisplayPropertiesImp::Private { typedef boost::signals2::connection DlgDisplayPropertiesImp_Connection; @@ -507,6 +513,7 @@ void DlgDisplayPropertiesImp::setShapeColor(const std::vectorui.buttonColor->setEnabled(shapeColor); } @@ -526,6 +533,7 @@ void DlgDisplayPropertiesImp::setLineColor(const std::vector break; } } + d->ui.buttonLineColor->setEnabled(shapeColor); } @@ -542,6 +550,7 @@ void DlgDisplayPropertiesImp::setPointSize(const std::vector break; } } + d->ui.spinPointSize->setEnabled(pointSize); } @@ -558,6 +567,7 @@ void DlgDisplayPropertiesImp::setLineWidth(const std::vector break; } } + d->ui.spinLineWidth->setEnabled(lineWidth); } @@ -578,6 +588,7 @@ void DlgDisplayPropertiesImp::setTransparency(const std::vectorui.spinTransparency->setEnabled(transparency); d->ui.horizontalSlider->setEnabled(transparency); } @@ -599,6 +610,7 @@ void DlgDisplayPropertiesImp::setLineTransparency(const std::vectorui.spinLineTransparency->setEnabled(transparency); d->ui.sliderLineTransparency->setEnabled(transparency); } @@ -613,6 +625,7 @@ std::vector DlgDisplayPropertiesImp::getSelection() const Gui::ViewProvider* view = Application::Instance->getDocument(it->pDoc)->getViewProvider(it->pObject); views.push_back(view); } + return views; } diff --git a/src/Gui/DlgParameterImp.cpp b/src/Gui/DlgParameterImp.cpp index 4bbbed0fdd..543ad7376a 100644 --- a/src/Gui/DlgParameterImp.cpp +++ b/src/Gui/DlgParameterImp.cpp @@ -86,6 +86,11 @@ DlgParameterImp::DlgParameterImp( QWidget* parent, Qt::WindowFlags fl ) policy.setHorizontalStretch(3); paramValue->setSizePolicy(policy); +#if 0 // This is needed for Qt's lupdate + qApp->translate( "Gui::Dialog::DlgParameterImp", "System parameter" ); + qApp->translate( "Gui::Dialog::DlgParameterImp", "User parameter" ); +#endif + ParameterManager* sys = App::GetApplication().GetParameterSet("System parameter"); const std::map& rcList = App::GetApplication().GetParameterSetList(); for (std::map::const_iterator it= rcList.begin();it!=rcList.end();++it) { diff --git a/src/Gui/DlgSettingsUnitsImp.cpp b/src/Gui/DlgSettingsUnitsImp.cpp index ed7f051f38..5769018fa7 100644 --- a/src/Gui/DlgSettingsUnitsImp.cpp +++ b/src/Gui/DlgSettingsUnitsImp.cpp @@ -38,6 +38,19 @@ using namespace Gui::Dialog; using namespace Base; +/* TRANSLATOR Gui::Dialog::DlgSettingsUnitsImp */ + +#if 0 // needed for Qt's lupdate utility + qApp->translate("Gui::Dialog::DlgSettingsUnits", "Standard (mm/kg/s/degree)"); + qApp->translate("Gui::Dialog::DlgSettingsUnits", "MKS (m/kg/s/degree)"); + qApp->translate("Gui::Dialog::DlgSettingsUnits", "US customary (in/lb)"); + qApp->translate("Gui::Dialog::DlgSettingsUnits", "Imperial decimal (in/lb)"); + qApp->translate("Gui::Dialog::DlgSettingsUnits", "Building Euro (cm/m²/m³)"); + qApp->translate("Gui::Dialog::DlgSettingsUnits", "Building US (ft-in/sqft/cft)"); + qApp->translate("Gui::Dialog::DlgSettingsUnits", "Metric small parts & CNC(mm, mm/min)"); + qApp->translate("Gui::Dialog::DlgSettingsUnits", "Imperial for Civil Eng (ft, ft/sec)"); + qApp->translate("Gui::Dialog::DlgSettingsUnits", "FEM (mm, N, sec)"); +#endif /** * Constructs a DlgSettingsUnitsImp which is a child of 'parent', with the diff --git a/src/Gui/PythonWrapper.cpp b/src/Gui/PythonWrapper.cpp index 1be2246c87..ced8eb0295 100644 --- a/src/Gui/PythonWrapper.cpp +++ b/src/Gui/PythonWrapper.cpp @@ -363,6 +363,11 @@ QObject* PythonWrapper::toQObject(const Py::Object& pyobject) return reinterpret_cast(ptr); #endif +#ifdef HAVE_PYQT // Unwrapping using sip/PyQt + void* ptr = qt_getCppPointer(pyobject, "sip", "unwrapinstance"); + return reinterpret_cast(ptr); +#endif + return nullptr; } @@ -494,6 +499,10 @@ Py::Object PythonWrapper::fromQObject(QObject* object, const char* className) // return qt_wrapInstance(object, className, "shiboken2", "PySide2.QtCore", "wrapInstance"); #endif +#ifdef HAVE_PYQT // Unwrapping using sip/PyQt + Q_UNUSED(className); + return qt_wrapInstance(object, "QObject", "sip", "PyQt5.QtCore", "wrapinstance"); +#endif } Py::Object PythonWrapper::fromQWidget(QWidget* widget, const char* className) @@ -519,6 +528,11 @@ Py::Object PythonWrapper::fromQWidget(QWidget* widget, const char* className) // return qt_wrapInstance(widget, className, "shiboken2", "PySide2.QtWidgets", "wrapInstance"); #endif + +#ifdef HAVE_PYQT // Unwrapping using sip/PyQt + Q_UNUSED(className); + return qt_wrapInstance(widget, "QWidget", "sip", "PyQt5.QtWidgets", "wrapinstance"); +#endif } const char* PythonWrapper::getWrapperName(QObject* obj) const diff --git a/src/Gui/SoFCDB.cpp b/src/Gui/SoFCDB.cpp index ad7f7ea50c..8ea25b80be 100644 --- a/src/Gui/SoFCDB.cpp +++ b/src/Gui/SoFCDB.cpp @@ -694,6 +694,7 @@ bool Gui::SoFCDB::writeToFile(SoNode* node, const char* filename, bool binary) ret = true; } } + return ret; } diff --git a/src/Gui/SoFCSelection.cpp b/src/Gui/SoFCSelection.cpp index 4016ef2ab8..7017ac4920 100644 --- a/src/Gui/SoFCSelection.cpp +++ b/src/Gui/SoFCSelection.cpp @@ -882,7 +882,7 @@ SoFCSelection::redrawHighlighted(SoAction * action , SbBool doHighlight ) SoState *state = action->getState(); - QtGLWidget* window; + QtGLWidget* window; SoGLRenderAction *glAction; SoGLWidgetElement::get(state, window); SoGLRenderActionElement::get(state, glAction); diff --git a/src/Gui/SoTextLabel.cpp b/src/Gui/SoTextLabel.cpp index f69505bc4f..528b565c59 100644 --- a/src/Gui/SoTextLabel.cpp +++ b/src/Gui/SoTextLabel.cpp @@ -68,6 +68,31 @@ using namespace Gui; +/*! +\code + +s=""" + #Inventor V2.1 ascii + + Annotation { + Translation { translation 4 0 0 } + FontStyle { + size 20 + style BOLD + } + BaseColor { + rgb 0.0 0.0 0.0 + } + + + SoTextLabel { string ["Text label", "Second line"] backgroundColor 1.0 0.447059 0.337255} + } +""" + +App.ActiveDocument.addObject("App::InventorObject","iv").Buffer=s + +\endcode +*/ SO_NODE_SOURCE(SoTextLabel) @@ -116,6 +141,7 @@ void SoTextLabel::GLRender(SoGLRenderAction *action) const SbViewportRegion & vp = SoViewportRegionElement::get(state); SbVec2s vpsize = vp.getViewportSizePixels(); + // font stuff SbName fontname = SoFontNameElement::get(state); int lines = this->string.getNum(); @@ -125,7 +151,6 @@ void SoTextLabel::GLRender(SoGLRenderAction *action) nilpoint[0] = (nilpoint[0] + 1.0f) * 0.5f * vpsize[0]; nilpoint[1] = (nilpoint[1] + 1.0f) * 0.5f * vpsize[1]; - // Unfortunately, the size of the label is stored in the pimpl class of // SoText2 which cannot be accessed directly. However, there is a trick // to get the required information: set model, viewing and projection diff --git a/src/Gui/View3DInventorViewer.cpp b/src/Gui/View3DInventorViewer.cpp index f726039e5f..e034b39c9d 100644 --- a/src/Gui/View3DInventorViewer.cpp +++ b/src/Gui/View3DInventorViewer.cpp @@ -119,6 +119,8 @@ FC_LOG_LEVEL_INIT("3DViewer",true,true) +//#define FC_LOGGING_CB + using namespace Gui; /*** zoom-style cursor ******/ @@ -479,6 +481,7 @@ void View3DInventorViewer::init() this->getSoRenderManager()->setGLRenderAction(new SoBoxSelectionRenderAction); this->getSoRenderManager()->getGLRenderAction()->setCacheContext(id); + // set the transparency and antialiasing settings getSoRenderManager()->getGLRenderAction()->setTransparencyType(SoGLRenderAction::SORTED_OBJECT_SORTED_TRIANGLE_BLEND); // Settings @@ -1402,6 +1405,7 @@ void View3DInventorViewer::setAxisCross(bool on) axisCross->scaleFactor = 1.0f; axisGroup = new SoSkipBoundingGroup; axisGroup->addChild(axisCross); + sep->addChild(axisGroup); } } @@ -2161,6 +2165,7 @@ void View3DInventorViewer::renderToFramebuffer(QtGLFramebufferObject* fbo) if (this->axiscrossEnabled) { this->drawAxisCross(); } + fbo->release(); } @@ -2253,6 +2258,9 @@ void View3DInventorViewer::renderGLImage() glEnable(GL_DEPTH_TEST); } +// #define ENABLE_GL_DEPTH_RANGE +// The calls of glDepthRange inside renderScene() causes problems with transparent objects +// so that's why it is disabled now: http://forum.freecadweb.org/viewtopic.php?f=3&t=6037&hilit=transparency // Documented in superclass. Overrides this method to be able to draw // the axis cross, if selected, and to keep a continuous animation @@ -2273,6 +2281,11 @@ void View3DInventorViewer::renderScene(void) glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glEnable(GL_DEPTH_TEST); +#if defined(ENABLE_GL_DEPTH_RANGE) + // using 90% of the z-buffer for the background and the main node + glDepthRange(0.1,1.0); +#endif + // Render our scenegraph with the image. SoGLRenderAction* glra = this->getSoRenderManager()->getGLRenderAction(); SoState* state = glra->getState(); @@ -2307,6 +2320,11 @@ void View3DInventorViewer::renderScene(void) state->pop(); } +#if defined (ENABLE_GL_DEPTH_RANGE) + // using 10% of the z-buffer for the foreground node + glDepthRange(0.0,0.1); +#endif + // Render overlay front scenegraph. glra->apply(this->foregroundroot); @@ -2314,6 +2332,11 @@ void View3DInventorViewer::renderScene(void) this->drawAxisCross(); } +#if defined (ENABLE_GL_DEPTH_RANGE) + // using the main portion of z-buffer again (for frontbuffer highlighting) + glDepthRange(0.1,1.0); +#endif + // Immediately reschedule to get continuous spin animation. if (this->isAnimating()) { this->getSoRenderManager()->scheduleRedraw(); @@ -2406,6 +2429,7 @@ void View3DInventorViewer::selectAll() if (obj) objs.push_back(obj); } } + if (!objs.empty()) Gui::Selection().setSelection(objs.front()->getDocument()->getName(), objs); } @@ -2435,6 +2459,7 @@ bool View3DInventorViewer::processSoEvent(const SoEvent* ev) break; } } + return navigation->processEvent(ev); } @@ -3221,11 +3246,8 @@ void View3DInventorViewer::drawAxisCross(void) // Set the viewport in the OpenGL canvas. Dimensions are calculated // as a percentage of the total canvas size. SbVec2s view = this->getSoRenderManager()->getSize(); - const int pixelarea = - int(float(this->axiscrossSize)/100.0f * std::min(view[0], view[1])); - + const int pixelarea = int(float(this->axiscrossSize)/100.0f * std::min(view[0], view[1])); SbVec2s origin(view[0] - pixelarea, 0); - glViewport(origin[0], origin[1], pixelarea, pixelarea); // Set up the projection matrix. diff --git a/src/Gui/ViewProviderPythonFeature.cpp b/src/Gui/ViewProviderPythonFeature.cpp index bbdcddbde3..7e6d6f1e4d 100644 --- a/src/Gui/ViewProviderPythonFeature.cpp +++ b/src/Gui/ViewProviderPythonFeature.cpp @@ -147,6 +147,7 @@ QIcon ViewProviderPythonFeatureImp::getIcon() const e.ReportException(); } } + return QIcon(); } diff --git a/src/Gui/Workbench.cpp b/src/Gui/Workbench.cpp index fc390fb13b..b59f9d4cb3 100644 --- a/src/Gui/Workbench.cpp +++ b/src/Gui/Workbench.cpp @@ -511,6 +511,55 @@ std::list Workbench::listCommandbars() const return bars; } +// -------------------------------------------------------------------- + +#if 0 // needed for Qt's lupdate utility + qApp->translate("CommandGroup", "File"); + qApp->translate("CommandGroup", "Edit"); + qApp->translate("CommandGroup", "Help"); + qApp->translate("CommandGroup", "Link"); + qApp->translate("CommandGroup", "Tools"); + qApp->translate("CommandGroup", "View"); + qApp->translate("CommandGroup", "Window"); + qApp->translate("CommandGroup", "Standard"); + qApp->translate("CommandGroup", "Macros"); + qApp->translate("CommandGroup", "Macro"); + qApp->translate("CommandGroup", "Structure"); + qApp->translate("CommandGroup", "Standard-Test"); + qApp->translate("CommandGroup", "Standard-View"); + qApp->translate("CommandGroup", "TreeView"); + qApp->translate("CommandGroup", "Measure"); + + qApp->translate("Workbench", "&File"); + qApp->translate("Workbench", "&Edit"); + qApp->translate("Workbench", "Standard views"); + qApp->translate("Workbench", "Axonometric"); + qApp->translate("Workbench", "&Stereo"); + qApp->translate("Workbench", "&Zoom"); + qApp->translate("Workbench", "Visibility"); + qApp->translate("Workbench", "&View"); + qApp->translate("Workbench", "&Tools"); + qApp->translate("Workbench", "&Macro"); + qApp->translate("Workbench", "&Windows"); + qApp->translate("Workbench", "&On-line help"); + qApp->translate("Workbench", "&Help"); + qApp->translate("Workbench", "File"); + qApp->translate("Workbench", "Macro"); + qApp->translate("Workbench", "View"); + qApp->translate("Workbench", "Special Ops"); + // needed for Structure toolbar + qApp->translate("Workbench", "Link actions"); +#endif + +#if 0 // needed for the application menu on OSX + qApp->translate("MAC_APPLICATION_MENU", "Services"); + qApp->translate("MAC_APPLICATION_MENU", "Hide %1"); + qApp->translate("MAC_APPLICATION_MENU", "Hide Others"); + qApp->translate("MAC_APPLICATION_MENU", "Show All"); + qApp->translate("MAC_APPLICATION_MENU", "Preferences..."); + qApp->translate("MAC_APPLICATION_MENU", "Quit %1"); + qApp->translate("MAC_APPLICATION_MENU", "About %1"); +#endif TYPESYSTEM_SOURCE(Gui::StdWorkbench, Gui::Workbench) diff --git a/src/Gui/propertyeditor/PropertyItemDelegate.cpp b/src/Gui/propertyeditor/PropertyItemDelegate.cpp index 527d15a78a..616c428e65 100644 --- a/src/Gui/propertyeditor/PropertyItemDelegate.cpp +++ b/src/Gui/propertyeditor/PropertyItemDelegate.cpp @@ -130,8 +130,12 @@ bool PropertyItemDelegate::eventFilter(QObject *o, QEvent *ev) PropertyEditor *parentEditor = qobject_cast(this->parent()); auto widget = qobject_cast(o); if (widget && parentEditor && parentEditor->activeEditor - && widget != parentEditor->activeEditor) - { + && widget != parentEditor->activeEditor) { + // All the attempts to ignore the focus-out event has been approved to not work + // reliably because there are still cases that cannot be handled. + // So, the best for now is to always ignore this event. + // See https://forum.freecadweb.org/viewtopic.php?p=579530#p579530 why this is not + // possible. return false; } } diff --git a/src/Gui/propertyeditor/PropertyModel.cpp b/src/Gui/propertyeditor/PropertyModel.cpp index 8db3a650f7..3bbc507617 100644 --- a/src/Gui/propertyeditor/PropertyModel.cpp +++ b/src/Gui/propertyeditor/PropertyModel.cpp @@ -35,6 +35,8 @@ using namespace Gui; using namespace Gui::PropertyEditor; +/* TRANSLATOR Gui::PropertyEditor::PropertyModel */ + PropertyModel::PropertyModel(QObject* parent) : QAbstractItemModel(parent) {