Skip to content

Commit

Permalink
Add colection of toy items
Browse files Browse the repository at this point in the history
  • Loading branch information
gpospelov committed Feb 9, 2021
1 parent 450b16c commit 3541be0
Show file tree
Hide file tree
Showing 4 changed files with 121 additions and 3 deletions.
2 changes: 2 additions & 0 deletions examples/groupproperty/grouppropertycore/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,6 @@ target_link_libraries(${library_name} PRIVATE MVVM::View)
target_sources(${library_name} PRIVATE
mainwindow.cpp
mainwindow.h
items.cpp
items.h
)
54 changes: 54 additions & 0 deletions examples/groupproperty/grouppropertycore/items.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// ************************************************************************** //
//
// Model-view-view-model framework for large GUI applications
//
//! @license GNU General Public License v3 or higher (see COPYING)
//! @authors see AUTHORS
//
// ************************************************************************** //

#include "items.h"
#include "mvvm/standarditems/vectoritem.h"
#include <QColor>

namespace GroupProperty {

UndefinedShapeItem::UndefinedShapeItem() : ModelView::CompoundItem("Undefined")
{
// no properties
}

SphereItem::SphereItem() : ModelView::CompoundItem("Sphere")
{
addProperty("Radius", 5.0);
}

CylinderItem::CylinderItem() : ModelView::CompoundItem("Cylinder")
{
addProperty("Radius", 8.0);
addProperty("Height", 10.0);
}

BoxItem::BoxItem() : ModelView::CompoundItem("Box")
{
addProperty("Length", 12.0);
addProperty("Width", 6.0);
addProperty("Height", 3.0);
}

ShapeGroupItem::ShapeGroupItem() : ModelView::GroupItem("Shape")
{
addToGroup<UndefinedShapeItem>("xxx");
addToGroup<SphereItem>("xxx");
addToGroup<CylinderItem>("xxx");
addToGroup<BoxItem>("xxx");
}

ParticleItem::ParticleItem() : ModelView::CompoundItem("Particle")
{
addProperty("Color", QColor(Qt::green));
addProperty<ModelView::VectorItem>("Position");
addProperty<ShapeGroupItem>("Shape");
}

} // namespace GroupProperty
62 changes: 62 additions & 0 deletions examples/groupproperty/grouppropertycore/items.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
// ************************************************************************** //
//
// Model-view-view-model framework for large GUI applications
//
//! @license GNU General Public License v3 or higher (see COPYING)
//! @authors see AUTHORS
//
// ************************************************************************** //

#ifndef GROUPPROPERTYCORE_ITEMS_H
#define GROUPPROPERTYCORE_ITEMS_H

#include "mvvm/model/compounditem.h"
#include "mvvm/model/groupitem.h"

namespace GroupProperty {

//! Represents undefined shape.

class UndefinedShapeItem : public ModelView::CompoundItem {
public:
UndefinedShapeItem();
};

//! Represents a shpere.

class SphereItem : public ModelView::CompoundItem {
public:
SphereItem();
};

//! Represents a cylindrical shape.

class CylinderItem : public ModelView::CompoundItem {
public:
CylinderItem();
};

//! Represents a box.

class BoxItem : public ModelView::CompoundItem {
public:
BoxItem();
};

//! Represents a group of possible shapes.

class ShapeGroupItem : public ModelView::GroupItem {
public:
ShapeGroupItem();
};

//! Represents a particle. Particle has a color, position, and a selection of possible shapes.

class ParticleItem : public ModelView::CompoundItem {
public:
ParticleItem();
};

} // namespace GroupProperty

#endif // GROUPPROPERTYCORE_ITEMS_H
6 changes: 3 additions & 3 deletions examples/groupproperty/grouppropertycore/mainwindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
//
// ************************************************************************** //

#ifndef PLOTGRAPHSCORE_MAINWINDOW_H
#define PLOTGRAPHSCORE_MAINWINDOW_H
#ifndef GROUPPROPERTYCORE_MAINWINDOW_H
#define GROUPPROPERTYCORE_MAINWINDOW_H

#include <QMainWindow>
#include <memory>
Expand All @@ -34,4 +34,4 @@ class MainWindow : public QMainWindow {

} // namespace PlotGraphs

#endif // PLOTGRAPHSCORE_MAINWINDOW_H
#endif // GROUPPROPERTYCORE_MAINWINDOW_H

0 comments on commit 3541be0

Please sign in to comment.