feat(parameters): add defaults and remove qt keywords
This commit is contained in:
@@ -54,6 +54,7 @@ set(GUI_SOURCES
|
|||||||
# qt
|
# qt
|
||||||
find_package(Qt6 REQUIRED COMPONENTS Core Widgets SvgWidgets OpenGLWidgets)
|
find_package(Qt6 REQUIRED COMPONENTS Core Widgets SvgWidgets OpenGLWidgets)
|
||||||
qt_standard_project_setup()
|
qt_standard_project_setup()
|
||||||
|
ADD_DEFINITIONS(-DQT_NO_KEYWORDS)
|
||||||
|
|
||||||
# glm
|
# glm
|
||||||
find_package(glm REQUIRED)
|
find_package(glm REQUIRED)
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ private:
|
|||||||
enzo::nt::OpId maxOpId_=0;
|
enzo::nt::OpId maxOpId_=0;
|
||||||
// operator selected for displaying in the viewport
|
// operator selected for displaying in the viewport
|
||||||
std::optional<OpId> displayOp_=std::nullopt;
|
std::optional<OpId> displayOp_=std::nullopt;
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
void updateDisplay(enzo::geo::Geometry& geometry);
|
void updateDisplay(enzo::geo::Geometry& geometry);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -5,6 +5,7 @@
|
|||||||
enzo::prm::Parameter::Parameter(Template prmTemplate)
|
enzo::prm::Parameter::Parameter(Template prmTemplate)
|
||||||
: template_{prmTemplate}
|
: template_{prmTemplate}
|
||||||
{
|
{
|
||||||
|
floatValue_ = prmTemplate.getDefault();
|
||||||
std::cout << "created new parameter: " << prmTemplate.getName() << "\n";
|
std::cout << "created new parameter: " << prmTemplate.getName() << "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
#include "Engine/Parameter/Template.h"
|
#include "Engine/Parameter/Template.h"
|
||||||
#include "Engine/Parameter/Type.h"
|
#include "Engine/Parameter/Type.h"
|
||||||
|
|
||||||
enzo::prm::Template::Template(enzo::prm::Type type, const char* name)
|
enzo::prm::Template::Template(enzo::prm::Type type, const char* name, bt::floatT theDefault)
|
||||||
: type_{type}, name_{name}
|
: type_{type}, name_{name}, default_{theDefault}
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -18,6 +18,11 @@ bool enzo::prm::Template::isValid() const
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const enzo::bt::floatT enzo::prm::Template::getDefault() const
|
||||||
|
{
|
||||||
|
return default_;
|
||||||
|
}
|
||||||
|
|
||||||
const char* enzo::prm::Template::getName() const
|
const char* enzo::prm::Template::getName() const
|
||||||
{
|
{
|
||||||
return name_;
|
return name_;
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include "Engine/Parameter/Type.h"
|
#include "Engine/Parameter/Type.h"
|
||||||
|
#include "Engine/Types.h"
|
||||||
|
|
||||||
namespace enzo::prm
|
namespace enzo::prm
|
||||||
{
|
{
|
||||||
@@ -7,12 +8,19 @@ namespace enzo::prm
|
|||||||
class Template
|
class Template
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
Template(enzo::prm::Type type, const char* name);
|
Template(
|
||||||
|
enzo::prm::Type type,
|
||||||
|
const char* name,
|
||||||
|
// TODO: change default to class that can store multiple types
|
||||||
|
bt::floatT theDefault
|
||||||
|
);
|
||||||
Template();
|
Template();
|
||||||
const char* getName() const;
|
const char* getName() const;
|
||||||
|
const bt::floatT getDefault() const;
|
||||||
bool isValid() const;
|
bool isValid() const;
|
||||||
private:
|
private:
|
||||||
enzo::prm::Type type_;
|
enzo::prm::Type type_;
|
||||||
|
bt::floatT default_;
|
||||||
// TODO: make a class that holds token and name
|
// TODO: make a class that holds token and name
|
||||||
const char* name_;
|
const char* name_;
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ protected:
|
|||||||
void focusOutEvent(QFocusEvent *event) override;
|
void focusOutEvent(QFocusEvent *event) override;
|
||||||
bool event(QEvent *event) override;
|
bool event(QEvent *event) override;
|
||||||
// void resizeEvent(QResizeEvent *event) override;
|
// void resizeEvent(QResizeEvent *event) override;
|
||||||
protected slots:
|
protected Q_SLOTS:
|
||||||
void nodeClicked();
|
void nodeClicked();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,6 @@ enzo::ui::AbstractFormParm::AbstractFormParm(std::weak_ptr<prm::Parameter> param
|
|||||||
label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
label->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Preferred);
|
||||||
|
|
||||||
auto slider = new AbstractSliderParm();
|
auto slider = new AbstractSliderParm();
|
||||||
connect(slider, &AbstractSliderParm::valueChanged, this, &AbstractFormParm::changeValue);
|
|
||||||
slider->setValue(sharedParameter->evalFloat());
|
slider->setValue(sharedParameter->evalFloat());
|
||||||
|
|
||||||
mainLayout_ = new QHBoxLayout();
|
mainLayout_ = new QHBoxLayout();
|
||||||
@@ -28,6 +27,8 @@ enzo::ui::AbstractFormParm::AbstractFormParm(std::weak_ptr<prm::Parameter> param
|
|||||||
setProperty("class", "Parameter");
|
setProperty("class", "Parameter");
|
||||||
setStyleSheet(".Parameter { background-color: none;}");
|
setStyleSheet(".Parameter { background-color: none;}");
|
||||||
setLayout(mainLayout_);
|
setLayout(mainLayout_);
|
||||||
|
|
||||||
|
connect(slider, &AbstractSliderParm::valueChanged, this, &AbstractFormParm::changeValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
#include <QWidget>
|
#include <QWidget>
|
||||||
#include <QHBoxLayout>
|
#include <QHBoxLayout>
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include <qtmetamacros.h>
|
||||||
|
|
||||||
namespace enzo::ui
|
namespace enzo::ui
|
||||||
{
|
{
|
||||||
@@ -9,13 +10,13 @@ namespace enzo::ui
|
|||||||
class AbstractFormParm
|
class AbstractFormParm
|
||||||
: public QWidget
|
: public QWidget
|
||||||
{
|
{
|
||||||
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
AbstractFormParm(std::weak_ptr<prm::Parameter> parameter);
|
AbstractFormParm(std::weak_ptr<prm::Parameter> parameter);
|
||||||
|
|
||||||
protected slots:
|
protected Q_SLOTS:
|
||||||
void changeValue(bt::floatT value);
|
void changeValue(bt::floatT value);
|
||||||
|
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QHBoxLayout* mainLayout_;
|
QHBoxLayout* mainLayout_;
|
||||||
std::weak_ptr<prm::Parameter> parameter_;
|
std::weak_ptr<prm::Parameter> parameter_;
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ public:
|
|||||||
AbstractSliderParm(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
AbstractSliderParm(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||||
void setValue(bt::floatT value);
|
void setValue(bt::floatT value);
|
||||||
|
|
||||||
signals:
|
Q_SIGNALS:
|
||||||
void valueChanged(bt::floatT value);
|
void valueChanged(bt::floatT value);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ class ParametersPanel
|
|||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
ParametersPanel(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
ParametersPanel(QWidget *parent = nullptr, Qt::WindowFlags f = Qt::WindowFlags());
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
void selectionChanged();
|
void selectionChanged();
|
||||||
private:
|
private:
|
||||||
QVBoxLayout* mainLayout_;
|
QVBoxLayout* mainLayout_;
|
||||||
|
|||||||
@@ -23,6 +23,6 @@ private:
|
|||||||
QPointF leftStartPos_;
|
QPointF leftStartPos_;
|
||||||
bool rightMouseDown_=false;
|
bool rightMouseDown_=false;
|
||||||
QPointF rightStartPos_;
|
QPointF rightStartPos_;
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
void geometryChanged(enzo::geo::Geometry& geometry);
|
void geometryChanged(enzo::geo::Geometry& geometry);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -25,6 +25,6 @@ protected:
|
|||||||
void resizeGL(int w, int h) override;
|
void resizeGL(int w, int h) override;
|
||||||
void paintGL() override;
|
void paintGL() override;
|
||||||
|
|
||||||
public slots:
|
public Q_SLOTS:
|
||||||
void geometryChanged(enzo::geo::Geometry& geometry);
|
void geometryChanged(enzo::geo::Geometry& geometry);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ void GOP_house::cookOp(enzo::op::Context context)
|
|||||||
for(int i=0; i<PAttrHandle.getAllValues().size(); ++i)
|
for(int i=0; i<PAttrHandle.getAllValues().size(); ++i)
|
||||||
{
|
{
|
||||||
enzo::bt::Vector3 vector = PAttrHandle.getValue(i);
|
enzo::bt::Vector3 vector = PAttrHandle.getValue(i);
|
||||||
vector.x()+=2.5;
|
vector*=context.evalFloatParm("size");
|
||||||
PAttrHandle.setValue(i, vector);
|
PAttrHandle.setValue(i, vector);
|
||||||
}
|
}
|
||||||
// ----
|
// ----
|
||||||
@@ -69,18 +69,10 @@ void GOP_house::cookOp(enzo::op::Context context)
|
|||||||
setOutputGeometry(0, geo);
|
setOutputGeometry(0, geo);
|
||||||
}
|
}
|
||||||
|
|
||||||
// if(outputRequested(1))
|
|
||||||
// {
|
|
||||||
// // create new geometry
|
|
||||||
// const geo::Geometry& geo1 = getInputGeoView(0);
|
|
||||||
// geo::Geometry geo2;
|
|
||||||
|
|
||||||
// setOutputGeometry(1, geo2);
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
|
|
||||||
enzo::prm::Template GOP_house::parameterList[] =
|
enzo::prm::Template GOP_house::parameterList[] =
|
||||||
{
|
{
|
||||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "Size"),
|
enzo::prm::Template(enzo::prm::Type::FLOAT, "size", 1),
|
||||||
enzo::prm::Terminator
|
enzo::prm::Terminator
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -43,9 +43,9 @@ void GopTransform::cookOp(enzo::op::Context context)
|
|||||||
|
|
||||||
enzo::prm::Template GopTransform::parameterList[] =
|
enzo::prm::Template GopTransform::parameterList[] =
|
||||||
{
|
{
|
||||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "translateX"),
|
enzo::prm::Template(enzo::prm::Type::FLOAT, "translateX", 0),
|
||||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "translateY"),
|
enzo::prm::Template(enzo::prm::Type::FLOAT, "translateY", 0),
|
||||||
enzo::prm::Template(enzo::prm::Type::FLOAT, "translateZ"),
|
enzo::prm::Template(enzo::prm::Type::FLOAT, "translateZ", 0),
|
||||||
enzo::prm::Terminator
|
enzo::prm::Terminator
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user