SILICON
Loading...
Searching...
No Matches
circuitEditor.hpp
Go to the documentation of this file.
1/*
2 Copyright (c) 2026. Giulio Cocconi
3
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation, either version 3 of the License, or
7 (at your option) any later version.
8 */
9
10#pragma once
11
13#include <ui/lifetime.hpp>
14
15namespace SILICON::ui {
16
17class DiagramScene;
18class DiagramView;
19struct ProjectSession;
20
22class CircuitEditor final : public DocumentEditor {
23public:
24 CircuitEditor(ProjectSession& session, QWidget* parent,
25 EditorNotifications notifications);
26 ~CircuitEditor() override;
27
28 [[nodiscard]] DiagramScene* scene() const noexcept { return diagramScene.get(); }
29 [[nodiscard]] DiagramView* view() const noexcept { return diagramView.get(); }
30
31 [[nodiscard]] QWidget* widget() const noexcept override;
32 [[nodiscard]] std::shared_ptr<PreparedEditorDocument>
33 prepare(const SILICON::project::Document& document) override;
34 void apply(const PreparedEditorDocument& prepared) override;
35 void flush(const std::string& path) override;
36 [[nodiscard]] bool isDirty() const override;
37 void resetDirtyState() noexcept override;
38 void reset() override;
39 void undo() override;
40 void redo() override;
41 [[nodiscard]] bool canUndo() const override;
42 [[nodiscard]] bool canRedo() const override;
43 void copy() override;
44 void cut() override;
45 void paste() override;
46 void deleteSelection() override;
47 void zoom(bool in) override;
48
55 [[nodiscard]] EditorEditState editState() const override;
56
57private:
59
61 std::unique_ptr<DiagramScene> diagramScene;
62 std::unique_ptr<DiagramView> diagramView;
64};
65
66} // namespace SILICON::ui
std::unique_ptr< DiagramView > diagramView
std::unique_ptr< DiagramScene > diagramScene
void resetDirtyState() noexcept override
bool canUndo() const override
DiagramScene * scene() const noexcept
bool canRedo() const override
void apply(const PreparedEditorDocument &prepared) override
QWidget * widget() const noexcept override
void zoom(bool in) override
Zooms the document in (true) or out (false) by one step.
void flush(const std::string &path) override
EditorEditState editState() const override
Reports which editing commands the diagram currently accepts.
bool isDirty() const override
CircuitEditor(ProjectSession &session, QWidget *parent, EditorNotifications notifications)
std::shared_ptr< PreparedEditorDocument > prepare(const SILICON::project::Document &document) override
DiagramView * view() const noexcept
Graphics scene for the circuit diagram editor.