Skip to content

Commit ced0efb

Browse files
authored
Merge pull request #731 from openstudiocoalition/162_DisplayMoreSchedules
Fix #162 - Display ScheduleConstant, ScheduleCompact and ScheduleFile
2 parents a78a443 + 80af9d4 commit ced0efb

21 files changed

+1584
-45
lines changed

src/openstudio_lib/CMakeLists.txt

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,16 @@ set(${target_name}_SRC
254254
SchedulesTabView.hpp
255255
SchedulesView.cpp
256256
SchedulesView.hpp
257+
ScheduleOthersController.cpp
258+
ScheduleOthersController.hpp
259+
ScheduleOthersView.cpp
260+
ScheduleOthersView.hpp
261+
ScheduleConstantInspectorView.cpp
262+
ScheduleConstantInspectorView.hpp
263+
ScheduleCompactInspectorView.cpp
264+
ScheduleCompactInspectorView.hpp
265+
ScheduleFileInspectorView.cpp
266+
ScheduleFileInspectorView.hpp
257267
ScriptItem.cpp
258268
ScriptItem.hpp
259269
ScriptsTabController.cpp
@@ -393,6 +403,7 @@ set(${target_name}_SRC
393403
../shared_gui_components/CollapsibleComponentHeader.hpp
394404
../shared_gui_components/CollapsibleComponentList.cpp
395405
../shared_gui_components/CollapsibleComponentList.hpp
406+
../shared_gui_components/ColorPalettes.hpp
396407
../shared_gui_components/Component.cpp
397408
../shared_gui_components/Component.hpp
398409
../shared_gui_components/ComponentList.cpp
@@ -608,6 +619,11 @@ set(${target_name}_moc
608619
SchedulesTabController.hpp
609620
SchedulesTabView.hpp
610621
SchedulesView.hpp
622+
ScheduleOthersView.hpp
623+
ScheduleOthersController.hpp
624+
ScheduleConstantInspectorView.hpp
625+
ScheduleCompactInspectorView.hpp
626+
ScheduleFileInspectorView.hpp
611627
ScriptItem.hpp
612628
ScriptsTabController.hpp
613629
ScriptsTabView.hpp

src/openstudio_lib/GridItem.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,11 +31,11 @@
3131
#include "ServiceWaterGridItems.hpp"
3232
#include "IconLibrary.hpp"
3333
#include "LoopScene.hpp"
34-
#include "SchedulesView.hpp"
3534
#include "OSDocument.hpp"
3635
#include "OSAppBase.hpp"
3736
#include "MainRightColumnController.hpp"
3837
#include "ModelObjectItem.hpp"
38+
#include "../shared_gui_components/ColorPalettes.hpp"
3939

4040
#include <openstudio/utilities/core/Assert.hpp>
4141
#include <openstudio/utilities/core/Compare.hpp>
@@ -1380,11 +1380,11 @@ QColor SystemItem::plenumColor(const Handle& plenumHandle) {
13801380
} else {
13811381
int index = plenumIndex(plenumHandle);
13821382
if (index < 0) {
1383-
color = SchedulesView::colors[0];
1383+
color = ColorPalettes::schedule_rules_colors[0];
13841384
} else if (index > 12) {
1385-
color = SchedulesView::colors[12];
1385+
color = ColorPalettes::schedule_rules_colors[12];
13861386
} else {
1387-
color = SchedulesView::colors[index];
1387+
color = ColorPalettes::schedule_rules_colors[index];
13881388
}
13891389

13901390
// DLM: Create a RenderingColor and associate it with the thermal zone?

src/openstudio_lib/IconLibrary.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -448,6 +448,7 @@ IconLibrary::IconLibrary() {
448448
new QPixmap(":/images/mini_icons/mini_water_cooled.png");
449449
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Schedule_Compact).value()] = new QPixmap(":/images/mini_icons/schedule.png");
450450
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Schedule_Constant).value()] = new QPixmap(":/images/mini_icons/schedule.png");
451+
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Schedule_File).value()] = new QPixmap(":/images/mini_icons/schedule.png");
451452
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Schedule_FixedInterval).value()] =
452453
new QPixmap(":/images/mini_icons/schedule.png");
453454
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Schedule_Ruleset).value()] = new QPixmap(":/images/mini_icons/schedule.png");

