/
Team8
/
kittycad
Обзор
Документация
Войти
/
Team8
/
kittycad
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
src/gui/tools/assembly/fixed_3d_constraint.cpp
134 строки
3 KB
levovix
progress: refactor<BIG>: new update system
30 дек 2025, 15:28
30 дек 2025, 15:28
52348a7
Код
Авторство
О чём код?
#include "./fixed_3d_constraint.h" #include <QVBoxLayout> #include <QLabel> #include <QPushButton> #include <QFormLayout> #include <QGroupBox> #include <QToolButton> #include <QMenu> #include "data/document.h" #include "data/assembly/assembly.h" #include "data/assembly/constraints.h" #include "data/assembly/solid_clone.h" #include "gui/document_view.h" #include "gui/edits/scene_segment_select.h" Fixed3dConstraintToolPanel::Fixed3dConstraintToolPanel(Fixed3dConstraintTool* tool, QWidget* parent): ToolPanel(parent), m_tool(tool) { initUi(); } Fixed3dConstraintToolPanel::~Fixed3dConstraintToolPanel() {} void Fixed3dConstraintToolPanel::initUi() { auto layout = ToolPanel::newFormLayout(this); auto jig = m_tool->m_jig.lock(); if (m_tool->m_activatedFromModelTree) { layout->addRow(newObjectNameEdit(m_tool->m_jig.lock().get())); } targetSolid_edit = new SceneSegmentSelect(m_tool->m_docView->m_sceneTracer, m_tool->m_docView, this); { auto edit = targetSolid_edit; layout->addRow(tr("Part:"), edit); if (!jig->item.obj.expired()) { auto ent = jig->item.obj.lock(); edit->setValue(ent->visual); } connect( edit, &SceneSegmentSelect::valueChanged, this, [this, edit](VSN::SceneSegment* v) { auto jig = m_tool->m_jig.lock(); if (!jig->document.lock()->sceneToData.contains(v)) { return; } auto obj = jig->document.lock()->sceneToData[v]; if (obj.expired()) { return; } auto ent = std::dynamic_pointer_cast<data::SolidClone>(obj.lock()); if (ent == nullptr) { return; } jig->item = data::AssemblyItemPtr(ent, 0); jig->markDependencyChanged(ent); } ); connect(edit, &SceneSegmentSelect::interactiveEntryAccepted, this, [edit]() { edit->setInteractiveEntry(false); }, Qt::QueuedConnection); } if (!m_tool->m_activatedFromModelTree) { targetSolid_edit->setInteractiveEntry(true); } if (!m_tool->m_activatedFromModelTree) { layout->addRow(newStandardButtons(m_tool)); } } Fixed3dConstraintTool::Fixed3dConstraintTool(QWidget* parent) : Tool(parent) {} Fixed3dConstraintTool::~Fixed3dConstraintTool() {} void Fixed3dConstraintTool::activated(DocumentView *docView) { m_docView = docView; start(); assert(m_panel == nullptr); m_panel = new Fixed3dConstraintToolPanel(this, (QWidget*)parent()); ((QWidget*)parent())->layout()->addWidget(m_panel); } void Fixed3dConstraintTool::deactivated() { if (m_panel != nullptr) { delete m_panel; m_panel = nullptr; } Tool::deactivated(); } void Fixed3dConstraintTool::createJig() { auto jig = create<data::Fixed3dConstraint>(m_docView->document()->getOrCreateActiveAssembly()); m_jig = m_jigRef = jig; } void Fixed3dConstraintTool::deteachFromJig() { if (!m_jig.expired()) { if (m_jig.lock()->tool == this) { m_jig.lock()->tool = nullptr; } } m_jig.reset(); m_jigRef.reset(); } void Fixed3dConstraintTool::start() { if (m_jig.expired()) { createJig(); } } void Fixed3dConstraintTool::finish() { if (m_jigRef != nullptr) { if (!m_jigRef->item.obj.expired()) { m_jigRef->assembly.lock()->addChild(m_jigRef); m_jigRef->item.obj.lock()->usedBy.push_back(m_jigRef); } } deactivated(); }