Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add environment variable to control which tab is shown on startup - Supported by Ladybug Tools #288

Merged
merged 7 commits into from
Jan 4, 2021
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
3 changes: 2 additions & 1 deletion .github/workflows/cppcheck.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ jobs:
- name: Run cppcheck
shell: bash
run: |
sudo snap install cppcheck
# Current stable (2.3-25-20201207-23616-ga9f4a14c8, rev 1637) is broken, so use edge for now
sudo snap install cppcheck --edge
cppcheck \
--suppress=noExplicitConstructor \
--suppress=useStlAlgorithm \
Expand Down
2 changes: 1 addition & 1 deletion src/model_editor/InspectorDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ openstudio::model::Model InspectorDialog::model() const {
return m_model;
}

void InspectorDialog::setModel(openstudio::model::Model& model, bool force) {
void InspectorDialog::setModel(const openstudio::model::Model& model, bool force) {
if ((model == m_model) && !force) {
return;
}
Expand Down
2 changes: 1 addition & 1 deletion src/model_editor/InspectorDialog.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ class MODELEDITOR_API InspectorDialog : public QMainWindow, public Nano::Observe
openstudio::model::Model model() const;

// point the dialog at a new model
void setModel(openstudio::model::Model& model, bool force = false);
void setModel(const openstudio::model::Model& model, bool force = false);

// void rebuild inspector gadget
void rebuildInspectorGadget(bool recursive);
Expand Down
4 changes: 2 additions & 2 deletions src/model_editor/InspectorGadget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -771,8 +771,8 @@ void InspectorGadget::layoutComboBox(QVBoxLayout* layout, QWidget* parent, opens
combo->addItem("");
}

for (const std::string& name : names) {
combo->addItem(name.c_str());
for (const std::string& thisName : names) {
combo->addItem(thisName.c_str());
}
} else {
if (!prop.required) {
Expand Down
4 changes: 2 additions & 2 deletions src/model_editor/InspectorGadget.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ class MODELEDITOR_API InspectorGadget : public QWidget, public Nano::Observer
* parameter to true
*
*/
void layoutModelObj(openstudio::WorkspaceObject& workObj, bool force = false, bool recursive = true, bool locked = false,
void layoutModelObj(openstudio::WorkspaceObject& workspaceObj, bool force = false, bool recursive = true, bool locked = false,
bool hideChildren = false);

/*! \brief sets the display precision for number fields
Expand Down Expand Up @@ -302,7 +302,7 @@ class MODELEDITOR_API InspectorGadget : public QWidget, public Nano::Observer
const std::string& name, const std::string& curVal, int index, const std::string& comment, bool exists, bool number,
bool real = false);

void layoutComboBox(QVBoxLayout* layout, QWidget* parent, openstudio::IddField& field, openstudio::IddFieldProperties& properties,
void layoutComboBox(QVBoxLayout* layout, QWidget* parent, openstudio::IddField& field, openstudio::IddFieldProperties& prop,
const std::string& name, const std::string& curVal, int index, const std::string& comment, bool exists);

void createExtensibleToolBar(QVBoxLayout* layout, QWidget* parent, const openstudio::IddObjectProperties& props);
Expand Down
29 changes: 23 additions & 6 deletions src/openstudio_app/OpenStudioApp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ void OpenStudioApp::onMeasureManagerAndLibraryReady() {
boost::optional<openstudio::model::Model> model = versionTranslator.loadModel(toPath(fileName));
if (model) {

m_osDocument = std::shared_ptr<OSDocument>(new OSDocument(componentLibrary(), resourcesPath(), model, fileName));
m_osDocument = std::shared_ptr<OSDocument>(new OSDocument(componentLibrary(), resourcesPath(), model, fileName, false, startTabIndex()));

connectOSDocumentSignals();

Expand Down Expand Up @@ -325,7 +325,7 @@ bool OpenStudioApp::openFile(const QString& fileName, bool restoreTabs) {
bool wasQuitOnLastWindowClosed = this->quitOnLastWindowClosed();
this->setQuitOnLastWindowClosed(false);

int startTabIndex = 0;
int startTabIndex = this->startTabIndex();
int startSubTabIndex = 0;
if (m_osDocument) {

Expand Down Expand Up @@ -453,7 +453,7 @@ void OpenStudioApp::newFromEmptyTemplateSlot() {
}

void OpenStudioApp::newFromTemplateSlot(NewFromTemplateEnum newFromTemplateEnum) {
m_osDocument = std::shared_ptr<OSDocument>(new OSDocument(componentLibrary(), resourcesPath()));
m_osDocument = std::shared_ptr<OSDocument>(new OSDocument(componentLibrary(), resourcesPath(), boost::none, QString(), false, startTabIndex()));

connectOSDocumentSignals();

Expand Down Expand Up @@ -552,7 +552,7 @@ void OpenStudioApp::importIdf() {
processEvents();
}

m_osDocument = std::shared_ptr<OSDocument>(new OSDocument(componentLibrary(), resourcesPath(), model));
m_osDocument = std::shared_ptr<OSDocument>(new OSDocument(componentLibrary(), resourcesPath(), model, QString(), false, startTabIndex()));
m_osDocument->markAsModified();
// ETH: parent should change now ...
//parent = m_osDocument->mainWindow();
Expand Down Expand Up @@ -678,7 +678,7 @@ void OpenStudioApp::importIFC() {
processEvents();
}

m_osDocument = std::shared_ptr<OSDocument>(new OSDocument(componentLibrary(), resourcesPath(), *model));
m_osDocument = std::shared_ptr<OSDocument>(new OSDocument(componentLibrary(), resourcesPath(), *model, QString(), false, startTabIndex()));

m_osDocument->markAsModified();

Expand Down Expand Up @@ -740,7 +740,7 @@ void OpenStudioApp::import(OpenStudioApp::fileType type) {
processEvents();
}

m_osDocument = std::shared_ptr<OSDocument>(new OSDocument(componentLibrary(), resourcesPath(), *model));
m_osDocument = std::shared_ptr<OSDocument>(new OSDocument(componentLibrary(), resourcesPath(), *model, QString(), false, startTabIndex()));
m_osDocument->markAsModified();
// ETH: parent should change now ...
//parent = m_osDocument->mainWindow();
Expand Down Expand Up @@ -1356,6 +1356,23 @@ void OpenStudioApp::writeLibraryPaths(std::vector<openstudio::path> paths) {
}
}

int OpenStudioApp::startTabIndex() const {
int result = OSDocument::VerticalTabID::SITE;
if (qEnvironmentVariableIsSet("OPENSTUDIO_APPLICATION_START_TAB_INDEX")) {
LOG(Debug, "OPENSTUDIO_APPLICATION_START_TAB_INDEX is set");
bool ok;
int test = qEnvironmentVariableIntValue("OPENSTUDIO_APPLICATION_START_TAB_INDEX", &ok);
if (ok) {
if ((test >= OSDocument::VerticalTabID::SITE) && (test <= OSDocument::VerticalTabID::RESULTS_SUMMARY)) {
result = test;
LOG(Debug, "OPENSTUDIO_APPLICATION_START_TAB_INDEX is " << result);
}
}
}

return result;
}

void OpenStudioApp::loadLibrary() {
if (this->currentDocument()) {
QWidget* parent = this->currentDocument()->mainWindow();
Expand Down
2 changes: 2 additions & 0 deletions src/openstudio_app/OpenStudioApp.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,8 @@ class OpenStudioApp : public OSAppBase
*/
void writeLibraryPaths(std::vector<openstudio::path> paths);

int startTabIndex() const;

QProcess* m_measureManagerProcess;

openstudio::model::Model m_compLibrary;
Expand Down
11 changes: 0 additions & 11 deletions src/openstudio_lib/MainRightColumnController.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1157,17 +1157,6 @@ void MainRightColumnController::configureForHVACSystemsSubTab(int subTabID) {
doc->openSidebar();
}

void MainRightColumnController::configureForBuildingSummarySubTab(int subTabID) {
std::shared_ptr<OSDocument> doc = OSAppBase::instance()->currentDocument();

setLibraryView(nullptr);
setMyModelView(nullptr);
setEditView(nullptr);

//doc->openSidebar();
doc->closeSidebar();
}

void MainRightColumnController::configureForOutputVariablesSubTab(int subTabID) {
std::shared_ptr<OSDocument> doc = OSAppBase::instance()->currentDocument();

Expand Down
2 changes: 0 additions & 2 deletions src/openstudio_lib/MainRightColumnController.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,6 @@ class MainRightColumnController : public OSQObjectController

void configureForHVACSystemsSubTab(int subTabID);

void configureForBuildingSummarySubTab(int subTabID);

void configureForOutputVariablesSubTab(int subTabID);

void configureForSimulationSettingsSubTab(int subTabID);
Expand Down
28 changes: 8 additions & 20 deletions src/openstudio_lib/OSDocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,9 +142,7 @@ OSDocument::OSDocument(const openstudio::model::Model& library, const openstudio
m_onlineBclDialog(nullptr),
m_localLibraryDialog(nullptr),
m_savePath(filePath),
m_isPlugin(isPlugin),
m_startTabIndex(startTabIndex),
m_startSubTabIndex(startSubTabIndex) {
m_isPlugin(isPlugin) {
QFile data(":openstudiolib.qss");

static QString style;
Expand Down Expand Up @@ -230,6 +228,13 @@ OSDocument::OSDocument(const openstudio::model::Model& library, const openstudio
if (initalizeWorkflow) {
QTimer::singleShot(0, this, SLOT(addStandardMeasures()));
}

if (startTabIndex != m_verticalId) {
QTimer::singleShot(0, [=] {
this->onVerticalTabSelected(startTabIndex);
this->updateSubTabSelected(startSubTabIndex);
});
}
}

//void OSDocument::showRubyConsole()
Expand Down Expand Up @@ -660,20 +665,6 @@ void OSDocument::createTab(int verticalId) {

break;

case BUILDING_SUMMARY:
//******************************************************************************************************
//
//// Summary
//
//m_summaryTabController = std::shared_ptr<SummaryTabController>( new SummaryTabController(m_model) );
//m_mainWindow->setView( m_summaryTabController->mainContentWidget(),BUILDING_SUMMARY );
////connect(m_summaryTabController->mainContentWidget(), &MainTabView::tabSelected,
//// m_mainRightColumnController.get(), &MainRightColumnController::configureForBuildingSummarySubTab);
//
//******************************************************************************************************

break;

case OUTPUT_VARIABLES:
// Variables

Expand Down Expand Up @@ -1170,9 +1161,6 @@ void OSDocument::onVerticalTabSelected(int verticalId) {
qobject_cast<HVACSystemsTabController*>(m_mainTabController.get())->clearSceneSelection();
}
break;
case BUILDING_SUMMARY:
m_mainRightColumnController->configureForBuildingSummarySubTab(m_subTabId);
break;
case OUTPUT_VARIABLES:
m_mainRightColumnController->configureForOutputVariablesSubTab(m_subTabId);
break;
Expand Down
6 changes: 1 addition & 5 deletions src/openstudio_lib/OSDocument.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ class OPENSTUDIO_API OSDocument : public OSQObjectController

enum VerticalTabID
{
SITE,
SITE = 0,
SCHEDULES,
CONSTRUCTIONS,
LOADS,
Expand All @@ -151,7 +151,6 @@ class OPENSTUDIO_API OSDocument : public OSQObjectController
SPACES,
THERMAL_ZONES,
HVAC_SYSTEMS,
BUILDING_SUMMARY,
OUTPUT_VARIABLES,
SIMULATION_SETTINGS,
RUBY_SCRIPTS,
Expand Down Expand Up @@ -353,9 +352,6 @@ class OPENSTUDIO_API OSDocument : public OSQObjectController
int m_subTabId = 0;
bool m_isPlugin;

int m_startTabIndex;
int m_startSubTabIndex;

int m_verticalId;
std::vector<int> m_subTabIds;

Expand Down
Loading