Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/openstudio_lib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,16 @@ set(${target_name}_SRC
SchedulesTabView.hpp
SchedulesView.cpp
SchedulesView.hpp
ScheduleOthersController.cpp
ScheduleOthersController.hpp
ScheduleOthersView.cpp
ScheduleOthersView.hpp
ScheduleConstantInspectorView.cpp
ScheduleConstantInspectorView.hpp
ScheduleCompactInspectorView.cpp
ScheduleCompactInspectorView.hpp
ScheduleFileInspectorView.cpp
ScheduleFileInspectorView.hpp
ScriptItem.cpp
ScriptItem.hpp
ScriptsTabController.cpp
Expand Down Expand Up @@ -393,6 +403,7 @@ set(${target_name}_SRC
../shared_gui_components/CollapsibleComponentHeader.hpp
../shared_gui_components/CollapsibleComponentList.cpp
../shared_gui_components/CollapsibleComponentList.hpp
../shared_gui_components/ColorPalettes.hpp
../shared_gui_components/Component.cpp
../shared_gui_components/Component.hpp
../shared_gui_components/ComponentList.cpp
Expand Down Expand Up @@ -608,6 +619,11 @@ set(${target_name}_moc
SchedulesTabController.hpp
SchedulesTabView.hpp
SchedulesView.hpp
ScheduleOthersView.hpp
ScheduleOthersController.hpp
ScheduleConstantInspectorView.hpp
ScheduleCompactInspectorView.hpp
ScheduleFileInspectorView.hpp
ScriptItem.hpp
ScriptsTabController.hpp
ScriptsTabView.hpp
Expand Down
8 changes: 4 additions & 4 deletions src/openstudio_lib/GridItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,11 @@
#include "ServiceWaterGridItems.hpp"
#include "IconLibrary.hpp"
#include "LoopScene.hpp"
#include "SchedulesView.hpp"
#include "OSDocument.hpp"
#include "OSAppBase.hpp"
#include "MainRightColumnController.hpp"
#include "ModelObjectItem.hpp"
#include "../shared_gui_components/ColorPalettes.hpp"

#include <openstudio/utilities/core/Assert.hpp>
#include <openstudio/utilities/core/Compare.hpp>
Expand Down Expand Up @@ -1380,11 +1380,11 @@ QColor SystemItem::plenumColor(const Handle& plenumHandle) {
} else {
int index = plenumIndex(plenumHandle);
if (index < 0) {
color = SchedulesView::colors[0];
color = ColorPalettes::schedule_rules_colors[0];
} else if (index > 12) {
color = SchedulesView::colors[12];
color = ColorPalettes::schedule_rules_colors[12];
} else {
color = SchedulesView::colors[index];
color = ColorPalettes::schedule_rules_colors[index];
}

// DLM: Create a RenderingColor and associate it with the thermal zone?
Expand Down
1 change: 1 addition & 0 deletions src/openstudio_lib/IconLibrary.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -448,6 +448,7 @@ IconLibrary::IconLibrary() {
new QPixmap(":/images/mini_icons/mini_water_cooled.png");
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Schedule_Compact).value()] = new QPixmap(":/images/mini_icons/schedule.png");
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Schedule_Constant).value()] = new QPixmap(":/images/mini_icons/schedule.png");
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Schedule_File).value()] = new QPixmap(":/images/mini_icons/schedule.png");
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Schedule_FixedInterval).value()] =
new QPixmap(":/images/mini_icons/schedule.png");
m_miniIcons[openstudio::IddObjectType(openstudio::IddObjectType::OS_Schedule_Ruleset).value()] = new QPixmap(":/images/mini_icons/schedule.png");
Expand Down
19 changes: 19 additions & 0 deletions src/openstudio_lib/MainRightColumnController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -319,6 +319,25 @@ void MainRightColumnController::configureForSchedulesSubTab(int subTabID) {

break;
}
case SchedulesTabController::SCHEDULESOTHER: {
model::Model lib = doc->componentLibrary();

// my library
auto* myLibraryList = new ModelObjectTypeListView(lib, true, OSItemType::CollapsibleListHeader, true);
myLibraryList->setItemsDraggable(true);
myLibraryList->setItemsRemoveable(false);
myLibraryList->setItemsType(OSItemType::LibraryItem);

myLibraryList->addModelObjectType(IddObjectType::OS_Schedule_Constant, "Constant Schedules");
// myLibraryList->addModelObjectType(IddObjectType::OS_Schedule_Compact, "Compact Schedules");
myLibraryList->addModelObjectCategoryPlaceholder("Schedules");

setLibraryView(myLibraryList);
doc->openSidebar();
//doc->closeSidebar();

break;
}
default:
break;
}
Expand Down
148 changes: 148 additions & 0 deletions src/openstudio_lib/ScheduleCompactInspectorView.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,148 @@
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2020-2023, OpenStudio Coalition and other contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.
*
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission from the respective party.
*
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works
* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior
* written permission from Alliance for Sustainable Energy, LLC.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************************************************************/

#include "ScheduleCompactInspectorView.hpp"

