├── .gitignore ├── CircuitFileParser.cpp ├── CircuitFileParser.h ├── Common.pri ├── Components ├── ComplexLogic │ ├── AbstractComplexLogic.cpp │ ├── AbstractComplexLogic.h │ ├── Counter.cpp │ ├── Counter.h │ ├── DFlipFlop.cpp │ ├── DFlipFlop.h │ ├── DMsFlipFlop.cpp │ ├── DMsFlipFlop.h │ ├── Decoder.cpp │ ├── Decoder.h │ ├── Demultiplexer.cpp │ ├── Demultiplexer.h │ ├── Encoder.cpp │ ├── Encoder.h │ ├── FullAdder.cpp │ ├── FullAdder.h │ ├── HalfAdder.cpp │ ├── HalfAdder.h │ ├── JKFlipFlop.cpp │ ├── JKFlipFlop.h │ ├── JkMsFlipFlop.cpp │ ├── JkMsFlipFlop.h │ ├── LogicCells │ │ ├── LogicCounterCell.cpp │ │ ├── LogicCounterCell.h │ │ ├── LogicDFlipFlopCell.cpp │ │ ├── LogicDFlipFlopCell.h │ │ ├── LogicDMsFlipFlopCell.cpp │ │ ├── LogicDMsFlipFlopCell.h │ │ ├── LogicDecoderCell.cpp │ │ ├── LogicDecoderCell.h │ │ ├── LogicDemultiplexerCell.cpp │ │ ├── LogicDemultiplexerCell.h │ │ ├── LogicEncoderCell.cpp │ │ ├── LogicEncoderCell.h │ │ ├── LogicFullAdderCell.cpp │ │ ├── LogicFullAdderCell.h │ │ ├── LogicHalfAdderCell.cpp │ │ ├── LogicHalfAdderCell.h │ │ ├── LogicJKFlipFlopCell.cpp │ │ ├── LogicJKFlipFlopCell.h │ │ ├── LogicJkMsFlipFlopCell.cpp │ │ ├── LogicJkMsFlipFlopCell.h │ │ ├── LogicMultiplexerCell.cpp │ │ ├── LogicMultiplexerCell.h │ │ ├── LogicRsClockedFlipFlopCell.cpp │ │ ├── LogicRsClockedFlipFlopCell.h │ │ ├── LogicRsFlipFlopCell.cpp │ │ ├── LogicRsFlipFlopCell.h │ │ ├── LogicRsMsFlipFlopCell.cpp │ │ ├── LogicRsMsFlipFlopCell.h │ │ ├── LogicShiftRegisterCell.cpp │ │ ├── LogicShiftRegisterCell.h │ │ ├── LogicTFlipFlopCell.cpp │ │ └── LogicTFlipFlopCell.h │ ├── Multiplexer.cpp │ ├── Multiplexer.h │ ├── RsClockedFlipFlop.cpp │ ├── RsClockedFlipFlop.h │ ├── RsFlipFlop.cpp │ ├── RsFlipFlop.h │ ├── RsMsFlipFlop.cpp │ ├── RsMsFlipFlop.h │ ├── ShiftRegister.cpp │ ├── ShiftRegister.h │ ├── TFlipFlop.cpp │ └── TFlipFlop.h ├── ConPoint.cpp ├── ConPoint.h ├── Gates │ ├── AbstractGate.cpp │ ├── AbstractGate.h │ ├── AndGate.cpp │ ├── AndGate.h │ ├── BufferGate.cpp │ ├── BufferGate.h │ ├── LogicCells │ │ ├── LogicAndGateCell.cpp │ │ ├── LogicAndGateCell.h │ │ ├── LogicBufferGateCell.cpp │ │ ├── LogicBufferGateCell.h │ │ ├── LogicNotGateCell.cpp │ │ ├── LogicNotGateCell.h │ │ ├── LogicOrGateCell.cpp │ │ ├── LogicOrGateCell.h │ │ ├── LogicXorGateCell.cpp │ │ └── LogicXorGateCell.h │ ├── NotGate.cpp │ ├── NotGate.h │ ├── OrGate.cpp │ ├── OrGate.h │ ├── XorGate.cpp │ └── XorGate.h ├── IBaseComponent.cpp ├── IBaseComponent.h ├── Inputs │ ├── LogicButton.cpp │ ├── LogicButton.h │ ├── LogicCells │ │ ├── LogicButtonCell.cpp │ │ ├── LogicButtonCell.h │ │ ├── LogicClockCell.cpp │ │ ├── LogicClockCell.h │ │ ├── LogicConstantCell.cpp │ │ ├── LogicConstantCell.h │ │ ├── LogicInputCell.cpp │ │ └── LogicInputCell.h │ ├── LogicClock.cpp │ ├── LogicClock.h │ ├── LogicConstant.cpp │ ├── LogicConstant.h │ ├── LogicInput.cpp │ └── LogicInput.h ├── LogicBaseCell.cpp ├── LogicBaseCell.h ├── LogicDiodeCell.cpp ├── LogicDiodeCell.h ├── LogicWire.cpp ├── LogicWire.h ├── LogicWireCell.cpp ├── LogicWireCell.h ├── Outputs │ ├── LogicCells │ │ ├── LogicOutputCell.cpp │ │ └── LogicOutputCell.h │ ├── LogicOutput.cpp │ └── LogicOutput.h ├── TextLabel.cpp └── TextLabel.h ├── Configuration.h ├── CoreLogic.cpp ├── CoreLogic.h ├── Gui ├── AboutDialog.cpp ├── AboutDialog.h ├── AboutDialog.ui ├── IconToolButton.cpp ├── IconToolButton.h ├── MainWindow.cpp ├── MainWindow.h ├── MainWindow.ui ├── PieMenu.cpp ├── PieMenu.h ├── TutorialFrame.cpp ├── TutorialFrame.h ├── TutorialFrame.ui ├── WelcomeDialog.cpp ├── WelcomeDialog.h ├── WelcomeDialog.ui └── resources.qrc ├── HelperFunctions.h ├── HelperStructures.h ├── LICENSE.md ├── Linkuit_Studio.pro ├── QtAwesome ├── QtAwesome.cpp ├── QtAwesome.h ├── QtAwesome.pri ├── QtAwesome.pro ├── QtAwesome.qrc ├── QtAwesomeAnim.cpp ├── QtAwesomeAnim.h └── fonts │ └── fontawesome-4.7.0.ttf ├── README.md ├── RuntimeConfigParser.cpp ├── RuntimeConfigParser.h ├── Undo ├── UndoAddType.cpp ├── UndoAddType.h ├── UndoBaseType.cpp ├── UndoBaseType.h ├── UndoConfigureType.cpp ├── UndoConfigureType.h ├── UndoCopyType.cpp ├── UndoCopyType.h ├── UndoDeleteType.cpp ├── UndoDeleteType.h ├── UndoMoveType.cpp └── UndoMoveType.h ├── View.cpp ├── View.h ├── fonts ├── Quicksand-Bold.ttf ├── Quicksand-Light.ttf ├── Quicksand-Medium.ttf ├── Quicksand-SemiBold.ttf └── SourceSansPro-Regular.ttf ├── images ├── Linkuit_RS_counter.PNG ├── Linkuit_Selection.PNG ├── background_bottom.png ├── background_top.png ├── icons │ ├── button24.png │ ├── button_icon.png │ ├── clock24.png │ ├── clock_icon.png │ ├── constant24.png │ ├── constant_icon.png │ ├── decoder.png │ ├── decoder24.png │ ├── demultiplexer.png │ ├── demux24.png │ ├── encoder.png │ ├── encoder24.png │ ├── flipflop24.png │ ├── flipflop_icon.png │ ├── full_adder24.png │ ├── full_adder_icon.png │ ├── gate.png │ ├── gate24.png │ ├── icon_default.ico │ ├── icon_default.png │ ├── icon_file.ico │ ├── icon_file.png │ ├── icon_smaller.png │ ├── input24.png │ ├── input_icon.png │ ├── label_icon.png │ ├── material_symbols │ │ ├── add_FILL1_wght400_GRAD0_opsz20.svg │ │ ├── arrow_selector_tool_FILL1_wght400_GRAD0_opsz24.svg │ │ ├── cancel_FILL1_wght400_GRAD0_opsz20.svg │ │ ├── check_circle_FILL1_wght400_GRAD0_opsz20.svg │ │ ├── close_FILL1_wght400_GRAD0_opsz24.svg │ │ ├── delete_FILL0_wght400_GRAD0_opsz24.svg │ │ ├── edit_FILL1_wght400_GRAD0_opsz24.svg │ │ ├── expand_less_FILL0_wght600_GRAD0_opsz20.svg │ │ ├── expand_more_FILL0_wght600_GRAD0_opsz20.svg │ │ ├── pause_FILL1_wght400_GRAD0_opsz24.svg │ │ ├── play_arrow_FILL1_wght400_GRAD0_opsz24.svg │ │ ├── power_settings_new_FILL1_wght400_GRAD0_opsz24.svg │ │ ├── redo_FILL0_wght400_GRAD0_opsz24.svg │ │ ├── refresh_FILL1_wght400_GRAD0_opsz24.svg │ │ ├── remove_FILL1_wght400_GRAD0_opsz20.svg │ │ ├── restart_alt_FILL0_wght400_GRAD0_opsz24.svg │ │ ├── screenshot_monitor_FILL0_wght400_GRAD0_opsz20.svg │ │ ├── search_FILL1_wght400_GRAD0_opsz20.svg │ │ ├── skip_next_FILL1_wght400_GRAD0_opsz24.svg │ │ ├── sort_FILL1_wght400_GRAD0_opsz24.svg │ │ ├── speed_FILL0_wght400_GRAD0_opsz24.svg │ │ ├── timelapse_FILL0_wght400_GRAD0_opsz24.svg │ │ ├── undo_FILL0_wght400_GRAD0_opsz24.svg │ │ └── unfold_more_FILL1_wght400_GRAD0_opsz24.svg │ ├── output24.png │ ├── output_icon.png │ ├── pushpin-icon.png │ ├── x-icon.png │ └── x-icon.svg ├── linkuit_logo_new.png ├── logo_processing.png ├── traffic_lights.png └── welcome_img.png ├── main.cpp ├── qt.conf ├── styles └── style.css ├── tutorial ├── icons │ ├── edit_FILL1_wght400_GRAD0_opsz15.svg │ ├── gate.png │ ├── input.png │ ├── keyboard_control_key_FILL0_wght400_GRAD0_opsz15.svg │ ├── output.png │ ├── pause_FILL1_wght400_GRAD0_opsz15.svg │ ├── play_arrow_FILL1_wght400_GRAD0_opsz15.svg │ ├── power_settings_new_FILL1_wght400_GRAD0_opsz15.svg │ ├── restart_alt_FILL0_wght400_GRAD0_opsz15.svg │ └── skip_next_FILL1_wght400_GRAD0_opsz15.svg ├── step1.html ├── step2.html ├── step3.html ├── step4.html ├── step5.html ├── step6.html ├── step7.html └── step8.html └── version.txt /.gitignore: -------------------------------------------------------------------------------- 1 | # Prerequisites 2 | *.d 3 | 4 | /build 5 | 6 | *.bak 7 | 8 | # QMake User files 9 | *.pro.user* 10 | 11 | # Compiled Object files 12 | *.slo 13 | *.lo 14 | *.o 15 | *.obj 16 | 17 | # Precompiled Headers 18 | *.gch 19 | *.pch 20 | 21 | # Compiled Dynamic libraries 22 | *.so 23 | *.dylib 24 | *.dll 25 | 26 | # Fortran module files 27 | *.mod 28 | *.smod 29 | 30 | # Compiled Static libraries 31 | *.lai 32 | *.la 33 | *.a 34 | *.lib 35 | 36 | # Executables 37 | *.exe 38 | *.out 39 | *.app 40 | /.vscode/c_cpp_properties.json 41 | /installer 42 | /build_inc.bat 43 | /build.txt 44 | -------------------------------------------------------------------------------- /Components/ComplexLogic/Counter.h: -------------------------------------------------------------------------------- 1 | #ifndef COUNTER_H 2 | #define COUNTER_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The Counter class represents a synchronous logic counter 8 | /// 9 | class Counter : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for Counter 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | /// \param pBitWidth: The amount of output digits of the counter 17 | Counter(const CoreLogic* pCoreLogic, Direction pDirection, uint8_t pBitWidth); 18 | 19 | /// \brief Copy constructor for Counter 20 | /// \param pObj: The object to be copied 21 | /// \param pCoreLogic: Pointer to the core logic 22 | Counter(const Counter& pObj, const CoreLogic* pCoreLogic); 23 | 24 | /// \brief Constructor for loading from JSON 25 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 26 | /// \param pJson: The JSON object to load the component's data from 27 | Counter(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 28 | 29 | /// \brief Clone function for the component 30 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 31 | /// \return A pointer to the new component 32 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 33 | 34 | /// \brief Saves the dats of this component to the given JSON object 35 | /// \return The JSON object with the component data 36 | QJsonObject GetJson(void) const override; 37 | 38 | /// \brief Gets the minimum version compatible with this component 39 | /// \return the minimum version 40 | SwVersion GetMinVersion(void) const override; 41 | 42 | protected: 43 | uint8_t mBitWidth; 44 | }; 45 | 46 | #endif // COUNTER_H 47 | -------------------------------------------------------------------------------- /Components/ComplexLogic/DFlipFlop.cpp: -------------------------------------------------------------------------------- 1 | #include "DFlipFlop.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicDFlipFlopCell.h" 5 | 6 | DFlipFlop::DFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection): 7 | AbstractComplexLogic(pCoreLogic, std::make_shared(), 2, 2, pDirection) 8 | { 9 | mComponentText = components::complex_logic::D_FLIPFLOP_TEXT; 10 | mInputLabels = {"D", ">"}; 11 | mOutputLabels = {"Q", "Q̅"}; 12 | } 13 | 14 | DFlipFlop::DFlipFlop(const DFlipFlop& pObj, const CoreLogic* pCoreLogic): 15 | DFlipFlop(pCoreLogic, pObj.mDirection) 16 | { 17 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 18 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 19 | }; 20 | 21 | DFlipFlop::DFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 22 | DFlipFlop(pCoreLogic, static_cast(pJson["dir"].toInt())) 23 | { 24 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 25 | 26 | std::vector ininv, outinv; 27 | auto ininvArray = pJson["ininv"].toArray(); 28 | for (const auto& inv : ininvArray) 29 | { 30 | ininv.push_back(inv.toBool()); 31 | } 32 | GetLogicCell()->SetInputInversions(ininv); 33 | 34 | auto outinvArray = pJson["outinv"].toArray(); 35 | for (const auto& inv : outinvArray) 36 | { 37 | outinv.push_back(inv.toBool()); 38 | } 39 | GetLogicCell()->SetOutputInversions(outinv); 40 | } 41 | 42 | IBaseComponent* DFlipFlop::CloneBaseComponent(const CoreLogic* pCoreLogic) const 43 | { 44 | return new DFlipFlop(*this, pCoreLogic); 45 | } 46 | 47 | QJsonObject DFlipFlop::GetJson() const 48 | { 49 | QJsonObject json; 50 | 51 | json["type"] = file::ComponentId::D_FLIPFLOP; 52 | json["x"] = x(); 53 | json["y"] = y(); 54 | json["dir"] = static_cast(mDirection); 55 | { 56 | QJsonArray ininv, outinv; 57 | 58 | for(const bool& inv : mLogicCell->GetInputInversions()) 59 | { 60 | ininv.append(inv); 61 | } 62 | 63 | json["ininv"] = ininv; 64 | 65 | for(const bool& inv : mLogicCell->GetOutputInversions()) 66 | { 67 | outinv.append(inv); 68 | } 69 | 70 | json["outinv"] = outinv; 71 | } 72 | 73 | return json; 74 | } 75 | 76 | SwVersion DFlipFlop::GetMinVersion(void) const 77 | { 78 | return SwVersion(0, 0, 0); 79 | } 80 | -------------------------------------------------------------------------------- /Components/ComplexLogic/DFlipFlop.h: -------------------------------------------------------------------------------- 1 | #ifndef DFLIPFLOP_H 2 | #define DFLIPFLOP_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The DFlipFlop class represents a rising-edge-triggered D flip-flop 8 | /// 9 | class DFlipFlop : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for DFlipFlop 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | DFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for DFlipFlop 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | DFlipFlop(const DFlipFlop& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | DFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the component 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // DFLIPFLOP_H 43 | -------------------------------------------------------------------------------- /Components/ComplexLogic/DMsFlipFlop.cpp: -------------------------------------------------------------------------------- 1 | #include "DMsFlipFlop.h" 2 | #include "HelperFunctions.h" 3 | #include "LogicCells/LogicDMsFlipFlopCell.h" 4 | 5 | DMasterSlaveFlipFlop::DMasterSlaveFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection): 6 | AbstractComplexLogic(pCoreLogic, std::make_shared(), 2, 2, pDirection) 7 | { 8 | mComponentText = components::complex_logic::D_MS_FLIPFLOP_TEXT; 9 | mInputLabels = {"D", ">"}; 10 | mOutputLabels = {"Q", "Q̅"}; 11 | 12 | mDescriptionFontSize = 10; 13 | } 14 | 15 | DMasterSlaveFlipFlop::DMasterSlaveFlipFlop(const DMasterSlaveFlipFlop& pObj, const CoreLogic* pCoreLogic): 16 | DMasterSlaveFlipFlop(pCoreLogic, pObj.mDirection) 17 | { 18 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 19 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 20 | }; 21 | 22 | DMasterSlaveFlipFlop::DMasterSlaveFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 23 | DMasterSlaveFlipFlop(pCoreLogic, static_cast(pJson["dir"].toInt())) 24 | { 25 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 26 | 27 | std::vector ininv, outinv; 28 | auto ininvArray = pJson["ininv"].toArray(); 29 | for (const auto& inv : ininvArray) 30 | { 31 | ininv.push_back(inv.toBool()); 32 | } 33 | GetLogicCell()->SetInputInversions(ininv); 34 | 35 | auto outinvArray = pJson["outinv"].toArray(); 36 | for (const auto& inv : outinvArray) 37 | { 38 | outinv.push_back(inv.toBool()); 39 | } 40 | GetLogicCell()->SetOutputInversions(outinv); 41 | } 42 | 43 | IBaseComponent* DMasterSlaveFlipFlop::CloneBaseComponent(const CoreLogic* pCoreLogic) const 44 | { 45 | return new DMasterSlaveFlipFlop(*this, pCoreLogic); 46 | } 47 | 48 | QJsonObject DMasterSlaveFlipFlop::GetJson() const 49 | { 50 | QJsonObject json; 51 | 52 | json["type"] = file::ComponentId::D_MS_FLIPFLOP; 53 | json["x"] = x(); 54 | json["y"] = y(); 55 | json["dir"] = static_cast(mDirection); 56 | { 57 | QJsonArray ininv, outinv; 58 | 59 | for(const bool& inv : mLogicCell->GetInputInversions()) 60 | { 61 | ininv.append(inv); 62 | } 63 | 64 | json["ininv"] = ininv; 65 | 66 | for(const bool& inv : mLogicCell->GetOutputInversions()) 67 | { 68 | outinv.append(inv); 69 | } 70 | 71 | json["outinv"] = outinv; 72 | } 73 | 74 | return json; 75 | } 76 | 77 | SwVersion DMasterSlaveFlipFlop::GetMinVersion(void) const 78 | { 79 | return SwVersion(0, 9, 8); 80 | } 81 | -------------------------------------------------------------------------------- /Components/ComplexLogic/DMsFlipFlop.h: -------------------------------------------------------------------------------- 1 | #ifndef DMSFLIPFLOP_H 2 | #define DMSFLIPFLOP_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The DMasterSlaveFlipFlop class represents an D master-slave flip-flop 8 | /// 9 | class DMasterSlaveFlipFlop : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for DMasterSlaveFlipFlop 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | DMasterSlaveFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for DMasterSlaveFlipFlop 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | DMasterSlaveFlipFlop(const DMasterSlaveFlipFlop& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | DMasterSlaveFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the component 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // DMSFLIPFLOP_H 43 | -------------------------------------------------------------------------------- /Components/ComplexLogic/Decoder.h: -------------------------------------------------------------------------------- 1 | #ifndef DECODER_H 2 | #define DECODER_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The Decoder class represents a logic decoder 8 | /// 9 | class Decoder : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for Decoder 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | /// \param pInputCount: The amount of input digits for this decoder 17 | Decoder(const CoreLogic* pCoreLogic, Direction pDirection, uint8_t pInputCount); 18 | 19 | /// \brief Copy constructor for Decoder 20 | /// \param pObj: The object to be copied 21 | /// \param pCoreLogic: Pointer to the core logic 22 | Decoder(const Decoder& pObj, const CoreLogic* pCoreLogic); 23 | 24 | /// \brief Constructor for loading from JSON 25 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 26 | /// \param pJson: The JSON object to load the component's data from 27 | Decoder(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 28 | 29 | /// \brief Clone function for the component 30 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 31 | /// \return A pointer to the new component 32 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 33 | 34 | /// \brief Saves the dats of this component to the given JSON object 35 | /// \return The JSON object with the component data 36 | QJsonObject GetJson(void) const override; 37 | 38 | /// \brief Gets the minimum version compatible with this component 39 | /// \return the minimum version 40 | SwVersion GetMinVersion(void) const override; 41 | }; 42 | 43 | #endif // DECODER_H 44 | -------------------------------------------------------------------------------- /Components/ComplexLogic/Demultiplexer.h: -------------------------------------------------------------------------------- 1 | #ifndef DEMULTIPLEXER_H 2 | #define DEMULTIPLEXER_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The Demultiplexer class represents a logic demultiplexer 8 | /// 9 | class Demultiplexer : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for Demultiplexer 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | /// \param pBitWidth: The amount of input digits for this demultiplexer 17 | Demultiplexer(const CoreLogic* pCoreLogic, Direction pDirection, uint8_t pBitWidth); 18 | 19 | /// \brief Copy constructor for Demultiplexer 20 | /// \param pObj: The object to be copied 21 | /// \param pCoreLogic: Pointer to the core logic 22 | Demultiplexer(const Demultiplexer& pObj, const CoreLogic* pCoreLogic); 23 | 24 | /// \brief Constructor for loading from JSON 25 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 26 | /// \param pJson: The JSON object to load the component's data from 27 | Demultiplexer(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 28 | 29 | /// \brief Clone function for the component 30 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 31 | /// \return A pointer to the new component 32 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 33 | 34 | /// \brief Saves the dats of this component to the given JSON object 35 | /// \return The JSON object with the component data 36 | QJsonObject GetJson(void) const override; 37 | 38 | /// \brief Gets the minimum version compatible with this component 39 | /// \return the minimum version 40 | SwVersion GetMinVersion(void) const override; 41 | 42 | protected: 43 | uint8_t mBitWidth; 44 | }; 45 | 46 | #endif // DEMULTIPLEXER_H 47 | -------------------------------------------------------------------------------- /Components/ComplexLogic/Encoder.h: -------------------------------------------------------------------------------- 1 | #ifndef ENCODER_H 2 | #define ENCODER_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The Encoder class represents a logic encoder 8 | /// 9 | class Encoder : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for Encoder 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | /// \param pOutputCount: The amount of output digits for this encoder 17 | Encoder(const CoreLogic* pCoreLogic, Direction pDirection, uint8_t pOutputCount); 18 | 19 | /// \brief Copy constructor for Encoder 20 | /// \param pObj: The object to be copied 21 | /// \param pCoreLogic: Pointer to the core logic 22 | Encoder(const Encoder& pObj, const CoreLogic* pCoreLogic); 23 | 24 | /// \brief Constructor for loading from JSON 25 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 26 | /// \param pJson: The JSON object to load the component's data from 27 | Encoder(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 28 | 29 | /// \brief Clone function for the component 30 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 31 | /// \return A pointer to the new component 32 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 33 | 34 | /// \brief Saves the dats of this component to the given JSON object 35 | /// \return The JSON object with the component data 36 | QJsonObject GetJson(void) const override; 37 | 38 | /// \brief Gets the minimum version compatible with this component 39 | /// \return the minimum version 40 | SwVersion GetMinVersion(void) const override; 41 | }; 42 | 43 | #endif // ENCODER_H 44 | -------------------------------------------------------------------------------- /Components/ComplexLogic/FullAdder.cpp: -------------------------------------------------------------------------------- 1 | #include "FullAdder.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicFullAdderCell.h" 5 | 6 | FullAdder::FullAdder(const CoreLogic* pCoreLogic, Direction pDirection): 7 | AbstractComplexLogic(pCoreLogic, std::make_shared(), 3, 2, pDirection) 8 | { 9 | mComponentText = components::complex_logic::FULL_ADDER_TEXT; 10 | mInputLabels = {"", "", ""}; 11 | mOutputLabels = {"S", "C"}; 12 | } 13 | 14 | FullAdder::FullAdder(const FullAdder& pObj, const CoreLogic* pCoreLogic): 15 | FullAdder(pCoreLogic, pObj.mDirection) 16 | { 17 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 18 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 19 | }; 20 | 21 | FullAdder::FullAdder(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 22 | FullAdder(pCoreLogic, static_cast(pJson["dir"].toInt())) 23 | { 24 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 25 | 26 | std::vector ininv, outinv; 27 | auto ininvArray = pJson["ininv"].toArray(); 28 | for (const auto& inv : ininvArray) 29 | { 30 | ininv.push_back(inv.toBool()); 31 | } 32 | GetLogicCell()->SetInputInversions(ininv); 33 | 34 | auto outinvArray = pJson["outinv"].toArray(); 35 | for (const auto& inv : outinvArray) 36 | { 37 | outinv.push_back(inv.toBool()); 38 | } 39 | GetLogicCell()->SetOutputInversions(outinv); 40 | } 41 | 42 | IBaseComponent* FullAdder::CloneBaseComponent(const CoreLogic* pCoreLogic) const 43 | { 44 | return new FullAdder(*this, pCoreLogic); 45 | } 46 | 47 | QJsonObject FullAdder::GetJson() const 48 | { 49 | QJsonObject json; 50 | 51 | json["type"] = file::ComponentId::FULL_ADDER; 52 | json["x"] = x(); 53 | json["y"] = y(); 54 | json["dir"] = static_cast(mDirection); 55 | { 56 | QJsonArray ininv, outinv; 57 | 58 | for(const bool& inv : mLogicCell->GetInputInversions()) 59 | { 60 | ininv.append(inv); 61 | } 62 | 63 | json["ininv"] = ininv; 64 | 65 | for(const bool& inv : mLogicCell->GetOutputInversions()) 66 | { 67 | outinv.append(inv); 68 | } 69 | 70 | json["outinv"] = outinv; 71 | } 72 | 73 | return json; 74 | } 75 | 76 | SwVersion FullAdder::GetMinVersion(void) const 77 | { 78 | return SwVersion(0, 0, 0); 79 | } 80 | -------------------------------------------------------------------------------- /Components/ComplexLogic/FullAdder.h: -------------------------------------------------------------------------------- 1 | #ifndef FULLADDER_H 2 | #define FULLADDER_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The FullAdder class represents a full-adder component 8 | /// 9 | class FullAdder : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for FullAdder 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | FullAdder(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for FullAdder 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | FullAdder(const FullAdder& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | FullAdder(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the component 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // FULLADDER_H 43 | -------------------------------------------------------------------------------- /Components/ComplexLogic/HalfAdder.cpp: -------------------------------------------------------------------------------- 1 | #include "HalfAdder.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicHalfAdderCell.h" 5 | 6 | HalfAdder::HalfAdder(const CoreLogic* pCoreLogic, Direction pDirection): 7 | AbstractComplexLogic(pCoreLogic, std::make_shared(), 2, 2, pDirection) 8 | { 9 | mComponentText = components::complex_logic::HALF_ADDER_TEXT; 10 | mInputLabels = {"", ""}; 11 | mOutputLabels = {"S", "C"}; 12 | } 13 | 14 | HalfAdder::HalfAdder(const HalfAdder& pObj, const CoreLogic* pCoreLogic): 15 | HalfAdder(pCoreLogic, pObj.mDirection) 16 | { 17 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 18 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 19 | }; 20 | 21 | HalfAdder::HalfAdder(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 22 | HalfAdder(pCoreLogic, static_cast(pJson["dir"].toInt())) 23 | { 24 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 25 | 26 | std::vector ininv, outinv; 27 | auto ininvArray = pJson["ininv"].toArray(); 28 | for (const auto& inv : ininvArray) 29 | { 30 | ininv.push_back(inv.toBool()); 31 | } 32 | GetLogicCell()->SetInputInversions(ininv); 33 | 34 | auto outinvArray = pJson["outinv"].toArray(); 35 | for (const auto& inv : outinvArray) 36 | { 37 | outinv.push_back(inv.toBool()); 38 | } 39 | GetLogicCell()->SetOutputInversions(outinv); 40 | } 41 | 42 | IBaseComponent* HalfAdder::CloneBaseComponent(const CoreLogic* pCoreLogic) const 43 | { 44 | return new HalfAdder(*this, pCoreLogic); 45 | } 46 | 47 | QJsonObject HalfAdder::GetJson() const 48 | { 49 | QJsonObject json; 50 | 51 | json["type"] = file::ComponentId::HALF_ADDER; 52 | json["x"] = x(); 53 | json["y"] = y(); 54 | json["dir"] = static_cast(mDirection); 55 | { 56 | QJsonArray ininv, outinv; 57 | 58 | for(const bool& inv : mLogicCell->GetInputInversions()) 59 | { 60 | ininv.append(inv); 61 | } 62 | 63 | json["ininv"] = ininv; 64 | 65 | for(const bool& inv : mLogicCell->GetOutputInversions()) 66 | { 67 | outinv.append(inv); 68 | } 69 | 70 | json["outinv"] = outinv; 71 | } 72 | 73 | return json; 74 | } 75 | 76 | SwVersion HalfAdder::GetMinVersion(void) const 77 | { 78 | return SwVersion(0, 0, 0); 79 | } 80 | -------------------------------------------------------------------------------- /Components/ComplexLogic/HalfAdder.h: -------------------------------------------------------------------------------- 1 | #ifndef HALFADDER_H 2 | #define HALFADDER_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The HalfAdder class represents a half-adder component 8 | /// 9 | class HalfAdder : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for HalfAdder 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | HalfAdder(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for HalfAdder 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | HalfAdder(const HalfAdder& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | HalfAdder(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the component 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // HALFADDER_H 43 | -------------------------------------------------------------------------------- /Components/ComplexLogic/JKFlipFlop.cpp: -------------------------------------------------------------------------------- 1 | #include "JKFlipFlop.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicJKFlipFlopCell.h" 5 | 6 | JKFlipFlop::JKFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection): 7 | AbstractComplexLogic(pCoreLogic, std::make_shared(), 3, 2, pDirection) 8 | { 9 | mComponentText = components::complex_logic::JK_FLIPFLOP_TEXT; 10 | mInputLabels = {"J", ">", "K"}; 11 | mOutputLabels = {"Q", "Q̅"}; 12 | } 13 | 14 | JKFlipFlop::JKFlipFlop(const JKFlipFlop& pObj, const CoreLogic* pCoreLogic): 15 | JKFlipFlop(pCoreLogic, pObj.mDirection) 16 | { 17 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 18 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 19 | }; 20 | 21 | JKFlipFlop::JKFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 22 | JKFlipFlop(pCoreLogic, static_cast(pJson["dir"].toInt())) 23 | { 24 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 25 | 26 | std::vector ininv, outinv; 27 | auto ininvArray = pJson["ininv"].toArray(); 28 | for (const auto& inv : ininvArray) 29 | { 30 | ininv.push_back(inv.toBool()); 31 | } 32 | GetLogicCell()->SetInputInversions(ininv); 33 | 34 | auto outinvArray = pJson["outinv"].toArray(); 35 | for (const auto& inv : outinvArray) 36 | { 37 | outinv.push_back(inv.toBool()); 38 | } 39 | GetLogicCell()->SetOutputInversions(outinv); 40 | } 41 | 42 | IBaseComponent* JKFlipFlop::CloneBaseComponent(const CoreLogic* pCoreLogic) const 43 | { 44 | return new JKFlipFlop(*this, pCoreLogic); 45 | } 46 | 47 | QJsonObject JKFlipFlop::GetJson() const 48 | { 49 | QJsonObject json; 50 | 51 | json["type"] = file::ComponentId::JK_FLIPFLOP; 52 | json["x"] = x(); 53 | json["y"] = y(); 54 | json["dir"] = static_cast(mDirection); 55 | { 56 | QJsonArray ininv, outinv; 57 | 58 | for(const bool& inv : mLogicCell->GetInputInversions()) 59 | { 60 | ininv.append(inv); 61 | } 62 | 63 | json["ininv"] = ininv; 64 | 65 | for(const bool& inv : mLogicCell->GetOutputInversions()) 66 | { 67 | outinv.append(inv); 68 | } 69 | 70 | json["outinv"] = outinv; 71 | } 72 | 73 | return json; 74 | } 75 | 76 | SwVersion JKFlipFlop::GetMinVersion(void) const 77 | { 78 | return SwVersion(0, 0, 0); 79 | } 80 | -------------------------------------------------------------------------------- /Components/ComplexLogic/JKFlipFlop.h: -------------------------------------------------------------------------------- 1 | #ifndef JKFLIPFLOP_H 2 | #define JKFLIPFLOP_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The JKFlipFlop class represents a rising-edge-triggered JK flip-flop 8 | /// 9 | class JKFlipFlop : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for JKFlipFlop 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | JKFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for JKFlipFlop 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | JKFlipFlop(const JKFlipFlop& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | JKFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the component 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // JKFLIPFLOP_H 43 | -------------------------------------------------------------------------------- /Components/ComplexLogic/JkMsFlipFlop.cpp: -------------------------------------------------------------------------------- 1 | #include "JkMsFlipFlop.h" 2 | #include "HelperFunctions.h" 3 | #include "LogicCells/LogicJkMsFlipFlopCell.h" 4 | 5 | JkMasterSlaveFlipFlop::JkMasterSlaveFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection): 6 | AbstractComplexLogic(pCoreLogic, std::make_shared(), 3, 2, pDirection) 7 | { 8 | mComponentText = components::complex_logic::JK_MS_FLIPFLOP_TEXT; 9 | mInputLabels = {"J", ">", "K"}; 10 | mOutputLabels = {"Q", "Q̅"}; 11 | 12 | mDescriptionFontSize = 10; 13 | } 14 | 15 | JkMasterSlaveFlipFlop::JkMasterSlaveFlipFlop(const JkMasterSlaveFlipFlop& pObj, const CoreLogic* pCoreLogic): 16 | JkMasterSlaveFlipFlop(pCoreLogic, pObj.mDirection) 17 | { 18 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 19 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 20 | }; 21 | 22 | JkMasterSlaveFlipFlop::JkMasterSlaveFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 23 | JkMasterSlaveFlipFlop(pCoreLogic, static_cast(pJson["dir"].toInt())) 24 | { 25 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 26 | 27 | std::vector ininv, outinv; 28 | auto ininvArray = pJson["ininv"].toArray(); 29 | for (const auto& inv : ininvArray) 30 | { 31 | ininv.push_back(inv.toBool()); 32 | } 33 | GetLogicCell()->SetInputInversions(ininv); 34 | 35 | auto outinvArray = pJson["outinv"].toArray(); 36 | for (const auto& inv : outinvArray) 37 | { 38 | outinv.push_back(inv.toBool()); 39 | } 40 | GetLogicCell()->SetOutputInversions(outinv); 41 | } 42 | 43 | IBaseComponent* JkMasterSlaveFlipFlop::CloneBaseComponent(const CoreLogic* pCoreLogic) const 44 | { 45 | return new JkMasterSlaveFlipFlop(*this, pCoreLogic); 46 | } 47 | 48 | QJsonObject JkMasterSlaveFlipFlop::GetJson() const 49 | { 50 | QJsonObject json; 51 | 52 | json["type"] = file::ComponentId::JK_MS_FLIPFLOP; 53 | json["x"] = x(); 54 | json["y"] = y(); 55 | json["dir"] = static_cast(mDirection); 56 | { 57 | QJsonArray ininv, outinv; 58 | 59 | for(const bool& inv : mLogicCell->GetInputInversions()) 60 | { 61 | ininv.append(inv); 62 | } 63 | 64 | json["ininv"] = ininv; 65 | 66 | for(const bool& inv : mLogicCell->GetOutputInversions()) 67 | { 68 | outinv.append(inv); 69 | } 70 | 71 | json["outinv"] = outinv; 72 | } 73 | 74 | return json; 75 | } 76 | 77 | SwVersion JkMasterSlaveFlipFlop::GetMinVersion(void) const 78 | { 79 | return SwVersion(0, 9, 8); 80 | } 81 | -------------------------------------------------------------------------------- /Components/ComplexLogic/JkMsFlipFlop.h: -------------------------------------------------------------------------------- 1 | #ifndef JKMSFLIPFLOP_H 2 | #define JKMSFLIPFLOP_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The JkMasterSlaveFlipFlop class represents an JK master-slave flip-flop 8 | /// 9 | class JkMasterSlaveFlipFlop : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for JkMasterSlaveFlipFlop 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | JkMasterSlaveFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for JkMasterSlaveFlipFlop 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | JkMasterSlaveFlipFlop(const JkMasterSlaveFlipFlop& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | JkMasterSlaveFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the component 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // JKMSFLIPFLOP_H 43 | -------------------------------------------------------------------------------- /Components/ComplexLogic/LogicCells/LogicDFlipFlopCell.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LogicDFlipFlopCell.h 3 | * \brief Logic Cell class for the D Flip-Flop 4 | * \author Simon Buchholz 5 | * \copyright Copyright (c) 2023, Simon Buchholz 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef LOGICDFLIPFLOPCELL_H 27 | #define LOGICDFLIPFLOPCELL_H 28 | 29 | #include "Components/LogicBaseCell.h" 30 | 31 | /// 32 | /// \brief Logic Cell class for the D Flip-Flop 33 | /// 34 | class LogicDFlipFlopCell : public LogicBaseCell 35 | { 36 | Q_OBJECT 37 | public: 38 | /// \brief Constructor for the D flip-flop logic cell 39 | LogicDFlipFlopCell(void); 40 | 41 | /// \brief The logic function that determines the output states based on the inputs 42 | void LogicFunction(void) override; 43 | 44 | /// \brief Getter for the current output state number pOutput of this cell 45 | /// \param pOutput: The number of the output to retreive 46 | /// \return The logic state of this cell's output number pOutput 47 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 48 | 49 | public slots: 50 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 51 | void OnShutdown(void) override; 52 | 53 | /// \brief Initializes the logic cell's states and triggers a component repaint 54 | void OnWakeUp(void) override; 55 | 56 | protected: 57 | std::vector mPrevInputStates; 58 | }; 59 | 60 | #endif // LOGICDFLIPFLOPCELL_H 61 | -------------------------------------------------------------------------------- /Components/ComplexLogic/LogicCells/LogicDecoderCell.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LogicDecoderCell.h 3 | * \brief Logic Cell class for the decoder 4 | * \author Simon Buchholz 5 | * \copyright Copyright (c) 2023, Simon Buchholz 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef LOGICDECODERCELL_H 27 | #define LOGICDECODERCELL_H 28 | 29 | #include "Components/LogicBaseCell.h" 30 | 31 | /// 32 | /// \brief Logic Cell class for the decoder 33 | /// 34 | class LogicDecoderCell : public LogicBaseCell 35 | { 36 | Q_OBJECT 37 | public: 38 | /// \brief Constructor for the decoder cell 39 | /// \param pInputCount: The amount of inputs for this decoder 40 | LogicDecoderCell(uint8_t pInputCount); 41 | 42 | /// \brief The logic function that determines the output states based on the inputs 43 | void LogicFunction(void) override; 44 | 45 | /// \brief Getter for the current output state number pOutput of this cell 46 | /// \param pOutput: The number of the output to retreive 47 | /// \return The logic state of this cell's output number pOutput 48 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 49 | 50 | public slots: 51 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 52 | void OnShutdown(void) override; 53 | 54 | /// \brief Initializes the logic cell's states and triggers a component repaint 55 | void OnWakeUp(void) override; 56 | 57 | protected: 58 | uint8_t mInputCount; 59 | uint8_t mPreviousValue; 60 | }; 61 | 62 | #endif // LOGICDECODERCELL_H 63 | -------------------------------------------------------------------------------- /Components/ComplexLogic/LogicCells/LogicEncoderCell.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LogicEncoderCell.h 3 | * \brief Logic Cell class for the encoder 4 | * \author Simon Buchholz 5 | * \copyright Copyright (c) 2023, Simon Buchholz 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef LOGICENCODERCELL_H 27 | #define LOGICENCODERCELL_H 28 | 29 | #include "Components/LogicBaseCell.h" 30 | 31 | /// 32 | /// \brief Logic Cell class for the encoder 33 | /// 34 | class LogicEncoderCell : public LogicBaseCell 35 | { 36 | Q_OBJECT 37 | public: 38 | /// \brief Constructor for the encoder cell 39 | /// \param pInputCount: The amount of outputs for this encoder 40 | LogicEncoderCell(uint8_t pOutputCount); 41 | 42 | /// \brief The logic function that determines the output states based on the inputs 43 | void LogicFunction(void) override; 44 | 45 | /// \brief Getter for the current output state number pOutput of this cell 46 | /// \param pOutput: The number of the output to retreive 47 | /// \return The logic state of this cell's output number pOutput 48 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 49 | 50 | public slots: 51 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 52 | void OnShutdown(void) override; 53 | 54 | /// \brief Initializes the logic cell's states and triggers a component repaint 55 | void OnWakeUp(void) override; 56 | 57 | protected: 58 | uint8_t mOutputCount; 59 | int8_t mPreviousValue; 60 | }; 61 | 62 | #endif // LOGICENCODERCELL_H 63 | -------------------------------------------------------------------------------- /Components/ComplexLogic/LogicCells/LogicFullAdderCell.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LogicFullAdderCell.h 3 | * \brief Logic Cell class for the full-adder 4 | * \author Simon Buchholz 5 | * \copyright Copyright (c) 2023, Simon Buchholz 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef LOGICFULLADDERCELL_H 27 | #define LOGICFULLADDERCELL_H 28 | 29 | #include "Components/LogicBaseCell.h" 30 | 31 | /// 32 | /// \brief Logic Cell class for the full-adder 33 | /// 34 | class LogicFullAdderCell : public LogicBaseCell 35 | { 36 | Q_OBJECT 37 | public: 38 | /// \brief Constructor for the full-adder logic cell 39 | LogicFullAdderCell(void); 40 | 41 | /// \brief The logic function that determines the output states based on the inputs 42 | void LogicFunction(void) override; 43 | 44 | /// \brief Getter for the current output state number pOutput of this cell 45 | /// \param pOutput: The number of the output to retreive 46 | /// \return The logic state of this cell's output number pOutput 47 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 48 | 49 | public slots: 50 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 51 | void OnShutdown(void) override; 52 | 53 | /// \brief Initializes the logic cell's states and triggers a component repaint 54 | void OnWakeUp(void) override; 55 | }; 56 | 57 | #endif // LOGICFULLADDERCELL_H 58 | -------------------------------------------------------------------------------- /Components/ComplexLogic/LogicCells/LogicHalfAdderCell.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LogicHalfAdderCell.h 3 | * \brief Logic Cell class for the half-adder 4 | * \author Simon Buchholz 5 | * \copyright Copyright (c) 2023, Simon Buchholz 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef LOGICHALFADDERCELL_H 27 | #define LOGICHALFADDERCELL_H 28 | 29 | #include "Components/LogicBaseCell.h" 30 | 31 | /// 32 | /// \brief Logic Cell class for the half-adder 33 | /// 34 | class LogicHalfAdderCell : public LogicBaseCell 35 | { 36 | Q_OBJECT 37 | public: 38 | /// \brief Constructor for the half-adder logic cell 39 | LogicHalfAdderCell(void); 40 | 41 | /// \brief The logic function that determines the output states based on the inputs 42 | void LogicFunction(void) override; 43 | 44 | /// \brief Getter for the current output state number pOutput of this cell 45 | /// \param pOutput: The number of the output to retreive 46 | /// \return The logic state of this cell's output number pOutput 47 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 48 | 49 | public slots: 50 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 51 | void OnShutdown(void) override; 52 | 53 | /// \brief Initializes the logic cell's states and triggers a component repaint 54 | void OnWakeUp(void) override; 55 | }; 56 | 57 | #endif // LOGICHALFADDERCELL_H 58 | -------------------------------------------------------------------------------- /Components/ComplexLogic/LogicCells/LogicJKFlipFlopCell.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LogicJKFlipFlopCell.h 3 | * \brief Logic Cell class for the JK Flip-Flop 4 | * \author Simon Buchholz 5 | * \copyright Copyright (c) 2023, Simon Buchholz 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef LOGICJKFLIPFLOPCELL_H 27 | #define LOGICJKFLIPFLOPCELL_H 28 | 29 | #include "Components/LogicBaseCell.h" 30 | 31 | /// 32 | /// \brief Logic Cell class for the JK Flip-Flop 33 | /// 34 | class LogicJKFlipFlopCell : public LogicBaseCell 35 | { 36 | Q_OBJECT 37 | public: 38 | /// \brief Constructor for the JK flip-flop logic cell 39 | LogicJKFlipFlopCell(void); 40 | 41 | /// \brief The logic function that determines the output states based on the inputs 42 | void LogicFunction(void) override; 43 | 44 | /// \brief Getter for the current output state number pOutput of this cell 45 | /// \param pOutput: The number of the output to retreive 46 | /// \return The logic state of this cell's output number pOutput 47 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 48 | 49 | public slots: 50 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 51 | void OnShutdown(void) override; 52 | 53 | /// \brief Initializes the logic cell's states and triggers a component repaint 54 | void OnWakeUp(void) override; 55 | 56 | protected: 57 | std::vector mPrevInputStates; 58 | }; 59 | 60 | #endif // LOGICJKFLIPFLOPCELL_H 61 | -------------------------------------------------------------------------------- /Components/ComplexLogic/LogicCells/LogicMultiplexerCell.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LogicMultiplexerCell.h 3 | * \brief Logic Cell class for the multiplexer 4 | * \author Simon Buchholz 5 | * \copyright Copyright (c) 2023, Simon Buchholz 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef LOGICMULTIPLEXERCELL_H 27 | #define LOGICMULTIPLEXERCELL_H 28 | 29 | #include "Components/LogicBaseCell.h" 30 | 31 | /// 32 | /// \brief Logic Cell class for the multiplexer 33 | /// 34 | class LogicMultiplexerCell : public LogicBaseCell 35 | { 36 | Q_OBJECT 37 | public: 38 | /// \brief Constructor for the multiplexer cell 39 | /// \param pDigitCount: The amount of input digits for this multiplexer 40 | LogicMultiplexerCell(uint8_t pDigitCount); 41 | 42 | /// \brief The logic function that determines the output states based on the inputs 43 | void LogicFunction(void) override; 44 | 45 | /// \brief Getter for the current output state number pOutput of this cell 46 | /// \param pOutput: The number of the output to retreive 47 | /// \return The logic state of this cell's output number pOutput 48 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 49 | 50 | public slots: 51 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 52 | void OnShutdown(void) override; 53 | 54 | /// \brief Initializes the logic cell's states and triggers a component repaint 55 | void OnWakeUp(void) override; 56 | 57 | protected: 58 | uint8_t mDigitCount; 59 | }; 60 | 61 | #endif // LOGICMULTIPLEXERCELL_H 62 | -------------------------------------------------------------------------------- /Components/ComplexLogic/LogicCells/LogicRsClockedFlipFlopCell.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LogicRsClockedFlipFlopCell.h 3 | * \brief Logic Cell class for the clocked RS Flip-Flop 4 | * \author Simon Buchholz 5 | * \copyright Copyright (c) 2023, Simon Buchholz 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef LOGICRSCLOCKEDFLIPFLOPCELL_H 27 | #define LOGICRSCLOCKEDFLIPFLOPCELL_H 28 | 29 | #include "Components/LogicBaseCell.h" 30 | 31 | /// 32 | /// \brief Logic Cell class for the clocked RS Flip-Flop 33 | /// 34 | class LogicRsClockedFlipFlopCell : public LogicBaseCell 35 | { 36 | Q_OBJECT 37 | public: 38 | /// \brief Constructor for the clocked RS flip-flop logic cell 39 | LogicRsClockedFlipFlopCell(void); 40 | 41 | /// \brief The logic function that determines the output states based on the inputs 42 | void LogicFunction(void) override; 43 | 44 | /// \brief Getter for the current output state number pOutput of this cell 45 | /// \param pOutput: The number of the output to retreive 46 | /// \return The logic state of this cell's output number pOutput 47 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 48 | 49 | public slots: 50 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 51 | void OnShutdown(void) override; 52 | 53 | /// \brief Initializes the logic cell's states and triggers a component repaint 54 | void OnWakeUp(void) override; 55 | 56 | protected: 57 | std::vector mPrevInputStates; 58 | }; 59 | 60 | #endif // LOGICRSCLOCKEDFLIPFLOPCELL_H 61 | -------------------------------------------------------------------------------- /Components/ComplexLogic/LogicCells/LogicRsFlipFlopCell.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LogicRsFlipFlopCell.h 3 | * \brief Logic Cell class for the RS Flip-Flop 4 | * \author Simon Buchholz 5 | * \copyright Copyright (c) 2023, Simon Buchholz 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef LOGICRSFLIPFLOPCELL_H 27 | #define LOGICRSFLIPFLOPCELL_H 28 | 29 | #include "Components/LogicBaseCell.h" 30 | 31 | /// 32 | /// \brief Logic Cell class for the RS Flip-Flop 33 | /// 34 | class LogicRsFlipFlopCell : public LogicBaseCell 35 | { 36 | Q_OBJECT 37 | public: 38 | /// \brief Constructor for the RS flip-flop logic cell 39 | LogicRsFlipFlopCell(void); 40 | 41 | /// \brief The logic function that determines the output states based on the inputs 42 | void LogicFunction(void) override; 43 | 44 | /// \brief Getter for the current output state number pOutput of this cell 45 | /// \param pOutput: The number of the output to retreive 46 | /// \return The logic state of this cell's output number pOutput 47 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 48 | 49 | public slots: 50 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 51 | void OnShutdown(void) override; 52 | 53 | /// \brief Initializes the logic cell's states and triggers a component repaint 54 | void OnWakeUp(void) override; 55 | }; 56 | 57 | #endif // LOGICRSFLIPFLOPCELL_H 58 | -------------------------------------------------------------------------------- /Components/ComplexLogic/LogicCells/LogicTFlipFlopCell.h: -------------------------------------------------------------------------------- 1 | /*! 2 | * \file LogicTFlipFlopCell.h 3 | * \brief Logic Cell class for the T Flip-Flop 4 | * \author Simon Buchholz 5 | * \copyright Copyright (c) 2023, Simon Buchholz 6 | * 7 | * Permission is hereby granted, free of charge, to any person obtaining a copy 8 | * of this software and associated documentation files (the "Software"), to deal 9 | * in the Software without restriction, including without limitation the rights 10 | * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 11 | * copies of the Software, and to permit persons to whom the Software is 12 | * furnished to do so, subject to the following conditions: 13 | * 14 | * The above copyright notice and this permission notice shall be included in all 15 | * copies or substantial portions of the Software. 16 | * 17 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 18 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 19 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 20 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 21 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 22 | * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 23 | * SOFTWARE. 24 | */ 25 | 26 | #ifndef LOGICTFLIPFLOPCELL_H 27 | #define LOGICTFLIPFLOPCELL_H 28 | 29 | #include "Components/LogicBaseCell.h" 30 | 31 | /// 32 | /// \brief Logic Cell class for the T Flip-Flop 33 | /// 34 | class LogicTFlipFlopCell : public LogicBaseCell 35 | { 36 | Q_OBJECT 37 | public: 38 | /// \brief Constructor for the T flip-flop logic cell 39 | LogicTFlipFlopCell(void); 40 | 41 | /// \brief The logic function that determines the output states based on the inputs 42 | void LogicFunction(void) override; 43 | 44 | /// \brief Getter for the current output state number pOutput of this cell 45 | /// \param pOutput: The number of the output to retreive 46 | /// \return The logic state of this cell's output number pOutput 47 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 48 | 49 | public slots: 50 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 51 | void OnShutdown(void) override; 52 | 53 | /// \brief Initializes the logic cell's states and triggers a component repaint 54 | void OnWakeUp(void) override; 55 | 56 | protected: 57 | std::vector mPrevInputStates; 58 | }; 59 | 60 | #endif // LOGICTFLIPFLOPCELL_H 61 | -------------------------------------------------------------------------------- /Components/ComplexLogic/Multiplexer.h: -------------------------------------------------------------------------------- 1 | #ifndef MULTIPLEXER_H 2 | #define MULTIPLEXER_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The Multiplexer class represents a logic multiplexer 8 | /// 9 | class Multiplexer : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for Multiplexer 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | /// \param pBitWidth: The amount of input digits for this multiplexer 17 | Multiplexer(const CoreLogic* pCoreLogic, Direction pDirection, uint8_t pBitWidth); 18 | 19 | /// \brief Copy constructor for Multiplexer 20 | /// \param pObj: The object to be copied 21 | /// \param pCoreLogic: Pointer to the core logic 22 | Multiplexer(const Multiplexer& pObj, const CoreLogic* pCoreLogic); 23 | 24 | /// \brief Constructor for loading from JSON 25 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 26 | /// \param pJson: The JSON object to load the component's data from 27 | Multiplexer(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 28 | 29 | /// \brief Clone function for the component 30 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 31 | /// \return A pointer to the new component 32 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 33 | 34 | /// \brief Saves the dats of this component to the given JSON object 35 | /// \return The JSON object with the component data 36 | QJsonObject GetJson(void) const override; 37 | 38 | /// \brief Gets the minimum version compatible with this component 39 | /// \return the minimum version 40 | SwVersion GetMinVersion(void) const override; 41 | 42 | protected: 43 | uint8_t mBitWidth; 44 | }; 45 | 46 | #endif // MULTIPLEXER_H 47 | -------------------------------------------------------------------------------- /Components/ComplexLogic/RsClockedFlipFlop.cpp: -------------------------------------------------------------------------------- 1 | #include "RsClockedFlipFlop.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicRsClockedFlipFlopCell.h" 5 | 6 | RsClockedFlipFlop::RsClockedFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection): 7 | AbstractComplexLogic(pCoreLogic, std::make_shared(), 3, 2, pDirection) 8 | { 9 | mComponentText = components::complex_logic::RS_FLIPFLOP_TEXT; 10 | mInputLabels = {"S", ">", "R"}; 11 | mOutputLabels = {"Q", "Q̅"}; 12 | } 13 | 14 | RsClockedFlipFlop::RsClockedFlipFlop(const RsClockedFlipFlop& pObj, const CoreLogic* pCoreLogic): 15 | RsClockedFlipFlop(pCoreLogic, pObj.mDirection) 16 | { 17 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 18 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 19 | }; 20 | 21 | RsClockedFlipFlop::RsClockedFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 22 | RsClockedFlipFlop(pCoreLogic, static_cast(pJson["dir"].toInt())) 23 | { 24 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 25 | 26 | std::vector ininv, outinv; 27 | auto ininvArray = pJson["ininv"].toArray(); 28 | for (const auto& inv : ininvArray) 29 | { 30 | ininv.push_back(inv.toBool()); 31 | } 32 | GetLogicCell()->SetInputInversions(ininv); 33 | 34 | auto outinvArray = pJson["outinv"].toArray(); 35 | for (const auto& inv : outinvArray) 36 | { 37 | outinv.push_back(inv.toBool()); 38 | } 39 | GetLogicCell()->SetOutputInversions(outinv); 40 | } 41 | 42 | IBaseComponent* RsClockedFlipFlop::CloneBaseComponent(const CoreLogic* pCoreLogic) const 43 | { 44 | return new RsClockedFlipFlop(*this, pCoreLogic); 45 | } 46 | 47 | QJsonObject RsClockedFlipFlop::GetJson() const 48 | { 49 | QJsonObject json; 50 | 51 | json["type"] = file::ComponentId::RS_CLOCKED_FLIPFLOP; 52 | json["x"] = x(); 53 | json["y"] = y(); 54 | json["dir"] = static_cast(mDirection); 55 | { 56 | QJsonArray ininv, outinv; 57 | 58 | for(const bool& inv : mLogicCell->GetInputInversions()) 59 | { 60 | ininv.append(inv); 61 | } 62 | 63 | json["ininv"] = ininv; 64 | 65 | for(const bool& inv : mLogicCell->GetOutputInversions()) 66 | { 67 | outinv.append(inv); 68 | } 69 | 70 | json["outinv"] = outinv; 71 | } 72 | 73 | return json; 74 | } 75 | 76 | SwVersion RsClockedFlipFlop::GetMinVersion(void) const 77 | { 78 | return SwVersion(0, 9, 7); 79 | } 80 | -------------------------------------------------------------------------------- /Components/ComplexLogic/RsClockedFlipFlop.h: -------------------------------------------------------------------------------- 1 | #ifndef RSCLOCKEDFLIPFLOP_H 2 | #define RSCLOCKEDFLIPFLOP_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The RsClockedFlipFlop class represents a rising-edge-triggered clocked RS flip-flop 8 | /// 9 | class RsClockedFlipFlop : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for RsClockedFlipFlop 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | RsClockedFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for RsClockedFlipFlop 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | RsClockedFlipFlop(const RsClockedFlipFlop& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | RsClockedFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the component 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // RSCLOCKEDFLIPFLOP_H 43 | -------------------------------------------------------------------------------- /Components/ComplexLogic/RsFlipFlop.cpp: -------------------------------------------------------------------------------- 1 | #include "RsFlipFlop.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicRsFlipFlopCell.h" 5 | 6 | RsFlipFlop::RsFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection): 7 | AbstractComplexLogic(pCoreLogic, std::make_shared(), 2, 2, pDirection) 8 | { 9 | mComponentText = components::complex_logic::RS_FLIPFLOP_TEXT; 10 | mInputLabels = {"S", "R"}; 11 | mOutputLabels = {"Q", "Q̅"}; 12 | } 13 | 14 | RsFlipFlop::RsFlipFlop(const RsFlipFlop& pObj, const CoreLogic* pCoreLogic): 15 | RsFlipFlop(pCoreLogic, pObj.mDirection) 16 | { 17 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 18 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 19 | }; 20 | 21 | RsFlipFlop::RsFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 22 | RsFlipFlop(pCoreLogic, static_cast(pJson["dir"].toInt())) 23 | { 24 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 25 | 26 | std::vector ininv, outinv; 27 | auto ininvArray = pJson["ininv"].toArray(); 28 | for (const auto& inv : ininvArray) 29 | { 30 | ininv.push_back(inv.toBool()); 31 | } 32 | GetLogicCell()->SetInputInversions(ininv); 33 | 34 | auto outinvArray = pJson["outinv"].toArray(); 35 | for (const auto& inv : outinvArray) 36 | { 37 | outinv.push_back(inv.toBool()); 38 | } 39 | GetLogicCell()->SetOutputInversions(outinv); 40 | } 41 | 42 | IBaseComponent* RsFlipFlop::CloneBaseComponent(const CoreLogic* pCoreLogic) const 43 | { 44 | return new RsFlipFlop(*this, pCoreLogic); 45 | } 46 | 47 | QJsonObject RsFlipFlop::GetJson() const 48 | { 49 | QJsonObject json; 50 | 51 | json["type"] = file::ComponentId::RS_FLIPFLOP; 52 | json["x"] = x(); 53 | json["y"] = y(); 54 | json["dir"] = static_cast(mDirection); 55 | { 56 | QJsonArray ininv, outinv; 57 | 58 | for(const bool& inv : mLogicCell->GetInputInversions()) 59 | { 60 | ininv.append(inv); 61 | } 62 | 63 | json["ininv"] = ininv; 64 | 65 | for(const bool& inv : mLogicCell->GetOutputInversions()) 66 | { 67 | outinv.append(inv); 68 | } 69 | 70 | json["outinv"] = outinv; 71 | } 72 | 73 | return json; 74 | } 75 | 76 | SwVersion RsFlipFlop::GetMinVersion(void) const 77 | { 78 | return SwVersion(0, 0, 0); 79 | } 80 | -------------------------------------------------------------------------------- /Components/ComplexLogic/RsFlipFlop.h: -------------------------------------------------------------------------------- 1 | #ifndef RSFLIPFLOP_H 2 | #define RSFLIPFLOP_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The RsFlipFlop class represents an unclocked level-triggered RS flip-flop 8 | /// 9 | class RsFlipFlop : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for RsFlipFlop 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | RsFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for RsFlipFlop 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | RsFlipFlop(const RsFlipFlop& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | RsFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the component 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // RSFLIPFLOP_H 43 | -------------------------------------------------------------------------------- /Components/ComplexLogic/RsMsFlipFlop.h: -------------------------------------------------------------------------------- 1 | #ifndef RSMSFLIPFLOP_H 2 | #define RSMSFLIPFLOP_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The RsMasterSlaveFlipFlop class represents an RS master-slave flip-flop 8 | /// 9 | class RsMasterSlaveFlipFlop : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for RsMasterSlaveFlipFlop 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | RsMasterSlaveFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for RsMasterSlaveFlipFlop 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | RsMasterSlaveFlipFlop(const RsMasterSlaveFlipFlop& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | RsMasterSlaveFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the component 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // RSMSFLIPFLOP_H 43 | -------------------------------------------------------------------------------- /Components/ComplexLogic/TFlipFlop.cpp: -------------------------------------------------------------------------------- 1 | #include "TFlipFlop.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicTFlipFlopCell.h" 5 | 6 | TFlipFlop::TFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection): 7 | AbstractComplexLogic(pCoreLogic, std::make_shared(), 2, 2, pDirection) 8 | { 9 | mComponentText = components::complex_logic::T_FLIPFLOP_TEXT; 10 | mInputLabels = {"T", ">"}; 11 | mOutputLabels = {"Q", "Q̅"}; 12 | } 13 | 14 | TFlipFlop::TFlipFlop(const TFlipFlop& pObj, const CoreLogic* pCoreLogic): 15 | TFlipFlop(pCoreLogic, pObj.mDirection) 16 | { 17 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 18 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 19 | }; 20 | 21 | TFlipFlop::TFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 22 | TFlipFlop(pCoreLogic, static_cast(pJson["dir"].toInt())) 23 | { 24 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 25 | 26 | std::vector ininv, outinv; 27 | auto ininvArray = pJson["ininv"].toArray(); 28 | for (const auto& inv : ininvArray) 29 | { 30 | ininv.push_back(inv.toBool()); 31 | } 32 | GetLogicCell()->SetInputInversions(ininv); 33 | 34 | auto outinvArray = pJson["outinv"].toArray(); 35 | for (const auto& inv : outinvArray) 36 | { 37 | outinv.push_back(inv.toBool()); 38 | } 39 | GetLogicCell()->SetOutputInversions(outinv); 40 | } 41 | 42 | IBaseComponent* TFlipFlop::CloneBaseComponent(const CoreLogic* pCoreLogic) const 43 | { 44 | return new TFlipFlop(*this, pCoreLogic); 45 | } 46 | 47 | QJsonObject TFlipFlop::GetJson() const 48 | { 49 | QJsonObject json; 50 | 51 | json["type"] = file::ComponentId::T_FLIPFLOP; 52 | json["x"] = x(); 53 | json["y"] = y(); 54 | json["dir"] = static_cast(mDirection); 55 | { 56 | QJsonArray ininv, outinv; 57 | 58 | for(const bool& inv : mLogicCell->GetInputInversions()) 59 | { 60 | ininv.append(inv); 61 | } 62 | 63 | json["ininv"] = ininv; 64 | 65 | for(const bool& inv : mLogicCell->GetOutputInversions()) 66 | { 67 | outinv.append(inv); 68 | } 69 | 70 | json["outinv"] = outinv; 71 | } 72 | 73 | return json; 74 | } 75 | 76 | SwVersion TFlipFlop::GetMinVersion(void) const 77 | { 78 | return SwVersion(0, 0, 0); 79 | } 80 | -------------------------------------------------------------------------------- /Components/ComplexLogic/TFlipFlop.h: -------------------------------------------------------------------------------- 1 | #ifndef TFLIPFLOP_H 2 | #define TFLIPFLOP_H 3 | 4 | #include "AbstractComplexLogic.h" 5 | 6 | /// 7 | /// \brief The TFlipFlop class represents a rising-edge-triggered T flip-flop 8 | /// 9 | class TFlipFlop : public AbstractComplexLogic 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for TFlipFlop 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the component 16 | TFlipFlop(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for TFlipFlop 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | TFlipFlop(const TFlipFlop& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | TFlipFlop(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the component 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // TFLIPFLOP_H 43 | -------------------------------------------------------------------------------- /Components/Gates/AndGate.cpp: -------------------------------------------------------------------------------- 1 | #include "AndGate.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicAndGateCell.h" 5 | 6 | AndGate::AndGate(const CoreLogic* pCoreLogic, uint8_t pInputCount, Direction pDirection): 7 | AbstractGate(pCoreLogic, std::make_shared(pInputCount), pInputCount, pDirection) 8 | { 9 | mComponentText = components::gates::AND_TEXT; 10 | } 11 | 12 | AndGate::AndGate(const AndGate& pObj, const CoreLogic* pCoreLogic): 13 | AndGate(pCoreLogic, pObj.mInputCount, pObj.mDirection) 14 | { 15 | mComponentText = pObj.mComponentText; 16 | mWidth = pObj.mWidth; 17 | mHeight = pObj.mHeight; 18 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 19 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 20 | }; 21 | 22 | AndGate::AndGate(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 23 | AndGate(pCoreLogic, pJson["inputs"].toInt(), static_cast(pJson["dir"].toInt())) 24 | { 25 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 26 | 27 | std::vector ininv; 28 | auto ininvArray = pJson["ininv"].toArray(); 29 | for (const auto& inv : ininvArray) 30 | { 31 | ininv.push_back(inv.toBool()); 32 | } 33 | GetLogicCell()->SetInputInversions(ininv); 34 | GetLogicCell()->SetOutputInversions(std::vector{pJson["outinv"].toBool()}); 35 | } 36 | 37 | IBaseComponent* AndGate::CloneBaseComponent(const CoreLogic* pCoreLogic) const 38 | { 39 | return new AndGate(*this, pCoreLogic); 40 | } 41 | 42 | QJsonObject AndGate::GetJson() const 43 | { 44 | QJsonObject json; 45 | 46 | json["type"] = file::ComponentId::AND_GATE; 47 | json["x"] = x(); 48 | json["y"] = y(); 49 | json["dir"] = static_cast(mDirection); 50 | json["inputs"] = mInputCount; 51 | 52 | { 53 | QJsonArray ininv; 54 | 55 | for(const bool& inv : mLogicCell->GetInputInversions()) 56 | { 57 | ininv.append(inv); 58 | } 59 | 60 | json["ininv"] = ininv; 61 | 62 | json["outinv"] = QJsonValue(mLogicCell->GetOutputInversions()[0]); 63 | } 64 | 65 | return json; 66 | } 67 | 68 | SwVersion AndGate::GetMinVersion(void) const 69 | { 70 | return SwVersion(0, 0, 0); 71 | } 72 | -------------------------------------------------------------------------------- /Components/Gates/AndGate.h: -------------------------------------------------------------------------------- 1 | #ifndef ANDGATE_H 2 | #define ANDGATE_H 3 | 4 | #include "AbstractGate.h" 5 | 6 | /// 7 | /// \brief The AndGate class represents a logic AND gate 8 | /// 9 | class AndGate : public AbstractGate 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for the AND gate 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pInputCount: The number of inputs of the gate 16 | /// \param pDirection: The direction of the gate 17 | AndGate(const CoreLogic* pCoreLogic, uint8_t pInputCount, Direction pDirection); 18 | 19 | /// \brief Copy constructor for the AND gate 20 | /// \param pObj: The object to be copied 21 | /// \param pCoreLogic: Pointer to the core logic 22 | AndGate(const AndGate& pObj, const CoreLogic* pCoreLogic); 23 | 24 | /// \brief Constructor for loading from JSON 25 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 26 | /// \param pJson: The JSON object to load the component's data from 27 | AndGate(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 28 | 29 | /// \brief Clone function for the gate 30 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 31 | /// \return A pointer to the new gate component 32 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 33 | 34 | /// \brief Saves the dats of this component to the given JSON object 35 | /// \return The JSON object with the component data 36 | QJsonObject GetJson(void) const override; 37 | 38 | /// \brief Gets the minimum version compatible with this component 39 | /// \return the minimum version 40 | SwVersion GetMinVersion(void) const override; 41 | }; 42 | 43 | #endif // ANDGATE_H 44 | -------------------------------------------------------------------------------- /Components/Gates/BufferGate.cpp: -------------------------------------------------------------------------------- 1 | #include "BufferGate.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicBufferGateCell.h" 5 | 6 | BufferGate::BufferGate(const CoreLogic* pCoreLogic, Direction pDirection): 7 | AbstractGate(pCoreLogic, std::make_shared(), 1, pDirection) 8 | { 9 | mComponentText = components::gates::BUFFER_TEXT; 10 | } 11 | 12 | BufferGate::BufferGate(const BufferGate& pObj, const CoreLogic* pCoreLogic): 13 | BufferGate(pCoreLogic, pObj.mDirection) 14 | { 15 | mComponentText = pObj.mComponentText; 16 | mWidth = pObj.mWidth; 17 | mHeight = pObj.mHeight; 18 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 19 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 20 | }; 21 | 22 | BufferGate::BufferGate(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 23 | BufferGate(pCoreLogic, static_cast(pJson["dir"].toInt())) 24 | { 25 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 26 | 27 | GetLogicCell()->SetInputInversions(std::vector{pJson["ininv"].toBool()}); 28 | GetLogicCell()->SetOutputInversions(std::vector{pJson["outinv"].toBool()}); 29 | } 30 | 31 | IBaseComponent* BufferGate::CloneBaseComponent(const CoreLogic* pCoreLogic) const 32 | { 33 | return new BufferGate(*this, pCoreLogic); 34 | } 35 | 36 | QJsonObject BufferGate::GetJson() const 37 | { 38 | QJsonObject json; 39 | 40 | json["type"] = file::ComponentId::BUFFER_GATE; 41 | json["x"] = x(); 42 | json["y"] = y(); 43 | json["dir"] = static_cast(mDirection); 44 | 45 | json["ininv"] = QJsonValue(mLogicCell->GetInputInversions()[0]); 46 | json["outinv"] = QJsonValue(mLogicCell->GetOutputInversions()[0]); 47 | 48 | return json; 49 | } 50 | 51 | SwVersion BufferGate::GetMinVersion(void) const 52 | { 53 | return SwVersion(0, 0, 0); 54 | } 55 | -------------------------------------------------------------------------------- /Components/Gates/BufferGate.h: -------------------------------------------------------------------------------- 1 | #ifndef BUFFERGATE_H 2 | #define BUFFERGATE_H 3 | 4 | #include "AbstractGate.h" 5 | 6 | /// 7 | /// \brief The BufferGate class represents a logic buffer gate 8 | /// 9 | class BufferGate : public AbstractGate 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for the buffer gate 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the gate 16 | BufferGate(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for the buffer gate 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | BufferGate(const BufferGate& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | BufferGate(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the gate 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new gate component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // BUFFERGATE_H 43 | -------------------------------------------------------------------------------- /Components/Gates/LogicCells/LogicAndGateCell.cpp: -------------------------------------------------------------------------------- 1 | #include "LogicAndGateCell.h" 2 | #include "HelperFunctions.h" 3 | 4 | LogicAndGateCell::LogicAndGateCell(uint32_t pInputs): 5 | LogicBaseCell(pInputs, 1) 6 | {} 7 | 8 | void LogicAndGateCell::LogicFunction() 9 | { 10 | for (const auto& input : mInputStates) 11 | { 12 | if (input != LogicState::HIGH) 13 | { 14 | if (mCurrentOutputStates[0] != LogicState::LOW) 15 | { 16 | mNextOutputStates[0] = LogicState::LOW; 17 | mStateChanged = true; 18 | } 19 | return; 20 | } 21 | } 22 | if (mCurrentOutputStates[0] != LogicState::HIGH) 23 | { 24 | mNextOutputStates[0] = LogicState::HIGH; 25 | mStateChanged = true; 26 | } 27 | } 28 | 29 | LogicState LogicAndGateCell::GetOutputState(uint32_t pOutput) const 30 | { 31 | if (mOutputInverted[pOutput] && mIsActive) 32 | { 33 | return InvertState(mCurrentOutputStates[0]); 34 | } 35 | else 36 | { 37 | return mCurrentOutputStates[0]; 38 | } 39 | } 40 | 41 | void LogicAndGateCell::OnWakeUp() 42 | { 43 | mInputStates = std::vector(mInputStates.size(), LogicState::LOW); 44 | 45 | for (size_t i = 0; i < mInputStates.size(); i++) 46 | { 47 | mInputStates[i] = mInputInverted[i] ? LogicState::HIGH : LogicState::LOW; 48 | } 49 | 50 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 51 | mNextOutputStates = std::vector{1, LogicState::LOW}; 52 | mIsActive = true; 53 | mStateChanged = true; 54 | } 55 | 56 | void LogicAndGateCell::OnShutdown() 57 | { 58 | mOutputCells = std::vector, uint32_t>>(mOutputCells.size(), std::make_pair(nullptr, 0)); 59 | mInputStates = std::vector{mInputStates.size(), LogicState::LOW}; 60 | mInputConnected = std::vector(mInputConnected.size(), false); 61 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 62 | mNextOutputStates = std::vector{1, LogicState::LOW}; 63 | mIsActive = false; 64 | mStateChanged = true; 65 | } 66 | -------------------------------------------------------------------------------- /Components/Gates/LogicCells/LogicAndGateCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICANDGATECELL_H 2 | #define LOGICANDGATECELL_H 3 | 4 | #include "Components/LogicBaseCell.h" 5 | 6 | /// 7 | /// \brief Logic cell class for the AND gate 8 | /// 9 | class LogicAndGateCell : public LogicBaseCell 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for LogicAndGateCell 14 | /// \param pInputs: The number of gate inputs 15 | LogicAndGateCell(uint32_t pInputs); 16 | 17 | /// \brief The logic function that determines the output states based on the inputs 18 | void LogicFunction(void) override; 19 | 20 | /// \brief Getter for the current output state number pOutput of this cell 21 | /// \param pOutput: The number of the output to retreive 22 | /// \return The logic state of this cell's output number pOutput 23 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 24 | 25 | public slots: 26 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 27 | void OnShutdown(void) override; 28 | 29 | /// \brief Initializes the logic cell's states and triggers a component repaint 30 | void OnWakeUp(void) override; 31 | }; 32 | 33 | #endif // LOGICANDGATECELL_H 34 | -------------------------------------------------------------------------------- /Components/Gates/LogicCells/LogicBufferGateCell.cpp: -------------------------------------------------------------------------------- 1 | #include "LogicBufferGateCell.h" 2 | #include "HelperFunctions.h" 3 | 4 | LogicBufferGateCell::LogicBufferGateCell(): 5 | LogicBaseCell(1, 1) 6 | {} 7 | 8 | void LogicBufferGateCell::LogicFunction() 9 | { 10 | if (mCurrentOutputStates[0] != mInputStates[0]) 11 | { 12 | mNextOutputStates[0] = mInputStates[0]; 13 | mStateChanged = true; 14 | } 15 | } 16 | 17 | LogicState LogicBufferGateCell::GetOutputState(uint32_t pOutput) const 18 | { 19 | if (mOutputInverted[pOutput] && mIsActive) 20 | { 21 | return InvertState(mCurrentOutputStates[0]); 22 | } 23 | else 24 | { 25 | return mCurrentOutputStates[0]; 26 | } 27 | } 28 | 29 | void LogicBufferGateCell::OnWakeUp() 30 | { 31 | mInputStates = std::vector(mInputStates.size(), LogicState::LOW); 32 | 33 | for (size_t i = 0; i < mInputStates.size(); i++) 34 | { 35 | mInputStates[i] = mInputInverted[i] ? LogicState::HIGH : LogicState::LOW; 36 | } 37 | 38 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 39 | mNextOutputStates = std::vector{1, LogicState::LOW}; 40 | mIsActive = true; 41 | mStateChanged = true; 42 | } 43 | 44 | void LogicBufferGateCell::OnShutdown() 45 | { 46 | mOutputCells = std::vector, uint32_t>>(mOutputCells.size(), std::make_pair(nullptr, 0)); 47 | mInputStates = std::vector{mInputStates.size(), LogicState::LOW}; 48 | mInputConnected = std::vector(mInputConnected.size(), false); 49 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 50 | mNextOutputStates = std::vector{1, LogicState::LOW}; 51 | mIsActive = false; 52 | mStateChanged = true; 53 | } 54 | -------------------------------------------------------------------------------- /Components/Gates/LogicCells/LogicBufferGateCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICBUFFERGATECELL_H 2 | #define LOGICBUFFERGATECELL_H 3 | 4 | #include "Components/LogicBaseCell.h" 5 | 6 | /// 7 | /// \brief Logic cell class for the buffer gate 8 | /// 9 | class LogicBufferGateCell : public LogicBaseCell 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for LogicBufferGateCell 14 | LogicBufferGateCell(void); 15 | 16 | /// \brief The logic function that determines the output states based on the inputs 17 | void LogicFunction(void) override; 18 | 19 | /// \brief Getter for the current output state number pOutput of this cell 20 | /// \param pOutput: The number of the output to retreive 21 | /// \return The logic state of this cell's output number pOutput 22 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 23 | 24 | public slots: 25 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 26 | void OnShutdown(void) override; 27 | 28 | /// \brief Initializes the logic cell's states and triggers a component repaint 29 | void OnWakeUp(void) override; 30 | }; 31 | 32 | #endif // LOGICBUFFERGATECELL_H 33 | -------------------------------------------------------------------------------- /Components/Gates/LogicCells/LogicNotGateCell.cpp: -------------------------------------------------------------------------------- 1 | #include "LogicNotGateCell.h" 2 | #include "HelperFunctions.h" 3 | 4 | LogicNotGateCell::LogicNotGateCell(): 5 | LogicBaseCell(1, 1) 6 | { 7 | mOutputInverted[0] = true; 8 | } 9 | 10 | void LogicNotGateCell::LogicFunction() 11 | { 12 | if (mCurrentOutputStates[0] != mInputStates[0]) 13 | { 14 | mNextOutputStates[0] = mInputStates[0]; 15 | mStateChanged = true; 16 | } 17 | } 18 | 19 | LogicState LogicNotGateCell::GetOutputState(uint32_t pOutput) const 20 | { 21 | if (mOutputInverted[pOutput] && mIsActive) 22 | { 23 | return InvertState(mCurrentOutputStates[0]); 24 | } 25 | else 26 | { 27 | return mCurrentOutputStates[0]; 28 | } 29 | } 30 | 31 | void LogicNotGateCell::OnWakeUp() 32 | { 33 | mInputStates = std::vector(mInputStates.size(), LogicState::LOW); 34 | 35 | for (size_t i = 0; i < mInputStates.size(); i++) 36 | { 37 | mInputStates[i] = mInputInverted[i] ? LogicState::HIGH : LogicState::LOW; 38 | } 39 | 40 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 41 | mNextOutputStates = std::vector{1, LogicState::LOW}; 42 | mIsActive = true; 43 | mStateChanged = true; 44 | } 45 | 46 | void LogicNotGateCell::OnShutdown() 47 | { 48 | mOutputCells = std::vector, uint32_t>>(mOutputCells.size(), std::make_pair(nullptr, 0)); 49 | mInputStates = std::vector{mInputStates.size(), LogicState::LOW}; 50 | mInputConnected = std::vector(mInputConnected.size(), false); 51 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 52 | mNextOutputStates = std::vector{1, LogicState::LOW}; 53 | mIsActive = false; 54 | mStateChanged = true; 55 | } 56 | -------------------------------------------------------------------------------- /Components/Gates/LogicCells/LogicNotGateCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICNOTGATECELL_H 2 | #define LOGICNOTGATECELL_H 3 | 4 | #include "Components/LogicBaseCell.h" 5 | 6 | /// 7 | /// \brief Logic cell class for the NOT gate 8 | /// 9 | class LogicNotGateCell : public LogicBaseCell 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for LogicNotGateCell 14 | LogicNotGateCell(void); 15 | 16 | /// \brief The logic function that determines the output states based on the inputs 17 | void LogicFunction(void) override; 18 | 19 | /// \brief Getter for the current output state number pOutput of this cell 20 | /// \param pOutput: The number of the output to retreive 21 | /// \return The logic state of this cell's output number pOutput 22 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 23 | 24 | public slots: 25 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 26 | void OnShutdown(void) override; 27 | 28 | /// \brief Initializes the logic cell's states and triggers a component repaint 29 | void OnWakeUp(void) override; 30 | 31 | protected: 32 | LogicState mPreviousState; 33 | LogicState mCurrentState; 34 | bool mStateChanged; 35 | }; 36 | 37 | #endif // LOGICNOTGATECELL_H 38 | -------------------------------------------------------------------------------- /Components/Gates/LogicCells/LogicOrGateCell.cpp: -------------------------------------------------------------------------------- 1 | #include "LogicOrGateCell.h" 2 | #include "HelperFunctions.h" 3 | 4 | LogicOrGateCell::LogicOrGateCell(uint32_t pInputs): 5 | LogicBaseCell(pInputs, 1) 6 | {} 7 | 8 | void LogicOrGateCell::LogicFunction() 9 | { 10 | for (const auto& input : mInputStates) 11 | { 12 | if (input == LogicState::HIGH) 13 | { 14 | if (mCurrentOutputStates[0] != LogicState::HIGH) 15 | { 16 | mNextOutputStates[0] = LogicState::HIGH; 17 | mStateChanged = true; 18 | } 19 | return; 20 | } 21 | } 22 | if (mCurrentOutputStates[0] != LogicState::LOW) 23 | { 24 | mNextOutputStates[0] = LogicState::LOW; 25 | mStateChanged = true; 26 | } 27 | } 28 | 29 | LogicState LogicOrGateCell::GetOutputState(uint32_t pOutput) const 30 | { 31 | if (mOutputInverted[pOutput] && mIsActive) 32 | { 33 | return InvertState(mCurrentOutputStates[0]); 34 | } 35 | else 36 | { 37 | return mCurrentOutputStates[0]; 38 | } 39 | } 40 | 41 | void LogicOrGateCell::OnWakeUp() 42 | { 43 | mInputStates = std::vector(mInputStates.size(), LogicState::LOW); 44 | 45 | for (size_t i = 0; i < mInputStates.size(); i++) 46 | { 47 | mInputStates[i] = mInputInverted[i] ? LogicState::HIGH : LogicState::LOW; 48 | } 49 | 50 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 51 | mNextOutputStates = std::vector{1, LogicState::LOW}; 52 | mIsActive = true; 53 | mStateChanged = true; 54 | } 55 | 56 | void LogicOrGateCell::OnShutdown() 57 | { 58 | mOutputCells = std::vector, uint32_t>>(mOutputCells.size(), std::make_pair(nullptr, 0)); 59 | mInputStates = std::vector{mInputStates.size(), LogicState::LOW}; 60 | mInputConnected = std::vector(mInputConnected.size(), false); 61 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 62 | mNextOutputStates = std::vector{1, LogicState::LOW}; 63 | mIsActive = false; 64 | mStateChanged = true; 65 | } 66 | -------------------------------------------------------------------------------- /Components/Gates/LogicCells/LogicOrGateCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICORGATECELL_H 2 | #define LOGICORGATECELL_H 3 | 4 | #include "Components/LogicBaseCell.h" 5 | 6 | /// 7 | /// \brief Logic cell class for the OR gate 8 | /// 9 | class LogicOrGateCell : public LogicBaseCell 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for LogicOrGateCell 14 | /// \param pInputs: The number of gate inputs 15 | LogicOrGateCell(uint32_t pInputs); 16 | 17 | /// \brief The logic function that determines the output states based on the inputs 18 | void LogicFunction(void) override; 19 | 20 | /// \brief Getter for the current output state number pOutput of this cell 21 | /// \param pOutput: The number of the output to retreive 22 | /// \return The logic state of this cell's output number pOutput 23 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 24 | 25 | public slots: 26 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 27 | void OnShutdown(void) override; 28 | 29 | /// \brief Initializes the logic cell's states and triggers a component repaint 30 | void OnWakeUp(void) override; 31 | }; 32 | 33 | #endif // LOGICORGATECELL_H 34 | -------------------------------------------------------------------------------- /Components/Gates/LogicCells/LogicXorGateCell.cpp: -------------------------------------------------------------------------------- 1 | #include "LogicXorGateCell.h" 2 | #include "HelperFunctions.h" 3 | 4 | LogicXorGateCell::LogicXorGateCell(uint32_t pInputs): 5 | LogicBaseCell(pInputs, 1) 6 | {} 7 | 8 | void LogicXorGateCell::LogicFunction() 9 | { 10 | bool oneHigh = false; 11 | 12 | for (const auto& input : mInputStates) 13 | { 14 | if (input == LogicState::HIGH) 15 | { 16 | if (oneHigh) 17 | { 18 | if (mCurrentOutputStates[0] != LogicState::LOW) 19 | { 20 | mNextOutputStates[0] = LogicState::LOW; 21 | mStateChanged = true; 22 | } 23 | return; 24 | } 25 | oneHigh = true; 26 | } 27 | } 28 | 29 | if (mCurrentOutputStates[0] != (oneHigh ? LogicState::HIGH : LogicState::LOW)) 30 | { 31 | mNextOutputStates[0] = oneHigh ? LogicState::HIGH : LogicState::LOW; 32 | mStateChanged = true; 33 | return; 34 | } 35 | } 36 | 37 | LogicState LogicXorGateCell::GetOutputState(uint32_t pOutput) const 38 | { 39 | if (mOutputInverted[pOutput] && mIsActive) 40 | { 41 | return InvertState(mCurrentOutputStates[0]); 42 | } 43 | else 44 | { 45 | return mCurrentOutputStates[0]; 46 | } 47 | } 48 | 49 | void LogicXorGateCell::OnWakeUp() 50 | { 51 | mInputStates = std::vector(mInputStates.size(), LogicState::LOW); 52 | 53 | for (size_t i = 0; i < mInputStates.size(); i++) 54 | { 55 | mInputStates[i] = mInputInverted[i] ? LogicState::HIGH : LogicState::LOW; 56 | } 57 | 58 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 59 | mNextOutputStates = std::vector{1, LogicState::LOW}; 60 | mIsActive = true; 61 | mStateChanged = true; 62 | } 63 | 64 | void LogicXorGateCell::OnShutdown() 65 | { 66 | mOutputCells = std::vector, uint32_t>>(mOutputCells.size(), std::make_pair(nullptr, 0)); 67 | mInputStates = std::vector{mInputStates.size(), LogicState::LOW}; 68 | mInputConnected = std::vector(mInputConnected.size(), false); 69 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 70 | mNextOutputStates = std::vector{1, LogicState::LOW}; 71 | mIsActive = false; 72 | mStateChanged = true; 73 | } 74 | -------------------------------------------------------------------------------- /Components/Gates/LogicCells/LogicXorGateCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICXORGATECELL_H 2 | #define LOGICXORGATECELL_H 3 | 4 | #include "Components/LogicBaseCell.h" 5 | 6 | /// 7 | /// \brief Logic cell class for the XOR gate 8 | /// 9 | class LogicXorGateCell : public LogicBaseCell 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for LogicXorGateCell 14 | /// \param pInputs: The number of gate inputs 15 | LogicXorGateCell(uint32_t pInputs); 16 | 17 | /// \brief The logic function that determines the output states based on the inputs 18 | void LogicFunction(void) override; 19 | 20 | /// \brief Getter for the current output state number pOutput of this cell 21 | /// \param pOutput: The number of the output to retreive 22 | /// \return The logic state of this cell's output number pOutput 23 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 24 | 25 | public slots: 26 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 27 | void OnShutdown(void) override; 28 | 29 | /// \brief Initializes the logic cell's states and triggers a component repaint 30 | void OnWakeUp(void) override; 31 | }; 32 | 33 | #endif // LOGICXORGATECELL_H 34 | -------------------------------------------------------------------------------- /Components/Gates/NotGate.cpp: -------------------------------------------------------------------------------- 1 | #include "NotGate.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicNotGateCell.h" 5 | 6 | NotGate::NotGate(const CoreLogic* pCoreLogic, Direction pDirection): 7 | AbstractGate(pCoreLogic, std::make_shared(), 1, pDirection) 8 | { 9 | mComponentText = components::gates::NOT_TEXT; 10 | } 11 | 12 | NotGate::NotGate(const NotGate& pObj, const CoreLogic* pCoreLogic): 13 | NotGate(pCoreLogic, pObj.mDirection) 14 | { 15 | mComponentText = pObj.mComponentText; 16 | mWidth = pObj.mWidth; 17 | mHeight = pObj.mHeight; 18 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 19 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 20 | }; 21 | 22 | NotGate::NotGate(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 23 | NotGate(pCoreLogic, static_cast(pJson["dir"].toInt())) 24 | { 25 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 26 | 27 | GetLogicCell()->SetInputInversions(std::vector{pJson["ininv"].toBool()}); 28 | GetLogicCell()->SetOutputInversions(std::vector{pJson["outinv"].toBool()}); 29 | } 30 | 31 | IBaseComponent* NotGate::CloneBaseComponent(const CoreLogic* pCoreLogic) const 32 | { 33 | return new NotGate(*this, pCoreLogic); 34 | } 35 | 36 | QJsonObject NotGate::GetJson() const 37 | { 38 | QJsonObject json; 39 | 40 | json["type"] = file::ComponentId::NOT_GATE; 41 | json["x"] = x(); 42 | json["y"] = y(); 43 | json["dir"] = static_cast(mDirection); 44 | 45 | json["ininv"] = QJsonValue(mLogicCell->GetInputInversions()[0]); 46 | json["outinv"] = QJsonValue(mLogicCell->GetOutputInversions()[0]); 47 | 48 | return json; 49 | } 50 | 51 | SwVersion NotGate::GetMinVersion(void) const 52 | { 53 | return SwVersion(0, 0, 0); 54 | } 55 | -------------------------------------------------------------------------------- /Components/Gates/NotGate.h: -------------------------------------------------------------------------------- 1 | #ifndef NOTGATE_H 2 | #define NOTGATE_H 3 | 4 | #include "AbstractGate.h" 5 | 6 | /// 7 | /// \brief The AndGate class represents a logic NOT gate 8 | /// 9 | class NotGate : public AbstractGate 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for the NOT gate 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pDirection: The direction of the gate 16 | NotGate(const CoreLogic* pCoreLogic, Direction pDirection); 17 | 18 | /// \brief Copy constructor for the NOT gate 19 | /// \param pObj: The object to be copied 20 | /// \param pCoreLogic: Pointer to the core logic 21 | NotGate(const NotGate& pObj, const CoreLogic* pCoreLogic); 22 | 23 | /// \brief Constructor for loading from JSON 24 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 25 | /// \param pJson: The JSON object to load the component's data from 26 | NotGate(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 27 | 28 | /// \brief Clone function for the gate 29 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 30 | /// \return A pointer to the new gate component 31 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 32 | 33 | /// \brief Saves the dats of this component to the given JSON object 34 | /// \return The JSON object with the component data 35 | QJsonObject GetJson(void) const override; 36 | 37 | /// \brief Gets the minimum version compatible with this component 38 | /// \return the minimum version 39 | SwVersion GetMinVersion(void) const override; 40 | }; 41 | 42 | #endif // NOTGATE_H 43 | -------------------------------------------------------------------------------- /Components/Gates/OrGate.cpp: -------------------------------------------------------------------------------- 1 | #include "OrGate.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicOrGateCell.h" 5 | 6 | OrGate::OrGate(const CoreLogic* pCoreLogic, uint8_t pInputCount, Direction pDirection): 7 | AbstractGate(pCoreLogic, std::make_shared(pInputCount), pInputCount, pDirection) 8 | { 9 | mComponentText = components::gates::OR_TEXT; 10 | } 11 | 12 | OrGate::OrGate(const OrGate& pObj, const CoreLogic* pCoreLogic): 13 | OrGate(pCoreLogic, pObj.mInputCount, pObj.mDirection) 14 | { 15 | mComponentText = pObj.mComponentText; 16 | mWidth = pObj.mWidth; 17 | mHeight = pObj.mHeight; 18 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 19 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 20 | }; 21 | 22 | OrGate::OrGate(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 23 | OrGate(pCoreLogic, pJson["inputs"].toInt(), static_cast(pJson["dir"].toInt())) 24 | { 25 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 26 | 27 | std::vector ininv; 28 | auto ininvArray = pJson["ininv"].toArray(); 29 | for (const auto& inv : ininvArray) 30 | { 31 | ininv.push_back(inv.toBool()); 32 | } 33 | GetLogicCell()->SetInputInversions(ininv); 34 | GetLogicCell()->SetOutputInversions(std::vector{pJson["outinv"].toBool()}); 35 | } 36 | 37 | IBaseComponent* OrGate::CloneBaseComponent(const CoreLogic* pCoreLogic) const 38 | { 39 | return new OrGate(*this, pCoreLogic); 40 | } 41 | 42 | QJsonObject OrGate::GetJson() const 43 | { 44 | QJsonObject json; 45 | 46 | json["type"] = file::ComponentId::OR_GATE; 47 | json["x"] = x(); 48 | json["y"] = y(); 49 | json["dir"] = static_cast(mDirection); 50 | json["inputs"] = mInputCount; 51 | 52 | { 53 | QJsonArray ininv; 54 | 55 | for(const bool& inv : mLogicCell->GetInputInversions()) 56 | { 57 | ininv.append(inv); 58 | } 59 | 60 | json["ininv"] = ininv; 61 | 62 | json["outinv"] = QJsonValue(mLogicCell->GetOutputInversions()[0]); 63 | } 64 | 65 | return json; 66 | } 67 | 68 | SwVersion OrGate::GetMinVersion(void) const 69 | { 70 | return SwVersion(0, 0, 0); 71 | } 72 | -------------------------------------------------------------------------------- /Components/Gates/OrGate.h: -------------------------------------------------------------------------------- 1 | #ifndef ORGATE_H 2 | #define ORGATE_H 3 | 4 | #include "AbstractGate.h" 5 | 6 | /// 7 | /// \brief The AndGate class represents a logic OR gate 8 | /// 9 | class OrGate : public AbstractGate 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for the OR gate 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pInputCount: The number of inputs of the gate 16 | /// \param pDirection: The direction of the gate 17 | OrGate(const CoreLogic* pCoreLogic, uint8_t pInputCount, Direction pDirection); 18 | 19 | /// \brief Copy constructor for the OR gate 20 | /// \param pObj: The object to be copied 21 | /// \param pCoreLogic: Pointer to the core logic 22 | OrGate(const OrGate& pObj, const CoreLogic* pCoreLogic); 23 | 24 | /// \brief Constructor for loading from JSON 25 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 26 | /// \param pJson: The JSON object to load the component's data from 27 | OrGate(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 28 | 29 | /// \brief Clone function for the gate 30 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 31 | /// \return A pointer to the new gate component 32 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 33 | 34 | /// \brief Saves the dats of this component to the given JSON object 35 | /// \return The JSON object with the component data 36 | QJsonObject GetJson(void) const override; 37 | 38 | /// \brief Gets the minimum version compatible with this component 39 | /// \return the minimum version 40 | SwVersion GetMinVersion(void) const override; 41 | 42 | }; 43 | 44 | #endif // ORGATE_H 45 | -------------------------------------------------------------------------------- /Components/Gates/XorGate.cpp: -------------------------------------------------------------------------------- 1 | #include "XorGate.h" 2 | #include "CoreLogic.h" 3 | #include "HelperFunctions.h" 4 | #include "LogicCells/LogicXorGateCell.h" 5 | 6 | XorGate::XorGate(const CoreLogic* pCoreLogic, uint8_t pInputCount, Direction pDirection): 7 | AbstractGate(pCoreLogic, std::make_shared(pInputCount), pInputCount, pDirection) 8 | { 9 | mComponentText = components::gates::XOR_TEXT; 10 | } 11 | 12 | XorGate::XorGate(const XorGate& pObj, const CoreLogic* pCoreLogic): 13 | XorGate(pCoreLogic, pObj.mInputCount, pObj.mDirection) 14 | { 15 | mComponentText = pObj.mComponentText; 16 | mWidth = pObj.mWidth; 17 | mHeight = pObj.mHeight; 18 | mLogicCell->SetInputInversions(pObj.mLogicCell->GetInputInversions()); 19 | mLogicCell->SetOutputInversions(pObj.mLogicCell->GetOutputInversions()); 20 | }; 21 | 22 | XorGate::XorGate(const CoreLogic* pCoreLogic, const QJsonObject& pJson): 23 | XorGate(pCoreLogic, pJson["inputs"].toInt(), static_cast(pJson["dir"].toInt())) 24 | { 25 | setPos(SnapToGrid(QPointF(pJson["x"].toInt(), pJson["y"].toInt()))); 26 | 27 | std::vector ininv; 28 | auto ininvArray = pJson["ininv"].toArray(); 29 | for (const auto& inv : ininvArray) 30 | { 31 | ininv.push_back(inv.toBool()); 32 | } 33 | GetLogicCell()->SetInputInversions(ininv); 34 | GetLogicCell()->SetOutputInversions(std::vector{pJson["outinv"].toBool()}); 35 | } 36 | 37 | 38 | IBaseComponent* XorGate::CloneBaseComponent(const CoreLogic* pCoreLogic) const 39 | { 40 | return new XorGate(*this, pCoreLogic); 41 | } 42 | 43 | QJsonObject XorGate::GetJson() const 44 | { 45 | QJsonObject json; 46 | 47 | json["type"] = file::ComponentId::XOR_GATE; 48 | json["x"] = x(); 49 | json["y"] = y(); 50 | json["dir"] = static_cast(mDirection); 51 | json["inputs"] = mInputCount; 52 | 53 | { 54 | QJsonArray ininv; 55 | 56 | for(const bool& inv : mLogicCell->GetInputInversions()) 57 | { 58 | ininv.append(inv); 59 | } 60 | 61 | json["ininv"] = ininv; 62 | 63 | json["outinv"] = QJsonValue(mLogicCell->GetOutputInversions()[0]); 64 | } 65 | 66 | return json; 67 | } 68 | 69 | SwVersion XorGate::GetMinVersion(void) const 70 | { 71 | return SwVersion(0, 0, 0); 72 | } 73 | -------------------------------------------------------------------------------- /Components/Gates/XorGate.h: -------------------------------------------------------------------------------- 1 | #ifndef XORGATE_H 2 | #define XORGATE_H 3 | 4 | #include "AbstractGate.h" 5 | 6 | /// 7 | /// \brief The AndGate class represents a logic XOR gate 8 | /// 9 | class XorGate : public AbstractGate 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for the XOR gate 14 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 15 | /// \param pInputCount: The number of inputs of the gate 16 | /// \param pDirection: The direction of the gate 17 | XorGate(const CoreLogic* pCoreLogic, uint8_t pInputCount, Direction pDirection); 18 | 19 | /// \brief Copy constructor for the XOR gate 20 | /// \param pObj: The object to be copied 21 | /// \param pCoreLogic: Pointer to the core logic 22 | XorGate(const XorGate& pObj, const CoreLogic* pCoreLogic); 23 | 24 | /// \brief Constructor for loading from JSON 25 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 26 | /// \param pJson: The JSON object to load the component's data from 27 | XorGate(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 28 | 29 | /// \brief Clone function for the gate 30 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 31 | /// \return A pointer to the new gate component 32 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 33 | 34 | /// \brief Saves the dats of this component to the given JSON object 35 | /// \return The JSON object with the component data 36 | QJsonObject GetJson(void) const override; 37 | 38 | /// \brief Gets the minimum version compatible with this component 39 | /// \return the minimum version 40 | SwVersion GetMinVersion(void) const override; 41 | }; 42 | 43 | #endif // XORGATE_H 44 | -------------------------------------------------------------------------------- /Components/Inputs/LogicButton.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICBUTTON_H 2 | #define LOGICBUTTON_H 3 | 4 | #include "../IBaseComponent.h" 5 | #include "HelperStructures.h" 6 | #include "LogicCells/LogicButtonCell.h" 7 | 8 | /// 9 | /// \brief The LogicButton class represents a logic button input 10 | /// 11 | class LogicButton : public IBaseComponent 12 | { 13 | Q_OBJECT 14 | public: 15 | /// \brief Constructor for LogicButton 16 | /// \param pCoreLogic: Pointer to the core logic 17 | LogicButton(const CoreLogic* pCoreLogic); 18 | 19 | /// \brief Copy constructor for LogicButton 20 | /// \param pObj: The object to be copied 21 | /// \param pCoreLogic: Pointer to the core logic 22 | LogicButton(const LogicButton& pObj, const CoreLogic* pCoreLogic); 23 | 24 | /// \brief Constructor for loading from JSON 25 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 26 | /// \param pJson: The JSON object to load the component's data from 27 | LogicButton(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 28 | 29 | /// \brief Clone function for the button component 30 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 31 | /// \return A pointer to the new component 32 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 33 | 34 | /// \brief Triggers the button to toggle if in simulation mode 35 | /// \param pEvent: Pointer to the mouse press event 36 | void mousePressEvent(QGraphicsSceneMouseEvent *pEvent) override; 37 | 38 | /// \brief Defines the bounding rect of this component 39 | /// \return A rectangle describing the bounding rect 40 | QRectF boundingRect(void) const override; 41 | 42 | /// \brief Sets the Z-value to its defined value, to reset it after components have been copied 43 | void ResetZValue(void) override; 44 | 45 | /// \brief Saves the dats of this component to the given JSON object 46 | /// \return The JSON object with the component data 47 | QJsonObject GetJson(void) const override; 48 | 49 | /// \brief Gets the minimum version compatible with this component 50 | /// \return the minimum version 51 | SwVersion GetMinVersion(void) const override; 52 | 53 | protected: 54 | /// \brief Paints the button component 55 | /// \param pPainter: The painter to use 56 | /// \param pItem: Contains drawing parameters 57 | /// \param pWidget: Unused, the widget that is been painted on 58 | void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pItem, QWidget *pWidget) override; 59 | }; 60 | 61 | #endif // LOGICBUTTON_H 62 | -------------------------------------------------------------------------------- /Components/Inputs/LogicCells/LogicButtonCell.cpp: -------------------------------------------------------------------------------- 1 | #include "LogicButtonCell.h" 2 | #include "Configuration.h" 3 | 4 | LogicButtonCell::LogicButtonCell(): 5 | LogicBaseCell(0, 1), 6 | mRemainingTicks(0) 7 | {} 8 | 9 | void LogicButtonCell::LogicFunction() 10 | { 11 | if (mCurrentOutputStates[0] == LogicState::HIGH) 12 | { 13 | mRemainingTicks--; 14 | if (mRemainingTicks == 0) 15 | { 16 | mNextOutputStates[0] = LogicState::LOW; 17 | mStateChanged = true; 18 | } 19 | } 20 | } 21 | 22 | void LogicButtonCell::ButtonClick() 23 | { 24 | if (mCurrentOutputStates[0] != LogicState::HIGH) 25 | { 26 | mRemainingTicks = components::inputs::BUTTON_TOGGLE_TICKS; 27 | mNextOutputStates[0] = LogicState::HIGH; 28 | mStateChanged = true; 29 | } 30 | else // Allows buttons to be disabled again, especially during pause 31 | { 32 | mRemainingTicks = 0; 33 | mNextOutputStates[0] = LogicState::LOW; 34 | mStateChanged = true; 35 | } 36 | 37 | // Keep states synced and trigger immediate repaint to make buttons responsive during pause 38 | if (mCurrentOutputStates[0] != mNextOutputStates[0]) 39 | { 40 | mCurrentOutputStates[0] = mNextOutputStates[0]; 41 | emit StateChangedSignal(); 42 | } 43 | } 44 | 45 | LogicState LogicButtonCell::GetOutputState(uint32_t pOutput) const 46 | { 47 | Q_UNUSED(pOutput); 48 | return mCurrentOutputStates[0]; 49 | } 50 | 51 | void LogicButtonCell::OnWakeUp() 52 | { 53 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 54 | mNextOutputStates = std::vector{1, LogicState::LOW}; 55 | mIsActive = true; 56 | mStateChanged = true; 57 | } 58 | 59 | void LogicButtonCell::OnShutdown() 60 | { 61 | mOutputCells = std::vector, uint32_t>>(mOutputCells.size(), std::make_pair(nullptr, 0)); 62 | mInputStates = std::vector{mInputStates.size(), LogicState::LOW}; 63 | mInputConnected = std::vector(mInputConnected.size(), false); 64 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 65 | mNextOutputStates = std::vector{1, LogicState::LOW}; 66 | mIsActive = false; 67 | mStateChanged = true; 68 | } 69 | -------------------------------------------------------------------------------- /Components/Inputs/LogicCells/LogicButtonCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICBUTTONCELL_H 2 | #define LOGICBUTTONCELL_H 3 | 4 | #include "Components/LogicBaseCell.h" 5 | 6 | /// 7 | /// \brief Logic cell class for the button input 8 | /// 9 | class LogicButtonCell : public LogicBaseCell 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for LogicButtonCell 14 | LogicButtonCell(void); 15 | 16 | /// \brief The logic function that determines the output state 17 | void LogicFunction(void) override; 18 | 19 | /// \brief Sets the button state to HIGH, resets the remaining ticks and propagates immediately 20 | void ButtonClick(void); 21 | 22 | /// \brief Getter for the current output state number pOutput of this cell 23 | /// \param pOutput: The number of the output to retreive 24 | /// \return The logic state of this cell's output number pOutput 25 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 26 | 27 | public slots: 28 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 29 | void OnShutdown(void) override; 30 | 31 | /// \brief Initializes the logic cell's states and triggers a component repaint 32 | void OnWakeUp(void) override; 33 | 34 | protected: 35 | uint32_t mRemainingTicks; 36 | }; 37 | 38 | #endif // LOGICBUTTONCELL_H 39 | -------------------------------------------------------------------------------- /Components/Inputs/LogicCells/LogicClockCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICCLOCKCELL_H 2 | #define LOGICCLOCKCELL_H 3 | 4 | #include "Components/LogicBaseCell.h" 5 | 6 | /// 7 | /// \brief Logic cell class for the clock input 8 | /// 9 | class LogicClockCell : public LogicBaseCell 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for LogicClockCell 14 | LogicClockCell(void); 15 | 16 | /// \brief The logic function that determines the output states based on the inputs 17 | void LogicFunction(void) override; 18 | 19 | /// \brief Getter for the current output state number pOutput of this cell 20 | /// \param pOutput: The number of the output to retreive 21 | /// \return The logic state of this cell's output number pOutput 22 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 23 | 24 | /// \brief Sets the toggle speed of this clock logic cell 25 | /// \param pTicks: The new toggle speed in ticks 26 | void SetToggleTicks(uint32_t pTicks); 27 | 28 | /// \brief Sets the pulse duration of this clock logic cell 29 | /// \param pTicks: The new pulse duration in ticks 30 | void SetPulseTicks(uint32_t pTicks); 31 | 32 | /// \brief Sets the clock mode of this clock logic cell 33 | /// \param pMode: The new clock mode (toggle or pulse) 34 | void SetClockMode(ClockMode pMode); 35 | 36 | /// \brief Getter for the toggle speed of this clock logic cell 37 | /// \return The toggle speed in ticks 38 | uint32_t GetToggleTicks(void); 39 | 40 | /// \brief Getter for the pulse duration of this clock logic cell 41 | /// \return The pulse duration in ticks 42 | uint32_t GetPulseTicks(void); 43 | 44 | /// \brief Getter for the clock mode of this clock logic cell 45 | /// \return The clock mode (toggle or pulse) 46 | ClockMode GetClockMode(void); 47 | 48 | public slots: 49 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 50 | void OnShutdown(void) override; 51 | 52 | /// \brief Initializes the logic cell's states and triggers a component repaint 53 | void OnWakeUp(void) override; 54 | 55 | protected: 56 | uint32_t mToggleTicks; 57 | uint32_t mPulseTicks; 58 | 59 | uint32_t mTickCountdown; 60 | uint32_t mPulseCountdown; 61 | 62 | ClockMode mMode; 63 | }; 64 | 65 | #endif // LOGICCLOCKCELL_H 66 | -------------------------------------------------------------------------------- /Components/Inputs/LogicCells/LogicConstantCell.cpp: -------------------------------------------------------------------------------- 1 | #include "LogicConstantCell.h" 2 | 3 | LogicConstantCell::LogicConstantCell(LogicState pConstantState): 4 | LogicBaseCell(0, 1), 5 | mConstantState(pConstantState) 6 | {} 7 | 8 | LogicState LogicConstantCell::GetOutputState(uint32_t pOutput) const 9 | { 10 | Q_UNUSED(pOutput); 11 | return mCurrentOutputStates[0]; 12 | } 13 | 14 | void LogicConstantCell::OnWakeUp() 15 | { 16 | mCurrentOutputStates = std::vector{1, mConstantState}; 17 | mNextOutputStates = std::vector{1, mConstantState}; 18 | mIsActive = true; 19 | mStateChanged = true; 20 | } 21 | 22 | void LogicConstantCell::OnShutdown() 23 | { 24 | mOutputCells = std::vector, uint32_t>>(mOutputCells.size(), std::make_pair(nullptr, 0)); 25 | mInputStates = std::vector{mInputStates.size(), LogicState::LOW}; 26 | mInputConnected = std::vector(mInputConnected.size(), false); 27 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 28 | mNextOutputStates = std::vector{1, LogicState::LOW}; 29 | mIsActive = false; 30 | mStateChanged = true; 31 | } 32 | 33 | LogicState LogicConstantCell::GetConstantState() const 34 | { 35 | return mConstantState; 36 | } 37 | -------------------------------------------------------------------------------- /Components/Inputs/LogicCells/LogicConstantCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICCONSTANTCELL_H 2 | #define LOGICCONSTANTCELL_H 3 | 4 | #include "Components/LogicBaseCell.h" 5 | 6 | /// 7 | /// \brief Logic cell class for the HIGH/LOW constant 8 | /// 9 | class LogicConstantCell : public LogicBaseCell 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for LogicConstantCell 14 | LogicConstantCell(LogicState pConstantState); 15 | 16 | /// \brief Getter for the current output state number pOutput of this cell 17 | /// \param pOutput: The number of the output to retreive 18 | /// \return The logic state of this cell's output number pOutput 19 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 20 | 21 | /// \brief Getter for this cell's constant state 22 | /// \return the constant logic state of this logic cell 23 | LogicState GetConstantState(void) const; 24 | 25 | public slots: 26 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 27 | void OnShutdown(void) override; 28 | 29 | /// \brief Initializes the logic cell's states and triggers a component repaint 30 | void OnWakeUp(void) override; 31 | 32 | protected: 33 | LogicState mConstantState; 34 | }; 35 | 36 | #endif // LOGICCONSTANTCELL_H 37 | -------------------------------------------------------------------------------- /Components/Inputs/LogicCells/LogicInputCell.cpp: -------------------------------------------------------------------------------- 1 | #include "LogicInputCell.h" 2 | 3 | LogicInputCell::LogicInputCell(): 4 | LogicBaseCell(0, 1) 5 | {} 6 | 7 | void LogicInputCell::ToggleState() 8 | { 9 | mNextOutputStates[0] = ((mCurrentOutputStates[0] == LogicState::HIGH) ? LogicState::LOW : LogicState::HIGH); 10 | 11 | // Keep states synced and trigger immediate repaint to make inputs responsive during pause 12 | if (mCurrentOutputStates[0] != mNextOutputStates[0]) 13 | { 14 | mCurrentOutputStates[0] = mNextOutputStates[0]; 15 | emit StateChangedSignal(); 16 | } 17 | } 18 | 19 | LogicState LogicInputCell::GetOutputState(uint32_t pOutput) const 20 | { 21 | Q_UNUSED(pOutput); 22 | return mCurrentOutputStates[0]; 23 | } 24 | 25 | void LogicInputCell::OnWakeUp() 26 | { 27 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 28 | mNextOutputStates = std::vector{1, LogicState::LOW}; 29 | mIsActive = true; 30 | mStateChanged = true; 31 | } 32 | 33 | void LogicInputCell::OnShutdown() 34 | { 35 | mOutputCells = std::vector, uint32_t>>(mOutputCells.size(), std::make_pair(nullptr, 0)); 36 | mInputStates = std::vector{mInputStates.size(), LogicState::LOW}; 37 | mInputConnected = std::vector(mInputConnected.size(), false); 38 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 39 | mNextOutputStates = std::vector{1, LogicState::LOW}; 40 | mIsActive = false; 41 | mStateChanged = true; 42 | } 43 | -------------------------------------------------------------------------------- /Components/Inputs/LogicCells/LogicInputCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICINPUTCELL_H 2 | #define LOGICINPUTCELL_H 3 | 4 | #include "Components/LogicBaseCell.h" 5 | 6 | /// 7 | /// \brief Logic cell class for the switch input 8 | /// 9 | class LogicInputCell : public LogicBaseCell 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for LogicInputCell 14 | LogicInputCell(void); 15 | 16 | /// \brief Toggles the input's logic state 17 | void ToggleState(void); 18 | 19 | /// \brief Getter for the current output state number pOutput of this cell 20 | /// \param pOutput: The number of the output to retreive 21 | /// \return The logic state of this cell's output number pOutput 22 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 23 | 24 | public slots: 25 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 26 | void OnShutdown(void) override; 27 | 28 | /// \brief Initializes the logic cell's states and triggers a component repaint 29 | void OnWakeUp(void) override; 30 | 31 | }; 32 | 33 | #endif // LOGICINPUTCELL_H 34 | -------------------------------------------------------------------------------- /Components/Inputs/LogicInput.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICINPUT_H 2 | #define LOGICINPUT_H 3 | 4 | #include "../IBaseComponent.h" 5 | #include "HelperStructures.h" 6 | #include "LogicCells/LogicInputCell.h" 7 | 8 | /// 9 | /// \brief The LogicInput class represents a logic switch input 10 | /// 11 | class LogicInput : public IBaseComponent 12 | { 13 | Q_OBJECT 14 | public: 15 | /// \brief Constructor for LogicInput 16 | /// \param pCoreLogic: Pointer to the core logic 17 | LogicInput(const CoreLogic* pCoreLogic); 18 | 19 | /// \brief Copy constructor for LogicInput 20 | /// \param pObj: The object to be copied 21 | /// \param pCoreLogic: Pointer to the core logic 22 | LogicInput(const LogicInput& pObj, const CoreLogic* pCoreLogic); 23 | 24 | /// \brief Constructor for loading from JSON 25 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 26 | /// \param pJson: The JSON object to load the component's data from 27 | LogicInput(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 28 | 29 | /// \brief Clone function for the input component 30 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 31 | /// \return A pointer to the new component 32 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 33 | 34 | /// \brief Triggers the switch input to toggle if in simulation mode 35 | /// \param pEvent: Pointer to the mouse press event 36 | void mousePressEvent(QGraphicsSceneMouseEvent *pEvent) override; 37 | 38 | /// \brief Defines the bounding rect of this component 39 | /// \return A rectangle describing the bounding rect 40 | QRectF boundingRect(void) const override; 41 | 42 | /// \brief Sets the Z-value to its defined value, to reset it after components have been copied 43 | void ResetZValue(void) override; 44 | 45 | /// \brief Saves the dats of this component to the given JSON object 46 | /// \return The JSON object with the component data 47 | QJsonObject GetJson(void) const override; 48 | 49 | /// \brief Gets the minimum version compatible with this component 50 | /// \return the minimum version 51 | SwVersion GetMinVersion(void) const override; 52 | 53 | protected: 54 | /// \brief Paints the input component 55 | /// \param pPainter: The painter to use 56 | /// \param pItem: Contains drawing parameters 57 | /// \param pWidget: Unused, the widget that is been painted on 58 | void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pItem, QWidget *pWidget) override; 59 | }; 60 | 61 | #endif // LOGICINPUT_H 62 | -------------------------------------------------------------------------------- /Components/LogicDiodeCell.cpp: -------------------------------------------------------------------------------- 1 | #include "LogicDiodeCell.h" 2 | #include "CoreLogic.h" 3 | 4 | LogicDiodeCell::LogicDiodeCell(const CoreLogic* pCoreLogic): 5 | LogicBaseCell(1, 1) // Diodes always have exactly one input wire and one output wire 6 | { 7 | QObject::connect(pCoreLogic, &CoreLogic::SimulationStartSignal, this, &LogicDiodeCell::OnWakeUp); 8 | QObject::connect(pCoreLogic, &CoreLogic::SimulationStopSignal, this, &LogicDiodeCell::OnShutdown); 9 | } 10 | 11 | void LogicDiodeCell::SetInputState(uint32_t pInput, LogicState pState) 12 | { 13 | LogicBaseCell::SetInputState(pInput, pState); 14 | 15 | LogicState newOutputState = LogicState::LOW; 16 | 17 | if (mCurrentOutputStates[0] != mInputStates[0]) 18 | { 19 | newOutputState = mInputStates[0]; 20 | 21 | emit StateChangedSignal(); 22 | 23 | mCurrentOutputStates[0] = newOutputState; 24 | mNextOutputStates[0] = newOutputState; 25 | 26 | for (const auto& outputConnection : mOutputCells) 27 | { 28 | if (outputConnection.first != nullptr) 29 | { 30 | outputConnection.first->SetInputState(outputConnection.second, newOutputState); 31 | } 32 | } 33 | } 34 | } 35 | 36 | LogicState LogicDiodeCell::GetOutputState(uint32_t pOutput) const 37 | { 38 | Q_UNUSED(pOutput); 39 | return mCurrentOutputStates[0]; 40 | } 41 | 42 | void LogicDiodeCell::OnWakeUp() 43 | { 44 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 45 | mNextOutputStates = std::vector{1, LogicState::LOW}; 46 | mIsActive = true; 47 | mStateChanged = true; 48 | } 49 | 50 | void LogicDiodeCell::OnShutdown() 51 | { 52 | mOutputCells = std::vector, uint32_t>>(mOutputCells.size(), std::make_pair(nullptr, 0)); 53 | mInputStates = std::vector{LogicState::LOW}; 54 | mInputConnected = std::vector(mInputConnected.size(), false); 55 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 56 | mNextOutputStates = std::vector{1, LogicState::LOW}; 57 | //mOutputInverted = std::vector{false}; 58 | //mInputInverted = std::vector{false}; 59 | mIsActive = false; 60 | mStateChanged = true; 61 | } 62 | -------------------------------------------------------------------------------- /Components/LogicDiodeCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICDIODECELL_H 2 | #define LOGICDIODECELL_H 3 | 4 | #include "LogicBaseCell.h" 5 | 6 | class CoreLogic; 7 | 8 | /// 9 | /// \brief Logic cell class for the logic diode ConPoints 10 | /// 11 | class LogicDiodeCell : public LogicBaseCell 12 | { 13 | Q_OBJECT 14 | public: 15 | /// \brief Constructor for LogicDiodeCell 16 | /// \param pCoreLogic: Pointer to the core logic 17 | LogicDiodeCell(const CoreLogic* pCoreLogic); 18 | 19 | void SetInputState(uint32_t pInput, LogicState pState) override; 20 | 21 | /// \brief Getter for the current output state number pOutput of this cell 22 | /// \param pOutput: The number of the output to retreive 23 | /// \return The logic state of this cell's output number pOutput 24 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 25 | 26 | void CommitState(void) override {}; 27 | 28 | public slots: 29 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 30 | void OnShutdown(void) override; 31 | 32 | /// \brief Initializes the logic cell's states and triggers a component repaint 33 | void OnWakeUp(void) override; 34 | 35 | protected: 36 | LogicState mState; 37 | }; 38 | 39 | #endif // LOGICDIODECELL_H 40 | -------------------------------------------------------------------------------- /Components/LogicWireCell.cpp: -------------------------------------------------------------------------------- 1 | #include "LogicWireCell.h" 2 | 3 | LogicWireCell::LogicWireCell(): 4 | LogicBaseCell(0, 1) 5 | {} 6 | 7 | void LogicWireCell::SetInputState(uint32_t pInput, LogicState pState) 8 | { 9 | LogicBaseCell::SetInputState(pInput, pState); 10 | 11 | LogicState newOutputState = LogicState::LOW; 12 | 13 | for (const auto& inputState : mInputStates) 14 | { 15 | if (inputState == LogicState::HIGH) 16 | { 17 | newOutputState = LogicState::HIGH; 18 | break; 19 | } 20 | } 21 | 22 | if (mCurrentOutputStates[0] != newOutputState) 23 | { 24 | emit StateChangedSignal(); 25 | 26 | mCurrentOutputStates[0] = newOutputState; 27 | mNextOutputStates[0] = newOutputState; 28 | 29 | for (const auto& outputConnection : mOutputCells) 30 | { 31 | if (outputConnection.first != nullptr) 32 | { 33 | outputConnection.first->SetInputState(outputConnection.second, newOutputState); 34 | } 35 | } 36 | } 37 | } 38 | 39 | void LogicWireCell::AppendOutput(const std::shared_ptr& pLogicCell, uint32_t pInput) 40 | { 41 | mOutputCells.push_back(std::make_pair(pLogicCell, pInput)); 42 | mOutputInverted.push_back(false); 43 | pLogicCell->SetConnected(pInput); 44 | } 45 | 46 | void LogicWireCell::AddInputSlot() 47 | { 48 | mInputStates.push_back(LogicState::LOW); 49 | mInputInverted.push_back(false); 50 | } 51 | 52 | uint32_t LogicWireCell::GetInputSize(void) const 53 | { 54 | return mInputStates.size(); 55 | } 56 | 57 | LogicState LogicWireCell::GetOutputState(uint32_t pOutput) const 58 | { 59 | Q_UNUSED(pOutput); 60 | return mCurrentOutputStates[0]; 61 | } 62 | 63 | void LogicWireCell::OnWakeUp() 64 | { 65 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 66 | mNextOutputStates = std::vector{1, LogicState::LOW}; 67 | mIsActive = true; 68 | mStateChanged = true; 69 | } 70 | 71 | void LogicWireCell::OnShutdown() 72 | { 73 | mOutputCells.clear(); 74 | mInputStates.clear(); 75 | mInputConnected.clear(); 76 | mCurrentOutputStates = std::vector{1, LogicState::LOW}; 77 | mNextOutputStates = std::vector{1, LogicState::LOW}; 78 | mOutputInverted.clear(); 79 | mInputInverted.clear(); 80 | mIsActive = false; 81 | mStateChanged = true; 82 | } 83 | -------------------------------------------------------------------------------- /Components/LogicWireCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICWIRECELL_H 2 | #define LOGICWIRECELL_H 3 | 4 | #include "LogicBaseCell.h" 5 | 6 | class CoreLogic; 7 | 8 | /// 9 | /// \brief Logic cell class for the logic wires and non-diode ConPoints 10 | /// 11 | class LogicWireCell : public LogicBaseCell 12 | { 13 | Q_OBJECT 14 | public: 15 | /// \brief Constructor for LogicWireCell 16 | LogicWireCell(void); 17 | 18 | /// \brief The logic function that determines the output states based on the inputs 19 | //void LogicFunction(void) override; 20 | 21 | void SetInputState(uint32_t pInput, LogicState pState) override; 22 | 23 | /// \brief Getter for the current output state number pOutput of this cell 24 | /// \param pOutput: The number of the output to retreive 25 | /// \return The logic state of this cell's output number pOutput 26 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 27 | 28 | /// \brief Appends a logic cell as a new output to this wire cell 29 | /// \param pLogicCell: The logic cell to connect 30 | /// \param pInput: The number of the input of pCell to connect to 31 | void AppendOutput(const std::shared_ptr& pLogicCell, uint32_t pInput); 32 | 33 | /// \brief Adds an input slot to this wire cell where other logic cells can connect to 34 | void AddInputSlot(void); 35 | 36 | /// \brief Getter for the number of inputs to this wire cell 37 | /// \return The number of inputs to this wire cell 38 | uint32_t GetInputSize(void) const; 39 | 40 | void CommitState(void) override {}; 41 | 42 | public slots: 43 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 44 | void OnShutdown(void) override; 45 | 46 | /// \brief Initializes the logic cell's states and triggers a component repaint 47 | void OnWakeUp(void) override; 48 | }; 49 | 50 | #endif // LOGICWIRECELL_H 51 | -------------------------------------------------------------------------------- /Components/Outputs/LogicCells/LogicOutputCell.cpp: -------------------------------------------------------------------------------- 1 | #include "LogicOutputCell.h" 2 | 3 | LogicOutputCell::LogicOutputCell(): 4 | LogicBaseCell(1, 0), 5 | mState(LogicState::LOW) 6 | {} 7 | 8 | void LogicOutputCell::LogicFunction() 9 | { 10 | if (mState != mInputStates[0]) 11 | { 12 | mState = mInputStates[0]; 13 | mStateChanged = true; 14 | } 15 | } 16 | 17 | LogicState LogicOutputCell::GetOutputState(uint32_t pOutput) const 18 | { 19 | Q_UNUSED(pOutput); 20 | return mState; 21 | } 22 | 23 | void LogicOutputCell::OnWakeUp() 24 | { 25 | mInputStates = std::vector{1, LogicState::LOW}; 26 | mState = LogicState::LOW; 27 | mIsActive = true; 28 | mStateChanged = true; 29 | } 30 | 31 | void LogicOutputCell::OnShutdown() 32 | { 33 | mInputStates = std::vector{1, LogicState::LOW}; 34 | mInputConnected = std::vector(mInputConnected.size(), false); 35 | mState = LogicState::LOW; 36 | mIsActive = false; 37 | mStateChanged = true; 38 | } 39 | -------------------------------------------------------------------------------- /Components/Outputs/LogicCells/LogicOutputCell.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICOUTPUTCELL_H 2 | #define LOGICOUTPUTCELL_H 3 | 4 | #include "Components/LogicBaseCell.h" 5 | 6 | /// 7 | /// \brief Logic cell class for the logic output 8 | /// 9 | class LogicOutputCell : public LogicBaseCell 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for LogicOutputCell 14 | LogicOutputCell(void); 15 | 16 | /// \brief The logic function that determines the output states based on the inputs 17 | void LogicFunction(void) override; 18 | 19 | /// \brief Getter for the current output state number pOutput of this cell 20 | /// \param pOutput: The number of the output to retreive 21 | /// \return The logic state of this cell's output number pOutput 22 | LogicState GetOutputState(uint32_t pOutput = 0) const override; 23 | 24 | public slots: 25 | /// \brief Sets the in- and outputs low for edit mode and triggers a component repaint 26 | void OnShutdown(void) override; 27 | 28 | /// \brief Initializes the logic cell's states and triggers a component repaint 29 | void OnWakeUp(void) override; 30 | 31 | protected: 32 | LogicState mState; 33 | }; 34 | 35 | #endif // LOGICOUTPUTCELL_H 36 | -------------------------------------------------------------------------------- /Components/Outputs/LogicOutput.h: -------------------------------------------------------------------------------- 1 | #ifndef LOGICOUTPUT_H 2 | #define LOGICOUTPUT_H 3 | 4 | #include "../IBaseComponent.h" 5 | #include "HelperStructures.h" 6 | 7 | /// 8 | /// \brief The LogicOutput class represents a logic output 9 | /// 10 | class LogicOutput : public IBaseComponent 11 | { 12 | Q_OBJECT 13 | public: 14 | /// \brief Constructor for LogicOutput 15 | /// \param pCoreLogic: Pointer to the core logic 16 | /// \param pColor: The output's color 17 | LogicOutput(const CoreLogic* pCoreLogic, OutputColor pColor = OutputColor::DEFAULT); 18 | 19 | /// \brief Copy constructor for LogicOutput 20 | /// \param pObj: The object to be copied 21 | /// \param pCoreLogic: Pointer to the core logic 22 | LogicOutput(const LogicOutput& pObj, const CoreLogic* pCoreLogic); 23 | 24 | /// \brief Constructor for loading from JSON 25 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 26 | /// \param pJson: The JSON object to load the component's data from 27 | LogicOutput(const CoreLogic* pCoreLogic, const QJsonObject& pJson); 28 | 29 | /// \brief Clone function for the output component 30 | /// \param pCoreLogic: Pointer to the core logic, used to connect the component's signals and slots 31 | /// \return A pointer to the new component 32 | IBaseComponent* CloneBaseComponent(const CoreLogic* pCoreLogic) const override; 33 | 34 | /// \brief Defines the bounding rect of this component 35 | /// \return A rectangle describing the bounding rect 36 | QRectF boundingRect(void) const override; 37 | 38 | /// \brief Sets the Z-value to its defined value, to reset it after components have been copied 39 | void ResetZValue(void) override; 40 | 41 | /// \brief Saves the dats of this component to the given JSON object 42 | /// \return The JSON object with the component data 43 | QJsonObject GetJson(void) const override; 44 | 45 | /// \brief Gets the minimum version compatible with this component 46 | /// \return the minimum version 47 | SwVersion GetMinVersion(void) const override; 48 | 49 | protected: 50 | /// \brief Paints the output component 51 | /// \param pPainter: The painter to use 52 | /// \param pItem: Contains drawing parameters 53 | /// \param pWidget: Unused, the widget that is been painted on 54 | void paint(QPainter *pPainter, const QStyleOptionGraphicsItem *pItem, QWidget *pWidget) override; 55 | 56 | protected: 57 | OutputColor mColor; 58 | }; 59 | 60 | #endif // LOGICOUTPUT_H 61 | -------------------------------------------------------------------------------- /Gui/AboutDialog.cpp: -------------------------------------------------------------------------------- 1 | #include "AboutDialog.h" 2 | #include "ui_AboutDialog.h" 3 | #include 4 | 5 | AboutDialog::AboutDialog(QWidget *pParent): 6 | QDialog(pParent), 7 | mUi(new Ui::AboutDialog) 8 | { 9 | const QString BUILD_TIME = QStringLiteral(__DATE__ " " __TIME__); 10 | 11 | mUi->setupUi(this); 12 | 13 | mUi->uSoftwareNameLabel->setText(tr("Version %0").arg(QString(FULL_VERSION))); 14 | 15 | QString buildMode; 16 | #ifdef QT_DEBUG 17 | buildMode = "Debug"; 18 | #else 19 | buildMode = "Release"; 20 | #endif 21 | 22 | mUi->uBuildInfoText->setText(tr("Software version: %0
Build time: %1
Build mode: %2
Qt version: %3
Compiler: MinGW 64-bit %4").arg(QString(FULL_VERSION), BUILD_TIME, buildMode, qVersion(), __VERSION__)); 23 | 24 | QObject::connect(mUi->uCheckForUpdateButton, &QPushButton::clicked, this, &AboutDialog::CheckForUpdateClickedSignal); 25 | } 26 | 27 | AboutDialog::~AboutDialog() 28 | { 29 | delete mUi; 30 | } 31 | -------------------------------------------------------------------------------- /Gui/AboutDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef ABOUTDIALOG_H 2 | #define ABOUTDIALOG_H 3 | 4 | #include 5 | 6 | namespace Ui { 7 | class AboutDialog; 8 | } 9 | 10 | /// 11 | /// \brief The WelcomeDialog class represents the about dialog 12 | /// 13 | class AboutDialog : public QDialog 14 | { 15 | Q_OBJECT 16 | public: 17 | /// \brief Constructor for the about dialog 18 | /// \param pParent: Pointer to the parent widget 19 | explicit AboutDialog(QWidget *pParent = nullptr); 20 | 21 | /// \brief Destructor for the about dialog 22 | ~AboutDialog(void) override; 23 | 24 | signals: 25 | /// \brief Emitted when the user clicks the update button 26 | void CheckForUpdateClickedSignal(void); 27 | 28 | protected: 29 | Ui::AboutDialog *mUi; 30 | }; 31 | 32 | #endif // ABOUTDIALOG_H 33 | -------------------------------------------------------------------------------- /Gui/IconToolButton.cpp: -------------------------------------------------------------------------------- 1 | #include "IconToolButton.h" 2 | 3 | #include 4 | 5 | IconToolButton::IconToolButton(QWidget *pParent) : 6 | QPushButton(pParent) 7 | { 8 | QObject::connect(this, &QAbstractButton::toggled, this, &IconToolButton::UpdateIcon); 9 | } 10 | 11 | void IconToolButton::SetIcon(const QImage &pImage) 12 | { 13 | mUncheckedIcon = QIcon(QPixmap::fromImage(pImage)); 14 | 15 | { 16 | auto image = pImage; 17 | image.invertPixels(); 18 | 19 | mCheckedIcon = QIcon(QPixmap::fromImage(image)); 20 | } 21 | 22 | { 23 | auto img = pImage; 24 | img.fill(Qt::transparent); 25 | 26 | QPainter painter(&img); 27 | painter.setCompositionMode(QPainter::CompositionMode_Source); 28 | painter.setOpacity(0.1); 29 | painter.drawImage(0, 0, pImage); 30 | 31 | mUncheckedIcon.addPixmap(QPixmap::fromImage(img), QIcon::Disabled); 32 | mCheckedIcon.addPixmap(QPixmap::fromImage(img), QIcon::Disabled); 33 | } 34 | 35 | UpdateIcon(isChecked()); 36 | } 37 | 38 | void IconToolButton::UpdateIcon(bool pChecked) 39 | { 40 | if (pChecked && isCheckable()) 41 | { 42 | this->setIcon(mCheckedIcon); 43 | } 44 | else 45 | { 46 | this->setIcon(mUncheckedIcon); 47 | } 48 | } 49 | -------------------------------------------------------------------------------- /Gui/IconToolButton.h: -------------------------------------------------------------------------------- 1 | #ifndef ICONTOOLBUTTON_H 2 | #define ICONTOOLBUTTON_H 3 | 4 | #include 5 | 6 | /// 7 | /// \brief The IconToolButton class represents a tool button with associated icons 8 | /// 9 | class IconToolButton : public QPushButton 10 | { 11 | Q_OBJECT 12 | public: 13 | /// \brief Constructor for IconToolButton 14 | /// \param pParent: Pointer to the parent widget 15 | IconToolButton(QWidget *pParent = nullptr); 16 | 17 | /// \brief Setter for the icon that is displayed when the button is not checkable 18 | /// \param pImage: Image for the icon to display 19 | void SetIcon(const QImage &pImage); 20 | 21 | protected: 22 | /// \brief Updates the icon based on the buttons state 23 | /// \param pChecked 24 | void UpdateIcon(bool pChecked); 25 | 26 | protected: 27 | QIcon mCheckedIcon; 28 | QIcon mUncheckedIcon; 29 | }; 30 | 31 | #endif // ICONTOOLBUTTON_H 32 | -------------------------------------------------------------------------------- /Gui/TutorialFrame.h: -------------------------------------------------------------------------------- 1 | #ifndef TUTORIALFRAME_H 2 | #define TUTORIALFRAME_H 3 | 4 | #include 5 | #include 6 | 7 | #include "HelperStructures.h" 8 | 9 | namespace Ui { 10 | class TutorialFrame; 11 | } 12 | static constexpr auto NUMBER_OF_STEPS = 8; 13 | static const std::array HAS_AUTO_ADVANCE{false, true, true, true, true, true, true, true}; 14 | 15 | class TutorialFrame : public QWidget 16 | { 17 | Q_OBJECT 18 | 19 | public: 20 | /// \brief Constructor for TutorialFrame 21 | /// \param pParent: Reference to the parent widget 22 | explicit TutorialFrame(QWidget *pParent = nullptr); 23 | 24 | /// \brief Default destructor for TutorialFrame 25 | ~TutorialFrame(void) override; 26 | 27 | void SetTopLeftPosition(QPoint pPos); 28 | void SetTopRightPosition(QPoint pPos); 29 | void SetCenterPosition(QPoint pPos); 30 | 31 | void StartTutorial(void); 32 | 33 | void OnAdvanceStepApproved(TutorialStep pStep); 34 | void OnAdvanceStepDeclined(TutorialStep pStep); 35 | 36 | uint8_t GetCurrentStep(void) const; 37 | 38 | void ApproveStepOnCondition(TutorialStep pStep); 39 | 40 | signals: 41 | void AdvanceStepRequestSignal(TutorialStep pStep); 42 | 43 | void CurrentStepChangedSignal(TutorialStep pStep); 44 | 45 | protected: 46 | void SetCurrentStep(TutorialStep pStep); 47 | 48 | void UpdateContinueButton(bool pEnabled); 49 | 50 | std::optional LoadTutorialFile(const QString &pFilename); 51 | 52 | protected: 53 | Ui::TutorialFrame *mUi; 54 | 55 | TutorialStep mCurrentStep = TutorialStep::NONE; 56 | uint8_t mNumberOfSteps = NUMBER_OF_STEPS; 57 | 58 | QIcon mWhiteCheckIcon; 59 | }; 60 | 61 | #endif // TUTORIALFRAME_H 62 | -------------------------------------------------------------------------------- /Gui/WelcomeDialog.h: -------------------------------------------------------------------------------- 1 | #ifndef WELCOMEDIALOG_H 2 | #define WELCOMEDIALOG_H 3 | 4 | #include "QtAwesome.h" 5 | 6 | #include 7 | #include 8 | 9 | // forward declarations 10 | namespace Ui { 11 | class WelcomeDialog; 12 | } 13 | 14 | /// 15 | /// \brief The WelcomeDialog class represents the welcome dialog pop-up 16 | /// 17 | class WelcomeDialog : public QDialog 18 | { 19 | Q_OBJECT 20 | public: 21 | /// \brief Constructor for the welcome dialog 22 | /// \param pAwesome: Reference to the QtAwesome object 23 | /// \param pParent: Pointer to the parent widget 24 | explicit WelcomeDialog(QtAwesome &pAwesome, QWidget *pParent = nullptr); 25 | 26 | /// \brief Destructor for the welcome dialog 27 | ~WelcomeDialog(void) override; 28 | 29 | /// \brief Sets the "show on startup" checkbox on the dialog 30 | /// \param pShowOnStartup: Whether the checbox should be checked or not 31 | void SetShowOnStartup(bool pShowOnStartup); 32 | 33 | /// \brief Sets the recently used files 34 | /// \param pRecentFilePaths: The file infos to display as recent files 35 | void SetRecentFilePaths(const std::vector& pRecentFilePaths); 36 | 37 | signals: 38 | /// \brief Emitted when the user clicks the new circuit button 39 | void NewCircuitClickedSignal(void); 40 | 41 | /// \brief Emitted when the user clicks the open circuit button 42 | void OpenCircuitClickedSignal(void); 43 | 44 | /// \brief Emitted when the user clicks the GitHub button 45 | void OpenGithubClickedSignal(void); 46 | 47 | /// \brief Emitted when the user clicks the Twitter button 48 | void OpenTwitterClickedSignal(void); 49 | 50 | /// \brief Emitted when the user clicks the update button 51 | void CheckForUpdateClickedSignal(void); 52 | 53 | /// \brief Emitted when the user clicks on a recently used file 54 | /// \param pPath: The file info of the recently used file 55 | void OpenRecentClickedSignal(const QFileInfo& pPath); 56 | 57 | /// \brief Emitted when the user toggles the "show on startup" checkbox 58 | /// \param pChecked: The new checkbox state 59 | void ShowOnStartupToggledSignal(bool pChecked); 60 | 61 | protected: 62 | Ui::WelcomeDialog *mUi; 63 | 64 | QtAwesome &mAwesome; // Contains Fontawesome logos 65 | 66 | QVariantMap mStandardIconVariant; 67 | QVariantMap mWhiteIconVariant; 68 | 69 | std::vector mRecentFilePaths; 70 | }; 71 | 72 | #endif // WELCOMEDIALOG_H 73 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2025 Simon Buchholz 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /Linkuit_Studio.pro: -------------------------------------------------------------------------------- 1 | QT += core gui 2 | 3 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 4 | 5 | CONFIG += c++14 6 | 7 | # Default rules for deployment. 8 | qnx: target.path = /tmp/$${TARGET}/bin 9 | else: unix:!android: target.path = /opt/$${TARGET}/bin 10 | !isEmpty(target.path): INSTALLS += target 11 | 12 | TARGET_SUBDIR = 13 | CONFIG(debug, debug|release) { 14 | TARGET_SUBDIR = debug 15 | } else { 16 | TARGET_SUBDIR = release 17 | } 18 | 19 | CONF_FILE = $$PWD/qt.conf 20 | DEST_DIR = $$OUT_PWD/$$TARGET_SUBDIR 21 | 22 | win32: QMAKE_POST_LINK += copy /Y $$shell_path($$CONF_FILE) $$shell_path($$DEST_DIR) 23 | unix: QMAKE_POST_LINK += cp $$shell_path($$CONF_FILE) $$shell_path($$DEST_DIR) 24 | 25 | #build_nr.commands = $${PWD}/build_inc.bat 26 | #build_nr.depends = FORCE 27 | #QMAKE_EXTRA_TARGETS += build_nr 28 | #PRE_TARGETDEPS += build_nr 29 | 30 | FULL_VERSION = "$$cat($${OUT_PWD}/version.txt)" 31 | DEFINES += FULL_VERSION='\\"$$FULL_VERSION\\"' 32 | 33 | VERSION = "$$FULL_VERSION" 34 | 35 | SOURCES += \ 36 | $${PWD}/main.cpp 37 | 38 | RESOURCES += \ 39 | Gui/resources.qrc 40 | 41 | RC_ICONS = images/icons/icon_default.ico \ 42 | images/icons/icon_file.ico 43 | 44 | include(Common.pri) 45 | include(QtAwesome/QtAwesome.pri) 46 | -------------------------------------------------------------------------------- /QtAwesome/QtAwesome.pri: -------------------------------------------------------------------------------- 1 | 2 | INCLUDEPATH += $$PWD 3 | 4 | SOURCES += $$PWD/QtAwesome.cpp \ 5 | $$PWD/QtAwesomeAnim.cpp 6 | 7 | HEADERS += $$PWD/QtAwesome.h \ 8 | $$PWD/QtAwesomeAnim.h 9 | 10 | RESOURCES += $$PWD/QtAwesome.qrc 11 | 12 | 13 | -------------------------------------------------------------------------------- /QtAwesome/QtAwesome.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2013-04-18T13:28:42 4 | # 5 | #------------------------------------------------- 6 | 7 | TARGET = QtAwesome 8 | TEMPLATE = lib 9 | CONFIG += staticlib c++11 10 | QT += widgets 11 | 12 | SOURCES += QtAwesome.cpp QtAwesomeAnim.cpp 13 | HEADERS += QtAwesome.h QtAwesomeAnim.h 14 | 15 | isEmpty(PREFIX) { 16 | unix { 17 | PREFIX = /usr 18 | } else { 19 | PREFIX = $$[QT_INSTALL_PREFIX] 20 | } 21 | } 22 | 23 | install_headers.files = QtAwesome.h QtAwesomeAnim.h 24 | install_headers.path = $$PREFIX/include 25 | target.path = $$PREFIX/lib 26 | INSTALLS += install_headers target 27 | 28 | RESOURCES += \ 29 | QtAwesome.qrc 30 | -------------------------------------------------------------------------------- /QtAwesome/QtAwesome.qrc: -------------------------------------------------------------------------------- 1 | 2 | 3 | fonts/fontawesome-4.7.0.ttf 4 | 5 | 6 | -------------------------------------------------------------------------------- /QtAwesome/QtAwesomeAnim.cpp: -------------------------------------------------------------------------------- 1 | #include "QtAwesomeAnim.h" 2 | 3 | #include 4 | #include 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | QtAwesomeAnimation::QtAwesomeAnimation(QWidget *parentWidget, int interval, int step) 11 | : parentWidgetRef_( parentWidget ) 12 | , timer_( QTAWESOME_NULL ) 13 | , interval_( interval ) 14 | , step_( step ) 15 | , angle_( 0.0f ) 16 | { 17 | 18 | } 19 | 20 | void QtAwesomeAnimation::setup( QPainter &painter, const QRect &rect) 21 | { 22 | // first time set the timer 23 | if( !timer_ ) 24 | { 25 | timer_ = new QTimer(); 26 | connect(timer_,SIGNAL(timeout()), this, SLOT(update()) ); 27 | timer_->start(interval_); 28 | } 29 | else 30 | { 31 | //timer, angle, self.step = self.info[self.parent_widget] 32 | float x_center = rect.width() * 0.5f; 33 | float y_center = rect.height() * 0.5f; 34 | painter.translate(x_center, y_center); 35 | painter.rotate(angle_); 36 | painter.translate(-x_center, -y_center); 37 | } 38 | } 39 | 40 | 41 | void QtAwesomeAnimation::update() 42 | { 43 | angle_ += step_; 44 | angle_ = std::fmod( angle_, 360); 45 | parentWidgetRef_->update(); 46 | } 47 | -------------------------------------------------------------------------------- /QtAwesome/QtAwesomeAnim.h: -------------------------------------------------------------------------------- 1 | #ifndef QTAWESOMEANIMATION_H 2 | #define QTAWESOMEANIMATION_H 3 | 4 | #if __cplusplus <= 199711L 5 | #define QTAWESOME_NULL NULL 6 | #else 7 | #define QTAWESOME_NULL nullptr 8 | #endif 9 | 10 | #include 11 | 12 | class QPainter; 13 | class QRect; 14 | class QTimer; 15 | class QWidget; 16 | 17 | /// 18 | /// Basic Animation Support for QtAwesome (Inspired by https://github.com/spyder-ide/qtawesome) 19 | /// 20 | class QtAwesomeAnimation : public QObject 21 | { 22 | Q_OBJECT 23 | 24 | public: 25 | QtAwesomeAnimation( QWidget* parentWidget, int interval=10, int step=1); 26 | 27 | void setup( QPainter& painter, const QRect& rect ); 28 | 29 | public slots: 30 | void update(); 31 | 32 | private: 33 | QWidget* parentWidgetRef_; 34 | QTimer* timer_; 35 | int interval_; 36 | int step_; 37 | float angle_; 38 | 39 | }; 40 | 41 | 42 | #endif // QTAWESOMEANIMATION_H 43 | -------------------------------------------------------------------------------- /QtAwesome/fonts/fontawesome-4.7.0.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/QtAwesome/fonts/fontawesome-4.7.0.ttf -------------------------------------------------------------------------------- /RuntimeConfigParser.h: -------------------------------------------------------------------------------- 1 | #ifndef RUNTIMECONFIGPARSER_H 2 | #define RUNTIMECONFIGPARSER_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | 11 | /// 12 | /// \brief The RuntimeConfigParser class parses the runtime config file 13 | /// 14 | class RuntimeConfigParser 15 | { 16 | public: 17 | /// \brief Constructor for the RuntimeConfigParser 18 | RuntimeConfigParser(void); 19 | 20 | /// \brief Loads the runtime config from the given file path 21 | /// \param pPath: The path to the runtime config 22 | /// \return True, if the file was loaded sucessfully 23 | bool LoadRuntimeConfig(const QString& pPath); 24 | 25 | /// \brief Saves the runtime configto the given file path 26 | /// \param pPath: The path to save the runtime config into 27 | /// \return True, if the file was saved sucessfully 28 | bool SaveRuntimeConfig(const QString& pPath); 29 | 30 | /// \brief Returns true if the welcome dialog should be displayed on startup 31 | /// \return True, if the welcome dialog should be displayed on startup 32 | bool IsWelcomeDialogEnabledOnStartup(void) const; 33 | 34 | /// \brief Setter for whether the welcome dialog should be displayed on startup 35 | /// \param pShowOnStartup: If true, the welcome dialog will be displayed on startup 36 | void IsWelcomeDialogEnabledOnStartup(bool pShowOnStartup); 37 | 38 | /// \brief Getter for the list of recent files 39 | /// \return Vector of recent files 40 | const std::vector& GetRecentFilePaths(void) const; 41 | 42 | /// \brief Adds a file's info to the list of recent files 43 | /// \param pFilePath: The file info to add 44 | void AddRecentFilePath(const QFileInfo& pFilePath); 45 | 46 | /// \brief Tries to remove a file from the list of recent files 47 | /// \param pFilePath: The file info to remove 48 | void RemoveRecentFilePath(const QFileInfo &pFilePath); 49 | 50 | /// \brief Getter for the last file path 51 | /// \return The path of the last opened or saved file 52 | const QString& GetLastFilePath(void) const; 53 | 54 | /// \brief Setter for the last file path 55 | /// \param pLastFilePath: The path of the last opened or saved file 56 | void SetLastFilePath(const QString& pLastFilePath); 57 | 58 | protected: 59 | std::vector mRecentFiles; 60 | 61 | bool mIsWelcomeDialogEnabledOnStartup; 62 | 63 | QString mLastFilePath; 64 | }; 65 | 66 | #endif // RUNTIMECONFIGPARSER_H 67 | -------------------------------------------------------------------------------- /Undo/UndoAddType.cpp: -------------------------------------------------------------------------------- 1 | #include "UndoAddType.h" 2 | 3 | UndoAddType::UndoAddType(std::vector &pAddedComponents): 4 | mAddedComponents(pAddedComponents), 5 | mDeletedComponents() 6 | {} 7 | 8 | UndoAddType::UndoAddType(std::vector &pAddedComponents, std::vector &pDeletedComponents): 9 | mAddedComponents(pAddedComponents), 10 | mDeletedComponents(pDeletedComponents) 11 | {} 12 | 13 | UndoAddType::~UndoAddType() 14 | { 15 | for (auto& comp : mDeletedComponents) 16 | { 17 | delete comp; 18 | } 19 | } 20 | 21 | undo::Type UndoAddType::Type() const 22 | { 23 | return undo::Type::ADD; 24 | } 25 | 26 | const std::vector& UndoAddType::AddedComponents() const 27 | { 28 | return mAddedComponents; 29 | } 30 | 31 | const std::vector& UndoAddType::DeletedComponents() const 32 | { 33 | return mDeletedComponents; 34 | } 35 | -------------------------------------------------------------------------------- /Undo/UndoAddType.h: -------------------------------------------------------------------------------- 1 | #ifndef UNDOADDTYPE_H 2 | #define UNDOADDTYPE_H 3 | 4 | #include "UndoBaseType.h" 5 | #include "../Components/IBaseComponent.h" 6 | 7 | /// 8 | /// \brief The UndoAddType class represents an undo action where objects where added and deleted 9 | /// 10 | class UndoAddType : public UndoBaseType 11 | { 12 | public: 13 | /// \brief Constructor for the UndoAddType 14 | /// \param pAddedComponents: Components that have been added 15 | UndoAddType(std::vector &pAddedComponents); 16 | 17 | /// \brief Constructor for the UndoAddType 18 | /// \param pAddedComponents: Components that have been added 19 | /// \param pDeletedComponents: Components that have been deleted 20 | UndoAddType(std::vector &pAddedComponents, std::vector &pDeletedComponents); 21 | 22 | /// \brief Destructor for the UndoAddType 23 | ~UndoAddType(void) override; 24 | 25 | /// \brief Gets the type of this undo action 26 | /// \return An undo::Type object 27 | undo::Type Type(void) const override; 28 | 29 | /// \brief Getter for the added components 30 | /// \return Vector containing pointers to the added components 31 | const std::vector& AddedComponents(void) const; 32 | 33 | /// \brief Getter for the deleted components 34 | /// \return Vector containing pointers to the deleted components 35 | const std::vector& DeletedComponents(void) const; 36 | 37 | protected: 38 | std::vector mAddedComponents; 39 | std::vector mDeletedComponents; 40 | }; 41 | 42 | #endif // UNDOADDTYPE_H 43 | -------------------------------------------------------------------------------- /Undo/UndoBaseType.cpp: -------------------------------------------------------------------------------- 1 | #include "UndoBaseType.h" 2 | 3 | UndoBaseType::UndoBaseType() 4 | {} 5 | -------------------------------------------------------------------------------- /Undo/UndoBaseType.h: -------------------------------------------------------------------------------- 1 | #ifndef UNDOBASETYPE_H 2 | #define UNDOBASETYPE_H 3 | 4 | #include "HelperStructures.h" 5 | 6 | /// 7 | /// \brief The UndoBaseType class represents a user action that can be undone 8 | /// 9 | class UndoBaseType 10 | { 11 | public: 12 | /// \brief Constructor for the UndoBaseType 13 | UndoBaseType(); 14 | 15 | /// \brief Default destructor for the UndoBaseType 16 | virtual ~UndoBaseType() = default; 17 | 18 | /// \brief Gets the type of this undo action 19 | /// \return An undo::Type object 20 | virtual undo::Type Type(void) const = 0; 21 | }; 22 | 23 | #endif // UNDOBASETYPE_H 24 | -------------------------------------------------------------------------------- /Undo/UndoConfigureType.cpp: -------------------------------------------------------------------------------- 1 | #include "UndoConfigureType.h" 2 | 3 | UndoConfigureType::UndoConfigureType(const std::shared_ptr& pData): 4 | mData(pData) 5 | {} 6 | 7 | undo::Type UndoConfigureType::Type() const 8 | { 9 | return undo::Type::CONFIGURE; 10 | } 11 | 12 | std::shared_ptr UndoConfigureType::Data(void) 13 | { 14 | return mData; 15 | } 16 | -------------------------------------------------------------------------------- /Undo/UndoCopyType.cpp: -------------------------------------------------------------------------------- 1 | #include "UndoCopyType.h" 2 | 3 | UndoCopyType::UndoCopyType(std::vector &pAddedComponents): 4 | mAddedComponents(pAddedComponents), 5 | mIsCompleted(false) 6 | {} 7 | 8 | UndoCopyType::UndoCopyType(std::vector &pMovedComponents, 9 | std::vector &pAddedComponents, 10 | std::vector &pDeletedComponents, 11 | QPointF pOffset): 12 | mMovedComponents(pMovedComponents), 13 | mAddedComponents(pAddedComponents), 14 | mDeletedComponents(pDeletedComponents), 15 | mOffset(pOffset), 16 | mIsCompleted(false) 17 | {} 18 | 19 | UndoCopyType::~UndoCopyType() 20 | { 21 | for (auto& comp : mDeletedComponents) 22 | { 23 | delete comp; 24 | } 25 | } 26 | 27 | undo::Type UndoCopyType::Type() const 28 | { 29 | return undo::Type::COPY; 30 | } 31 | 32 | const std::vector& UndoCopyType::MovedComponents() const 33 | { 34 | return mMovedComponents; 35 | } 36 | 37 | const std::vector& UndoCopyType::AddedComponents() const 38 | { 39 | return mAddedComponents; 40 | } 41 | 42 | const std::vector& UndoCopyType::DeletedComponents() const 43 | { 44 | return mDeletedComponents; 45 | } 46 | 47 | const QPointF UndoCopyType::Offset() const 48 | { 49 | return mOffset; 50 | } 51 | 52 | bool UndoCopyType::IsCompleted() const 53 | { 54 | return mIsCompleted; 55 | } 56 | 57 | void UndoCopyType::AppendMovedComponents(std::vector& pComponents) 58 | { 59 | Q_ASSERT(!mIsCompleted); 60 | mMovedComponents.insert(mMovedComponents.end(), pComponents.begin(), pComponents.end()); 61 | } 62 | 63 | void UndoCopyType::AppendAddedComponents(std::vector& pComponents) 64 | { 65 | Q_ASSERT(!mIsCompleted); 66 | mAddedComponents.insert(mAddedComponents.end(), pComponents.begin(), pComponents.end()); 67 | } 68 | 69 | void UndoCopyType::AppendDeletedComponents(std::vector& pComponents) 70 | { 71 | Q_ASSERT(!mIsCompleted); 72 | mDeletedComponents.insert(mDeletedComponents.end(), pComponents.begin(), pComponents.end()); 73 | } 74 | 75 | void UndoCopyType::SetOffset(const QPointF& pOffset) 76 | { 77 | Q_ASSERT(!mIsCompleted); 78 | mOffset = pOffset; 79 | } 80 | 81 | void UndoCopyType::MarkCompleted() 82 | { 83 | Q_ASSERT(!mIsCompleted); 84 | mIsCompleted = true; 85 | } 86 | -------------------------------------------------------------------------------- /Undo/UndoDeleteType.cpp: -------------------------------------------------------------------------------- 1 | #include "UndoDeleteType.h" 2 | 3 | UndoDeleteType::UndoDeleteType(std::vector &pDeletedComponents): 4 | mComponents(pDeletedComponents) 5 | {} 6 | 7 | UndoDeleteType::~UndoDeleteType() 8 | { 9 | for (auto& comp : mComponents) 10 | { 11 | delete comp; 12 | } 13 | } 14 | 15 | undo::Type UndoDeleteType::Type() const 16 | { 17 | return undo::Type::DEL; 18 | } 19 | 20 | const std::vector& UndoDeleteType::Components() const 21 | { 22 | return mComponents; 23 | } 24 | -------------------------------------------------------------------------------- /Undo/UndoDeleteType.h: -------------------------------------------------------------------------------- 1 | #ifndef UNDODELETETYPE_H 2 | #define UNDODELETETYPE_H 3 | 4 | #include "UndoBaseType.h" 5 | #include "../Components/IBaseComponent.h" 6 | 7 | /// 8 | /// \brief The UndoDeleteType class represents an undo action where objects where deleted 9 | /// 10 | class UndoDeleteType : public UndoBaseType 11 | { 12 | public: 13 | /// \brief Constructor for the UndoDeleteType 14 | /// \param pDeletedComponents: Components that have been deleted 15 | UndoDeleteType(std::vector &pDeletedComponents); 16 | 17 | /// \brief Destructor for the UndoDeleteType 18 | ~UndoDeleteType(void) override; 19 | 20 | /// \brief Gets the type of this undo action 21 | /// \return An undo::Type object 22 | undo::Type Type(void) const override; 23 | 24 | /// \brief Getter for the deleted components 25 | /// \return Vector containing pointers to the deleted components 26 | const std::vector& Components(void) const; 27 | 28 | protected: 29 | std::vector mComponents; 30 | }; 31 | 32 | #endif // UNDODELETETYPE_H 33 | -------------------------------------------------------------------------------- /Undo/UndoMoveType.cpp: -------------------------------------------------------------------------------- 1 | #include "UndoMoveType.h" 2 | 3 | UndoMoveType::UndoMoveType(std::vector &pMovedComponents, QPointF pOffset): 4 | mMovedComponents(pMovedComponents), 5 | mOffset(pOffset) 6 | {} 7 | 8 | UndoMoveType::UndoMoveType(std::vector &pMovedComponents, std::vector &pAddedComponents, std::vector &pDeletedComponents, QPointF pOffset): 9 | mMovedComponents(pMovedComponents), 10 | mAddedComponents(pAddedComponents), 11 | mDeletedComponents(pDeletedComponents), 12 | mOffset(pOffset) 13 | {} 14 | 15 | UndoMoveType::~UndoMoveType() 16 | { 17 | for (auto& comp : mDeletedComponents) 18 | { 19 | delete comp; 20 | } 21 | } 22 | 23 | undo::Type UndoMoveType::Type() const 24 | { 25 | return undo::Type::MOVE; 26 | } 27 | 28 | const std::vector& UndoMoveType::MovedComponents() const 29 | { 30 | return mMovedComponents; 31 | } 32 | 33 | const std::vector& UndoMoveType::AddedComponents() const 34 | { 35 | return mAddedComponents; 36 | } 37 | 38 | const std::vector& UndoMoveType::DeletedComponents() const 39 | { 40 | return mDeletedComponents; 41 | } 42 | 43 | 44 | const QPointF UndoMoveType::Offset() const 45 | { 46 | return mOffset; 47 | } 48 | 49 | -------------------------------------------------------------------------------- /Undo/UndoMoveType.h: -------------------------------------------------------------------------------- 1 | #ifndef UNDOMOVETYPE_H 2 | #define UNDOMOVETYPE_H 3 | 4 | #include "UndoBaseType.h" 5 | #include "../Components/IBaseComponent.h" 6 | 7 | /// 8 | /// \brief The UndoMoveType class represents an undo action where objects have been moved in the scene 9 | /// 10 | class UndoMoveType : public UndoBaseType 11 | { 12 | public: 13 | /// \brief Constructor for the UndoMoveType 14 | /// \param pMovedComponents: Components that have been moved 15 | /// \param pOffset: Offset from the original component positions 16 | UndoMoveType(std::vector &pMovedComponents, QPointF pOffset); 17 | 18 | /// \brief Constructor for the UndoMoveType 19 | /// \param pMovedComponents: Components that have been moved 20 | /// \param pAddedComponents: Components that have been added after moving 21 | /// \param pDeletedComponents: Components that have been deleted after moving 22 | /// \param pOffset: Offset from the original component positions 23 | UndoMoveType(std::vector &pMovedComponents, std::vector &pAddedComponents, std::vector &pDeletedComponents, QPointF pOffset); 24 | 25 | /// \brief Destructor for the UndoMoveType 26 | ~UndoMoveType(void) override; 27 | 28 | /// \brief Gets the type of this undo action 29 | /// \return An undo::Type object 30 | undo::Type Type(void) const override; 31 | 32 | /// \brief Getter for the moved components 33 | /// \return Vector containing pointers to the moved components 34 | const std::vector& MovedComponents(void) const; 35 | 36 | /// \brief Getter for the added components 37 | /// \return Vector containing pointers to the added components 38 | const std::vector& AddedComponents(void) const; 39 | 40 | /// \brief Getter for the deleted components 41 | /// \return Vector containing pointers to the deleted components 42 | const std::vector& DeletedComponents(void) const; 43 | 44 | /// \brief Getter for the offset by that the components have been moved 45 | /// \return The offset as a QPointF 46 | const QPointF Offset(void) const; 47 | 48 | protected: 49 | std::vector mMovedComponents; 50 | std::vector mAddedComponents; 51 | std::vector mDeletedComponents; 52 | 53 | QPointF mOffset; 54 | }; 55 | 56 | #endif // UNDOMOVETYPE_H 57 | -------------------------------------------------------------------------------- /fonts/Quicksand-Bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/fonts/Quicksand-Bold.ttf -------------------------------------------------------------------------------- /fonts/Quicksand-Light.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/fonts/Quicksand-Light.ttf -------------------------------------------------------------------------------- /fonts/Quicksand-Medium.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/fonts/Quicksand-Medium.ttf -------------------------------------------------------------------------------- /fonts/Quicksand-SemiBold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/fonts/Quicksand-SemiBold.ttf -------------------------------------------------------------------------------- /fonts/SourceSansPro-Regular.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/fonts/SourceSansPro-Regular.ttf -------------------------------------------------------------------------------- /images/Linkuit_RS_counter.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/Linkuit_RS_counter.PNG -------------------------------------------------------------------------------- /images/Linkuit_Selection.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/Linkuit_Selection.PNG -------------------------------------------------------------------------------- /images/background_bottom.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/background_bottom.png -------------------------------------------------------------------------------- /images/background_top.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/background_top.png -------------------------------------------------------------------------------- /images/icons/button24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/button24.png -------------------------------------------------------------------------------- /images/icons/button_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/button_icon.png -------------------------------------------------------------------------------- /images/icons/clock24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/clock24.png -------------------------------------------------------------------------------- /images/icons/clock_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/clock_icon.png -------------------------------------------------------------------------------- /images/icons/constant24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/constant24.png -------------------------------------------------------------------------------- /images/icons/constant_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/constant_icon.png -------------------------------------------------------------------------------- /images/icons/decoder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/decoder.png -------------------------------------------------------------------------------- /images/icons/decoder24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/decoder24.png -------------------------------------------------------------------------------- /images/icons/demultiplexer.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/demultiplexer.png -------------------------------------------------------------------------------- /images/icons/demux24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/demux24.png -------------------------------------------------------------------------------- /images/icons/encoder.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/encoder.png -------------------------------------------------------------------------------- /images/icons/encoder24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/encoder24.png -------------------------------------------------------------------------------- /images/icons/flipflop24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/flipflop24.png -------------------------------------------------------------------------------- /images/icons/flipflop_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/flipflop_icon.png -------------------------------------------------------------------------------- /images/icons/full_adder24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/full_adder24.png -------------------------------------------------------------------------------- /images/icons/full_adder_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/full_adder_icon.png -------------------------------------------------------------------------------- /images/icons/gate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/gate.png -------------------------------------------------------------------------------- /images/icons/gate24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/gate24.png -------------------------------------------------------------------------------- /images/icons/icon_default.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/icon_default.ico -------------------------------------------------------------------------------- /images/icons/icon_default.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/icon_default.png -------------------------------------------------------------------------------- /images/icons/icon_file.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/icon_file.ico -------------------------------------------------------------------------------- /images/icons/icon_file.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/icon_file.png -------------------------------------------------------------------------------- /images/icons/icon_smaller.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/icon_smaller.png -------------------------------------------------------------------------------- /images/icons/input24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/input24.png -------------------------------------------------------------------------------- /images/icons/input_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/input_icon.png -------------------------------------------------------------------------------- /images/icons/label_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/label_icon.png -------------------------------------------------------------------------------- /images/icons/material_symbols/add_FILL1_wght400_GRAD0_opsz20.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/arrow_selector_tool_FILL1_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/cancel_FILL1_wght400_GRAD0_opsz20.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/check_circle_FILL1_wght400_GRAD0_opsz20.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/close_FILL1_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/delete_FILL0_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/edit_FILL1_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/expand_less_FILL0_wght600_GRAD0_opsz20.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/expand_more_FILL0_wght600_GRAD0_opsz20.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/pause_FILL1_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/play_arrow_FILL1_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/power_settings_new_FILL1_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/redo_FILL0_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/refresh_FILL1_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/remove_FILL1_wght400_GRAD0_opsz20.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/restart_alt_FILL0_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/screenshot_monitor_FILL0_wght400_GRAD0_opsz20.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/search_FILL1_wght400_GRAD0_opsz20.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/skip_next_FILL1_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/sort_FILL1_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/speed_FILL0_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/timelapse_FILL0_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/undo_FILL0_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/material_symbols/unfold_more_FILL1_wght400_GRAD0_opsz24.svg: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /images/icons/output24.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/output24.png -------------------------------------------------------------------------------- /images/icons/output_icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/output_icon.png -------------------------------------------------------------------------------- /images/icons/pushpin-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/pushpin-icon.png -------------------------------------------------------------------------------- /images/icons/x-icon.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/icons/x-icon.png -------------------------------------------------------------------------------- /images/icons/x-icon.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | X Streamline Icon: https://streamlinehq.com 4 | 5 | X 6 | 7 | -------------------------------------------------------------------------------- /images/linkuit_logo_new.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/linkuit_logo_new.png -------------------------------------------------------------------------------- /images/logo_processing.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/logo_processing.png -------------------------------------------------------------------------------- /images/traffic_lights.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/traffic_lights.png -------------------------------------------------------------------------------- /images/welcome_img.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/images/welcome_img.png -------------------------------------------------------------------------------- /qt.conf: -------------------------------------------------------------------------------- 1 | [Platforms] 2 | WindowsArguments = fontengine=gdi -------------------------------------------------------------------------------- /styles/style.css: -------------------------------------------------------------------------------- 1 | QGraphicsView 2 | { 3 | selection-background-color: rgb(0, 39, 43); 4 | } 5 | 6 | QToolTip 7 | { 8 | background: rgb(242, 242, 242); 9 | color: rgb(0, 45, 50); 10 | border: none; 11 | font-family: 'Source Sans Pro'; 12 | font-size: 14px; 13 | } 14 | 15 | QScrollBar:vertical 16 | { 17 | width: 6px; 18 | border: none; 19 | background: none; 20 | } 21 | 22 | QScrollBar::handle:vertical 23 | { 24 | background: rgb(0, 204, 143); 25 | min-width: 20px; 26 | } 27 | 28 | QScrollBar::add-line:vertical 29 | { 30 | height: 0px; 31 | } 32 | 33 | QScrollBar::sub-line:vertical 34 | { 35 | height: 0px; 36 | } 37 | 38 | QScrollBar::add-page:vertical, QScrollBar::sub-page:vertical 39 | { 40 | background: none; 41 | height: 0px; 42 | } 43 | 44 | QScrollBar:horizontal 45 | { 46 | height: 6px; 47 | border: none; 48 | background: none; 49 | } 50 | 51 | QScrollBar::handle:horizontal 52 | { 53 | background: rgb(0, 204, 143); 54 | min-height: 20px; 55 | } 56 | 57 | QScrollBar::add-line:horizontal 58 | { 59 | width: 0px; 60 | } 61 | 62 | QScrollBar::sub-line:horizontal 63 | { 64 | width: 0px; 65 | } 66 | 67 | QScrollBar::add-page:horizontal, QScrollBar::sub-page:horizontal 68 | { 69 | background: none; 70 | width: 0px; 71 | } 72 | 73 | QPlainTextEdit 74 | { 75 | color: white; 76 | background: transparent; 77 | border: none; 78 | selection-color: rgb(0, 204, 143); 79 | selection-background-color: transparent; 80 | } 81 | 82 | QMessageBox { 83 | margin: 10px; 84 | background-color: white; 85 | } 86 | 87 | QMessageBox QLabel { 88 | font: 11pt "Source Sans Pro"; 89 | color: black; 90 | } 91 | 92 | QMessageBox QPushButton 93 | { 94 | padding: 8px 10px; 95 | min-width: 100px; 96 | border-radius: 3px; 97 | background: rgb(230, 230, 230); 98 | font: 11pt "Source Sans Pro"; 99 | color: rgb(0, 45, 50); 100 | } 101 | 102 | QMessageBox QPushButton:hover 103 | { 104 | background: rgb(220, 220, 220); 105 | } 106 | 107 | QMessageBox QPushButton:pressed 108 | { 109 | background: rgb(200, 200, 200); 110 | } 111 | -------------------------------------------------------------------------------- /tutorial/icons/edit_FILL1_wght400_GRAD0_opsz15.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tutorial/icons/gate.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/tutorial/icons/gate.png -------------------------------------------------------------------------------- /tutorial/icons/input.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/tutorial/icons/input.png -------------------------------------------------------------------------------- /tutorial/icons/keyboard_control_key_FILL0_wght400_GRAD0_opsz15.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tutorial/icons/output.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/SimonBuxx/Linkuit-Studio/b752dfb4cd59a0ef3f0849dbc1a0905ded6a7590/tutorial/icons/output.png -------------------------------------------------------------------------------- /tutorial/icons/pause_FILL1_wght400_GRAD0_opsz15.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tutorial/icons/play_arrow_FILL1_wght400_GRAD0_opsz15.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tutorial/icons/power_settings_new_FILL1_wght400_GRAD0_opsz15.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tutorial/icons/restart_alt_FILL0_wght400_GRAD0_opsz15.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tutorial/icons/skip_next_FILL1_wght400_GRAD0_opsz15.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | -------------------------------------------------------------------------------- /tutorial/step1.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 26 | 27 |

