Skip to content

Commit

Permalink
Merge pull request #2408 from NREL/LineEditFixes
Browse files Browse the repository at this point in the history
Fixes #1519, makes line edits work much better.  I want to be a littl…
  • Loading branch information
macumber authored Dec 5, 2016
2 parents df1bbab + 309af46 commit 99bf075
Show file tree
Hide file tree
Showing 6 changed files with 152 additions and 403 deletions.
257 changes: 0 additions & 257 deletions openstudiocore/src/openstudio_lib/PeopleInspectorView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,19 +28,13 @@

#include "PeopleInspectorView.hpp"

#include "ModelObjectItem.hpp"
#include "OSDropZone.hpp"
#include "OSVectorController.hpp"
#include "SpaceLoadInstancesWidget.hpp"

#include "../shared_gui_components/OSCheckBox.hpp"
#include "../shared_gui_components/OSComboBox.hpp"
#include "../shared_gui_components/OSDoubleEdit.hpp"
#include "../shared_gui_components/OSLineEdit.hpp"
#include "../shared_gui_components/OSQuantityEdit.hpp"

#include "../model/People.hpp"
#include "../model/People_Impl.hpp"
#include "../model/PeopleDefinition.hpp"
#include "../model/PeopleDefinition_Impl.hpp"
#include "../model/Schedule.hpp"
Expand All @@ -56,257 +50,6 @@
#include <QVBoxLayout>