#include "../shared_gui_components/OSLineEdit.hpp"
#include "../shared_gui_components/OSDoubleEdit.hpp"
#include "../model_editor/Utilities.hpp"

#include <openstudio/model/ScheduleCompact.hpp>
#include <openstudio/model/ScheduleCompact_Impl.hpp>

#include <openstudio/utilities/core/Assert.hpp>

#include <QGridLayout>
#include <QLabel>
#include <QStackedWidget>
#include <QPlainTextEdit>

#include <sstream>

namespace openstudio {

// ScheduleCompactInspectorView

ScheduleCompactInspectorView::ScheduleCompactInspectorView(const openstudio::model::Model& model, QWidget* parent)
: ModelObjectInspectorView(model, true, parent) {
createLayout();
}

void ScheduleCompactInspectorView::createLayout() {
auto* hiddenWidget = new QWidget();
this->stackedWidget()->addWidget(hiddenWidget);

auto* visibleWidget = new QWidget();
this->stackedWidget()->addWidget(visibleWidget);

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

int row = mainGridLayout->rowCount();

QLabel* label = nullptr;

// Name

label = new QLabel("Name: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label, row, 0);

++row;

m_nameEdit = new OSLineEdit2();
mainGridLayout->addWidget(m_nameEdit, row, 0, 1, 1);

++row;

// Value

label = new QLabel("Content: ");
label->setObjectName("H2");
mainGridLayout->addWidget(label, row++, 0);

m_content = new QPlainTextEdit();
m_content->setReadOnly(true);
const QFont f = QFontDatabase::systemFont(QFontDatabase::FixedFont);
m_content->setFont(f);

mainGridLayout->addWidget(m_content, row++, 0, 1, 2);

// Stretch

mainGridLayout->setRowStretch(100, 100);
mainGridLayout->setColumnStretch(0, 3);
mainGridLayout->setColumnStretch(1, 1);
mainGridLayout->setColumnStretch(2, 1);
}

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

void ScheduleCompactInspectorView::onSelectModelObject(const openstudio::model::ModelObject& modelObject) {
detach();
auto sch = modelObject.cast<model::ScheduleCompact>();
attach(sch);
refresh();
}

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

void ScheduleCompactInspectorView::attach(openstudio::model::ScheduleCompact& sch) {
m_sch = sch;

m_nameEdit->bind(
*m_sch, OptionalStringGetter(std::bind(&model::ScheduleCompact::name, m_sch.get_ptr(), true)),
boost::optional<StringSetterOptionalStringReturn>(std::bind(&model::ScheduleCompact::setName, m_sch.get_ptr(), std::placeholders::_1)));

std::stringstream ss;
sch.print(ss);

m_content->setPlainText(toQString(ss.str()));

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

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

m_nameEdit->unbind();

m_sch = boost::none;
}

void ScheduleCompactInspectorView::refresh() {}

} // namespace openstudio
76 changes: 76 additions & 0 deletions src/openstudio_lib/ScheduleCompactInspectorView.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/***********************************************************************************************************************
* OpenStudio(R), Copyright (c) 2020-2023, OpenStudio Coalition and other contributors. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are permitted provided that the
* following conditions are met:
*
* (1) Redistributions of source code must retain the above copyright notice, this list of conditions and the following
* disclaimer.
*
* (2) Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following
* disclaimer in the documentation and/or other materials provided with the distribution.
*
* (3) Neither the name of the copyright holder nor the names of any contributors may be used to endorse or promote products
* derived from this software without specific prior written permission from the respective party.
*
* (4) Other than as required in clauses (1) and (2), distributions in any form of modifications or other derivative works
* may not use the "OpenStudio" trademark, "OS", "os", or any other confusingly similar designation without specific prior
* written permission from Alliance for Sustainable Energy, LLC.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDER(S) AND ANY CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES,
* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER(S), ANY CONTRIBUTORS, THE UNITED STATES GOVERNMENT, OR THE UNITED
* STATES DEPARTMENT OF ENERGY, NOR ANY OF THEIR EMPLOYEES, BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
***********************************************************************************************************************/

#ifndef OPENSTUDIO_SCHEDULECOMPACTINSPECTORVIEW_HPP
#define OPENSTUDIO_SCHEDULECOMPACTINSPECTORVIEW_HPP

#include "ModelObjectInspectorView.hpp"
#include <openstudio/model/ScheduleCompact.hpp>

class QPlainTextEdit;

namespace openstudio {

class OSLineEdit2;

class ScheduleCompactInspectorView : public ModelObjectInspectorView
{
Q_OBJECT

public:
explicit ScheduleCompactInspectorView(const openstudio::model::Model& model, QWidget* parent = nullptr);

virtual ~ScheduleCompactInspectorView() = default;

protected:
virtual void onClearSelection() override;

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

virtual void onUpdate() override;

private:
void createLayout();

void attach(openstudio::model::ScheduleCompact& sch);

void detach();

void refresh();

boost::optional<model::ScheduleCompact> m_sch;

OSLineEdit2* m_nameEdit = nullptr;

QPlainTextEdit* m_content = nullptr;
};

} // namespace openstudio

#endif // OPENSTUDIO_SCHEDULECOMPACTINSPECTORVIEW_HPP
Loading