Sketcher: Refactor TaskSketcherMessages to move most of the logic into Core to be reused by Assembly
This commit is contained in:
@@ -452,6 +452,7 @@ SET(Gui_UIC_SRCS
|
||||
TaskView/TaskAppearance.ui
|
||||
TaskView/TaskOrientation.ui
|
||||
TaskView/TaskImage.ui
|
||||
TaskView/TaskSolverMessages.ui
|
||||
TaskView/TaskSelectLinkProperty.ui
|
||||
TaskElementColors.ui
|
||||
Dialogs/DlgObjectSelection.ui
|
||||
@@ -864,6 +865,9 @@ SET(Task_View_SRCS
|
||||
TaskView/TaskSelectLinkProperty.cpp
|
||||
TaskView/TaskSelectLinkProperty.h
|
||||
TaskView/TaskSelectLinkProperty.ui
|
||||
TaskView/TaskSolverMessages.cpp
|
||||
TaskView/TaskSolverMessages.h
|
||||
TaskView/TaskSolverMessages.ui
|
||||
TaskView/TaskEditControl.cpp
|
||||
TaskView/TaskEditControl.h
|
||||
TaskView/TaskEditControl.ui
|
||||
@@ -1437,6 +1441,7 @@ if(MSVC)
|
||||
TaskView/TaskOrientation.cpp
|
||||
TaskView/TaskImage.cpp
|
||||
TaskView/TaskSelectLinkProperty.cpp
|
||||
TaskView/TaskSolverMessages.ui
|
||||
TaskView/TaskEditControl.cpp
|
||||
TaskView/TaskView.cpp
|
||||
${Command_CPP_SRCS}
|
||||
|
||||
@@ -2735,7 +2735,7 @@ PlotWidget {
|
||||
SKETCHER
|
||||
==================================================================================================*/
|
||||
|
||||
Gui--StatefulLabel[state="empty_sketch"] {
|
||||
Gui--StatefulLabel[state="empty"] {
|
||||
color : #ffffff; /* 50% opacity white */
|
||||
}
|
||||
Gui--StatefulLabel[state="under_constrained"] {
|
||||
|
||||
@@ -2740,7 +2740,7 @@ PlotWidget {
|
||||
SKETCHER
|
||||
==================================================================================================*/
|
||||
|
||||
Gui--StatefulLabel[state="empty_sketch"] {
|
||||
Gui--StatefulLabel[state="empty"] {
|
||||
color : #393939; /* 50% opacity white */
|
||||
}
|
||||
Gui--StatefulLabel[state="under_constrained"] {
|
||||
|
||||
@@ -2479,7 +2479,7 @@ PlotWidget {
|
||||
SKETCHER
|
||||
==================================================================================================*/
|
||||
|
||||
Gui--StatefulLabel[state="empty_sketch"] {
|
||||
Gui--StatefulLabel[state="empty"] {
|
||||
color : @SketcherEmptySketchColor}
|
||||
Gui--StatefulLabel[state="under_constrained"] {
|
||||
color : @SketcherUnderConstrainedColor;
|
||||
|
||||
136
src/Gui/TaskView/TaskSolverMessages.cpp
Normal file
136
src/Gui/TaskView/TaskSolverMessages.cpp
Normal file
@@ -0,0 +1,136 @@
|
||||
// SPDX - License - Identifier: LGPL - 2.1 - or -later
|
||||
/****************************************************************************
|
||||
* *
|
||||
* Copyright (c) 2011 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#include "PreCompiled.h"
|
||||
#ifndef _PreComp_
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#endif
|
||||
|
||||
#include <Gui/Application.h>
|
||||
#include <Gui/BitmapFactory.h>
|
||||
#include <Gui/Command.h>
|
||||
#include <Gui/ViewProvider.h>
|
||||
|
||||
#include "TaskSolverMessages.h"
|
||||
#include "ui_TaskSolverMessages.h"
|
||||
|
||||
|
||||
using namespace Gui;
|
||||
using namespace Gui::TaskView;
|
||||
namespace sp = std::placeholders;
|
||||
|
||||
TaskSolverMessages::TaskSolverMessages(const QPixmap& icon,
|
||||
const QString& title)
|
||||
: TaskBox(icon, title, true, nullptr)
|
||||
, ui(new Ui_TaskSolverMessages)
|
||||
{
|
||||
// we need a separate container widget to add all controls to
|
||||
auto* proxy = new QWidget(this);
|
||||
ui->setupUi(proxy);
|
||||
setupConnections();
|
||||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
|
||||
ui->labelStatus->setOpenExternalLinks(false);
|
||||
|
||||
// Set up the possible state values for the status label
|
||||
ui->labelStatus->setParameterGroup(
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher/General");
|
||||
ui->labelStatus->registerState(QStringLiteral("empty"),
|
||||
palette().windowText().color(),
|
||||
std::string("EmptySketchMessageColor"));
|
||||
ui->labelStatus->registerState(QStringLiteral("under_constrained"),
|
||||
palette().windowText().color(),
|
||||
std::string("UnderconstrainedMessageColor"));
|
||||
ui->labelStatus->registerState(QStringLiteral("malformed_constraints"),
|
||||
QColor("red"),
|
||||
std::string("MalformedConstraintMessageColor"));
|
||||
ui->labelStatus->registerState(QStringLiteral("conflicting_constraints"),
|
||||
QColor("orangered"),
|
||||
std::string("ConflictingConstraintMessageColor"));
|
||||
ui->labelStatus->registerState(QStringLiteral("redundant_constraints"),
|
||||
QColor("red"),
|
||||
std::string("RedundantConstraintMessageColor"));
|
||||
ui->labelStatus->registerState(
|
||||
QStringLiteral("partially_redundant_constraints"),
|
||||
QColor("royalblue"),
|
||||
std::string("PartiallyRedundantConstraintMessageColor"));
|
||||
ui->labelStatus->registerState(
|
||||
QStringLiteral("solver_failed"), QColor("red"), std::string("SolverFailedMessageColor"));
|
||||
ui->labelStatus->registerState(QStringLiteral("fully_constrained"),
|
||||
QColor("green"),
|
||||
std::string("FullyConstrainedMessageColor"));
|
||||
|
||||
ui->labelStatusLink->setLaunchExternal(false);
|
||||
|
||||
createSettingsButtonActions();
|
||||
}
|
||||
|
||||
TaskSolverMessages::~TaskSolverMessages() = default;
|
||||
|
||||
void TaskSolverMessages::setupConnections()
|
||||
{
|
||||
connect(ui->labelStatusLink,
|
||||
&Gui::UrlLabel::linkClicked,
|
||||
this,
|
||||
&TaskSolverMessages::onLabelStatusLinkClicked);
|
||||
connect(ui->manualUpdate,
|
||||
&QToolButton::clicked,
|
||||
this,
|
||||
&TaskSolverMessages::onManualUpdateClicked);
|
||||
}
|
||||
|
||||
void TaskSolverMessages::slotSetUp(const QString& state, const QString& msg, const QString& link,
|
||||
const QString& linkText)
|
||||
{
|
||||
ui->labelStatus->setState(state);
|
||||
ui->labelStatus->setText(msg);
|
||||
ui->labelStatusLink->setUrl(link);
|
||||
ui->labelStatusLink->setText(linkText);
|
||||
updateToolTip(link);
|
||||
}
|
||||
|
||||
void TaskSolverMessages::setLinkTooltip(const QString& tooltip)
|
||||
{
|
||||
ui->labelStatusLink->setToolTip(tooltip);
|
||||
}
|
||||
|
||||
QToolButton* TaskSolverMessages::getSettingsButton()
|
||||
{
|
||||
return ui->settingsButton;
|
||||
}
|
||||
|
||||
void TaskSolverMessages::onManualUpdateClicked(bool checked)
|
||||
{
|
||||
Q_UNUSED(checked);
|
||||
Gui::Command::updateActive();
|
||||
}
|
||||
|
||||
void TaskSolverMessages::createSettingsButtonActions()
|
||||
{
|
||||
ui->settingsButton->hide();
|
||||
}
|
||||
|
||||
#include "moc_TaskSolverMessages.cpp"
|
||||
|
||||
77
src/Gui/TaskView/TaskSolverMessages.h
Normal file
77
src/Gui/TaskView/TaskSolverMessages.h
Normal file
@@ -0,0 +1,77 @@
|
||||
// SPDX - License - Identifier: LGPL - 2.1 - or -later
|
||||
/****************************************************************************
|
||||
* *
|
||||
* Copyright (c) 2011 Jürgen Riegel <juergen.riegel@web.de> *
|
||||
* *
|
||||
* This file is part of FreeCAD. *
|
||||
* *
|
||||
* FreeCAD is free software: you can redistribute it and/or modify it *
|
||||
* under the terms of the GNU Lesser General Public License as *
|
||||
* published by the Free Software Foundation, either version 2.1 of the *
|
||||
* License, or (at your option) any later version. *
|
||||
* *
|
||||
* FreeCAD is distributed in the hope that it will be useful, but *
|
||||
* WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU *
|
||||
* Lesser General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU Lesser General Public *
|
||||
* License along with FreeCAD. If not, see *
|
||||
* <https://www.gnu.org/licenses/>. *
|
||||
* *
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef GUI_TASKVIEW_TaskSolverMessages_H
|
||||
#define GUI_TASKVIEW_TaskSolverMessages_H
|
||||
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
|
||||
class Ui_TaskSolverMessages;
|
||||
using Connection = boost::signals2::connection;
|
||||
|
||||
namespace App
|
||||
{
|
||||
class Property;
|
||||
}
|
||||
|
||||
namespace Gui
|
||||
{
|
||||
|
||||
class GuiExport TaskSolverMessages: public Gui::TaskView::TaskBox
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit TaskSolverMessages(const QPixmap& icon,
|
||||
const QString& title);
|
||||
~TaskSolverMessages() override;
|
||||
FC_DISABLE_COPY_MOVE(TaskSolverMessages)
|
||||
|
||||
void slotSetUp(const QString& state,
|
||||
const QString& msg,
|
||||
const QString& link,
|
||||
const QString& linkText);
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
virtual void createSettingsButtonActions();
|
||||
virtual void onLabelStatusLinkClicked(const QString&) = 0;
|
||||
void onManualUpdateClicked(bool checked);
|
||||
|
||||
virtual void updateToolTip(const QString&) = 0;
|
||||
|
||||
protected:
|
||||
void setLinkTooltip(const QString& tooltip);
|
||||
QToolButton* getSettingsButton();
|
||||
|
||||
Connection connectionSetUp;
|
||||
|
||||
private:
|
||||
std::unique_ptr<Ui_TaskSolverMessages> ui;
|
||||
};
|
||||
|
||||
} // namespace Gui
|
||||
|
||||
#endif // GUI_TASKVIEW_TaskSolverMessages_H
|
||||
@@ -1,96 +1,102 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TaskSketcherMessages</class>
|
||||
<widget class="QWidget" name="TaskSketcherMessages">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>253</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="Gui::StatefulLabel" name="labelConstrainStatus">
|
||||
<property name="text">
|
||||
<string>DOF</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::UrlLabel" name="labelConstrainStatusLink">
|
||||
<property name="text">
|
||||
<string>Link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="manualUpdate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Forces the recomputation of the active document</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/icons/view-refresh.svg</normaloff>:/icons/view-refresh.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="settingsButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Sketch edit settings</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset resource="Resources/Sketcher.qrc">
|
||||
<normaloff>:/icons/dialogs/Sketcher_Settings.svg</normaloff>:/icons/dialogs/Sketcher_Settings.svg</iconset>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::MenuButtonPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::StatefulLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::UrlLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<ui version="4.0">
|
||||
<class>TaskSolverMessages</class>
|
||||
<widget class="QWidget" name="TaskSolverMessages">
|
||||
<property name="geometry">
|
||||
<rect>
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>350</width>
|
||||
<height>48</height>
|
||||
</rect>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>320</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="windowTitle">
|
||||
<string notr="true">Form</string>
|
||||
</property>
|
||||
<layout class="QHBoxLayout" name="horizontalLayout">
|
||||
<item>
|
||||
<widget class="Gui::StatefulLabel" name="labelStatus">
|
||||
<property name="text">
|
||||
<string>DOF</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="Gui::UrlLabel" name="labelStatusLink">
|
||||
<property name="text">
|
||||
<string>Link</string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="manualUpdate">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="minimumSize">
|
||||
<size>
|
||||
<width>0</width>
|
||||
<height>0</height>
|
||||
</size>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Forces the recomputation of the active document</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/icons/view-refresh.svg</normaloff>:/icons/view-refresh.svg</iconset>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
<item>
|
||||
<widget class="QToolButton" name="settingsButton">
|
||||
<property name="sizePolicy">
|
||||
<sizepolicy hsizetype="Maximum" vsizetype="Preferred">
|
||||
<horstretch>0</horstretch>
|
||||
<verstretch>0</verstretch>
|
||||
</sizepolicy>
|
||||
</property>
|
||||
<property name="toolTip">
|
||||
<string>Settings</string>
|
||||
</property>
|
||||
<property name="text">
|
||||
<string/>
|
||||
</property>
|
||||
<property name="icon">
|
||||
<iconset>
|
||||
<normaloff>:/icons/preferences-general.svg</normaloff>:/icons/preferences-general.svg</iconset>
|
||||
</property>
|
||||
<property name="popupMode">
|
||||
<enum>QToolButton::MenuButtonPopup</enum>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
</layout>
|
||||
</widget>
|
||||
<customwidgets>
|
||||
<customwidget>
|
||||
<class>Gui::StatefulLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
<customwidget>
|
||||
<class>Gui::UrlLabel</class>
|
||||
<extends>QLabel</extends>
|
||||
<header>Gui/Widgets.h</header>
|
||||
</customwidget>
|
||||
</customwidgets>
|
||||
<resources/>
|
||||
<connections/>
|
||||
</ui>
|
||||
@@ -23,7 +23,6 @@ set(SketcherGui_UIC_SRCS
|
||||
TaskSketcherConstraints.ui
|
||||
TaskSketcherElements.ui
|
||||
SketcherToolDefaultWidget.ui
|
||||
TaskSketcherMessages.ui
|
||||
TaskSketcherSolverAdvanced.ui
|
||||
TaskSketcherValidation.ui
|
||||
InsertDatum.ui
|
||||
@@ -103,7 +102,6 @@ SET(SketcherGui_SRCS
|
||||
SketcherToolDefaultWidget.h
|
||||
TaskSketcherTool.cpp
|
||||
TaskSketcherTool.h
|
||||
TaskSketcherMessages.ui
|
||||
TaskSketcherMessages.cpp
|
||||
TaskSketcherMessages.h
|
||||
TaskSketcherSolverAdvanced.ui
|
||||
|
||||
@@ -1480,7 +1480,7 @@ QWidget* SnapSpaceAction::createWidget(QWidget* parent)
|
||||
layout->addWidget(snapAngle, 1, 1);
|
||||
|
||||
languageChange();
|
||||
|
||||
|
||||
#if QT_VERSION >= QT_VERSION_CHECK(6,7,0)
|
||||
QObject::connect(snapToObjects, &QCheckBox::checkStateChanged, [this](int state) {
|
||||
#else
|
||||
@@ -1925,4 +1925,3 @@ void CreateSketcherCommands()
|
||||
rcCmdMgr.addCommand(new CmdRenderingOrder());
|
||||
}
|
||||
// clang-format on
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@
|
||||
#ifndef _PreComp_
|
||||
#include <QAction>
|
||||
#include <QMenu>
|
||||
#include <QCheckBox>
|
||||
#endif
|
||||
|
||||
#include <Gui/Application.h>
|
||||
@@ -34,7 +35,6 @@
|
||||
#include "Command.h"
|
||||
#include "TaskSketcherMessages.h"
|
||||
#include "ViewProviderSketch.h"
|
||||
#include "ui_TaskSketcherMessages.h"
|
||||
|
||||
|
||||
// clang-format off
|
||||
@@ -43,55 +43,15 @@ using namespace Gui::TaskView;
|
||||
namespace sp = std::placeholders;
|
||||
|
||||
TaskSketcherMessages::TaskSketcherMessages(ViewProviderSketch* sketchView)
|
||||
: TaskBox(Gui::BitmapFactory().pixmap("Sketcher_Sketch"), tr("Sketch Edit"), true, nullptr)
|
||||
: TaskSolverMessages(Gui::BitmapFactory().pixmap("Sketcher_Sketch"), tr("Sketch Edit"))
|
||||
, sketchView(sketchView)
|
||||
, ui(new Ui_TaskSketcherMessages)
|
||||
{
|
||||
// we need a separate container widget to add all controls to
|
||||
proxy = new QWidget(this);
|
||||
ui->setupUi(proxy);
|
||||
setupConnections();
|
||||
|
||||
this->groupLayout()->addWidget(proxy);
|
||||
createSettingsButtonActions();
|
||||
|
||||
//NOLINTBEGIN
|
||||
connectionSetUp = sketchView->signalSetUp.connect(std::bind(
|
||||
&SketcherGui::TaskSketcherMessages::slotSetUp, this, sp::_1, sp::_2, sp::_3, sp::_4));
|
||||
//NOLINTEND
|
||||
|
||||
ui->labelConstrainStatus->setOpenExternalLinks(false);
|
||||
|
||||
// Set up the possible state values for the status label
|
||||
ui->labelConstrainStatus->setParameterGroup(
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher/General");
|
||||
ui->labelConstrainStatus->registerState(QStringLiteral("empty_sketch"),
|
||||
palette().windowText().color(),
|
||||
std::string("EmptySketchMessageColor"));
|
||||
ui->labelConstrainStatus->registerState(QStringLiteral("under_constrained"),
|
||||
palette().windowText().color(),
|
||||
std::string("UnderconstrainedMessageColor"));
|
||||
ui->labelConstrainStatus->registerState(QStringLiteral("malformed_constraints"),
|
||||
QColor("red"),
|
||||
std::string("MalformedConstraintMessageColor"));
|
||||
ui->labelConstrainStatus->registerState(QStringLiteral("conflicting_constraints"),
|
||||
QColor("orangered"),
|
||||
std::string("ConflictingConstraintMessageColor"));
|
||||
ui->labelConstrainStatus->registerState(QStringLiteral("redundant_constraints"),
|
||||
QColor("red"),
|
||||
std::string("RedundantConstraintMessageColor"));
|
||||
ui->labelConstrainStatus->registerState(
|
||||
QStringLiteral("partially_redundant_constraints"),
|
||||
QColor("royalblue"),
|
||||
std::string("PartiallyRedundantConstraintMessageColor"));
|
||||
ui->labelConstrainStatus->registerState(
|
||||
QStringLiteral("solver_failed"), QColor("red"), std::string("SolverFailedMessageColor"));
|
||||
ui->labelConstrainStatus->registerState(QStringLiteral("fully_constrained"),
|
||||
QColor("green"),
|
||||
std::string("FullyConstrainedMessageColor"));
|
||||
|
||||
ui->labelConstrainStatusLink->setLaunchExternal(false);
|
||||
|
||||
createSettingsButtonActions();
|
||||
}
|
||||
|
||||
TaskSketcherMessages::~TaskSketcherMessages()
|
||||
@@ -99,121 +59,97 @@ TaskSketcherMessages::~TaskSketcherMessages()
|
||||
connectionSetUp.disconnect();
|
||||
}
|
||||
|
||||
void TaskSketcherMessages::setupConnections()
|
||||
{
|
||||
connect(ui->labelConstrainStatusLink,
|
||||
&Gui::UrlLabel::linkClicked,
|
||||
this,
|
||||
&TaskSketcherMessages::onLabelConstrainStatusLinkClicked);
|
||||
connect(ui->manualUpdate,
|
||||
&QToolButton::clicked,
|
||||
this,
|
||||
&TaskSketcherMessages::onManualUpdateClicked);
|
||||
}
|
||||
|
||||
void TaskSketcherMessages::slotSetUp(const QString& state, const QString& msg, const QString& link,
|
||||
const QString& linkText)
|
||||
{
|
||||
ui->labelConstrainStatus->setState(state);
|
||||
ui->labelConstrainStatus->setText(msg);
|
||||
ui->labelConstrainStatusLink->setUrl(link);
|
||||
ui->labelConstrainStatusLink->setText(linkText);
|
||||
updateToolTip(link);
|
||||
}
|
||||
|
||||
void TaskSketcherMessages::updateToolTip(const QString& link)
|
||||
{
|
||||
if (link == QStringLiteral("#conflicting"))
|
||||
ui->labelConstrainStatusLink->setToolTip(
|
||||
tr("Click to select these conflicting constraints."));
|
||||
else if (link == QStringLiteral("#redundant"))
|
||||
ui->labelConstrainStatusLink->setToolTip(tr("Click to select these redundant constraints."));
|
||||
else if (link == QStringLiteral("#dofs"))
|
||||
ui->labelConstrainStatusLink->setToolTip(
|
||||
tr("The sketch has unconstrained elements giving rise to those Degrees Of Freedom. "
|
||||
"Click to select these unconstrained elements."));
|
||||
else if (link == QStringLiteral("#malformed"))
|
||||
ui->labelConstrainStatusLink->setToolTip(tr("Click to select these malformed constraints."));
|
||||
else if (link == QStringLiteral("#partiallyredundant"))
|
||||
ui->labelConstrainStatusLink->setToolTip(
|
||||
if (link == QStringLiteral("#conflicting")) {
|
||||
setLinkTooltip(tr("Click to select these conflicting constraints."));
|
||||
}
|
||||
else if (link == QStringLiteral("#redundant")) {
|
||||
setLinkTooltip(tr("Click to select these redundant constraints."));
|
||||
}
|
||||
else if (link == QStringLiteral("#dofs")) {
|
||||
setLinkTooltip(tr("The sketch has unconstrained elements giving rise to those "
|
||||
"Degrees Of Freedom. Click to select these unconstrained elements."));
|
||||
}
|
||||
else if (link == QStringLiteral("#malformed")) {
|
||||
setLinkTooltip(tr("Click to select these malformed constraints."));
|
||||
}
|
||||
else if (link == QStringLiteral("#partiallyredundant")) {
|
||||
setLinkTooltip(
|
||||
tr("Some constraints in combination are partially redundant. Click to select these "
|
||||
"partially redundant constraints."));
|
||||
}
|
||||
}
|
||||
|
||||
void TaskSketcherMessages::onLabelConstrainStatusLinkClicked(const QString& str)
|
||||
void TaskSketcherMessages::onLabelStatusLinkClicked(const QString& str)
|
||||
{
|
||||
if (str == QStringLiteral("#conflicting"))
|
||||
Gui::Application::Instance->commandManager().runCommandByName(
|
||||
"Sketcher_SelectConflictingConstraints");
|
||||
else if (str == QStringLiteral("#redundant"))
|
||||
Gui::Application::Instance->commandManager().runCommandByName(
|
||||
"Sketcher_SelectRedundantConstraints");
|
||||
else if (str == QStringLiteral("#dofs"))
|
||||
Gui::Application::Instance->commandManager().runCommandByName(
|
||||
"Sketcher_SelectElementsWithDoFs");
|
||||
else if (str == QStringLiteral("#malformed"))
|
||||
Gui::Application::Instance->commandManager().runCommandByName(
|
||||
"Sketcher_SelectMalformedConstraints");
|
||||
else if (str == QStringLiteral("#partiallyredundant"))
|
||||
Gui::Application::Instance->commandManager().runCommandByName(
|
||||
"Sketcher_SelectPartiallyRedundantConstraints");
|
||||
}
|
||||
|
||||
void TaskSketcherMessages::onAutoUpdateStateChanged()
|
||||
{
|
||||
bool state = std::as_const(ui->settingsButton)->actions()[0]->isChecked();
|
||||
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
hGrp->SetBool("AutoRecompute", state);
|
||||
sketchView->getSketchObject()->noRecomputes = !state;
|
||||
}
|
||||
|
||||
void TaskSketcherMessages::onManualUpdateClicked(bool checked)
|
||||
{
|
||||
Q_UNUSED(checked);
|
||||
Gui::Command::updateActive();
|
||||
if (str == QStringLiteral("#conflicting")) {
|
||||
Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectConflictingConstraints");
|
||||
}
|
||||
else if (str == QStringLiteral("#redundant")) {
|
||||
Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectRedundantConstraints");
|
||||
}
|
||||
else if (str == QStringLiteral("#dofs")) {
|
||||
Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectElementsWithDoFs");
|
||||
}
|
||||
else if (str == QStringLiteral("#malformed")) {
|
||||
Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectMalformedConstraints");
|
||||
}
|
||||
else if (str == QStringLiteral("#partiallyredundant")) {
|
||||
Gui::Application::Instance->commandManager().runCommandByName("Sketcher_SelectPartiallyRedundantConstraints");
|
||||
}
|
||||
}
|
||||
|
||||
void TaskSketcherMessages::createSettingsButtonActions()
|
||||
{
|
||||
QToolButton* btn = getSettingsButton();
|
||||
btn->show();
|
||||
|
||||
// Set Auto Update in the 'Manual Update' button menu.
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
bool state = hGrp->GetBool("AutoRecompute", false);
|
||||
|
||||
sketchView->getSketchObject()->noRecomputes = !state;
|
||||
QAction* action = new QAction(tr("Auto-update"), this);
|
||||
action->setToolTip(tr("Executes a recomputation of active document after every sketch action"));
|
||||
action->setCheckable(true);
|
||||
action->setChecked(state);
|
||||
|
||||
auto* autoUpdateAction = new QWidgetAction(this);
|
||||
auto* containerWidget = new QWidget();
|
||||
auto* layout = new QGridLayout(containerWidget);
|
||||
auto* checkbox = new QCheckBox(tr("Auto-update"));
|
||||
checkbox->setToolTip(tr("Executes a recomputation of active document after every sketch action"));
|
||||
checkbox->setChecked(state);
|
||||
layout->addWidget(checkbox, 0, 0, 1, 2);
|
||||
containerWidget->setLayout(layout);
|
||||
autoUpdateAction->setDefaultWidget(containerWidget);
|
||||
|
||||
auto* gsa = new GridSpaceAction(this);
|
||||
auto* ssa = new SnapSpaceAction(this);
|
||||
auto* roa = new RenderingOrderAction(this);
|
||||
|
||||
QMenu* myMenu = new QMenu(this);
|
||||
myMenu->addAction(action);
|
||||
myMenu->addSeparator();
|
||||
myMenu->addAction(gsa);
|
||||
myMenu->addSeparator();
|
||||
myMenu->addAction(ssa);
|
||||
myMenu->addSeparator();
|
||||
myMenu->addAction(roa);
|
||||
ui->settingsButton->setMenu(myMenu);
|
||||
|
||||
QObject::connect(myMenu, &QMenu::aboutToShow, [gsa, ssa, roa]() {
|
||||
gsa->updateWidget();
|
||||
ssa->updateWidget(true);
|
||||
roa->updateWidget();
|
||||
connect(checkbox, &QCheckBox::toggled, this, [this](bool checked) {
|
||||
ParameterGrp::handle hGrp = App::GetApplication().GetParameterGroupByPath(
|
||||
"User parameter:BaseApp/Preferences/Mod/Sketcher");
|
||||
hGrp->SetBool("AutoRecompute", checked);
|
||||
sketchView->getSketchObject()->noRecomputes = !checked;
|
||||
});
|
||||
|
||||
QObject::connect(ui->settingsButton, &QToolButton::clicked, ui->settingsButton, &QToolButton::showMenu);
|
||||
QObject::connect(std::as_const(myMenu)->actions()[0],
|
||||
&QAction::changed,
|
||||
this,
|
||||
&TaskSketcherMessages::onAutoUpdateStateChanged);
|
||||
auto* gridAction = new GridSpaceAction(this);
|
||||
auto* snapAction = new SnapSpaceAction(this);
|
||||
auto* renderingAction = new RenderingOrderAction(this);
|
||||
|
||||
QMenu* myMenu = new QMenu(this);
|
||||
myMenu->addAction(autoUpdateAction);
|
||||
myMenu->addSeparator();
|
||||
myMenu->addAction(gridAction);
|
||||
myMenu->addSeparator();
|
||||
myMenu->addAction(snapAction);
|
||||
myMenu->addSeparator();
|
||||
myMenu->addAction(renderingAction);
|
||||
btn->setMenu(myMenu);
|
||||
|
||||
QObject::connect(myMenu, &QMenu::aboutToShow, [gridAction, snapAction, renderingAction]() {
|
||||
gridAction->updateWidget();
|
||||
snapAction->updateWidget(true);
|
||||
renderingAction->updateWidget();
|
||||
});
|
||||
|
||||
QObject::connect(btn, &QToolButton::clicked, btn, &QToolButton::showMenu);
|
||||
}
|
||||
|
||||
#include "moc_TaskSketcherMessages.cpp"
|
||||
|
||||
@@ -23,25 +23,14 @@
|
||||
#ifndef GUI_TASKVIEW_TaskSketcherMessages_H
|
||||
#define GUI_TASKVIEW_TaskSketcherMessages_H
|
||||
|
||||
#include <boost/signals2.hpp>
|
||||
|
||||
#include <Gui/TaskView/TaskView.h>
|
||||
|
||||
|
||||
class Ui_TaskSketcherMessages;
|
||||
using Connection = boost::signals2::connection;
|
||||
|
||||
namespace App
|
||||
{
|
||||
class Property;
|
||||
}
|
||||
#include <Gui/TaskView/TaskSolverMessages.h>
|
||||
|
||||
namespace SketcherGui
|
||||
{
|
||||
|
||||
class ViewProviderSketch;
|
||||
|
||||
class TaskSketcherMessages: public Gui::TaskView::TaskBox
|
||||
class TaskSketcherMessages: public Gui::TaskSolverMessages
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
@@ -49,27 +38,14 @@ public:
|
||||
explicit TaskSketcherMessages(ViewProviderSketch* sketchView);
|
||||
~TaskSketcherMessages() override;
|
||||
|
||||
void slotSetUp(const QString& state,
|
||||
const QString& msg,
|
||||
const QString& link,
|
||||
const QString& linkText);
|
||||
|
||||
private:
|
||||
void setupConnections();
|
||||
void createSettingsButtonActions();
|
||||
void onLabelConstrainStatusLinkClicked(const QString&);
|
||||
void onAutoUpdateStateChanged();
|
||||
void onManualUpdateClicked(bool checked);
|
||||
void createSettingsButtonActions() override;
|
||||
void onLabelStatusLinkClicked(const QString&) override;
|
||||
|
||||
void updateToolTip(const QString& link);
|
||||
void updateToolTip(const QString& link) override;
|
||||
|
||||
protected:
|
||||
ViewProviderSketch* sketchView;
|
||||
Connection connectionSetUp;
|
||||
|
||||
private:
|
||||
QWidget* proxy;
|
||||
std::unique_ptr<Ui_TaskSketcherMessages> ui;
|
||||
};
|
||||
|
||||
} // namespace SketcherGui
|
||||
|
||||
@@ -3259,7 +3259,7 @@ void ViewProviderSketch::UpdateSolverInformation()
|
||||
bool hasMalformed = getSketchObject()->getLastHasMalformedConstraints();
|
||||
|
||||
if (getSketchObject()->Geometry.getSize() == 0) {
|
||||
signalSetUp(QStringLiteral("empty_sketch"), tr("Empty sketch"), QString(), QString());
|
||||
signalSetUp(QStringLiteral("empty"), tr("Empty sketch"), QString(), QString());
|
||||
}
|
||||
else if (dofs < 0 || hasConflicts) {// over-constrained sketch
|
||||
signalSetUp(
|
||||
|
||||
Reference in New Issue
Block a user