feat: add node icons
This commit is contained in:
@@ -12,7 +12,7 @@ project(enzo_project)
|
||||
|
||||
|
||||
# qt
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Widgets)
|
||||
find_package(Qt6 REQUIRED COMPONENTS Core Widgets SvgWidgets)
|
||||
qt_standard_project_setup()
|
||||
|
||||
|
||||
@@ -28,9 +28,10 @@ qt_add_executable(${AppExec}
|
||||
src/gui/network/NodeEdgeGraphic.cpp
|
||||
src/gui/network/FloatingEdgeGraphic.cpp
|
||||
src/gui/network/DisplayFlagButton.cpp
|
||||
src/gui/network/NodeIconGraphic.cpp
|
||||
)
|
||||
|
||||
target_link_libraries(${AppExec} PRIVATE Qt6::Core Qt6::Widgets)
|
||||
target_link_libraries(${AppExec} PRIVATE Qt6::Core Qt6::Widgets Qt6::SvgWidgets)
|
||||
target_include_directories(${AppExec} PUBLIC src)
|
||||
|
||||
# tests
|
||||
|
||||
@@ -55,6 +55,8 @@ Network::Network(QWidget* parent)
|
||||
node4->setPos(50, -200);
|
||||
scene_->addItem(node4);
|
||||
|
||||
|
||||
|
||||
// scene_->addItem(new NodeEdgeGraphic(node1->getOutput(0), node2->getInput(0)));
|
||||
|
||||
// node1->addEdge(edge1);
|
||||
|
||||
@@ -8,6 +8,8 @@
|
||||
#include "gui/network/SocketGraphic.h"
|
||||
#include <QGraphicsScene>
|
||||
#include <QGraphicsSceneMouseEvent>
|
||||
#include <QGraphicsSvgItem>
|
||||
#include "gui/network/NodeIconGraphic.h"
|
||||
|
||||
NodeGraphic::NodeGraphic(QGraphicsItem *parent)
|
||||
: QGraphicsItem(parent)
|
||||
@@ -21,6 +23,17 @@ NodeGraphic::NodeGraphic(QGraphicsItem *parent)
|
||||
|
||||
initSockets();
|
||||
initFlagButtons();
|
||||
initIcon();
|
||||
|
||||
}
|
||||
|
||||
void NodeGraphic::initIcon()
|
||||
{
|
||||
NodeIconGraphic* icon = new NodeIconGraphic("/home/parker/MyRepos/masters/static/node-icons/grid.svg", this);
|
||||
float iconLeftPadding = 5;
|
||||
float iconScale = 12;
|
||||
icon->setScale(1.0f/icon->boundingRect().size().height()*iconScale);
|
||||
icon->setPos(iconLeftPadding-iconScale/2.0f, -iconScale/2.0f);
|
||||
}
|
||||
|
||||
void NodeGraphic::initFlagButtons()
|
||||
|
||||
@@ -31,6 +31,7 @@ public:
|
||||
private:
|
||||
void initSockets();
|
||||
void initFlagButtons();
|
||||
void initIcon();
|
||||
|
||||
std::vector<SocketGraphic*> inputs_;
|
||||
std::vector<SocketGraphic*> outputs_;
|
||||
|
||||
17
src/gui/network/NodeIconGraphic.cpp
Normal file
17
src/gui/network/NodeIconGraphic.cpp
Normal file
@@ -0,0 +1,17 @@
|
||||
#include "gui/network/NodeIconGraphic.h"
|
||||
#include <qgraphicssvgitem.h>
|
||||
#include <QBrush>
|
||||
#include <QPainter>
|
||||
|
||||
NodeIconGraphic::NodeIconGraphic(const QString &fileName, QGraphicsItem *parent)
|
||||
: QGraphicsSvgItem(fileName, parent)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
// void NodeIconGraphic::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)
|
||||
// {
|
||||
//
|
||||
// this->setProperty("color", QColor("red"));
|
||||
// QGraphicsSvgItem::paint(painter, option, widget);
|
||||
// }
|
||||
12
src/gui/network/NodeIconGraphic.h
Normal file
12
src/gui/network/NodeIconGraphic.h
Normal file
@@ -0,0 +1,12 @@
|
||||
#pragma once
|
||||
#include <QGraphicsSvgItem>
|
||||
|
||||
class NodeIconGraphic
|
||||
: public QGraphicsSvgItem
|
||||
{
|
||||
public:
|
||||
NodeIconGraphic(const QString &fileName, QGraphicsItem *parent = nullptr);
|
||||
protected:
|
||||
// void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = nullptr) override;
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user