Page MenuHomec4science

systempanel.cpp
No OneTemporary

File Metadata

Created
Thu, Dec 12, 07:30

systempanel.cpp

#include "systempanel.h"
//#include <QStackedLayout>
#include <QVBoxLayout>
#include <QTabWidget>
#include "actors/symsystem.h"
#include "skactor.h"
#include "actors/symsystem.h"
using namespace std;
/* SystemOffsetEdit section */
SystemOffsetEdit::SystemOffsetEdit(SymSystem* system, SystemPanel *parent)
: VectorEdit("Offset", parent), system(system)
{
adaptComponents();
}
void SystemOffsetEdit::uploadComponent(std::size_t index)
{
SVector<3> load = system->getOffset();
load[index] = getContent(index);
system->setOffset(load);
}
void SystemOffsetEdit::updateComponent(std::size_t index)
{
setContent(index, system->getOffset()[index]);
}
void SystemOffsetEdit::adaptComponents()
{
for (int i = 0; i < 3; ++i)
pushComponent(system->getOffset()[i]);
}
/* SystemPanel section */
SystemPanel::SystemPanel(SymSystem *system, QWidget *parent)
: ActorPanel(system, parent)
{
mainLayout = new QVBoxLayout();
offsetEdit = new SystemOffsetEdit(system, this);
mainLayout->addWidget(offsetEdit);
actorScreen = new QTabWidget(this);
mainLayout->addWidget(actorScreen);
// set 10% spacing
mainLayout->setStretch(0, 1);
// set 90% spacing
mainLayout->setStretch(1, 9);
setSystem(system);
setLayout(mainLayout);
}
SystemPanel::~SystemPanel()
{
delete mainLayout;
delete actorScreen;
delete offsetEdit;
}
void SystemPanel::setSystem(SymSystem *system)
{
actorScreen->clear();
nestedPanels.clear();
for (auto actor : *system)
{
ActorPanel * panel = new ActorPanel(actor, actorScreen);
nestedPanels.push_back(unique_ptr<ActorPanel>(panel));
actorScreen->addTab(panel, actor->getLabel());
}
this->system = system;
}
SymSystem * SystemPanel::getSystem()
{
return system;
}
const SymSystem * SystemPanel::getSystem() const
{
return system;
}

Event Timeline