refactor: Manage active sketch state in ApplicationController
Co-authored-by: aider (gemini/gemini-2.5-pro) <aider@aider.chat>
This commit is contained in:
@@ -35,8 +35,14 @@ Document* ApplicationController::document() const
|
|||||||
return m_document;
|
return m_document;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SketchFeature* ApplicationController::activeSketch() const
|
||||||
|
{
|
||||||
|
return m_activeSketch;
|
||||||
|
}
|
||||||
|
|
||||||
void ApplicationController::newDocument()
|
void ApplicationController::newDocument()
|
||||||
{
|
{
|
||||||
|
m_activeSketch = nullptr;
|
||||||
m_document->clear();
|
m_document->clear();
|
||||||
setCurrentFile(QString());
|
setCurrentFile(QString());
|
||||||
}
|
}
|
||||||
@@ -51,6 +57,7 @@ bool ApplicationController::openDocument()
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
setCurrentFile(fileName);
|
setCurrentFile(fileName);
|
||||||
|
m_activeSketch = nullptr;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
@@ -93,6 +100,7 @@ void ApplicationController::beginSketchCreation()
|
|||||||
"Plane:", items, 0, false, &ok);
|
"Plane:", items, 0, false, &ok);
|
||||||
if (ok && !item.isEmpty()) {
|
if (ok && !item.isEmpty()) {
|
||||||
auto feature = new SketchFeature("Sketch");
|
auto feature = new SketchFeature("Sketch");
|
||||||
|
m_activeSketch = feature;
|
||||||
ViewportWidget::SketchPlane plane;
|
ViewportWidget::SketchPlane plane;
|
||||||
if (item == "XY-Plane") {
|
if (item == "XY-Plane") {
|
||||||
plane = ViewportWidget::SketchPlane::XY;
|
plane = ViewportWidget::SketchPlane::XY;
|
||||||
@@ -111,6 +119,7 @@ void ApplicationController::beginSketchCreation()
|
|||||||
|
|
||||||
void ApplicationController::endSketch()
|
void ApplicationController::endSketch()
|
||||||
{
|
{
|
||||||
|
m_activeSketch = nullptr;
|
||||||
emit sketchModeEnded();
|
emit sketchModeEnded();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,6 +6,7 @@
|
|||||||
|
|
||||||
class Document;
|
class Document;
|
||||||
class MainWindow;
|
class MainWindow;
|
||||||
|
class SketchFeature;
|
||||||
|
|
||||||
class ApplicationController : public QObject
|
class ApplicationController : public QObject
|
||||||
{
|
{
|
||||||
@@ -15,6 +16,7 @@ public:
|
|||||||
|
|
||||||
void setMainWindow(MainWindow* mainWindow);
|
void setMainWindow(MainWindow* mainWindow);
|
||||||
Document* document() const;
|
Document* document() const;
|
||||||
|
SketchFeature* activeSketch() const;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
void newDocument();
|
void newDocument();
|
||||||
@@ -41,6 +43,7 @@ private:
|
|||||||
Document* m_document;
|
Document* m_document;
|
||||||
QString m_currentFile;
|
QString m_currentFile;
|
||||||
MainWindow* m_mainWindow = nullptr;
|
MainWindow* m_mainWindow = nullptr;
|
||||||
|
SketchFeature* m_activeSketch = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // APPLICATIONCONTROLLER_H
|
#endif // APPLICATIONCONTROLLER_H
|
||||||
|
|||||||
Reference in New Issue
Block a user