-
Notifications
You must be signed in to change notification settings - Fork 22
How to create a new logic element
Rodrigo Torres edited this page Jan 30, 2025
·
1 revision
- Design the vector image in Inkscape (or another vector graphics editor).
- Save the file in SVG format into
wiRedPanda/app/resources/
. - Depending on the type of logic element, place it in a specific subfolder (e.g.,
input/
,output/
, etc.).
2.1. Open the wiRedPanda project in Qt Creator.
2.2. Create a new element class
- Right-click on the
app/config/element
folder and click on Add New.... - Select C++ Class and click Choose.
- Enter the class name, leave the rest as default, and click Next > and then Finish.
- Write the code for the new element (you can use
and.h
andand.cpp
as reference).
2.3. Create a new logic class
- Open
ElementFactory::buildLogicElement
by pressing Ctrl + K and typing: buildLogicElement
. - Check if you can use an existing
LogicElement
class (such asLogicInput
,LogicOutput
, orLogicNone
). - If none of the existing classes are suitable:
- Right click on the
app/config/logicelement
folder and click on Add New.... - Select C++ Class and click Choose.
- Enter the class name (prefix it with
Logic
) and leave the rest as default, then click Next > and Finish. - Write the code for the new element (you can use
logicand.h
andlogicand.cpp
as reference).
- Right click on the
2.4. Add the new element to the menu
- Open
MainWindow::populateLeftMenu
by pressing Ctrl + K and typing: populateLeftMenu
. - Add your new element to the appropriate menu in the method.
2.5. Modify the ElementType
enum
- Open
enums.h
by pressing Ctrl + K and typingenums.h
. - Add a new entry in the
ElementType
enum with the same name as your class created in step 2.2. - Assign the highest number in the enum plus one as the new ID for your element.
2.6. Add the image to the resource file
- Find the
.qrc
file in the same folder where you saved your image. - Right-click on the
.qrc
file and click Open in Editor. - Click the Add Files button to add your image file to the resource file.
2.7. Update ElementFactory::buildLogicElement
- Open
ElementFactory::buildLogicElement
by pressing Ctrl + K and typing: buildLogicElement
. - Add a case for your new class in the switch statement.
- Ensure to #include your class header from step 2.3 at the beginning of the file.