Welcome!

28 |

This tutorial will give you a brief overview of Linkuit Studio.

29 |

It is designed as a quick introduction to the main features and doesn't require prior knowledge of logic circuits.

30 |

Let's get started!

31 | 32 | 33 | -------------------------------------------------------------------------------- /tutorial/step2.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 26 | 27 |

Navigation

28 |

To zoom the canvas, hold CTRL while scrolling the mouse wheel or use the slider in the bottom right corner.

29 |

You can pan the canvas by dragging with the left mouse button pressed while holding CTRL.

30 |

Pan and zoom the canvas to continue!

31 | 32 | 33 | -------------------------------------------------------------------------------- /tutorial/step3.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 26 | 27 |

The Toolbox

28 |

The toolbox contains all components that you can add to your circuit. Many components can be configured before adding them using the options shown when selecting a component.

29 |

Let's place an OR gate as the first component of our first circuit. Keep the component configuration unchanged for now

30 |

Click on the OR Gate item and place it on the canvas to continue!

31 | 32 | 33 | -------------------------------------------------------------------------------- /tutorial/step4.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 26 | 27 |

A first Circuit

28 |

Let's add Switches so that you can control the OR gate. We will connect them with the input pins of the OR gate later. 29 |

Switches are the simplest form of inputs, but there are more input types to choose from.