namespace openstudio {
/*
class PeopleVectorController : public OSVectorController
{
public:
PeopleVectorController(const openstudio::model::Model& model, QWidget* parent = 0)
: OSVectorController(model, parent)
{}
void setPeople(const model::People& people)
{
m_people = people;
}
void clearPeople()
{
m_people.reset();
}
protected:
boost::optional<model::People> m_people;
};
class PeopleNumberofPeopleScheduleVectorController : public PeopleVectorController
{
public:
PeopleNumberofPeopleScheduleVectorController(const openstudio::model::Model& model, QWidget* parent = 0)
: PeopleVectorController(model, parent)
{}
virtual void makeVector()
{
m_objects.clear();
if (m_people){
boost::optional<model::Schedule> numberofPeopleSchedule = m_people->numberofPeopleSchedule();
if (numberofPeopleSchedule){
m_objects.push_back(*numberofPeopleSchedule);
}
}
}
};
class PeopleActivityLevelScheduleVectorController : public PeopleVectorController
{
public:
PeopleActivityLevelScheduleVectorController(const openstudio::model::Model& model, QWidget* parent = 0)
: PeopleVectorController(model, parent)
{}
virtual void makeVector()
{
m_objects.clear();
if (m_people){
boost::optional<model::Schedule> activityLevelSchedule = m_people->activityLevelSchedule();
if (activityLevelSchedule){
m_objects.push_back(*activityLevelSchedule);
}
}
}
};
class PeopleAngleFactorListVectorController : public PeopleVectorController
{
public:
PeopleAngleFactorListVectorController(const openstudio::model::Model& model, QWidget* parent = 0)
: PeopleVectorController(model, parent)
{}
virtual void makeVector()
{
m_objects.clear();
if (m_people){
}
}
};
class PeopleWorkEfficiencyScheduleVectorController : public PeopleVectorController
{
public:
PeopleWorkEfficiencyScheduleVectorController(const openstudio::model::Model& model, QWidget* parent = 0)
: PeopleVectorController(model, parent)
{}
virtual void makeVector()
{
m_objects.clear();
if (m_people){
boost::optional<model::Schedule> workEfficiencySchedule = m_people->workEfficiencySchedule();
if (workEfficiencySchedule){
m_objects.push_back(*workEfficiencySchedule);
}
}
}
};
class PeopleClothingInsulationScheduleVectorController : public PeopleVectorController
{
public:
PeopleClothingInsulationScheduleVectorController(const openstudio::model::Model& model, QWidget* parent = 0)
: PeopleVectorController(model, parent)
{}
virtual void makeVector()
{
m_objects.clear();
if (m_people){
boost::optional<model::Schedule> clothingInsulationSchedule = m_people->clothingInsulationSchedule();
if (clothingInsulationSchedule){
m_objects.push_back(*clothingInsulationSchedule);
}
}
}
};
class PeopleAirVelocityScheduleVectorController : public PeopleVectorController
{
public:
PeopleAirVelocityScheduleVectorController(const openstudio::model::Model& model, QWidget* parent = 0)
: PeopleVectorController(model, parent)
{}
virtual void makeVector()
{
m_objects.clear();
if (m_people){
boost::optional<model::Schedule> airVelocitySchedule = m_people->airVelocitySchedule();
if (airVelocitySchedule){
m_objects.push_back(*airVelocitySchedule);
}
}
}
};
*/
PeopleInspectorView::PeopleInspectorView(bool isIP, const openstudio::model::Model& model, QWidget * parent )
: ModelObjectInspectorView(model, true, parent)
{
m_isIP = isIP;

auto hiddenWidget = new QWidget();
this->stackedWidget()->insertWidget(0, hiddenWidget);

auto visibleWidget = new QWidget();
this->stackedWidget()->insertWidget(1, visibleWidget);

this->stackedWidget()->setCurrentIndex(0);

auto mainGridLayout = new QGridLayout();
mainGridLayout->setContentsMargins(7,7,7,7);
mainGridLayout->setSpacing(14);
visibleWidget->setLayout(mainGridLayout);

// name
auto vLayout = new QVBoxLayout();

QLabel* label = new QLabel("Name:");
label->setObjectName("H1");
vLayout->addWidget(label);

m_nameEdit = new OSLineEdit();
vLayout->addWidget(m_nameEdit);

mainGridLayout->addLayout(vLayout,0,0,1,2, Qt::AlignTop);

// multiplier and definition
vLayout = new QVBoxLayout();

label = new QLabel();
label->setText("Multiplier: ");
label->setStyleSheet("QLabel { font: bold; }");
vLayout->addWidget(label);

m_multiplierEdit = new OSQuantityEdit(m_isIP);
connect(this, &PeopleInspectorView::toggleUnitsClicked, m_multiplierEdit, &OSQuantityEdit::onUnitSystemChange);
vLayout->addWidget(m_multiplierEdit);

mainGridLayout->addLayout(vLayout,1,0, Qt::AlignTop|Qt::AlignLeft);

vLayout = new QVBoxLayout();

label = new QLabel();
label->setText("People Definition: ");
label->setStyleSheet("QLabel { font: bold; }");
vLayout->addWidget(label);

m_peopleDefinitionComboBox = new OSComboBox();
vLayout->addWidget(m_peopleDefinitionComboBox);

mainGridLayout->addLayout(vLayout,1,1, Qt::AlignTop|Qt::AlignLeft);

mainGridLayout->setColumnMinimumWidth(0, 100);
mainGridLayout->setColumnMinimumWidth(1, 100);
mainGridLayout->setColumnStretch(2,1);
mainGridLayout->setRowMinimumHeight(0, 30);
mainGridLayout->setRowMinimumHeight(1, 30);
mainGridLayout->setRowStretch(2,1);
}

void PeopleInspectorView::onClearSelection()
{
ModelObjectInspectorView::onClearSelection(); // call parent implementation
detach();
}

void PeopleInspectorView::onSelectModelObject(const openstudio::model::ModelObject& modelObject)
{
detach();
model::People people = modelObject.cast<model::People>();
attach(people);
refresh();
}

void PeopleInspectorView::onUpdate()
{
refresh();
}

void PeopleInspectorView::attach(openstudio::model::People& people)
{
/*
m_nameEdit->bind(people,"name");
m_multiplierEdit->bind();
//m_peopleDefinitionComboBox->bind();
m_numberofPeopleScheduleVectorController->setPeople(people);
m_activityLevelScheduleVectorController->setPeople(people);
m_angleFactorListVectorController->setPeople(people);
m_workEfficiencyScheduleVectorController->setPeople(people);
m_clothingInsulationScheduleVectorController->setPeople(people);
m_airVelocityScheduleVectorController->setPeople(people);
*/

this->stackedWidget()->setCurrentIndex(1);
}

void PeopleInspectorView::detach()
{
this->stackedWidget()->setCurrentIndex(0);

m_nameEdit->unbind();
m_multiplierEdit->unbind();
//m_peopleDefinitionComboBox->unbind();
//m_numberofPeopleScheduleVectorController->clearPeople();
//m_activityLevelScheduleVectorController->clearPeople();
//m_angleFactorListVectorController->clearPeople();
//m_workEfficiencyScheduleVectorController->clearPeople();
//m_clothingInsulationScheduleVectorController->clearPeople();
//m_airVelocityScheduleVectorController->clearPeople();
}

void PeopleInspectorView::refresh()
{
}

PeopleDefinitionInspectorView::PeopleDefinitionInspectorView(bool isIP,
const openstudio::model::Model& model,
Expand Down
73 changes: 1 addition & 72 deletions openstudiocore/src/openstudio_lib/PeopleInspectorView.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,84 +32,13 @@
#include "ModelObjectInspectorView.hpp"
#include "../model/PeopleDefinition.hpp"

class QLabel;
class QPushButton;
class QColor;

namespace openstudio {

class OSDoubleEdit2;
class OSDropZone;
class OSLineEdit;

class OSLineEdit2;
class OSQuantityEdit;
class OSQuantityEdit2;
class OSCheckBox;
class OSComboBox;

class PeopleNumberofPeopleScheduleVectorController;
class PeopleActivityLevelScheduleVectorController;
class PeopleAngleFactorListVectorController;
class PeopleWorkEfficiencyScheduleVectorController;
class PeopleClothingInsulationScheduleVectorController;
class PeopleAirVelocityScheduleVectorController;

namespace model {
class People;
}

class PeopleInspectorView : public ModelObjectInspectorView
{
Q_OBJECT

public:

PeopleInspectorView(bool isIP, const openstudio::model::Model& model, QWidget * parent = nullptr );

virtual ~PeopleInspectorView() {}

protected:

virtual void onClearSelection() override;

virtual void onSelectModelObject(const openstudio::model::ModelObject& modelObject) override;

virtual void onUpdate() override;

private:

void attach(openstudio::model::People& people);

void detach();

void refresh();

OSLineEdit* m_nameEdit;

OSQuantityEdit* m_multiplierEdit;

OSComboBox* m_peopleDefinitionComboBox;

PeopleNumberofPeopleScheduleVectorController* m_numberofPeopleScheduleVectorController;
OSDropZone* m_numberofPeopleScheduleDropZone;

PeopleActivityLevelScheduleVectorController* m_activityLevelScheduleVectorController;
OSDropZone* m_activityLevelScheduleDropZone;

PeopleAngleFactorListVectorController* m_angleFactorListVectorController;
OSDropZone* m_angleFactorListDropZone;

PeopleWorkEfficiencyScheduleVectorController* m_workEfficiencyScheduleVectorController;
OSDropZone* m_workEfficiencyScheduleDropZone;

PeopleClothingInsulationScheduleVectorController* m_clothingInsulationScheduleVectorController;
OSDropZone* m_clothingInsulationScheduleDropZone;

PeopleAirVelocityScheduleVectorController* m_airVelocityScheduleVectorController;
OSDropZone* m_airVelocityScheduleDropZone;

bool m_isIP;
};

class PeopleDefinitionInspectorView : public ModelObjectInspectorView
{
Expand Down
Loading

4 comments on commit 99bf075

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (macumber) - x86_64-Linux-Ubuntu-14.04-clang-3.5: OK (2310 of 2508 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (macumber) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed, 0 test warnings)

Build Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (macumber) - i386-Windows-7-VisualStudio-12: OK (2334 of 2508 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

develop (macumber) - Win64-Windows-7-VisualStudio-12: OK (2334 of 2508 tests passed, 0 test warnings)

Build Badge Test Badge

Please sign in to comment.