Skip to content

Commit

Permalink
Merge pull request #2164 from NREL/constructionInheritance
Browse files Browse the repository at this point in the history
[#114600757] Construction Inheritance
  • Loading branch information
kbenne committed Mar 19, 2016
2 parents 99fdc85 + 0c35eea commit 8296251
Show file tree
Hide file tree
Showing 9 changed files with 79 additions and 12 deletions.
54 changes: 43 additions & 11 deletions openstudiocore/src/openstudio_lib/OSDropZone.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -712,17 +712,8 @@ void OSDropZone2::mouseReleaseEvent(QMouseEvent * event)
if (event->button() == Qt::LeftButton){
event->accept();

if (!m_item && m_get && *m_get) {
boost::optional<model::ModelObject> modelObject = (*m_get)();

if (modelObject)
{
m_item = OSItem::makeItem(modelObjectToItemId(*modelObject, false));
m_item->setParent(this);
connect(m_item, &OSItem::itemRemoveClicked, this, &OSDropZone2::onItemRemoveClicked);

connect(modelObject->getImpl<openstudio::model::detail::ModelObject_Impl>().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSDropZone2::refresh);
}
if (!m_item) {
makeItem();
}

if (m_item) {
Expand Down Expand Up @@ -786,5 +777,46 @@ void OSDropZone2::onItemRemoveClicked()
emit objectRemoved(parent);
}
}
void OSDropZone2::makeItem()
{
if (!m_item && m_get && *m_get) {
boost::optional<model::ModelObject> modelObject = (*m_get)();

if (modelObject)
{
m_item = OSItem::makeItem(modelObjectToItemId(*modelObject, false));
m_item->setParent(this);
connect(m_item, &OSItem::itemRemoveClicked, this, &OSDropZone2::onItemRemoveClicked);

connect(modelObject->getImpl<openstudio::model::detail::ModelObject_Impl>().get(), &openstudio::model::detail::ModelObject_Impl::onChange, this, &OSDropZone2::refresh);
}
}
}

void OSDropZone2::setIsDefaulted(bool defaulted)
{
if (!m_item) {
makeItem();
}

if (m_item) {
m_item->setIsDefaulted(defaulted);
}

if (defaulted) {
m_label->setStyleSheet("QLabel { color:green }"); // color: #006837
} else {
m_label->setStyleSheet("QLabel { color:black }");
}
}

bool OSDropZone2::isDefaulted()
{
bool isDefaluted = false;
if (m_item) {
isDefaluted = m_item->isDefaulted();
}
return isDefaluted;
}

} // openstudio
5 changes: 4 additions & 1 deletion openstudiocore/src/openstudio_lib/OSDropZone.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,8 @@ class OSDropZone2 : public QWidget
bool hasData() { return !this->m_label->text().isEmpty(); }
void setDeleteObject(bool deleteObject) { m_deleteObject = deleteObject; }
bool deleteObject() { return m_deleteObject; }

void setIsDefaulted(bool defaulted);
bool isDefaulted();
void bind(model::ModelObject & modelObject,
OptionalModelObjectGetter get,
ModelObjectSetter set,
Expand Down Expand Up @@ -97,6 +98,8 @@ private slots:

private:

void makeItem();

boost::optional<OptionalModelObjectGetter> m_get;
boost::optional<ModelObjectSetter> m_set;
boost::optional<NoFailAction> m_reset;
Expand Down
7 changes: 7 additions & 0 deletions openstudiocore/src/openstudio_lib/OSItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -285,6 +285,13 @@ bool OSItem::isDefaulted() const
void OSItem::setIsDefaulted(bool isDefaulted)
{
m_itemId.setIsDefaulted(isDefaulted);
if (isDefaulted) {
m_textLbl->setStyleSheet("QLabel { color: #006837 }");
this->setRemoveable(false);
} else {
m_textLbl->setStyleSheet("QLabel { color: black }");
this->setRemoveable(true);
}
}

QString OSItem::text() const
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,7 @@ namespace openstudio {
);
}
else if (field == CONSTRUCTIONNAME) {
m_constructionColumn = 4;
addDropZoneColumn(Heading(QString(CONSTRUCTIONNAME), true, false),
CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::construction),
CastNullAdapter<model::InteriorPartitionSurface>(&model::InteriorPartitionSurface::setConstruction),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,6 +233,7 @@ namespace openstudio {
);
}
else if (field == CONSTRUCTION) {
m_constructionColumn = 4;
addDropZoneColumn(Heading(QString(CONSTRUCTION)),
CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::construction),
CastNullAdapter<model::ShadingSurface>(&model::ShadingSurface::setConstruction),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,6 +480,7 @@ namespace openstudio {
);
}
else if (field == CONSTRUCTION) {
m_constructionColumn = 6;
addDropZoneColumn(Heading(QString(CONSTRUCTION)),
CastNullAdapter<model::SubSurface>(&model::SubSurface::construction),
CastNullAdapter<model::SubSurface>(&model::SubSurface::setConstruction),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@ namespace openstudio {
);
}
else if (field == CONSTRUCTION) {
m_constructionColumn = 4;
addDropZoneColumn(Heading(QString(CONSTRUCTION)),
CastNullAdapter<model::Surface>(&model::Surface::construction),
CastNullAdapter<model::Surface>(&model::Surface::setConstruction),
Expand Down
16 changes: 16 additions & 0 deletions openstudiocore/src/shared_gui_components/OSGridController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@

#include "../model/Model_Impl.hpp"
#include "../model/ModelObject_Impl.hpp"
#include "../model/PlanarSurface.hpp"
#include "../model/PlanarSurface_Impl.hpp"

#include "../utilities/core/Assert.hpp"

Expand Down Expand Up @@ -1349,6 +1351,20 @@ namespace openstudio {
connect(horizontalHeaderWidget, &HorizontalHeaderWidget::inFocus, holder, &Holder::inFocus);
}

// Is this widget's subrow a surface with a defaulted construction?
if (t_obj) {
if (auto planarSurface = t_obj->optionalCast<model::PlanarSurface>()) {
if (planarSurface && planarSurface->isConstructionDefaulted()) {
// Is this column a construction?
if (column == m_constructionColumn) {
if (OSDropZone2 * dropZone = qobject_cast<OSDropZone2 *>(t_widget)) {
dropZone->setIsDefaulted(true);
}
}
}
}
}

m_objectSelector->addWidget(t_obj, holder, row, column, hasSubRows ? numWidgets : boost::optional<int>(), t_selector);

++numWidgets;
Expand Down
5 changes: 5 additions & 0 deletions openstudiocore/src/shared_gui_components/OSGridController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@ class OSGridController : public QObject

OSGridView * gridView();

// If a column contains information about a construction, it may be an inherited construction
// (as determined by calling PlanarSurface::isConstructionDefaulted). An instantiated gridview
// should set this value, if appropriate.
int m_constructionColumn = -1;

protected:

// This function determines the category for
Expand Down

14 comments on commit 8296251

@macumber
Copy link
Contributor

Choose a reason for hiding this comment

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

I'll do a build and test this out, @kbenne did you test in the grid views?

@asparke2 and @DavidGoldwasser should test in 1.10.6

@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 (kbenne) - x86_64-Linux-Ubuntu-14.04-clang-3.5: OK (2343 of 2406 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 (kbenne) - x86_64-Linux-Ubuntu-14.04-cppcheck-1.61: OK (0 of 0 tests passed, 0 test warnings)

Build 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.

iteration (kbenne) - x86_64-Linux-Ubuntu-14.04-clang-3.5: OK (2340 of 2406 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.

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

Build Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

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

develop (kbenne) - x86_64-MacOS-10.10-clang: Tests Failed (0 of 0 tests passed, 0 test warnings)

Build Badge Test Badge

@DavidGoldwasser
Copy link
Collaborator

Choose a reason for hiding this comment

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

@macumber I can test this morning. Is it ok, if I work on develop (have build going now) or do you specifically want to test the installer?

@macumber
Copy link
Contributor

Choose a reason for hiding this comment

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

In the installer, @evanweaver is looking into this already so he'll let you know what you should test

@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.

new_branch_for_ci_test (kbenne) - x86_64-Linux-Ubuntu-14.04-clang-3.5: OK (2343 of 2406 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.

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

Build Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

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

iteration (kbenne) - x86_64-MacOS-10.10-clang: Tests Failed (2131 of 2406 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.

new_branch_for_ci_test (kbenne) - Win64-Windows-7-VisualStudio-12: Tests Failed (2148 of 2406 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.

new_branch_for_ci_test (kbenne) - i386-Windows-7-VisualStudio-12: OK (2384 of 2406 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

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

new_branch_for_ci_test (kbenne) - x86_64-MacOS-10.10-clang: OK (2368 of 2406 tests passed, 0 test warnings)

Build Badge Test Badge

Please sign in to comment.