30 |

Place at least one Switch on the canvas to continue!

31 | 32 | 33 | -------------------------------------------------------------------------------- /tutorial/step5.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 26 | 27 |

A first Circuit

28 |

Great! To see the output of the OR gate more easy, now add an Output to the circuit as well. You're almost done with your first logic circuit! 29 |

Place at least one Output on the canvas to continue!

30 | 31 | 32 | 33 | -------------------------------------------------------------------------------- /tutorial/step6.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 26 | 27 |

Completing the Circuit

28 |

Finally, select the Wiring Tool and connect the in- and outputs with the pins of the gate. 29 |

To add a wire, drag with the left mouse button pessed while the wiring tool is selected.

30 |

Make sure that the inputs are connected to the pins on the left side. Those are the input pins of the component.

31 |

Connect the components with wires to continue!

32 | 33 | 34 | -------------------------------------------------------------------------------- /tutorial/step7.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 26 | 27 |

Simulation

28 |

Congratulations, you just completed your first circuit in Linkuit Studio!

29 |

Now it is time to simulate the circuit and to analyze the behavior of the OR gate. With the simulation running, you can click on the inputs to see how the output changes with different inputs.

30 |

Click on Start to begin the simulation!

31 | 32 | 33 | -------------------------------------------------------------------------------- /tutorial/step8.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 24 | 25 | 26 | 27 |

Simulation

28 |

With the simulation started, there are multiple options to control it:

29 |

You can pause and resume the simulation and step through it while paused. You can also reset the simulation. In that case, the simulation is paused automatically.

30 |

For now, just click on Stop to end the simulation.

31 | 32 | 33 | -------------------------------------------------------------------------------- /version.txt: -------------------------------------------------------------------------------- 1 | 1.1.0.0 2 | --------------------------------------------------------------------------------