src/openstudio_lib/MainRightColumnController.cpp

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,25 @@ void MainRightColumnController::configureForSchedulesSubTab(int subTabID) {
319319

320320
break;
321321
}
322+
case SchedulesTabController::SCHEDULESOTHER: {
323+
model::Model lib = doc->componentLibrary();
324+
325+
// my library
326+
auto* myLibraryList = new ModelObjectTypeListView(lib, true, OSItemType::CollapsibleListHeader, true);
327+
myLibraryList->setItemsDraggable(true);
328+
myLibraryList->setItemsRemoveable(false);
329+
myLibraryList->setItemsType(OSItemType::LibraryItem);
330+
331+
myLibraryList->addModelObjectType(IddObjectType::OS_Schedule_Constant, "Constant Schedules");
332+
// myLibraryList->addModelObjectType(IddObjectType::OS_Schedule_Compact, "Compact Schedules");
333+
myLibraryList->addModelObjectCategoryPlaceholder("Schedules");
334+
335+
setLibraryView(myLibraryList);
336+
doc->openSidebar();
337+
//doc->closeSidebar();
338+
339+
break;
340+
}
322341
default:
323342
break;
324343
}
Lines changed: 148 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,148 @@
1+
/***********************************************************************************************************************
2+
* OpenStudio(R), Copyright (c) 2020-2023, OpenStudio Coalition and other contributors. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5+
* following conditions are met:
6+
*
7+
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
8+
* disclaimer.
9+
*
10+
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
11+
* disclaimer in the documentation and/or other materials provided with the distribution.
12+
*
13+
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission from the respective party.
15+
*
16+
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works
17+
* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior
18+
* written permission from Alliance for Sustainable Energy, LLC.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED
23+
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25+
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
***********************************************************************************************************************/
29+
30+
#include "ScheduleCompactInspectorView.hpp"
31+
32+
#include "../shared_gui_components/OSLineEdit.hpp"
33+
#include "../shared_gui_components/OSDoubleEdit.hpp"
34+
#include "../model_editor/Utilities.hpp"
35+
36+
#include <openstudio/model/ScheduleCompact.hpp>
37+
#include <openstudio/model/ScheduleCompact_Impl.hpp>
38+
39+
#include <openstudio/utilities/core/Assert.hpp>
40+
41+
#include <QGridLayout>
42+
#include <QLabel>
43+
#include <QStackedWidget>
44+
#include <QPlainTextEdit>
45+
46+
#include <sstream>
47+
48+
namespace openstudio {
49+
50+
// ScheduleCompactInspectorView
51+
52+
ScheduleCompactInspectorView::ScheduleCompactInspectorView(const openstudio::model::Model& model, QWidget* parent)
53+
: ModelObjectInspectorView(model, true, parent) {
54+
createLayout();
55+
}
56+
57+
void ScheduleCompactInspectorView::createLayout() {
58+
auto* hiddenWidget = new QWidget();
59+
this->stackedWidget()->addWidget(hiddenWidget);
60+
61+
auto* visibleWidget = new QWidget();
62+
this->stackedWidget()->addWidget(visibleWidget);
63+
64+
auto* mainGridLayout = new QGridLayout();
65+
mainGridLayout->setContentsMargins(7, 7, 7, 7);
66+
mainGridLayout->setSpacing(14);
67+
visibleWidget->setLayout(mainGridLayout);
68+
69+
int row = mainGridLayout->rowCount();
70+
71+
QLabel* label = nullptr;
72+
73+
// Name
74+
75+
label = new QLabel("Name: ");
76+
label->setObjectName("H2");
77+
mainGridLayout->addWidget(label, row, 0);
78+
79+
++row;
80+
81+
m_nameEdit = new OSLineEdit2();
82+
mainGridLayout->addWidget(m_nameEdit, row, 0, 1, 1);
83+
84+
++row;
85+
86+
// Value
87+
88+
label = new QLabel("Content: ");
89+
label->setObjectName("H2");
90+
mainGridLayout->addWidget(label, row++, 0);
91+
92+
m_content = new QPlainTextEdit();
93+
m_content->setReadOnly(true);
94+
const QFont f = QFontDatabase::systemFont(QFontDatabase::FixedFont);
95+
m_content->setFont(f);
96+
97+
mainGridLayout->addWidget(m_content, row++, 0, 1, 2);
98+
99+
// Stretch
100+
101+
mainGridLayout->setRowStretch(100, 100);
102+
mainGridLayout->setColumnStretch(0, 3);
103+
mainGridLayout->setColumnStretch(1, 1);
104+
mainGridLayout->setColumnStretch(2, 1);
105+
}
106+
107+
void ScheduleCompactInspectorView::onClearSelection() {
108+
ModelObjectInspectorView::onClearSelection(); // call parent implementation
109+
detach();
110+
}
111+
112+
void ScheduleCompactInspectorView::onSelectModelObject(const openstudio::model::ModelObject& modelObject) {
113+
detach();
114+
auto sch = modelObject.cast<model::ScheduleCompact>();
115+
attach(sch);
116+
refresh();
117+
}
118+
119+
void ScheduleCompactInspectorView::onUpdate() {
120+
refresh();
121+
}
122+
123+
void ScheduleCompactInspectorView::attach(openstudio::model::ScheduleCompact& sch) {
124+
m_sch = sch;
125+
126+
m_nameEdit->bind(
127+
*m_sch, OptionalStringGetter(std::bind(&model::ScheduleCompact::name, m_sch.get_ptr(), true)),
128+
boost::optional<StringSetterOptionalStringReturn>(std::bind(&model::ScheduleCompact::setName, m_sch.get_ptr(), std::placeholders::_1)));
129+
130+
std::stringstream ss;
131+
sch.print(ss);
132+
133+
m_content->setPlainText(toQString(ss.str()));
134+
135+
this->stackedWidget()->setCurrentIndex(1);
136+
}
137+
138+
void ScheduleCompactInspectorView::detach() {
139+
this->stackedWidget()->setCurrentIndex(0);
140+
141+
m_nameEdit->unbind();
142+
143+
m_sch = boost::none;
144+
}
145+
146+
void ScheduleCompactInspectorView::refresh() {}
147+
148+
} // namespace openstudio
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
/***********************************************************************************************************************
2+
* OpenStudio(R), Copyright (c) 2020-2023, OpenStudio Coalition and other contributors. All rights reserved.
3+
*
4+
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
5+
* following conditions are met:
6+
*
7+
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
8+
* disclaimer.
9+
*
10+
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
11+
* disclaimer in the documentation and/or other materials provided with the distribution.
12+
*
13+
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products
14+
* derived from this software without specific prior written permission from the respective party.
15+
*
16+
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works
17+
* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior
18+
* written permission from Alliance for Sustainable Energy, LLC.
19+
*
20+
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
21+
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
22+
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED
23+
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24+
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
25+
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
26+
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
27+
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28+
***********************************************************************************************************************/
29+
30+
#ifndef OPENSTUDIO_SCHEDULECOMPACTINSPECTORVIEW_HPP
31+
#define OPENSTUDIO_SCHEDULECOMPACTINSPECTORVIEW_HPP
32+
33+
#include "ModelObjectInspectorView.hpp"
34+
#include <openstudio/model/ScheduleCompact.hpp>
35+
36+
class QPlainTextEdit;
37+
38+
namespace openstudio {
39+
40+
class OSLineEdit2;
41+
42+
class ScheduleCompactInspectorView : public ModelObjectInspectorView
43+
{
44+
Q_OBJECT
45+
46+
public:
47+
explicit ScheduleCompactInspectorView(const openstudio::model::Model& model, QWidget* parent = nullptr);
48+
49+
virtual ~ScheduleCompactInspectorView() = default;
50+
51+
protected:
52+
virtual void onClearSelection() override;
53+
54+
virtual void onSelectModelObject(const openstudio::model::ModelObject& modelObject) override;
55+
56+
virtual void onUpdate() override;
57+
58+
private:
59+
void createLayout();
60+
61+
void attach(openstudio::model::ScheduleCompact& sch);
62+
63+
void detach();
64+
65+
void refresh();
66+
67+
boost::optional<model::ScheduleCompact> m_sch;
68+
69+
OSLineEdit2* m_nameEdit = nullptr;
70+
71+
QPlainTextEdit* m_content = nullptr;
72+
};
73+
74+
} // namespace openstudio
75+
76+
#endif // OPENSTUDIO_SCHEDULECOMPACTINSPECTORVIEW_HPP

0 commit comments

Comments
 (0)