From a63b205fd0b223a4cb3ecad8f13e5837089d74da Mon Sep 17 00:00:00 2001 From: Dan White Date: Thu, 12 May 2022 15:48:37 -0600 Subject: [PATCH 01/36] Improvements to I/O modules --- src/Modules/DataIO/GenericWriter.h | 6 ++-- .../Matlab/DataIO/ImportFieldsFromMatlab.cc | 30 +++++++++++-------- .../Matlab/DataIO/ImportFieldsFromMatlab.h | 1 + 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/Modules/DataIO/GenericWriter.h b/src/Modules/DataIO/GenericWriter.h index cd79ab7b9f..579249bd74 100644 --- a/src/Modules/DataIO/GenericWriter.h +++ b/src/Modules/DataIO/GenericWriter.h @@ -146,14 +146,16 @@ void GenericWriter::execute() { MODULE_ERROR_WITH_TYPE(Dataflow::Networks::GeneralModuleError, "No filename specified."); } - if (needToExecute()) + + if (!boost::filesystem::exists(filename_) || needToExecute()) { #ifdef SCIRUN4_CODE_TO_BE_ENABLED_LATER update_state(Executing); #endif remark("saving file " + filename_); - if (!overwrite()) return; + if (!overwrite()) + return; if (useCustomExporter(filename_)) { diff --git a/src/Modules/Legacy/Matlab/DataIO/ImportFieldsFromMatlab.cc b/src/Modules/Legacy/Matlab/DataIO/ImportFieldsFromMatlab.cc index 38a29b9c4c..2a389d5cca 100644 --- a/src/Modules/Legacy/Matlab/DataIO/ImportFieldsFromMatlab.cc +++ b/src/Modules/Legacy/Matlab/DataIO/ImportFieldsFromMatlab.cc @@ -36,6 +36,7 @@ // ReSharper disable once CppUnusedIncludeDirective #include #include +#include #include #include @@ -103,23 +104,26 @@ int ImportFieldsFromMatlab::indexMatlabFile(matlabconverter& converter, const ma void MatlabFileIndexModule::executeImpl(const StringPortName<0>& filenameIn, const StringPortName<6>& filenameOut) { auto fileOption = getOptionalInput(filenameIn); - - if (needToExecute()) + auto state = get_state(); + if (fileOption && *fileOption) { - auto state = get_state(); - if (fileOption && *fileOption) - { - state->setValue(Variables::Filename, (*fileOption)->value()); - } + state->setValue(Variables::Filename, (*fileOption)->value()); + } - auto filename = state->getValue(Variables::Filename).toFilename().string(); + auto filename = state->getValue(Variables::Filename).toFilename().string(); - if (filename.empty()) - { - error("No file name was specified"); - return; - } + if (filename.empty()) + { + error("No file name was specified"); + return; + } + time_t new_filemodification = boost::filesystem::last_write_time(filename); + + if (new_filemodification != old_filemodification_ || + needToExecute()) + { + old_filemodification_ = new_filemodification; indexmatlabfile(); auto choices = toStringVector(state->getValue(Parameters::PortChoices).toVector()); diff --git a/src/Modules/Legacy/Matlab/DataIO/ImportFieldsFromMatlab.h b/src/Modules/Legacy/Matlab/DataIO/ImportFieldsFromMatlab.h index 9c13fdbc86..eddc29383e 100644 --- a/src/Modules/Legacy/Matlab/DataIO/ImportFieldsFromMatlab.h +++ b/src/Modules/Legacy/Matlab/DataIO/ImportFieldsFromMatlab.h @@ -61,6 +61,7 @@ namespace Matlab { void executeImpl(const StringPortName<0>& filenameIn, const StringPortName<6>& filenameOut); virtual SCIRun::Core::Datatypes::DatatypeHandle processMatlabData(const MatlabIO::matlabarray&) const = 0; virtual int indexMatlabFile(MatlabIO::matlabconverter& converter, const MatlabIO::matlabarray& mlarray, std::string& infostring) const = 0; + time_t old_filemodification_{0}; }; class SCISHARE ImportFieldsFromMatlab : public MatlabFileIndexModule, From c80e3ba1db1f762d5b42e8870b565c7d69ff4b7e Mon Sep 17 00:00:00 2001 From: Dan White Date: Mon, 16 May 2022 14:31:09 -0600 Subject: [PATCH 02/36] Convert module --- .../Modules/Fields/ReportScalarFieldStats.ui | 210 ++++++++++++++++++ src/Modules/Legacy/Fields/CMakeLists.txt | 3 +- .../Legacy/Fields/ReportScalarFieldStats.cc | 175 ++++++++------- .../Legacy/Fields/ReportScalarFieldStats.h | 77 +++++++ 4 files changed, 379 insertions(+), 86 deletions(-) create mode 100644 src/Interface/Modules/Fields/ReportScalarFieldStats.ui create mode 100644 src/Modules/Legacy/Fields/ReportScalarFieldStats.h diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStats.ui b/src/Interface/Modules/Fields/ReportScalarFieldStats.ui new file mode 100644 index 0000000000..ecbdf99ca9 --- /dev/null +++ b/src/Interface/Modules/Fields/ReportScalarFieldStats.ui @@ -0,0 +1,210 @@ + + + CalculateFieldDataMetric + + + + 0 + 0 + 611 + 579 + + + + + 611 + 579 + + + + CalculateFieldDataMetric + + + + + + Result + + + + + + Metric: + + + + + + + -- + + + + + + + + + + Transform Field Data + + + + + + Transform the data before computing metric + + + + + + + true + + + Function: RESULT = function(DATA, POS, ELEMENT, INDEX, ...) + + + + + + + Input array: DATA (scalar/vector/tensor: data from field port) + + + + + + + Input array: X, Y, Z (scalar: Cartensian coordinates of node/element) + + + + + + + Input array: POS (vector: vector with node/element position) + + + + + + + Input array: INDEX (scalar: number of the element) + + + + + + + Input array: SIZE (scalar: number of elements) + + + + + + + Input array: ELEMENT (element: object containing element properties) + + + + + + + Output array: RESULT( scalar/vector/tensor) + + + + + + + true + + + Parser Help + + + + + + + + 557 + 120 + + + + Expression + + + Qt::AlignCenter + + + + + + + + + + + + + + + Metric + + + + + + + Minimum + + + + + Maximum + + + + + Median + + + + + Value-mean + + + + + Geometry-mean + + + + + Sum + + + + + Integral + + + + + Volthreshold + + + + + + + + + + + + + diff --git a/src/Modules/Legacy/Fields/CMakeLists.txt b/src/Modules/Legacy/Fields/CMakeLists.txt index 2a76581c8e..ad6b9a21bf 100644 --- a/src/Modules/Legacy/Fields/CMakeLists.txt +++ b/src/Modules/Legacy/Fields/CMakeLists.txt @@ -77,6 +77,7 @@ SET(Modules_Legacy_Fields_HEADERS MapFieldDataFromSourceToDestination.h MapFieldDataOntoNodesRadialbasis.h ReportFieldGeometryMeasures.h + ReportScalarFieldStats.h FlipSurfaceNormals.h SwapFieldDataWithMatrixEntries.h ConvertIndicesToFieldData.h @@ -175,7 +176,7 @@ SET(Modules_Legacy_Fields_SRCS CreateLatVol.cc CreateImage.cc #CreateStructHex.cc - #ReportScalarFieldStats.cc + ReportScalarFieldStats.cc GeneratePointSamplesFromField.cc #SelectFieldROIWithBoxWidget.cc SetFieldOrMeshStringProperty.cc diff --git a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc index 824f2ed2c8..d8cdacccc6 100644 --- a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc +++ b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc @@ -32,75 +32,78 @@ /// University of Utah ///@date February 2001 -#include -#include - -#include -#include -#include - -#include -#include - -#include - -namespace SCIRun { +#include +#include +#include + +#include +#include +#include +#include +#include +#include + + +using namespace SCIRun; +using namespace SCIRun::Core::Algorithms; +using namespace SCIRun::Core::Geometry; +using namespace SCIRun::Core::Algorithms::Fields; +using namespace SCIRun::Dataflow::Networks; +using namespace SCIRun::Core::Datatypes; +using namespace SCIRun::Modules::Fields; + +ALGORITHM_PARAMETER_DEF(Fields, AutoRangeEnabled); +ALGORITHM_PARAMETER_DEF(Fields, Mean); +ALGORITHM_PARAMETER_DEF(Fields, Median); +ALGORITHM_PARAMETER_DEF(Fields, StandardDeviation); /// @class ReportScalarFieldStats /// @brief Analyze data from a scalarfield. -class SCISHARE ReportScalarFieldStats : public Module +namespace SCIRun::Modules::Fields { +class ReportScalarFieldStatsImpl { public: - ReportScalarFieldStats(GuiContext* ctx); - virtual ~ReportScalarFieldStats() {} - virtual void execute(); + explicit ReportScalarFieldStatsImpl(ReportScalarFieldStats* module) : module_(module) {} - void fill_histogram( std::vector& hits); + void fill_histogram(const std::vector& hits); void clear_histogram(); - void local_reset_vars(){ reset_vars(); } - - private: - GuiDouble min_; - GuiDouble max_; - GuiDouble mean_; - GuiDouble median_; - GuiDouble sigma_; //standard deviation - - GuiInt is_fixed_; - GuiInt nbuckets_; + ReportScalarFieldStats* module_; + double min_; + double max_; + double mean_; + double median_; + double sigma_; //standard deviation + int is_fixed_; + int nbuckets_ {256}; }; +} -DECLARE_MAKER(ReportScalarFieldStats) +MODULE_INFO_DEF(ReportScalarFieldStats, MiscField, SCIRun) -ReportScalarFieldStats::ReportScalarFieldStats(GuiContext* ctx) - : Module("ReportScalarFieldStats", ctx, Filter, "MiscField", "SCIRun"), - min_(get_ctx()->subVar("min"), 0.0), - max_(get_ctx()->subVar("max"), 0.0), - mean_(get_ctx()->subVar("mean"), 0.0), - median_(get_ctx()->subVar("median"), 0.0), - sigma_(get_ctx()->subVar("sigma"),0.0), - is_fixed_(get_ctx()->subVar("is_fixed"), 0), - nbuckets_(get_ctx()->subVar("nbuckets"), 256) +ReportScalarFieldStats::ReportScalarFieldStats() + : Module(staticInfo_) + // min_(get_ctx()->subVar("min"), 0.0), + // max_(get_ctx()->subVar("max"), 0.0), + // mean_(get_ctx()->subVar("mean"), 0.0), + // median_(get_ctx()->subVar("median"), 0.0), + // sigma_(get_ctx()->subVar("sigma"),0.0), + // is_fixed_(get_ctx()->subVar("is_fixed"), 0), + // nbuckets_(get_ctx()->subVar("nbuckets"), 256) { + INITIALIZE_PORT(InputField); + INITIALIZE_PORT(HistogramData); } -void -ReportScalarFieldStats::clear_histogram() -{ - TCLInterface::execute(get_id() + " clear_data"); -} - -void -ReportScalarFieldStats::fill_histogram( std::vector& hits) +void ReportScalarFieldStatsImpl::fill_histogram(const std::vector& hits) { std::ostringstream ostr; int nmin, nmax; - std::vector::iterator it = hits.begin(); + auto it = hits.begin(); nmin = 0; nmax = *it; ostr << *it; ++it; @@ -110,32 +113,33 @@ ReportScalarFieldStats::fill_histogram( std::vector& hits) nmin = ((nmin < *it) ? nmin : *it ); nmax = ((nmax > *it) ? nmax : *it ); } - ostr <remark(" graph_data " + std::to_string(nmin) + " " + std::to_string(nmax) + " " + data ); } +ReportScalarFieldStats::~ReportScalarFieldStats() = default; + +void ReportScalarFieldStats::setStateDefaults() +{ + +} -void -ReportScalarFieldStats::execute() +void ReportScalarFieldStats::execute() { - // Get input field. - FieldHandle ifield_handle; - get_input_handle("Input Field", ifield_handle, true); + auto inputField = getRequiredInput(InputField); - if (!(ifield_handle->vfield()->is_scalar())) + if (!(inputField->vfield()->is_scalar())) { error("This module only works on scalar fields."); return; } - update_state(Executing); + //update_state(Executing); - VField* ifield = ifield_handle->vfield(); + VField* ifield = inputField->vfield(); bool init = false; double value = 0; @@ -144,12 +148,12 @@ ReportScalarFieldStats::execute() int counter = 0; std::vector values; - update_progress(0.3); + //update_progress(0.3); double mean = 0; - double mmin = min_.get(); - double mmax = max_.get(); + double mmin = 0; + double mmax = 0; - if ( is_fixed_.get() == 1 ) + if ( impl_->is_fixed_ == 1 ) { VField::size_type num_values = ifield->num_values(); for (VField::index_type idx=0; idx < num_values ;idx++) @@ -165,7 +169,7 @@ ReportScalarFieldStats::execute() } mean = value/double(counter); - mean_.set( mean ); + impl_->mean_ = mean; } else { @@ -189,47 +193,48 @@ ReportScalarFieldStats::execute() ++counter; } mean = value/double(counter); - mean_.set( mean ); + impl_->mean_ = mean; - min_.set( double( min ) ); - max_.set( double( max ) ); + impl_->min_ = min; + impl_->max_ = max; } - update_progress(0.6); + //update_progress(0.6); - local_reset_vars(); - if ((max_.get() - min_.get()) > 1e-16 && values.size() > 0) + if ((impl_->max_ - impl_->min_) > 1e-16 && values.size() > 0) { - int nbuckets = nbuckets_.get(); + int nbuckets = impl_->nbuckets_; std::vector hits(nbuckets, 0); double frac = 1.0; - frac = (nbuckets-1)/(max_.get() - min_.get()); + frac = (nbuckets-1)/(impl_->max_ - impl_->min_); double sigma = 0.0; - std::vector::iterator vit = values.begin(); - std::vector::iterator vit_end = values.end(); + auto vit = values.begin(); + auto vit_end = values.end(); for(; vit != vit_end; ++vit) { - if( *vit >= min_.get() && *vit <= max_.get()) + if( *vit >= impl_->min_ && *vit <= impl_->max_) { - double value = (*vit - min_.get())*frac; + double value = (*vit - impl_->min_)*frac; hits[int(value)]++; } sigma += (*vit - mean)*(*vit - mean); } - sigma_.set( sqrt( sigma / double(values.size()) )); + impl_->sigma_ = sqrt( sigma / double(values.size()) ); vit = values.begin(); nth_element(vit, vit+values.size()/2, vit_end); - median_.set( double ( values[ values.size()/2] ) ); - fill_histogram( hits ); + impl_->median_ = values[values.size()/2]; + impl_->fill_histogram(hits); } else { warning("min - max < precision or no values in range; clearing histogram"); - clear_histogram(); + impl_->clear_histogram(); } + auto state = get_state(); + state->setValue(Parameters::Mean, impl_->mean_); + state->setValue(Parameters::Median, impl_->median_); + state->setValue(Parameters::StandardDeviation, impl_->sigma_); } - -} // End namespace SCIRun diff --git a/src/Modules/Legacy/Fields/ReportScalarFieldStats.h b/src/Modules/Legacy/Fields/ReportScalarFieldStats.h new file mode 100644 index 0000000000..918cc3355f --- /dev/null +++ b/src/Modules/Legacy/Fields/ReportScalarFieldStats.h @@ -0,0 +1,77 @@ +/* + For more information, please see: http://software.sci.utah.edu + + The MIT License + + Copyright (c) 2020 Scientific Computing and Imaging Institute, + University of Utah. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + + +#ifndef MODULES_LEGACY_FIELDS_REPORTSCALARFIELDSTATS_H__ +#define MODULES_LEGACY_FIELDS_REPORTSCALARFIELDSTATS_H__ + +#include +#include + +namespace SCIRun { + namespace Core + { + namespace Algorithms + { + namespace Fields + { + ALGORITHM_PARAMETER_DECL(AutoRangeEnabled); + ALGORITHM_PARAMETER_DECL(Mean); + ALGORITHM_PARAMETER_DECL(Median); + ALGORITHM_PARAMETER_DECL(StandardDeviation); + // ALGORITHM_PARAMETER_DECL(IndexFlag); + // ALGORITHM_PARAMETER_DECL(SizeFlag); + // ALGORITHM_PARAMETER_DECL(NormalsFlag); + } + } + } + namespace Modules { + namespace Fields { + + class SCISHARE ReportScalarFieldStats : public Dataflow::Networks::Module, + public Has1InputPort, + public Has1OutputPort + { + public: + ReportScalarFieldStats(); + ~ReportScalarFieldStats() override; + + void execute() override; + void setStateDefaults() override; + + INPUT_PORT(0, InputField, Field); + OUTPUT_PORT(0, HistogramData, Matrix); + + MODULE_TRAITS_AND_INFO(ModuleFlags::ModuleHasUI) + private: + std::unique_ptr impl_; + }; + } + } +} + +#endif From d4da1de82f141d9223f339d7c3f415e88d049bac Mon Sep 17 00:00:00 2001 From: Dan White Date: Mon, 16 May 2022 14:39:46 -0600 Subject: [PATCH 03/36] Add UI --- src/Interface/Modules/Fields/CMakeLists.txt | 3 + .../Modules/Fields/ReportScalarFieldStats.ui | 199 +++++------------- .../Fields/ReportScalarFieldStatsDialog.cc | 65 ++++++ .../Fields/ReportScalarFieldStatsDialog.h | 55 +++++ 4 files changed, 178 insertions(+), 144 deletions(-) create mode 100644 src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc create mode 100644 src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.h diff --git a/src/Interface/Modules/Fields/CMakeLists.txt b/src/Interface/Modules/Fields/CMakeLists.txt index abfa282f80..08dfb2107f 100644 --- a/src/Interface/Modules/Fields/CMakeLists.txt +++ b/src/Interface/Modules/Fields/CMakeLists.txt @@ -81,6 +81,7 @@ SET(Interface_Modules_Fields_FORMS ApplyFilterToFieldData.ui CalculateFieldDataMetric.ui CalculateBundleDifference.ui + ReportScalarFieldStats.ui ) SET(Interface_Modules_Fields_HEADERS @@ -139,6 +140,7 @@ SET(Interface_Modules_Fields_HEADERS ApplyFilterToFieldDataDialog.h CalculateFieldDataMetricDialog.h CalculateBundleDifferenceDialog.h + ReportScalarFieldStatsDialog.h ) SET(Interface_Modules_Fields_SOURCES @@ -196,6 +198,7 @@ SET(Interface_Modules_Fields_SOURCES ApplyFilterToFieldDataDialog.cc CalculateFieldDataMetricDialog.cc CalculateBundleDifferenceDialog.cc + ReportScalarFieldStatsDialog.cc ) QT_WRAP_UI(Interface_Modules_Fields_FORMS_HEADERS "${Interface_Modules_Fields_FORMS}") diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStats.ui b/src/Interface/Modules/Fields/ReportScalarFieldStats.ui index ecbdf99ca9..772e091f00 100644 --- a/src/Interface/Modules/Fields/ReportScalarFieldStats.ui +++ b/src/Interface/Modules/Fields/ReportScalarFieldStats.ui @@ -1,202 +1,113 @@ - CalculateFieldDataMetric - + ReportScalarFieldStats + 0 0 - 611 - 579 + 330 + 200 - 611 - 579 + 330 + 200 - CalculateFieldDataMetric + ReportScalarFieldStats - - - - Result - - - - - - Metric: - - - - - - - -- - - - - - - - Transform Field Data + Auto Range + + + true - - - + + + - Transform the data before computing metric + Min - - - - true + + + + 9 - - Function: RESULT = function(DATA, POS, ELEMENT, INDEX, ...) + + -99999999999999.000000000000000 + + + 99999999999999.000000000000000 - + - Input array: DATA (scalar/vector/tensor: data from field port) + Max - - - - Input array: X, Y, Z (scalar: Cartensian coordinates of node/element) - - + + - - + + + + + + + Stats + + + + - Input array: POS (vector: vector with node/element position) + Mean - - + + - Input array: INDEX (scalar: number of the element) + m - - + + - Input array: SIZE (scalar: number of elements) + Median - - + + - Input array: ELEMENT (element: object containing element properties) + M - - + + - Output array: RESULT( scalar/vector/tensor) + Standard Deviation - - - - true - + + - Parser Help - - - - - - - - 557 - 120 - - - - Expression - - - Qt::AlignCenter + s - - - - - - - - - - - - - - Metric - - - - - - - Minimum - - - - - Maximum - - - - - Median - - - - - Value-mean - - - - - Geometry-mean - - - - - Sum - - - - - Integral - - - - - Volthreshold - - diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc new file mode 100644 index 0000000000..5ac520a8c4 --- /dev/null +++ b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc @@ -0,0 +1,65 @@ +/* + For more information, please see: http://software.sci.utah.edu + + The MIT License + + Copyright (c) 2020 Scientific Computing and Imaging Institute, + University of Utah. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + + +#include +#include +#include +#include + +using namespace SCIRun::Gui; +using namespace SCIRun::Dataflow::Networks; +using namespace SCIRun::Core::Algorithms; +using namespace SCIRun::Core::Algorithms::Fields; + +CalculateFieldDataMetricDialog::CalculateFieldDataMetricDialog(const std::string& name, ModuleStateHandle state, + QWidget* parent /* = 0 */) + : ModuleDialogWithParserHelp(state, parent) +{ + setupUi(this); + setWindowTitle(QString::fromStdString(name)); + fixSize(); + + addComboBoxManager(metricComboBox_, Variables::Method, + {{"Minimum", "min"}, + {"Maximum", "max"}, + {"Median", "median"}, + {"Value-mean", "value-mean"}, + {"Geometry-mean", "geom-mean"}, + {"Sum", "sum"}, + {"Integral", "integral"}, + {"Volthreshold", "volthreshold"} + }); + addCheckBoxManager(enableFunctionCheckBox_, Parameters::EnableFunction); + connectParserHelpButton(parserHelpButton_); + + { + codeEdit_ = new CodeEditor(this); + qobject_cast(expressionGroupBox_->layout())->insertWidget(0, codeEdit_); + addPlainTextEditManager(codeEdit_, Variables::FunctionString); + } +} diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.h b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.h new file mode 100644 index 0000000000..3e24419f35 --- /dev/null +++ b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.h @@ -0,0 +1,55 @@ +/* + For more information, please see: http://software.sci.utah.edu + + The MIT License + + Copyright (c) 2020 Scientific Computing and Imaging Institute, + University of Utah. + + Permission is hereby granted, free of charge, to any person obtaining a + copy of this software and associated documentation files (the "Software"), + to deal in the Software without restriction, including without limitation + the rights to use, copy, modify, merge, publish, distribute, sublicense, + and/or sell copies of the Software, and to permit persons to whom the + Software is furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included + in all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + DEALINGS IN THE SOFTWARE. +*/ + + +#ifndef INTERFACE_MODULES_CALCULATEFIELDDATA_H +#define INTERFACE_MODULES_CALCULATEFIELDDATA_H + +#include "Interface/Modules/Fields/ui_CalculateFieldData.h" +#include +#include + +namespace SCIRun { +namespace Gui { + +class SCISHARE CalculateFieldDataDialog : public ModuleDialogWithParserHelp, + public Ui::CalculateFieldData +{ + Q_OBJECT + +public: + CalculateFieldDataDialog(const std::string& name, + SCIRun::Dataflow::Networks::ModuleStateHandle state, + QWidget* parent = nullptr); + private: + class CodeEditor* codeEdit_; +}; + +} +} + +#endif From 386f401b78e3ac708d06402067a38b41658ac24f Mon Sep 17 00:00:00 2001 From: Dan White Date: Mon, 16 May 2022 16:31:02 -0600 Subject: [PATCH 04/36] UI --- .../Fields/ReportScalarFieldStatsDialog.cc | 27 +++---------------- .../Fields/ReportScalarFieldStatsDialog.h | 14 +++++----- .../Legacy/Fields/ReportScalarFieldStats.cc | 2 +- 3 files changed, 11 insertions(+), 32 deletions(-) diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc index 5ac520a8c4..b01e1129a8 100644 --- a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc +++ b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc @@ -26,9 +26,8 @@ */ -#include -#include -#include +#include +#include #include using namespace SCIRun::Gui; @@ -36,30 +35,12 @@ using namespace SCIRun::Dataflow::Networks; using namespace SCIRun::Core::Algorithms; using namespace SCIRun::Core::Algorithms::Fields; -CalculateFieldDataMetricDialog::CalculateFieldDataMetricDialog(const std::string& name, ModuleStateHandle state, +ReportScalarFieldStatsDialog::ReportScalarFieldStatsDialog(const std::string& name, ModuleStateHandle state, QWidget* parent /* = 0 */) - : ModuleDialogWithParserHelp(state, parent) + : ModuleDialogGeneric(state, parent) { setupUi(this); setWindowTitle(QString::fromStdString(name)); fixSize(); - addComboBoxManager(metricComboBox_, Variables::Method, - {{"Minimum", "min"}, - {"Maximum", "max"}, - {"Median", "median"}, - {"Value-mean", "value-mean"}, - {"Geometry-mean", "geom-mean"}, - {"Sum", "sum"}, - {"Integral", "integral"}, - {"Volthreshold", "volthreshold"} - }); - addCheckBoxManager(enableFunctionCheckBox_, Parameters::EnableFunction); - connectParserHelpButton(parserHelpButton_); - - { - codeEdit_ = new CodeEditor(this); - qobject_cast(expressionGroupBox_->layout())->insertWidget(0, codeEdit_); - addPlainTextEditManager(codeEdit_, Variables::FunctionString); - } } diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.h b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.h index 3e24419f35..c0d6a123e6 100644 --- a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.h +++ b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.h @@ -26,27 +26,25 @@ */ -#ifndef INTERFACE_MODULES_CALCULATEFIELDDATA_H -#define INTERFACE_MODULES_CALCULATEFIELDDATA_H +#ifndef INTERFACE_MODULES_REPORTSCALARFIELDSTATS_H +#define INTERFACE_MODULES_REPORTSCALARFIELDSTATS_H -#include "Interface/Modules/Fields/ui_CalculateFieldData.h" +#include "Interface/Modules/Fields/ui_ReportScalarFieldStats.h" #include #include namespace SCIRun { namespace Gui { -class SCISHARE CalculateFieldDataDialog : public ModuleDialogWithParserHelp, - public Ui::CalculateFieldData +class SCISHARE ReportScalarFieldStatsDialog : public ModuleDialogGeneric, + public Ui::ReportScalarFieldStats { Q_OBJECT public: - CalculateFieldDataDialog(const std::string& name, + ReportScalarFieldStatsDialog(const std::string& name, SCIRun::Dataflow::Networks::ModuleStateHandle state, QWidget* parent = nullptr); - private: - class CodeEditor* codeEdit_; }; } diff --git a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc index d8cdacccc6..09eb577b4f 100644 --- a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc +++ b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc @@ -67,7 +67,7 @@ class ReportScalarFieldStatsImpl explicit ReportScalarFieldStatsImpl(ReportScalarFieldStats* module) : module_(module) {} void fill_histogram(const std::vector& hits); - void clear_histogram(); + void clear_histogram() {} ReportScalarFieldStats* module_; double min_; From a94842601f66d3344727c1c94c2baf39210498fc Mon Sep 17 00:00:00 2001 From: Dan White Date: Mon, 16 May 2022 17:27:34 -0600 Subject: [PATCH 05/36] adjusting --- .../Modules/Fields/ReportScalarFieldStats.ui | 4 ++-- .../Config/ReportScalarFieldStats.module | 18 ++++++++++++++++++ 2 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 src/Modules/Factory/Config/ReportScalarFieldStats.module diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStats.ui b/src/Interface/Modules/Fields/ReportScalarFieldStats.ui index 772e091f00..192775f2d3 100644 --- a/src/Interface/Modules/Fields/ReportScalarFieldStats.ui +++ b/src/Interface/Modules/Fields/ReportScalarFieldStats.ui @@ -7,13 +7,13 @@ 0 0 330 - 200 + 220 330 - 200 + 220 diff --git a/src/Modules/Factory/Config/ReportScalarFieldStats.module b/src/Modules/Factory/Config/ReportScalarFieldStats.module new file mode 100644 index 0000000000..f9cdc37209 --- /dev/null +++ b/src/Modules/Factory/Config/ReportScalarFieldStats.module @@ -0,0 +1,18 @@ +{ + "module": { + "name": "ReportScalarFieldStats", + "namespace": "Fields", + "status": "Converted", + "description": "...", + "header": "Modules/Legacy/Fields/ReportScalarFieldStats.h" + }, + "algorithm": { + "name": "N/A", + "namespace": "N/A", + "header": "N/A" + }, + "UI": { + "name": "ReportScalarFieldStatsDialog", + "header": "Interface/Modules/Fields/ReportScalarFieldStatsDialog.h" + } +} From 3c1919a50778488cc386b986c3ca2c14c4a74454 Mon Sep 17 00:00:00 2001 From: Dan White Date: Mon, 16 May 2022 19:34:54 -0600 Subject: [PATCH 06/36] Filling out impl --- .../Modules/reportScalarFieldStats.srn5 | 2352 +++++++++++++++++ .../Modules/Fields/ReportScalarFieldStats.ui | 36 +- .../Fields/ReportScalarFieldStatsDialog.cc | 5 + .../Legacy/Fields/ReportScalarFieldStats.cc | 24 +- .../Legacy/Fields/ReportScalarFieldStats.h | 4 +- 5 files changed, 2400 insertions(+), 21 deletions(-) create mode 100644 src/ExampleNets/regression/Modules/reportScalarFieldStats.srn5 diff --git a/src/ExampleNets/regression/Modules/reportScalarFieldStats.srn5 b/src/ExampleNets/regression/Modules/reportScalarFieldStats.srn5 new file mode 100644 index 0000000000..7a438f0e89 --- /dev/null +++ b/src/ExampleNets/regression/Modules/reportScalarFieldStats.srn5 @@ -0,0 +1,2352 @@ + + + + + + + 9 + 0 + + CreateFieldData:0 + + + SCIRun + ChangeFieldData + CreateFieldData + + + + 4 + 0 + + + BasisString + + + BasisString + + 2 + Linear + + + + + + FormatString + + + FormatString + + 2 + Scalar + + + + + + FunctionString + + + FunctionString + + 2 + RESULT = X^2 - Y^2; + + + + + + ProgrammableInputPortEnabled + + + ProgrammableInputPortEnabled + + 3 + 0 + + + + + + + + + CreateLatVol:0 + + + SCIRun + NewField + CreateLatVol + + + + 7 + 0 + + + DataAtLocation + + + DataAtLocation + + 0 + 0 + + + + + + ElementSizeNormalized + + + ElementSizeNormalized + + 0 + 0 + + + + + + PadPercent + + + PadPercent + + 1 + 0.00000000000000000e+00 + + + + + + ProgrammableInputPortEnabled + + + ProgrammableInputPortEnabled + + 3 + 0 + + + + + + XSize + + + XSize + + 0 + 16 + + + + + + YSize + + + YSize + + 0 + 16 + + + + + + ZSize + + + ZSize + + 0 + 16 + + + + + + + + + CreateStandardColorMap:0 + + + SCIRun + Visualization + CreateStandardColorMap + + + + 10 + 0 + + + AlphaUserPointsVector + + + AlphaUserPointsVector + + 5 + + 0 + 0 + + + + + + + ColorMapInvert + + + ColorMapInvert + + 3 + 0 + + + + + + ColorMapName + + + ColorMapName + + 2 + Rainbow + + + + + + ColorMapOption + + + ColorMapOption + + 0 + 0 + + + + + + ColorMapResolution + + + ColorMapResolution + + 0 + 256 + + + + + + ColorMapShift + + + ColorMapShift + + 1 + 0.00000000000000000e+00 + + + + + + CustomColor0 + + + CustomColor0 + + 2 + Color(0.2,0.2,0.2) + + + + + + CustomColor1 + + + CustomColor1 + + 2 + Color(0.8,0.8,0.8) + + + + + + DefaultAlphaValue + + + DefaultAlphaValue + + 1 + 5.00000000000000000e-01 + + + + + + ProgrammableInputPortEnabled + + + ProgrammableInputPortEnabled + + 3 + 0 + + + + + + + + + DisplayHistogram:0 + + + SCIRun + Math + DisplayHistogram + + + + 1 + 0 + + + ProgrammableInputPortEnabled + + + ProgrammableInputPortEnabled + + 3 + 0 + + + + + + + + + GetFieldData:0 + + + SCIRun + ChangeFieldData + GetFieldData + + + + 1 + 0 + + + ProgrammableInputPortEnabled + + + ProgrammableInputPortEnabled + + 3 + 0 + + + + + + + + + ReportScalarFieldStats:0 + + + SCIRun + MiscField + ReportScalarFieldStats + + + + 7 + 0 + + + AutoRangeEnabled + + + AutoRangeEnabled + + 3 + 1 + + + + + + MaxRange + + + MaxRange + + 1 + 0.00000000000000000e+00 + + + + + + Mean + + + Mean + + 1 + 8.32938319011988781e-17 + + + + + + Median + + + Median + + 1 + 0.00000000000000000e+00 + + + + + + MinRange + + + MinRange + + 1 + 0.00000000000000000e+00 + + + + + + ProgrammableInputPortEnabled + + + ProgrammableInputPortEnabled + + 3 + 0 + + + + + + StandardDeviation + + + StandardDeviation + + 1 + 4.75036061009327715e-01 + + + + + + + + + RescaleColorMap:0 + + + SCIRun + Visualization + RescaleColorMap + + + + 5 + 0 + + + AutoScale + + + AutoScale + + 0 + 0 + + + + + + FixedMax + + + FixedMax + + 1 + 9.95555555555555527e-01 + + + + + + FixedMin + + + FixedMin + + 1 + -9.95555555555555527e-01 + + + + + + ProgrammableInputPortEnabled + + + ProgrammableInputPortEnabled + + 3 + 0 + + + + + + Symmetric + + + Symmetric + + 3 + 0 + + + + + + + + + ShowField:0 + + + SCIRun + Visualization + ShowField + + + + 39 + 0 + + + CullBackfacingText + + + CullBackfacingText + + 3 + 0 + + + + + + CylinderRadius + + + CylinderRadius + + 1 + 1.00000000000000006e-01 + + + + + + CylinderResolution + + + CylinderResolution + + 0 + 5 + + + + + + DefaultMeshColor + + + DefaultMeshColor + + 2 + Color(0.5,0.5,0.5) + + + + + + DefaultTextColor + + + DefaultTextColor + + 2 + Color(1,1,1) + + + + + + EdgeTransparency + + + EdgeTransparency + + 3 + 0 + + + + + + EdgeTransparencyValue + + + EdgeTransparencyValue + + 1 + 6.49999976158142090e-01 + + + + + + EdgesAsCylinders + + + EdgesAsCylinders + + 0 + 0 + + + + + + EdgesAvailable + + + EdgesAvailable + + 3 + 1 + + + + + + EdgesColoring + + + EdgesColoring + + 0 + 1 + + + + + + FaceInvertNormals + + + FaceInvertNormals + + 3 + 0 + + + + + + FaceTransparency + + + FaceTransparency + + 3 + 0 + + + + + + FaceTransparencyValue + + + FaceTransparencyValue + + 1 + 6.49999976158142090e-01 + + + + + + FacesAvailable + + + FacesAvailable + + 3 + 1 + + + + + + FacesColoring + + + FacesColoring + + 0 + 1 + + + + + + FieldName + + + FieldName + + 2 + + + + + + + NodeAsSpheres + + + NodeAsSpheres + + 0 + 0 + + + + + + NodeTransparency + + + NodeTransparency + + 3 + 0 + + + + + + NodeTransparencyValue + + + NodeTransparencyValue + + 1 + 6.49999976158142090e-01 + + + + + + NodesAvailable + + + NodesAvailable + + 3 + 1 + + + + + + NodesColoring + + + NodesColoring + + 0 + 1 + + + + + + ProgrammableInputPortEnabled + + + ProgrammableInputPortEnabled + + 3 + 0 + + + + + + RenderAsLocation + + + RenderAsLocation + + 3 + 0 + + + + + + ShowCellIndices + + + ShowCellIndices + + 3 + 0 + + + + + + ShowDataValues + + + ShowDataValues + + 3 + 1 + + + + + + ShowEdgeIndices + + + ShowEdgeIndices + + 3 + 0 + + + + + + ShowEdges + + + ShowEdges + + 3 + 1 + + + + + + ShowFaceIndices + + + ShowFaceIndices + + 3 + 0 + + + + + + ShowFaces + + + ShowFaces + + 3 + 1 + + + + + + ShowNodeIndices + + + ShowNodeIndices + + 3 + 0 + + + + + + ShowNodes + + + ShowNodes + + 3 + 0 + + + + + + ShowText + + + ShowText + + 3 + 0 + + + + + + SphereResolution + + + SphereResolution + + 0 + 5 + + + + + + SphereScaleValue + + + SphereScaleValue + + 1 + 2.99999999999999989e-02 + + + + + + TextAlwaysVisible + + + TextAlwaysVisible + + 3 + 0 + + + + + + TextColoring + + + TextColoring + + 0 + 0 + + + + + + TextPrecision + + + TextPrecision + + 0 + 3 + + + + + + TextSize + + + TextSize + + 0 + 8 + + + + + + UseFaceNormals + + + UseFaceNormals + + 3 + 0 + + + + + + + + + ViewScene:0 + + + SCIRun + Render + ViewScene + + + + 61 + 0 + + + Ambient + + + Ambient + + 1 + 2.00000000000000011e-01 + + + + + + AxesSize + + + AxesSize + + 0 + 10 + + + + + + AxesVisible + + + AxesVisible + + 3 + 1 + + + + + + AxesX + + + AxesX + + 0 + 100 + + + + + + AxesY + + + AxesY + + 0 + 100 + + + + + + BackgroundColor + + + BackgroundColor + + 2 + Color(0,0,0) + + + + + + CameraDistance + + + CameraDistance + + 1 + 3.00000000000000000e+00 + + + + + + CameraDistanceMinimum + + + CameraDistanceMinimum + + 1 + 1.00000000000000004e-10 + + + + + + CameraLookAt + + + CameraLookAt + + 5 + + 3 + 0 + + listElement + + 1 + 0.00000000000000000e+00 + + + + listElement + + 1 + 0.00000000000000000e+00 + + + + listElement + + 1 + 0.00000000000000000e+00 + + + + + + + + + CameraRotation + + + CameraRotation + + 5 + + 4 + 0 + + listElement + + 1 + 1.00000000000000000e+00 + + + + listElement + + 1 + 0.00000000000000000e+00 + + + + listElement + + 1 + 0.00000000000000000e+00 + + + + listElement + + 1 + 0.00000000000000000e+00 + + + + + + + + + ClippingPlaneD + + + ClippingPlaneD + + 5 + + 6 + 0 + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + + + + ClippingPlaneEnabled + + + ClippingPlaneEnabled + + 5 + + 6 + 0 + + + + 3 + 0 + + + + + + 3 + 0 + + + + + + 3 + 0 + + + + + + 3 + 0 + + + + + + 3 + 0 + + + + + + 3 + 0 + + + + + + + + + ClippingPlaneNormalReversed + + + ClippingPlaneNormalReversed + + 5 + + 6 + 0 + + + + 3 + 0 + + + + + + 3 + 0 + + + + + + 3 + 0 + + + + + + 3 + 0 + + + + + + 3 + 0 + + + + + + 3 + 0 + + + + + + + + + ClippingPlaneX + + + ClippingPlaneX + + 5 + + 6 + 0 + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + + + + ClippingPlaneY + + + ClippingPlaneY + + 5 + + 6 + 0 + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + + + + ClippingPlaneZ + + + ClippingPlaneZ + + 5 + + 6 + 0 + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + 1 + 0.00000000000000000e+00 + + + + + + + + + Diffuse + + + Diffuse + + 1 + 1.00000000000000000e+00 + + + + + + Emission + + + Emission + + 1 + 0.00000000000000000e+00 + + + + + + FogColor + + + FogColor + + 2 + Color(0,0,255) + + + + + + FogEnd + + + FogEnd + + 1 + 7.09999999999999964e-01 + + + + + + FogOn + + + FogOn + + 3 + 0 + + + + + + FogStart + + + FogStart + + 1 + 0.00000000000000000e+00 + + + + + + HasNewGeometry + + + HasNewGeometry + + 3 + 1 + + + + + + HeadLightAzimuth + + + HeadLightAzimuth + + 0 + 180 + + + + + + HeadLightColor + + + HeadLightColor + + 2 + Color(1,1,1) + + + + + + HeadLightInclination + + + HeadLightInclination + + 0 + 90 + + + + + + HeadLightOn + + + HeadLightOn + + 3 + 1 + + + + + + IsExecuting + + + IsExecuting + + 3 + 0 + + + + + + IsFloating + + + IsFloating + + 3 + 1 + + + + + + Light1Azimuth + + + Light1Azimuth + + 0 + 180 + + + + + + Light1Color + + + Light1Color + + 2 + Color(1,1,1) + + + + + + Light1Inclination + + + Light1Inclination + + 0 + 90 + + + + + + Light1On + + + Light1On + + 3 + 0 + + + + + + Light2Azimuth + + + Light2Azimuth + + 0 + 180 + + + + + + Light2Color + + + Light2Color + + 2 + Color(1,1,1) + + + + + + Light2Inclination + + + Light2Inclination + + 0 + 90 + + + + + + Light2On + + + Light2On + + 3 + 0 + + + + + + Light3Azimuth + + + Light3Azimuth + + 0 + 180 + + + + + + Light3Color + + + Light3Color + + 2 + Color(1,1,1) + + + + + + Light3Inclination + + + Light3Inclination + + 0 + 90 + + + + + + Light3On + + + Light3On + + 3 + 0 + + + + + + ObjectsOnly + + + ObjectsOnly + + 3 + 1 + + + + + + ProgrammableInputPortEnabled + + + ProgrammableInputPortEnabled + + 3 + 0 + + + + + + ScaleBarFontSize + + + ScaleBarFontSize + + 0 + 8 + + + + + + ScaleBarHeight + + + ScaleBarHeight + + 1 + 1.00000000000000000e+00 + + + + + + ScaleBarLength + + + ScaleBarLength + + 1 + 1.00000000000000000e+00 + + + + + + ScaleBarLineWidth + + + ScaleBarLineWidth + + 1 + 1.00000000000000000e+00 + + + + + + ScaleBarMultiplier + + + ScaleBarMultiplier + + 1 + 1.00000000000000000e+00 + + + + + + ScaleBarNumTicks + + + ScaleBarNumTicks + + 0 + 11 + + + + + + ScaleBarUnitValue + + + ScaleBarUnitValue + + 2 + mm + + + + + + ScreenshotDirectory + + + ScreenshotDirectory + + 2 + /Users/dan/Desktop + + + + + + Shine + + + Shine + + 1 + 5.00000000000000000e-01 + + + + + + ShowScaleBar + + + ShowScaleBar + + 3 + 0 + + + + + + ShowViewer + + + ShowViewer + + 3 + 0 + + + + + + Specular + + + Specular + + 1 + 2.99999999999999989e-01 + + + + + + UseBGColor + + + UseBGColor + + 3 + 1 + + + + + + VisibleItemListState + + + VisibleItemListState + + 5 + + 0 + 0 + + + + + + + WindowPositionX + + + WindowPositionX + + 0 + 200 + + + + + + WindowPositionY + + + WindowPositionY + + 0 + 200 + + + + + + WindowSizeX + + + WindowSizeX + + 0 + 450 + + + + + + WindowSizeY + + + WindowSizeY + + 0 + 450 + + + + + + + + + + 9 + 0 + + CreateFieldData:0 + + OutputField + 0 + + GetFieldData:0 + + InputField + 0 + + + + CreateFieldData:0 + + OutputField + 0 + + ReportScalarFieldStats:0 + + InputField + 0 + + + + CreateFieldData:0 + + OutputField + 0 + + RescaleColorMap:0 + + Field + 0 + + + + CreateFieldData:0 + + OutputField + 0 + + ShowField:0 + + Field + 0 + + + + CreateLatVol:0 + + OutputField + 0 + + CreateFieldData:0 + + InputField + 0 + + + + CreateStandardColorMap:0 + + ColorMapObject + 0 + + RescaleColorMap:0 + + ColorMapObject + 0 + + + + GetFieldData:0 + + OutputMatrix + 0 + + DisplayHistogram:0 + + InputMatrix + 0 + + + + RescaleColorMap:0 + + ColorMapOutput + 0 + + ShowField:0 + + ColorMapObject + 0 + + + + ShowField:0 + + SceneGraph + 0 + + ViewScene:0 + + GeneralGeom + 0 + + + + + + 9 + 0 + + CreateFieldData:0 + + -5.32000000000000000e+02 + -5.32000000000000000e+02 + + + + CreateLatVol:0 + + -5.32000000000000000e+02 + -6.08000000000000000e+02 + + + + CreateStandardColorMap:0 + + -3.04000000000000000e+02 + -5.32000000000000000e+02 + + + + DisplayHistogram:0 + + -7.01000000000000000e+02 + -2.60000000000000000e+02 + + + + GetFieldData:0 + + -7.95000000000000000e+02 + -4.50000000000000000e+02 + + + + ReportScalarFieldStats:0 + + -6.84000000000000000e+02 + -3.80000000000000000e+02 + + + + RescaleColorMap:0 + + -3.04000000000000000e+02 + -3.80000000000000000e+02 + + + + ShowField:0 + + -3.04000000000000000e+02 + -3.04000000000000000e+02 + + + + ViewScene:0 + + -4.56000000000000000e+02 + -1.52000000000000000e+02 + + + + + 0 + 0 + + + 0 + 0 + + + 9 + 0 + + CreateFieldData:0 + -1 + + + CreateLatVol:0 + -1 + + + CreateStandardColorMap:0 + -1 + + + DisplayHistogram:0 + -1 + + + GetFieldData:0 + -1 + + + ReportScalarFieldStats:0 + -1 + + + RescaleColorMap:0 + -1 + + + ShowField:0 + -1 + + + ViewScene:0 + -1 + + + + 0 + 0 + + + 0 + 0 + + + 0 + 0 + + 0 + + 0 + 0 + + + + diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStats.ui b/src/Interface/Modules/Fields/ReportScalarFieldStats.ui index 192775f2d3..6e2dd32f37 100644 --- a/src/Interface/Modules/Fields/ReportScalarFieldStats.ui +++ b/src/Interface/Modules/Fields/ReportScalarFieldStats.ui @@ -7,13 +7,13 @@ 0 0 330 - 220 + 245 330 - 220 + 245 @@ -23,20 +23,30 @@ - Auto Range + Range - true + false - + + + + + + + Max + + + + Min - + 9 @@ -49,15 +59,19 @@ - - + + - Max + Auto Scale - - + + + + Fixed Scale + + diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc index b01e1129a8..35f2a9e422 100644 --- a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc +++ b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc @@ -43,4 +43,9 @@ ReportScalarFieldStatsDialog::ReportScalarFieldStatsDialog(const std::string& na setWindowTitle(QString::fromStdString(name)); fixSize(); + addDynamicLabelManager(meanLabel_, Parameters::Mean); + addDynamicLabelManager(medianLabel_, Parameters::Median); + addDynamicLabelManager(sigmaLabel_, Parameters::StandardDeviation); + addDoubleSpinBoxManager(minDoubleSpinBox_, Parameters::MinRange); + addDoubleSpinBoxManager(maxDoubleSpinBox_, Parameters::MaxRange); } diff --git a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc index 09eb577b4f..4b7158456b 100644 --- a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc +++ b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc @@ -75,7 +75,7 @@ class ReportScalarFieldStatsImpl double mean_; double median_; double sigma_; //standard deviation - int is_fixed_; + int is_fixed_ {0}; int nbuckets_ {256}; }; } @@ -84,7 +84,7 @@ class ReportScalarFieldStatsImpl MODULE_INFO_DEF(ReportScalarFieldStats, MiscField, SCIRun) ReportScalarFieldStats::ReportScalarFieldStats() - : Module(staticInfo_) + : Module(staticInfo_), impl_(new ReportScalarFieldStatsImpl(this)) // min_(get_ctx()->subVar("min"), 0.0), // max_(get_ctx()->subVar("max"), 0.0), // mean_(get_ctx()->subVar("mean"), 0.0), @@ -124,7 +124,13 @@ ReportScalarFieldStats::~ReportScalarFieldStats() = default; void ReportScalarFieldStats::setStateDefaults() { - + auto state = get_state(); + state->setValue(Parameters::Mean, 0.0); + state->setValue(Parameters::Median, 0.0); + state->setValue(Parameters::StandardDeviation, 0.0); + state->setValue(Parameters::AutoRangeEnabled, true); + state->setValue(Parameters::MinRange, 0.0); + state->setValue(Parameters::MaxRange, 0.0); } void ReportScalarFieldStats::execute() @@ -140,6 +146,7 @@ void ReportScalarFieldStats::execute() //update_state(Executing); VField* ifield = inputField->vfield(); + auto state = get_state(); bool init = false; double value = 0; @@ -150,11 +157,11 @@ void ReportScalarFieldStats::execute() //update_progress(0.3); double mean = 0; - double mmin = 0; - double mmax = 0; - if ( impl_->is_fixed_ == 1 ) + if (!state->getValue(Parameters::AutoRangeEnabled).toBool()) { + double mmin = 0; + double mmax = 0; VField::size_type num_values = ifield->num_values(); for (VField::index_type idx=0; idx < num_values ;idx++) { @@ -200,6 +207,7 @@ void ReportScalarFieldStats::execute() } //update_progress(0.6); + //std::cout << "max " << impl_->max_ << " min " << impl_->min_ << " values size " << values.size() << std::endl; if ((impl_->max_ - impl_->min_) > 1e-16 && values.size() > 0) { @@ -230,10 +238,10 @@ void ReportScalarFieldStats::execute() } else { - warning("min - max < precision or no values in range; clearing histogram"); + warning("min - max less than precision or no values in range; clearing histogram"); impl_->clear_histogram(); } - auto state = get_state(); + state->setValue(Parameters::Mean, impl_->mean_); state->setValue(Parameters::Median, impl_->median_); state->setValue(Parameters::StandardDeviation, impl_->sigma_); diff --git a/src/Modules/Legacy/Fields/ReportScalarFieldStats.h b/src/Modules/Legacy/Fields/ReportScalarFieldStats.h index 918cc3355f..fb5ab1be0e 100644 --- a/src/Modules/Legacy/Fields/ReportScalarFieldStats.h +++ b/src/Modules/Legacy/Fields/ReportScalarFieldStats.h @@ -43,8 +43,8 @@ namespace SCIRun { ALGORITHM_PARAMETER_DECL(Mean); ALGORITHM_PARAMETER_DECL(Median); ALGORITHM_PARAMETER_DECL(StandardDeviation); - // ALGORITHM_PARAMETER_DECL(IndexFlag); - // ALGORITHM_PARAMETER_DECL(SizeFlag); + ALGORITHM_PARAMETER_DECL(MinRange); + ALGORITHM_PARAMETER_DECL(MaxRange); // ALGORITHM_PARAMETER_DECL(NormalsFlag); } } From c42763061e8cb438e1d910d4f526d02cc703297f Mon Sep 17 00:00:00 2001 From: Dan White Date: Tue, 17 May 2022 10:54:01 -0600 Subject: [PATCH 07/36] Histogram works nicely. Closes #2367 --- .../Modules/reportScalarFieldStats.srn5 | 421 ++++++++++-------- .../Base/CustomWidgets/QtHistogramWidget.cc | 4 +- .../Modules/Fields/ReportScalarFieldStats.ui | 63 ++- .../Fields/ReportScalarFieldStatsDialog.cc | 2 + .../Legacy/Fields/ReportScalarFieldStats.cc | 134 ++---- .../Legacy/Fields/ReportScalarFieldStats.h | 5 +- 6 files changed, 330 insertions(+), 299 deletions(-) diff --git a/src/ExampleNets/regression/Modules/reportScalarFieldStats.srn5 b/src/ExampleNets/regression/Modules/reportScalarFieldStats.srn5 index 7a438f0e89..923500adae 100644 --- a/src/ExampleNets/regression/Modules/reportScalarFieldStats.srn5 +++ b/src/ExampleNets/regression/Modules/reportScalarFieldStats.srn5 @@ -4,7 +4,7 @@ - 9 + 10 0 CreateFieldData:0 @@ -50,7 +50,7 @@ FunctionString 2 - RESULT = X^2 - Y^2; + RESULT = X+Y+Z+7.1; @@ -138,7 +138,7 @@ XSize 0 - 16 + 40 @@ -150,7 +150,7 @@ YSize 0 - 16 + 40 @@ -162,7 +162,7 @@ ZSize 0 - 16 + 40 @@ -337,6 +337,34 @@ + + DisplayHistogram:1 + + + SCIRun + Math + DisplayHistogram + + + + 1 + 0 + + + ProgrammableInputPortEnabled + + + ProgrammableInputPortEnabled + + 3 + 0 + + + + + + + GetFieldData:0 @@ -355,7 +383,7 @@ ProgrammableInputPortEnabled - + 3 0 @@ -375,7 +403,7 @@ - 7 + 8 0 @@ -383,9 +411,21 @@ AutoRangeEnabled - - 3 - 1 + + 0 + 0 + + + + + + HistogramBinCount + + + HistogramBinCount + + 0 + 34 @@ -395,9 +435,9 @@ MaxRange - + 1 - 0.00000000000000000e+00 + 8.00000000000000000e+00 @@ -407,9 +447,9 @@ Mean - - 1 - 8.32938319011988781e-17 + + 2 + 7.100000 @@ -419,9 +459,9 @@ Median - - 1 - 0.00000000000000000e+00 + + 2 + 7.125641 @@ -431,9 +471,9 @@ MinRange - + 1 - 0.00000000000000000e+00 + 5.00000000000000000e+00 @@ -443,7 +483,7 @@ ProgrammableInputPortEnabled - + 3 0 @@ -455,9 +495,9 @@ StandardDeviation - - 1 - 4.75036061009327715e-01 + + 2 + 1.025320 @@ -483,7 +523,7 @@ AutoScale - + 0 0 @@ -495,9 +535,9 @@ FixedMax - + 1 - 9.95555555555555527e-01 + 1.00999999999999996e+01 @@ -507,9 +547,9 @@ FixedMin - + 1 - -9.95555555555555527e-01 + 4.09999999999999964e+00 @@ -519,7 +559,7 @@ ProgrammableInputPortEnabled - + 3 0 @@ -531,7 +571,7 @@ Symmetric - + 3 0 @@ -559,7 +599,7 @@ CullBackfacingText - + 3 0 @@ -571,7 +611,7 @@ CylinderRadius - + 1 1.00000000000000006e-01 @@ -583,7 +623,7 @@ CylinderResolution - + 0 5 @@ -595,7 +635,7 @@ DefaultMeshColor - + 2 Color(0.5,0.5,0.5) @@ -607,7 +647,7 @@ DefaultTextColor - + 2 Color(1,1,1) @@ -619,7 +659,7 @@ EdgeTransparency - + 3 0 @@ -631,7 +671,7 @@ EdgeTransparencyValue - + 1 6.49999976158142090e-01 @@ -643,7 +683,7 @@ EdgesAsCylinders - + 0 0 @@ -655,7 +695,7 @@ EdgesAvailable - + 3 1 @@ -667,7 +707,7 @@ EdgesColoring - + 0 1 @@ -679,7 +719,7 @@ FaceInvertNormals - + 3 0 @@ -691,7 +731,7 @@ FaceTransparency - + 3 0 @@ -703,7 +743,7 @@ FaceTransparencyValue - + 1 6.49999976158142090e-01 @@ -715,7 +755,7 @@ FacesAvailable - + 3 1 @@ -727,7 +767,7 @@ FacesColoring - + 0 1 @@ -739,7 +779,7 @@ FieldName - + 2 @@ -751,7 +791,7 @@ NodeAsSpheres - + 0 0 @@ -763,7 +803,7 @@ NodeTransparency - + 3 0 @@ -775,7 +815,7 @@ NodeTransparencyValue - + 1 6.49999976158142090e-01 @@ -787,7 +827,7 @@ NodesAvailable - + 3 1 @@ -799,7 +839,7 @@ NodesColoring - + 0 1 @@ -811,7 +851,7 @@ ProgrammableInputPortEnabled - + 3 0 @@ -823,7 +863,7 @@ RenderAsLocation - + 3 0 @@ -835,7 +875,7 @@ ShowCellIndices - + 3 0 @@ -847,7 +887,7 @@ ShowDataValues - + 3 1 @@ -859,7 +899,7 @@ ShowEdgeIndices - + 3 0 @@ -871,7 +911,7 @@ ShowEdges - + 3 1 @@ -883,7 +923,7 @@ ShowFaceIndices - + 3 0 @@ -895,7 +935,7 @@ ShowFaces - + 3 1 @@ -907,7 +947,7 @@ ShowNodeIndices - + 3 0 @@ -919,7 +959,7 @@ ShowNodes - + 3 0 @@ -931,7 +971,7 @@ ShowText - + 3 0 @@ -943,7 +983,7 @@ SphereResolution - + 0 5 @@ -955,7 +995,7 @@ SphereScaleValue - + 1 2.99999999999999989e-02 @@ -967,7 +1007,7 @@ TextAlwaysVisible - + 3 0 @@ -979,7 +1019,7 @@ TextColoring - + 0 0 @@ -991,7 +1031,7 @@ TextPrecision - + 0 3 @@ -1003,7 +1043,7 @@ TextSize - + 0 8 @@ -1015,7 +1055,7 @@ UseFaceNormals - + 3 0 @@ -1043,7 +1083,7 @@ Ambient - + 1 2.00000000000000011e-01 @@ -1055,7 +1095,7 @@ AxesSize - + 0 10 @@ -1067,7 +1107,7 @@ AxesVisible - + 3 1 @@ -1079,7 +1119,7 @@ AxesX - + 0 100 @@ -1091,7 +1131,7 @@ AxesY - + 0 100 @@ -1103,7 +1143,7 @@ BackgroundColor - + 2 Color(0,0,0) @@ -1115,7 +1155,7 @@ CameraDistance - + 1 3.00000000000000000e+00 @@ -1127,7 +1167,7 @@ CameraDistanceMinimum - + 1 1.00000000000000004e-10 @@ -1139,28 +1179,28 @@ CameraLookAt - + 5 3 0 listElement - + 1 0.00000000000000000e+00 listElement - + 1 0.00000000000000000e+00 listElement - + 1 0.00000000000000000e+00 @@ -1175,35 +1215,35 @@ CameraRotation - + 5 4 0 listElement - + 1 1.00000000000000000e+00 listElement - + 1 0.00000000000000000e+00 listElement - + 1 0.00000000000000000e+00 listElement - + 1 0.00000000000000000e+00 @@ -1218,49 +1258,49 @@ ClippingPlaneD - + 5 6 0 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 @@ -1275,49 +1315,49 @@ ClippingPlaneEnabled - + 5 6 0 - + 3 0 - + 3 0 - + 3 0 - + 3 0 - + 3 0 - + 3 0 @@ -1332,49 +1372,49 @@ ClippingPlaneNormalReversed - + 5 6 0 - + 3 0 - + 3 0 - + 3 0 - + 3 0 - + 3 0 - + 3 0 @@ -1389,49 +1429,49 @@ ClippingPlaneX - + 5 6 0 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 @@ -1446,49 +1486,49 @@ ClippingPlaneY - + 5 6 0 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 @@ -1503,49 +1543,49 @@ ClippingPlaneZ - + 5 6 0 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 - + 1 0.00000000000000000e+00 @@ -1560,7 +1600,7 @@ Diffuse - + 1 1.00000000000000000e+00 @@ -1572,7 +1612,7 @@ Emission - + 1 0.00000000000000000e+00 @@ -1584,7 +1624,7 @@ FogColor - + 2 Color(0,0,255) @@ -1596,7 +1636,7 @@ FogEnd - + 1 7.09999999999999964e-01 @@ -1608,7 +1648,7 @@ FogOn - + 3 0 @@ -1620,7 +1660,7 @@ FogStart - + 1 0.00000000000000000e+00 @@ -1632,7 +1672,7 @@ HasNewGeometry - + 3 1 @@ -1644,7 +1684,7 @@ HeadLightAzimuth - + 0 180 @@ -1656,7 +1696,7 @@ HeadLightColor - + 2 Color(1,1,1) @@ -1668,7 +1708,7 @@ HeadLightInclination - + 0 90 @@ -1680,7 +1720,7 @@ HeadLightOn - + 3 1 @@ -1692,7 +1732,7 @@ IsExecuting - + 3 0 @@ -1704,7 +1744,7 @@ IsFloating - + 3 1 @@ -1716,7 +1756,7 @@ Light1Azimuth - + 0 180 @@ -1728,7 +1768,7 @@ Light1Color - + 2 Color(1,1,1) @@ -1740,7 +1780,7 @@ Light1Inclination - + 0 90 @@ -1752,7 +1792,7 @@ Light1On - + 3 0 @@ -1764,7 +1804,7 @@ Light2Azimuth - + 0 180 @@ -1776,7 +1816,7 @@ Light2Color - + 2 Color(1,1,1) @@ -1788,7 +1828,7 @@ Light2Inclination - + 0 90 @@ -1800,7 +1840,7 @@ Light2On - + 3 0 @@ -1812,7 +1852,7 @@ Light3Azimuth - + 0 180 @@ -1824,7 +1864,7 @@ Light3Color - + 2 Color(1,1,1) @@ -1836,7 +1876,7 @@ Light3Inclination - + 0 90 @@ -1848,7 +1888,7 @@ Light3On - + 3 0 @@ -1860,7 +1900,7 @@ ObjectsOnly - + 3 1 @@ -1872,7 +1912,7 @@ ProgrammableInputPortEnabled - + 3 0 @@ -1884,7 +1924,7 @@ ScaleBarFontSize - + 0 8 @@ -1896,7 +1936,7 @@ ScaleBarHeight - + 1 1.00000000000000000e+00 @@ -1908,7 +1948,7 @@ ScaleBarLength - + 1 1.00000000000000000e+00 @@ -1920,7 +1960,7 @@ ScaleBarLineWidth - + 1 1.00000000000000000e+00 @@ -1932,7 +1972,7 @@ ScaleBarMultiplier - + 1 1.00000000000000000e+00 @@ -1944,7 +1984,7 @@ ScaleBarNumTicks - + 0 11 @@ -1956,7 +1996,7 @@ ScaleBarUnitValue - + 2 mm @@ -1968,7 +2008,7 @@ ScreenshotDirectory - + 2 /Users/dan/Desktop @@ -1980,7 +2020,7 @@ Shine - + 1 5.00000000000000000e-01 @@ -1992,7 +2032,7 @@ ShowScaleBar - + 3 0 @@ -2004,7 +2044,7 @@ ShowViewer - + 3 0 @@ -2016,7 +2056,7 @@ Specular - + 1 2.99999999999999989e-01 @@ -2028,7 +2068,7 @@ UseBGColor - + 3 1 @@ -2040,7 +2080,7 @@ VisibleItemListState - + 5 0 @@ -2055,7 +2095,7 @@ WindowPositionX - + 0 200 @@ -2067,7 +2107,7 @@ WindowPositionY - + 0 200 @@ -2079,7 +2119,7 @@ WindowSizeX - + 0 450 @@ -2091,7 +2131,7 @@ WindowSizeY - + 0 450 @@ -2103,7 +2143,7 @@ - 9 + 10 0 CreateFieldData:0 @@ -2189,6 +2229,18 @@ 0 + + ReportScalarFieldStats:0 + + HistogramData + 0 + + DisplayHistogram:1 + + InputMatrix + 0 + + RescaleColorMap:0 @@ -2216,7 +2268,7 @@ - 9 + 10 0 CreateFieldData:0 @@ -2242,8 +2294,15 @@ DisplayHistogram:0 - -7.01000000000000000e+02 - -2.60000000000000000e+02 + -8.36000000000000000e+02 + -2.28000000000000000e+02 + + + + DisplayHistogram:1 + + -6.08000000000000000e+02 + -1.52000000000000000e+02 @@ -2291,7 +2350,7 @@ 0 - 9 + 10 0 CreateFieldData:0 @@ -2309,6 +2368,10 @@ DisplayHistogram:0 -1 + + DisplayHistogram:1 + -1 + GetFieldData:0 -1 diff --git a/src/Interface/Modules/Base/CustomWidgets/QtHistogramWidget.cc b/src/Interface/Modules/Base/CustomWidgets/QtHistogramWidget.cc index bcfdd4b1fe..6b0f09d07d 100644 --- a/src/Interface/Modules/Base/CustomWidgets/QtHistogramWidget.cc +++ b/src/Interface/Modules/Base/CustomWidgets/QtHistogramWidget.cc @@ -110,8 +110,8 @@ QtHistogramWidget::QtHistogramWidget( QWidget *parent, this->private_->ui_.label_3->setAlignment( Qt::AlignHCenter | Qt::AlignVCenter ); - // We will set the histogram to be logarithmic by default - this->private_->ui_.log_histogram_combo_->setCurrentIndex( 1 ); + // We will set the histogram to be linear by default + this->private_->ui_.log_histogram_combo_->setCurrentIndex( 0 ); } QtHistogramWidget::~QtHistogramWidget() diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStats.ui b/src/Interface/Modules/Fields/ReportScalarFieldStats.ui index 6e2dd32f37..6a0f4b7441 100644 --- a/src/Interface/Modules/Fields/ReportScalarFieldStats.ui +++ b/src/Interface/Modules/Fields/ReportScalarFieldStats.ui @@ -7,13 +7,13 @@ 0 0 330 - 245 + 310 330 - 245 + 310 @@ -30,7 +30,17 @@ - + + + 9 + + + -99999999999999.000000000000000 + + + 99999999999999.000000000000000 + + @@ -60,14 +70,14 @@ - + Auto Scale - + Fixed Scale @@ -89,6 +99,27 @@ + + + + M + + + + + + + s + + + + + + + Standard Deviation + + + @@ -103,24 +134,20 @@ - - + + - M + Histogram Bins - - - - Standard Deviation + + + + 1 - - - - - - s + + 9999999 diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc index 35f2a9e422..f856b61b54 100644 --- a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc +++ b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc @@ -48,4 +48,6 @@ ReportScalarFieldStatsDialog::ReportScalarFieldStatsDialog(const std::string& na addDynamicLabelManager(sigmaLabel_, Parameters::StandardDeviation); addDoubleSpinBoxManager(minDoubleSpinBox_, Parameters::MinRange); addDoubleSpinBoxManager(maxDoubleSpinBox_, Parameters::MaxRange); + addSpinBoxManager(binsSpinBox_, Parameters::HistogramBinCount); + addRadioButtonGroupManager({ autoScaleRadioButton_, fixedScaleRadioButton_ }, Parameters::AutoRangeEnabled); } diff --git a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc index 4b7158456b..bb7f159cf1 100644 --- a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc +++ b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc @@ -43,7 +43,6 @@ #include #include - using namespace SCIRun; using namespace SCIRun::Core::Algorithms; using namespace SCIRun::Core::Geometry; @@ -56,81 +55,34 @@ ALGORITHM_PARAMETER_DEF(Fields, AutoRangeEnabled); ALGORITHM_PARAMETER_DEF(Fields, Mean); ALGORITHM_PARAMETER_DEF(Fields, Median); ALGORITHM_PARAMETER_DEF(Fields, StandardDeviation); +ALGORITHM_PARAMETER_DEF(Fields, MinRange); +ALGORITHM_PARAMETER_DEF(Fields, MaxRange); +ALGORITHM_PARAMETER_DEF(Fields, HistogramBinCount); /// @class ReportScalarFieldStats /// @brief Analyze data from a scalarfield. -namespace SCIRun::Modules::Fields { -class ReportScalarFieldStatsImpl -{ - public: - explicit ReportScalarFieldStatsImpl(ReportScalarFieldStats* module) : module_(module) {} - - void fill_histogram(const std::vector& hits); - void clear_histogram() {} - - ReportScalarFieldStats* module_; - double min_; - double max_; - double mean_; - double median_; - double sigma_; //standard deviation - int is_fixed_ {0}; - int nbuckets_ {256}; -}; -} - - MODULE_INFO_DEF(ReportScalarFieldStats, MiscField, SCIRun) ReportScalarFieldStats::ReportScalarFieldStats() - : Module(staticInfo_), impl_(new ReportScalarFieldStatsImpl(this)) - // min_(get_ctx()->subVar("min"), 0.0), - // max_(get_ctx()->subVar("max"), 0.0), - // mean_(get_ctx()->subVar("mean"), 0.0), - // median_(get_ctx()->subVar("median"), 0.0), - // sigma_(get_ctx()->subVar("sigma"),0.0), - // is_fixed_(get_ctx()->subVar("is_fixed"), 0), - // nbuckets_(get_ctx()->subVar("nbuckets"), 256) + : Module(staticInfo_) { INITIALIZE_PORT(InputField); INITIALIZE_PORT(HistogramData); } - - -void ReportScalarFieldStatsImpl::fill_histogram(const std::vector& hits) -{ - std::ostringstream ostr; - int nmin, nmax; - auto it = hits.begin(); - nmin = 0; nmax = *it; - ostr << *it; ++it; - - for(; it != hits.end(); ++it) - { - ostr <<" "<<*it; - nmin = ((nmin < *it) ? nmin : *it ); - nmax = ((nmax > *it) ? nmax : *it ); - } - ostr << std::ends; - std::string data = ostr.str(); - - // TCLInterface::execute(); - module_->remark(" graph_data " + std::to_string(nmin) + " " + std::to_string(nmax) + " " + data ); -} - ReportScalarFieldStats::~ReportScalarFieldStats() = default; void ReportScalarFieldStats::setStateDefaults() { auto state = get_state(); - state->setValue(Parameters::Mean, 0.0); - state->setValue(Parameters::Median, 0.0); - state->setValue(Parameters::StandardDeviation, 0.0); - state->setValue(Parameters::AutoRangeEnabled, true); + state->setValue(Parameters::Mean, std::string("")); + state->setValue(Parameters::Median, std::string("")); + state->setValue(Parameters::StandardDeviation, std::string("")); + state->setValue(Parameters::AutoRangeEnabled, 0); state->setValue(Parameters::MinRange, 0.0); state->setValue(Parameters::MaxRange, 0.0); + state->setValue(Parameters::HistogramBinCount, 256); } void ReportScalarFieldStats::execute() @@ -143,8 +95,6 @@ void ReportScalarFieldStats::execute() return; } - //update_state(Executing); - VField* ifield = inputField->vfield(); auto state = get_state(); @@ -154,14 +104,14 @@ void ReportScalarFieldStats::execute() double max = 0; int counter = 0; std::vector values; - - //update_progress(0.3); double mean = 0; + double median = 0; + double sigma = 0; //standard deviation - if (!state->getValue(Parameters::AutoRangeEnabled).toBool()) + if (state->getValue(Parameters::AutoRangeEnabled).toInt() == 1) { - double mmin = 0; - double mmax = 0; + const double mmin = state->getValue(Parameters::MinRange).toDouble(); + const double mmax = state->getValue(Parameters::MaxRange).toDouble(); VField::size_type num_values = ifield->num_values(); for (VField::index_type idx=0; idx < num_values ;idx++) { @@ -175,8 +125,9 @@ void ReportScalarFieldStats::execute() } } + min = mmin; + max = mmax; mean = value/double(counter); - impl_->mean_ = mean; } else { @@ -194,55 +145,46 @@ void ReportScalarFieldStats::execute() } else { - min = (val < min) ? val:min; - max = (val > max) ? val:max; + min = std::min(val, min); + max = std::max(val, max); } ++counter; } mean = value/double(counter); - impl_->mean_ = mean; - - impl_->min_ = min; - impl_->max_ = max; } - //update_progress(0.6); - //std::cout << "max " << impl_->max_ << " min " << impl_->min_ << " values size " << values.size() << std::endl; - - if ((impl_->max_ - impl_->min_) > 1e-16 && values.size() > 0) + if ((max - min) > 1e-16 && values.size() > 0) { - int nbuckets = impl_->nbuckets_; - std::vector hits(nbuckets, 0); + const int nbuckets = state->getValue(Parameters::HistogramBinCount).toInt(); + std::vector hits; - double frac = 1.0; - frac = (nbuckets-1)/(impl_->max_ - impl_->min_); + const double frac = nbuckets/(max - min); - double sigma = 0.0; - auto vit = values.begin(); - auto vit_end = values.end(); - for(; vit != vit_end; ++vit) + for (const auto v : values) { - if( *vit >= impl_->min_ && *vit <= impl_->max_) + if( v >= min && v <= max) { - double value = (*vit - impl_->min_)*frac; - hits[int(value)]++; + const auto bin = std::floor((v - min)*frac); + const auto histoVal = bin / frac + min; + hits.push_back(histoVal); } - sigma += (*vit - mean)*(*vit - mean); + sigma += (v - mean)*(v - mean); } - impl_->sigma_ = sqrt( sigma / double(values.size()) ); + sigma = sqrt( sigma / double(values.size()) ); - vit = values.begin(); - nth_element(vit, vit+values.size()/2, vit_end); - impl_->median_ = values[values.size()/2]; - impl_->fill_histogram(hits); + std::nth_element(values.begin(), values.begin() + values.size()/2, values.end()); + median = values[values.size()/2]; + auto hitsM = makeShared(hits.size(), 1, 0); + std::copy(hits.begin(), hits.end(), &(*hitsM)(0,0)); + sendOutput(HistogramData, hitsM); } else { warning("min - max less than precision or no values in range; clearing histogram"); - impl_->clear_histogram(); + sendOutput(HistogramData, makeShared(0,0,0)); } - state->setValue(Parameters::Mean, impl_->mean_); - state->setValue(Parameters::Median, impl_->median_); - state->setValue(Parameters::StandardDeviation, impl_->sigma_); + state->setValue(Parameters::Mean, std::to_string(mean)); + state->setValue(Parameters::Median, std::to_string(median)); + state->setValue(Parameters::StandardDeviation, std::to_string(sigma)); } diff --git a/src/Modules/Legacy/Fields/ReportScalarFieldStats.h b/src/Modules/Legacy/Fields/ReportScalarFieldStats.h index fb5ab1be0e..f756a76952 100644 --- a/src/Modules/Legacy/Fields/ReportScalarFieldStats.h +++ b/src/Modules/Legacy/Fields/ReportScalarFieldStats.h @@ -45,7 +45,7 @@ namespace SCIRun { ALGORITHM_PARAMETER_DECL(StandardDeviation); ALGORITHM_PARAMETER_DECL(MinRange); ALGORITHM_PARAMETER_DECL(MaxRange); - // ALGORITHM_PARAMETER_DECL(NormalsFlag); + ALGORITHM_PARAMETER_DECL(HistogramBinCount); } } } @@ -58,7 +58,6 @@ namespace SCIRun { { public: ReportScalarFieldStats(); - ~ReportScalarFieldStats() override; void execute() override; void setStateDefaults() override; @@ -67,8 +66,6 @@ namespace SCIRun { OUTPUT_PORT(0, HistogramData, Matrix); MODULE_TRAITS_AND_INFO(ModuleFlags::ModuleHasUI) - private: - std::unique_ptr impl_; }; } } From 4eb1d89e53cf5564fc4f75ca62a328c4370885c4 Mon Sep 17 00:00:00 2001 From: Dan White Date: Tue, 17 May 2022 16:28:35 -0600 Subject: [PATCH 08/36] Update ReportScalarFieldStats.cc --- src/Modules/Legacy/Fields/ReportScalarFieldStats.cc | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc index bb7f159cf1..ce06772a8b 100644 --- a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc +++ b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc @@ -71,8 +71,6 @@ ReportScalarFieldStats::ReportScalarFieldStats() INITIALIZE_PORT(HistogramData); } -ReportScalarFieldStats::~ReportScalarFieldStats() = default; - void ReportScalarFieldStats::setStateDefaults() { auto state = get_state(); From e07009a2595c0160010909063b888aa27f07efc3 Mon Sep 17 00:00:00 2001 From: Dan White Date: Tue, 17 May 2022 20:49:56 -0600 Subject: [PATCH 09/36] Add enable/disable functions. UI needs updating --- src/Dataflow/Engine/Controller/PythonImpl.cc | 5 +++++ .../Engine/Python/NetworkEditorPythonAPI.cc | 20 +++++++++++++++++++ .../Engine/Python/NetworkEditorPythonAPI.h | 3 +++ .../Python/NetworkEditorPythonInterface.h | 1 + .../Engine/Python/SCIRunPythonModule.h | 3 +++ 5 files changed, 32 insertions(+) diff --git a/src/Dataflow/Engine/Controller/PythonImpl.cc b/src/Dataflow/Engine/Controller/PythonImpl.cc index e14bf2d976..09bbca441d 100644 --- a/src/Dataflow/Engine/Controller/PythonImpl.cc +++ b/src/Dataflow/Engine/Controller/PythonImpl.cc @@ -479,6 +479,11 @@ namespace return creationTime_; } + void setEnabled(bool enable) override + { + module_->setExecutionDisabled(!enable); + } + private: ModuleHandle module_; NetworkEditorController& nec_; diff --git a/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.cc b/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.cc index 7e5f629de8..16b928a2c3 100644 --- a/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.cc +++ b/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.cc @@ -483,6 +483,26 @@ boost::python::object NetworkEditorPythonAPI::scirun_get_module_input_value(cons return {}; } +std::string NetworkEditorPythonAPI::scirun_enable_module(const std::string& moduleId) +{ + auto module = impl_->findModule(moduleId); + if (module) + { + module->setEnabled(true); + } + return "TODO: " + moduleId + " enabled."; +} + +std::string NetworkEditorPythonAPI::scirun_disable_module(const std::string& moduleId) +{ + auto module = impl_->findModule(moduleId); + if (module) + { + module->setEnabled(false); + } + return "TODO: " + moduleId + " disabled."; +} + boost::python::object SimplePythonAPI::scirun_module_ids() { auto mods = NetworkEditorPythonAPI::modules(); diff --git a/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.h b/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.h index 847442c046..1f871cefd0 100644 --- a/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.h +++ b/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.h @@ -72,6 +72,9 @@ namespace SCIRun { static boost::python::dict get_output_data(const std::string& moduleId); static std::string set_output_data(const std::string& moduleId, const boost::python::dict& outputMap); + static std::string scirun_enable_module(const std::string& moduleId); + static std::string scirun_disable_module(const std::string& moduleId); + static std::string executeAll(); static std::string saveNetwork(const std::string& filename); static std::string loadNetwork(const std::string& filename); diff --git a/src/Dataflow/Engine/Python/NetworkEditorPythonInterface.h b/src/Dataflow/Engine/Python/NetworkEditorPythonInterface.h index e6b42393b7..a04cd3a9b8 100644 --- a/src/Dataflow/Engine/Python/NetworkEditorPythonInterface.h +++ b/src/Dataflow/Engine/Python/NetworkEditorPythonInterface.h @@ -65,6 +65,7 @@ namespace SCIRun //ports virtual SharedPointer output() = 0; virtual SharedPointer input() = 0; + virtual void setEnabled(bool enable) = 0; //time added to network, for id sorting virtual boost::posix_time::ptime creationTime() const = 0; diff --git a/src/Dataflow/Engine/Python/SCIRunPythonModule.h b/src/Dataflow/Engine/Python/SCIRunPythonModule.h index 07b258c859..886a9574b2 100644 --- a/src/Dataflow/Engine/Python/SCIRunPythonModule.h +++ b/src/Dataflow/Engine/Python/SCIRunPythonModule.h @@ -100,6 +100,9 @@ BOOST_PYTHON_MODULE(SCIRunPythonAPI) boost::python::def("get_output_data", &NetworkEditorPythonAPI::get_output_data); boost::python::def("set_output_data", &NetworkEditorPythonAPI::set_output_data); + boost::python::def("scirun_enable_module", &NetworkEditorPythonAPI::scirun_enable_module); + boost::python::def("scirun_disable_module", &NetworkEditorPythonAPI::scirun_disable_module); + boost::python::def("scirun_save_network", &NetworkEditorPythonAPI::saveNetwork); boost::python::def("scirun_load_network", &NetworkEditorPythonAPI::loadNetwork); boost::python::def("scirun_import_network", &NetworkEditorPythonAPI::importNetwork); From 14f8ce5de5353681f686ddcbc0d68d9daa053174 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Wed, 18 May 2022 09:50:42 -0600 Subject: [PATCH 10/36] Update README.md --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 1f93f903bd..04e70c8bcd 100644 --- a/README.md +++ b/README.md @@ -36,10 +36,10 @@ For documentation, please see: https://scirun.readthedocs.io/en/latest/ Please see https://scirun.readthedocs.io/en/latest/start/build.html #### Python API -Please see https://scirun.readthedocs.io/en/latest/user_doc/python.html +Please see https://scirun.readthedocs.io/en/latest/user_doc/python.html ### Questions and Answers -For help, email the testing mailing list at scirun5-testers@sci.utah.edu. +For help, check out the discussion page: https://github.com/SCIInstitute/SCIRun/discussions. ### License and Credits For more information, please see: http://software.sci.utah.edu From b3aa3e11d80c1498a941be82d28acbb6f41434fc Mon Sep 17 00:00:00 2001 From: Dan White Date: Fri, 20 May 2022 11:55:53 -0600 Subject: [PATCH 11/36] Fix build --- src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc | 1 + src/Modules/Legacy/Fields/ReportScalarFieldStats.cc | 4 +--- src/Modules/Legacy/Fields/ReportScalarFieldStats.h | 2 -- 3 files changed, 2 insertions(+), 5 deletions(-) diff --git a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc index f856b61b54..28a28f7cd1 100644 --- a/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc +++ b/src/Interface/Modules/Fields/ReportScalarFieldStatsDialog.cc @@ -29,6 +29,7 @@ #include #include #include +#include using namespace SCIRun::Gui; using namespace SCIRun::Dataflow::Networks; diff --git a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc index ce06772a8b..98d196622c 100644 --- a/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc +++ b/src/Modules/Legacy/Fields/ReportScalarFieldStats.cc @@ -39,7 +39,7 @@ #include #include #include -#include +#include #include #include @@ -55,8 +55,6 @@ ALGORITHM_PARAMETER_DEF(Fields, AutoRangeEnabled); ALGORITHM_PARAMETER_DEF(Fields, Mean); ALGORITHM_PARAMETER_DEF(Fields, Median); ALGORITHM_PARAMETER_DEF(Fields, StandardDeviation); -ALGORITHM_PARAMETER_DEF(Fields, MinRange); -ALGORITHM_PARAMETER_DEF(Fields, MaxRange); ALGORITHM_PARAMETER_DEF(Fields, HistogramBinCount); /// @class ReportScalarFieldStats diff --git a/src/Modules/Legacy/Fields/ReportScalarFieldStats.h b/src/Modules/Legacy/Fields/ReportScalarFieldStats.h index f756a76952..d06e0fee33 100644 --- a/src/Modules/Legacy/Fields/ReportScalarFieldStats.h +++ b/src/Modules/Legacy/Fields/ReportScalarFieldStats.h @@ -43,8 +43,6 @@ namespace SCIRun { ALGORITHM_PARAMETER_DECL(Mean); ALGORITHM_PARAMETER_DECL(Median); ALGORITHM_PARAMETER_DECL(StandardDeviation); - ALGORITHM_PARAMETER_DECL(MinRange); - ALGORITHM_PARAMETER_DECL(MaxRange); ALGORITHM_PARAMETER_DECL(HistogramBinCount); } } From 5ba2162554b9c068edf18e91539b0d0fafd58be3 Mon Sep 17 00:00:00 2001 From: Dan White Date: Fri, 27 May 2022 16:21:47 -0600 Subject: [PATCH 12/36] Add pin feature --- .clang-format | 7 +++--- .../CustomWidgets/CTK/ctkBasePopupWidget.cpp | 10 ++++----- .../CustomWidgets/CTK/ctkBasePopupWidget.h | 2 +- .../Modules/Render/ObjectSelection.ui | 22 +++++++++++++++++++ src/Interface/Modules/Render/ViewScene.cc | 21 +++++++++++++----- src/Interface/Modules/Render/ViewScene.h | 3 ++- 6 files changed, 49 insertions(+), 16 deletions(-) diff --git a/.clang-format b/.clang-format index cd4922dbc1..1bbbcc0197 100644 --- a/.clang-format +++ b/.clang-format @@ -2,11 +2,10 @@ BasedOnStyle: Google AlignAfterOpenBracket: DontAlign AllowAllConstructorInitializersOnNextLine: 'true' -AllowShortBlocksOnASingleLine: 'true' +AllowShortBlocksOnASingleLine: 'false' AllowShortCaseLabelsOnASingleLine: 'true' AllowShortFunctionsOnASingleLine: Inline -AllowShortIfStatementsOnASingleLine: WithoutElse -AllowShortLoopsOnASingleLine: 'true' +AllowShortLoopsOnASingleLine: 'false' AlwaysBreakTemplateDeclarations: 'Yes' BinPackArguments: 'true' BinPackParameters: 'true' @@ -28,7 +27,7 @@ BraceWrapping: SplitEmptyNamespace: false BreakBeforeBraces: Custom BreakConstructorInitializers: BeforeColon -ColumnLimit: '100' +ColumnLimit: '200' ConstructorInitializerAllOnOneLineOrOnePerLine: 'false' Cpp11BracedListStyle: 'true' DerivePointerAlignment: 'true' diff --git a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp index 9a2aed6019..d2247426b5 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp +++ b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.cpp @@ -89,7 +89,7 @@ ctkBasePopupWidgetPrivate::ctkBasePopupWidgetPrivate(ctkBasePopupWidget& object) // Geometry attributes this->Alignment = Qt::AlignJustify | Qt::AlignBottom; this->Orientations = Qt::Vertical; - this->VerticalDirection = ctkBasePopupWidget::TopToBottom; + this->VerticalDirection = ctkBasePopupWidget::VerticalDirection::TopToBottom; this->HorizontalDirection = Qt::LeftToRight; } @@ -249,7 +249,7 @@ void ctkBasePopupWidgetPrivate::setupPopupPixmapWidget() Qt::Alignment ctkBasePopupWidgetPrivate::pixmapAlignment()const { Qt::Alignment alignment; - if (this->VerticalDirection == ctkBasePopupWidget::TopToBottom) + if (this->VerticalDirection == ctkBasePopupWidget::VerticalDirection::TopToBottom) { alignment |= Qt::AlignBottom; } @@ -281,7 +281,7 @@ QRect ctkBasePopupWidgetPrivate::closedGeometry(QRect openGeom)const { if (this->Orientations & Qt::Vertical) { - if (this->VerticalDirection == ctkBasePopupWidget::BottomToTop) + if (this->VerticalDirection == ctkBasePopupWidget::VerticalDirection::BottomToTop) { openGeom.moveTop(openGeom.bottom()); } @@ -393,7 +393,7 @@ QRect ctkBasePopupWidgetPrivate::desiredOpenGeometry(QRect baseGeometry)const if (this->Alignment & Qt::AlignTop) { - if (this->VerticalDirection == ctkBasePopupWidget::TopToBottom) + if (this->VerticalDirection == ctkBasePopupWidget::VerticalDirection::TopToBottom) { geometry.moveTop(topLeft.y()); } @@ -404,7 +404,7 @@ QRect ctkBasePopupWidgetPrivate::desiredOpenGeometry(QRect baseGeometry)const } else if (this->Alignment & Qt::AlignBottom) { - if (this->VerticalDirection == ctkBasePopupWidget::TopToBottom) + if (this->VerticalDirection == ctkBasePopupWidget::VerticalDirection::TopToBottom) { geometry.moveTop(bottomRight.y() + 1); } diff --git a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h index ddc062282d..c8ea58d300 100644 --- a/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h +++ b/src/Interface/Modules/Base/CustomWidgets/CTK/ctkBasePopupWidget.h @@ -147,7 +147,7 @@ class CTK_WIDGETS_EXPORT ctkBasePopupWidget : public QFrame /// \sa orientation void setOrientation(Qt::Orientations orientation); - enum VerticalDirection{ + enum class VerticalDirection{ TopToBottom = 1, BottomToTop = 2 }; diff --git a/src/Interface/Modules/Render/ObjectSelection.ui b/src/Interface/Modules/Render/ObjectSelection.ui index 1aa75c1162..56368d3760 100644 --- a/src/Interface/Modules/Render/ObjectSelection.ui +++ b/src/Interface/Modules/Render/ObjectSelection.ui @@ -31,6 +31,12 @@ Object Selection + + false + + + false + @@ -75,6 +81,22 @@ + + + + + 20 + 16777215 + + + + Pin popup + + + + + + diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index ef5808aa19..468962f546 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -515,17 +515,22 @@ void ViewSceneDialog::addToolBar() namespace { - void setupPopupWidget(QPushButton* button, QWidget* underlyingWidget, int which) + void setupPopupWidget(QPushButton* button, QWidget* underlyingWidget, int which, QCheckBox* pinToggle) { auto* popup = new ctkPopupWidget(button); auto* popupLayout = new QVBoxLayout(popup); - const auto dir = which == 1 ? ctkBasePopupWidget::BottomToTop : ctkBasePopupWidget::TopToBottom; + const auto dir = which == 1 ? ctkBasePopupWidget::VerticalDirection::BottomToTop + : ctkBasePopupWidget::VerticalDirection::TopToBottom; const auto alignment = which == 1 ? Qt::AlignTop | Qt::AlignHCenter : Qt::AlignLeft | Qt::AlignVCenter; const auto orientation = which == 1 ? Qt::Vertical : Qt::Horizontal; popup->setAlignment(alignment); popup->setOrientation(orientation); popup->setVerticalDirection(dir); popup->setHorizontalDirection(Qt::LayoutDirectionAuto); // open outside the parent + popup->setShowDelay(500); + popup->setHideDelay(20); + if (pinToggle) + QObject::connect(pinToggle, &QCheckBox::toggled, popup, &ctkPopupWidget::pinPopup); popupLayout->addWidget(underlyingWidget); popupLayout->setContentsMargins(4,4,4,4); } @@ -545,7 +550,7 @@ void ViewSceneDialog::addObjectSelectionButton() auto* objectSelectionButton = new QPushButton(); objectSelectionButton->setIcon(QPixmap(":/general/Resources/ViewScene/selection.png")); impl_->objectSelectionControls_ = new ObjectSelectionControls(this); - addToolbarButton(objectSelectionButton, 1, impl_->objectSelectionControls_); + addToolbarButton(objectSelectionButton, 1, impl_->objectSelectionControls_, impl_->objectSelectionControls_->pinCheckBox_); } void ViewSceneDialog::addAutoRotateButton() @@ -626,7 +631,7 @@ void ViewSceneDialog::addCameraLocksButton() addToolbarButton(cameraLocksButton, 2, impl_->cameraLockControls_); } -void ViewSceneDialog::addToolbarButton(QWidget* widget, int which, QWidget* widgetToPopup) +void ViewSceneDialog::addToolbarButton(QWidget* widget, int which, QWidget* widgetToPopup, QCheckBox* pinToggle) { static const auto buttonSize = 30; static const auto iconSize = 22; @@ -635,7 +640,7 @@ void ViewSceneDialog::addToolbarButton(QWidget* widget, int which, QWidget* widg { button->setIconSize(QSize(iconSize, iconSize)); if (widgetToPopup) - setupPopupWidget(button, widgetToPopup, which); + setupPopupWidget(button, widgetToPopup, which, pinToggle); } (which == 1 ? impl_->toolBar1_ : impl_->toolBar2_)->addWidget(widget); @@ -2782,3 +2787,9 @@ void ViewSceneDialog::initializeVisibleObjects() { impl_->objectSelectionControls_->visibleItems().initializeSavedStateMap(); } + +void ViewSceneDialog::moveEvent(QMoveEvent* event) +{ + qDebug() << event; + ModuleDialogGeneric::moveEvent(event); +} \ No newline at end of file diff --git a/src/Interface/Modules/Render/ViewScene.h b/src/Interface/Modules/Render/ViewScene.h index df70b82d74..634c557a7d 100644 --- a/src/Interface/Modules/Render/ViewScene.h +++ b/src/Interface/Modules/Render/ViewScene.h @@ -214,6 +214,7 @@ namespace SCIRun { void focusInEvent(QFocusEvent* event) override; void closeEvent(QCloseEvent* evt) override; void contextMenuEvent(QContextMenuEvent*) override {} + void moveEvent(QMoveEvent* event) override; private: @@ -237,7 +238,7 @@ namespace SCIRun { void addInputControlButton(); void addCameraLocksButton(); void addDeveloperControlButton(); - void addToolbarButton(QWidget* w, int which, QWidget* widgetToPopup = nullptr); + void addToolbarButton(QWidget* w, int which, QWidget* widgetToPopup = nullptr, QCheckBox* pinToggle = nullptr); void addConfigurationButton(); void addObjectSelectionButton(); void addLightButtons(); From 8dcbde2f8888efddf8ce07daf1e5fa4a008e20ce Mon Sep 17 00:00:00 2001 From: Dan White Date: Mon, 30 May 2022 15:14:47 -0600 Subject: [PATCH 13/36] Reformat --- .../Modules/Render/ViewSceneControlsDock.h | 470 +++++++++--------- 1 file changed, 242 insertions(+), 228 deletions(-) diff --git a/src/Interface/Modules/Render/ViewSceneControlsDock.h b/src/Interface/Modules/Render/ViewSceneControlsDock.h index 249f0ddd02..e9b1dffe0e 100644 --- a/src/Interface/Modules/Render/ViewSceneControlsDock.h +++ b/src/Interface/Modules/Render/ViewSceneControlsDock.h @@ -25,25 +25,24 @@ DEALINGS IN THE SOFTWARE. */ - #ifndef INTERFACE_MODULES_VIEW_SCENE_CONTROLS_H #define INTERFACE_MODULES_VIEW_SCENE_CONTROLS_H -#include "Interface/Modules/Render/ui_ViewSceneControls.h" #include "Interface/Modules/Render/ui_AutoRotateSettings.h" +#include "Interface/Modules/Render/ui_CameraLocks.h" +#include "Interface/Modules/Render/ui_ClippingPlanes.h" #include "Interface/Modules/Render/ui_ColorOptions.h" -#include "Interface/Modules/Render/ui_Materials.h" +#include "Interface/Modules/Render/ui_DevControls.h" #include "Interface/Modules/Render/ui_Fog.h" +#include "Interface/Modules/Render/ui_InputControls.h" +#include "Interface/Modules/Render/ui_LightControls.h" +#include "Interface/Modules/Render/ui_Materials.h" #include "Interface/Modules/Render/ui_ObjectSelection.h" #include "Interface/Modules/Render/ui_OrientationAxes.h" -#include "Interface/Modules/Render/ui_Screenshot.h" #include "Interface/Modules/Render/ui_ScaleBar.h" -#include "Interface/Modules/Render/ui_ClippingPlanes.h" -#include "Interface/Modules/Render/ui_InputControls.h" -#include "Interface/Modules/Render/ui_CameraLocks.h" -#include "Interface/Modules/Render/ui_DevControls.h" -#include "Interface/Modules/Render/ui_LightControls.h" +#include "Interface/Modules/Render/ui_Screenshot.h" #include "Interface/Modules/Render/ui_ViewAxisChooser.h" +#include "Interface/Modules/Render/ui_ViewSceneControls.h" #ifndef Q_MOC_RUN #include @@ -55,197 +54,211 @@ class QwtKnob; class ctkColorPickerButton; namespace SCIRun { - namespace Gui { - class ViewSceneDialog; - - class VisibleItemManager : public QObject - { - Q_OBJECT - public: - VisibleItemManager(QTreeWidget* itemList, Dataflow::Networks::ModuleStateHandle state); - std::vector synchronize(const std::vector& geomList, - const Modules::Render::ShowFieldStatesMap& showFieldStates); - bool isVisible(const QString& name) const; - bool containsItem(const QString& name) const; - void initializeSavedStateMap(); - public Q_SLOTS: - void clear(); - void selectAllClicked(); - void deselectAllClicked(); - void updateVisible(QTreeWidgetItem* item, int column); - Q_SIGNALS: - void visibleItemChange(); - void meshComponentSelectionChange(const QString& moduleId, const QString& component, bool selected); - private Q_SLOTS: - void updateState(); - private: - void addRenderItem(const QString& name); - void updateCheckStates(const QString& name, const std::vector& checked); - QTreeWidget* itemList_; - Dataflow::Networks::ModuleStateHandle state_; - std::map topLevelItemMap_; - std::map> secondLevelItemMap_; - }; - - class SCISHARE AutoRotateControls : public QWidget, public Ui::AutoRotateSettings - { - Q_OBJECT - - public: - explicit AutoRotateControls(ViewSceneDialog* parent); - }; - - class SCISHARE ColorOptions : public QWidget, public Ui::ColorOptions - { - Q_OBJECT - - public: - explicit ColorOptions(ViewSceneDialog* parent); - void setSampleColor(const QColor& color); - }; - - class SCISHARE MaterialsControls : public QWidget, public Ui::Materials - { - Q_OBJECT - - public: - explicit MaterialsControls(ViewSceneDialog* parent); - void setMaterialValues(double ambient, double diffuse, double specular, double shine, double emission); - }; - - class SCISHARE ButtonStylesheetToggler - { - public: - ButtonStylesheetToggler(QPushButton* toolbarButton, std::function whatToToggle); - void updateToolbarButton(const QColor& color); - protected: - QPushButton* toolbarButton_{nullptr}; - std::function linkedCheckable_; - std::function whatToToggle_; - }; - - class SCISHARE LightButtonUpdater : public ButtonStylesheetToggler - { - public: - explicit LightButtonUpdater(QPushButton* toolbarButton, std::function whatToToggle); - QColor color() const; - void setColor(const QColor& color); - protected: - ctkColorPickerButton* colorPickerButton_{nullptr}; - QColor lightColor_; - void updateLightColor(); - virtual void lightColorUpdated() = 0; - }; - - class SCISHARE FogControls : public QWidget, public Ui::Fog, public LightButtonUpdater - { - Q_OBJECT - - public: - FogControls(ViewSceneDialog* parent, QPushButton* toolbarButton); - void setFogValues(bool fogVisible, bool objectsOnly, bool useBGColor, double fogStart, double fogEnd); - Q_SIGNALS: - void setFogTo(bool toggle); - void lightColorUpdated() override; - public Q_SLOTS: - void toggleFog(); - }; - - class SCISHARE ObjectSelectionControls : public QWidget, public Ui::ObjectSelection - { - Q_OBJECT - - public: - explicit ObjectSelectionControls(ViewSceneDialog* parent); - VisibleItemManager& visibleItems() { return *visibleItems_; } - private: - void setupObjectListWidget(); - std::unique_ptr visibleItems_; - }; - - class SCISHARE OrientationAxesControls : public QWidget, public Ui::OrientationAxes, public ButtonStylesheetToggler - { - Q_OBJECT - - public: - explicit OrientationAxesControls(ViewSceneDialog* parent, QPushButton* toolbarButton); - void toggleButton(); - private: - void setSliderDefaultPos(); - void setSliderCenterPos(); - }; - - class SCISHARE ScreenshotControls : public QWidget, public Ui::Screenshot - { - Q_OBJECT - - public: - explicit ScreenshotControls(ViewSceneDialog* parent); - void setScreenshotDirectory(const QString& dir); - private: - void setSliderDefaultPos(); - void setSliderCenterPos(); - }; - - struct SCISHARE ScaleBarData - { - bool visible; - int fontSize; - double length, height, multiplier, numTicks, lineWidth; - std::string unit; - double projLength; - }; - - class SCISHARE ScaleBarControls : public QWidget, public Ui::ScaleBar, public ButtonStylesheetToggler - { - Q_OBJECT - - public: - ScaleBarControls(ViewSceneDialog* parent, QPushButton* toolbarButton); - void setScaleBarValues(const ScaleBarData& scale); - private: - static const QColor buttonOutlineColor; - }; - - class SCISHARE ClippingPlaneControls : public QWidget, public Ui::ClippingPlanes, public ButtonStylesheetToggler - { - Q_OBJECT - - public: - ClippingPlaneControls(ViewSceneDialog* parent, QPushButton* toolbarButton); - void updatePlaneSettingsDisplay(bool visible, bool showPlane, bool reverseNormal); - void updatePlaneControlDisplay(double x, double y, double z, double d); - }; - - class SCISHARE InputControls : public QWidget, public Ui::Input - { - Q_OBJECT - - public: - explicit InputControls(ViewSceneDialog* parent); - void updateZoomOptionVisibility(); - }; - - class SCISHARE CameraLockControls : public QWidget, public Ui::CameraLocks - { - Q_OBJECT - - public: - explicit CameraLockControls(ViewSceneDialog* parent); - private Q_SLOTS: - void updateViewSceneTree(); - void addGroup(); - void removeGroup(); - void viewSceneTreeClicked(QTreeWidgetItem* widgetItem, int column); - }; - - class SCISHARE DeveloperControls : public QWidget, public Ui::Developer - { - Q_OBJECT - - public: - explicit DeveloperControls(ViewSceneDialog* parent); - }; +namespace Gui { + class ViewSceneDialog; + + class VisibleItemManager : public QObject + { + Q_OBJECT + public: + VisibleItemManager(QTreeWidget* itemList, Dataflow::Networks::ModuleStateHandle state); + std::vector synchronize(const std::vector& geomList, const Modules::Render::ShowFieldStatesMap& showFieldStates); + bool isVisible(const QString& name) const; + bool containsItem(const QString& name) const; + void initializeSavedStateMap(); + public Q_SLOTS: + void clear(); + void selectAllClicked(); + void deselectAllClicked(); + void updateVisible(QTreeWidgetItem* item, int column); + Q_SIGNALS: + void visibleItemChange(); + void meshComponentSelectionChange(const QString& moduleId, const QString& component, bool selected); + private Q_SLOTS: + void updateState(); + + private: + void addRenderItem(const QString& name); + void updateCheckStates(const QString& name, const std::vector& checked); + QTreeWidget* itemList_; + Dataflow::Networks::ModuleStateHandle state_; + std::map topLevelItemMap_; + std::map> secondLevelItemMap_; + }; + + class SCISHARE ViewSceneControlPopupWidget : public QWidget + { + Q_OBJECT + + public: + explicit ViewSceneControlPopupWidget(ViewSceneDialog* parent); + }; + + class SCISHARE AutoRotateControls : public QWidget, public Ui::AutoRotateSettings + { + Q_OBJECT + + public: + explicit AutoRotateControls(ViewSceneDialog* parent); + }; + + class SCISHARE ColorOptions : public QWidget, public Ui::ColorOptions + { + Q_OBJECT + + public: + explicit ColorOptions(ViewSceneDialog* parent); + void setSampleColor(const QColor& color); + }; + + class SCISHARE MaterialsControls : public QWidget, public Ui::Materials + { + Q_OBJECT + + public: + explicit MaterialsControls(ViewSceneDialog* parent); + void setMaterialValues(double ambient, double diffuse, double specular, double shine, double emission); + }; + + class SCISHARE ButtonStylesheetToggler + { + public: + ButtonStylesheetToggler(QPushButton* toolbarButton, std::function whatToToggle); + void updateToolbarButton(const QColor& color); + + protected: + QPushButton* toolbarButton_{nullptr}; + std::function linkedCheckable_; + std::function whatToToggle_; + }; + + class SCISHARE LightButtonUpdater : public ButtonStylesheetToggler + { + public: + explicit LightButtonUpdater(QPushButton* toolbarButton, std::function whatToToggle); + QColor color() const; + void setColor(const QColor& color); + + protected: + ctkColorPickerButton* colorPickerButton_{nullptr}; + QColor lightColor_; + void updateLightColor(); + virtual void lightColorUpdated() = 0; + }; + + class SCISHARE FogControls : public QWidget, public Ui::Fog, public LightButtonUpdater + { + Q_OBJECT + + public: + FogControls(ViewSceneDialog* parent, QPushButton* toolbarButton); + void setFogValues(bool fogVisible, bool objectsOnly, bool useBGColor, double fogStart, double fogEnd); + Q_SIGNALS: + void setFogTo(bool toggle); + void lightColorUpdated() override; + public Q_SLOTS: + void toggleFog(); + }; + + class SCISHARE ObjectSelectionControls : public QWidget, public Ui::ObjectSelection + { + Q_OBJECT + + public: + explicit ObjectSelectionControls(ViewSceneDialog* parent); + VisibleItemManager& visibleItems() { return *visibleItems_; } + + private: + void setupObjectListWidget(); + std::unique_ptr visibleItems_; + }; + + class SCISHARE OrientationAxesControls : public QWidget, public Ui::OrientationAxes, public ButtonStylesheetToggler + { + Q_OBJECT + + public: + explicit OrientationAxesControls(ViewSceneDialog* parent, QPushButton* toolbarButton); + void toggleButton(); + + private: + void setSliderDefaultPos(); + void setSliderCenterPos(); + }; + + class SCISHARE ScreenshotControls : public QWidget, public Ui::Screenshot + { + Q_OBJECT + + public: + explicit ScreenshotControls(ViewSceneDialog* parent); + void setScreenshotDirectory(const QString& dir); + + private: + void setSliderDefaultPos(); + void setSliderCenterPos(); + }; + + struct SCISHARE ScaleBarData + { + bool visible; + int fontSize; + double length, height, multiplier, numTicks, lineWidth; + std::string unit; + double projLength; + }; + + class SCISHARE ScaleBarControls : public QWidget, public Ui::ScaleBar, public ButtonStylesheetToggler + { + Q_OBJECT + + public: + ScaleBarControls(ViewSceneDialog* parent, QPushButton* toolbarButton); + void setScaleBarValues(const ScaleBarData& scale); + + private: + static const QColor buttonOutlineColor; + }; + + class SCISHARE ClippingPlaneControls : public QWidget, public Ui::ClippingPlanes, public ButtonStylesheetToggler + { + Q_OBJECT + + public: + ClippingPlaneControls(ViewSceneDialog* parent, QPushButton* toolbarButton); + void updatePlaneSettingsDisplay(bool visible, bool showPlane, bool reverseNormal); + void updatePlaneControlDisplay(double x, double y, double z, double d); + }; + + class SCISHARE InputControls : public QWidget, public Ui::Input + { + Q_OBJECT + + public: + explicit InputControls(ViewSceneDialog* parent); + void updateZoomOptionVisibility(); + }; + + class SCISHARE CameraLockControls : public QWidget, public Ui::CameraLocks + { + Q_OBJECT + + public: + explicit CameraLockControls(ViewSceneDialog* parent); + private Q_SLOTS: + void updateViewSceneTree(); + void addGroup(); + void removeGroup(); + void viewSceneTreeClicked(QTreeWidgetItem* widgetItem, int column); + }; + + class SCISHARE DeveloperControls : public QWidget, public Ui::Developer + { + Q_OBJECT + + public: + explicit DeveloperControls(ViewSceneDialog* parent); + }; #ifndef WIN32 #define LightSliderType QwtKnob @@ -253,34 +266,35 @@ namespace SCIRun { #define LightSliderType QSlider #endif - class SCISHARE LightControls : public QWidget, public Ui::LightControls, public LightButtonUpdater - { - Q_OBJECT - - public: - explicit LightControls(ViewSceneDialog* parent, int lightNumber, QPushButton* toolbarButton); - void setAdditionalLightState(int azimuth, int inclination, bool on); - private: - int lightNumber_ {-1}; - LightSliderType* lightAzimuthSlider_{nullptr}; - LightSliderType* lightInclinationSlider_{ nullptr }; - - private Q_SLOTS: - void resetAngles(); - Q_SIGNALS: - void lightColorUpdated() override; - }; - - class SCISHARE ViewAxisChooserControls : public QWidget, public Ui::ViewAxisChooser - { - Q_OBJECT - public: - explicit ViewAxisChooserControls(ViewSceneDialog* parent); - QString currentAxis() const; - private Q_SLOTS: - void viewAxisSelected(const QString& name); - }; - } + class SCISHARE LightControls : public QWidget, public Ui::LightControls, public LightButtonUpdater + { + Q_OBJECT + + public: + explicit LightControls(ViewSceneDialog* parent, int lightNumber, QPushButton* toolbarButton); + void setAdditionalLightState(int azimuth, int inclination, bool on); + + private: + int lightNumber_{-1}; + LightSliderType* lightAzimuthSlider_{nullptr}; + LightSliderType* lightInclinationSlider_{nullptr}; + + private Q_SLOTS: + void resetAngles(); + Q_SIGNALS: + void lightColorUpdated() override; + }; + + class SCISHARE ViewAxisChooserControls : public QWidget, public Ui::ViewAxisChooser + { + Q_OBJECT + public: + explicit ViewAxisChooserControls(ViewSceneDialog* parent); + QString currentAxis() const; + private Q_SLOTS: + void viewAxisSelected(const QString& name); + }; +} } #endif From 961d390a2f0f80b827c28f6f830820f2975a5f6f Mon Sep 17 00:00:00 2001 From: Dan White Date: Mon, 30 May 2022 15:41:51 -0600 Subject: [PATCH 14/36] All pop-ups pinnable with context menu --- src/Interface/Modules/Render/GLWidget.h | 1 - .../Modules/Render/ObjectSelection.ui | 16 ------- src/Interface/Modules/Render/ViewScene.cc | 11 +++-- src/Interface/Modules/Render/ViewScene.h | 2 +- .../Modules/Render/ViewSceneControlsDock.cc | 43 +++++++++++++------ .../Modules/Render/ViewSceneControlsDock.h | 35 ++++++++------- 6 files changed, 55 insertions(+), 53 deletions(-) diff --git a/src/Interface/Modules/Render/GLWidget.h b/src/Interface/Modules/Render/GLWidget.h index 5d3bb69b77..a765704c36 100644 --- a/src/Interface/Modules/Render/GLWidget.h +++ b/src/Interface/Modules/Render/GLWidget.h @@ -40,7 +40,6 @@ #ifndef Q_MOC_RUN #include -#include #include #endif #include diff --git a/src/Interface/Modules/Render/ObjectSelection.ui b/src/Interface/Modules/Render/ObjectSelection.ui index 56368d3760..5a2bd14489 100644 --- a/src/Interface/Modules/Render/ObjectSelection.ui +++ b/src/Interface/Modules/Render/ObjectSelection.ui @@ -81,22 +81,6 @@ - - - - - 20 - 16777215 - - - - Pin popup - - - - - - diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index 468962f546..09cd58fd19 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -515,7 +515,7 @@ void ViewSceneDialog::addToolBar() namespace { - void setupPopupWidget(QPushButton* button, QWidget* underlyingWidget, int which, QCheckBox* pinToggle) + void setupPopupWidget(QPushButton* button, ViewSceneControlPopupWidget* underlyingWidget, int which) { auto* popup = new ctkPopupWidget(button); auto* popupLayout = new QVBoxLayout(popup); @@ -529,8 +529,7 @@ namespace popup->setHorizontalDirection(Qt::LayoutDirectionAuto); // open outside the parent popup->setShowDelay(500); popup->setHideDelay(20); - if (pinToggle) - QObject::connect(pinToggle, &QCheckBox::toggled, popup, &ctkPopupWidget::pinPopup); + QObject::connect(underlyingWidget->pinToggleAction(), &QAction::toggled, popup, &ctkPopupWidget::pinPopup); popupLayout->addWidget(underlyingWidget); popupLayout->setContentsMargins(4,4,4,4); } @@ -550,7 +549,7 @@ void ViewSceneDialog::addObjectSelectionButton() auto* objectSelectionButton = new QPushButton(); objectSelectionButton->setIcon(QPixmap(":/general/Resources/ViewScene/selection.png")); impl_->objectSelectionControls_ = new ObjectSelectionControls(this); - addToolbarButton(objectSelectionButton, 1, impl_->objectSelectionControls_, impl_->objectSelectionControls_->pinCheckBox_); + addToolbarButton(objectSelectionButton, 1, impl_->objectSelectionControls_); } void ViewSceneDialog::addAutoRotateButton() @@ -631,7 +630,7 @@ void ViewSceneDialog::addCameraLocksButton() addToolbarButton(cameraLocksButton, 2, impl_->cameraLockControls_); } -void ViewSceneDialog::addToolbarButton(QWidget* widget, int which, QWidget* widgetToPopup, QCheckBox* pinToggle) +void ViewSceneDialog::addToolbarButton(QWidget* widget, int which, ViewSceneControlPopupWidget* widgetToPopup) { static const auto buttonSize = 30; static const auto iconSize = 22; @@ -640,7 +639,7 @@ void ViewSceneDialog::addToolbarButton(QWidget* widget, int which, QWidget* widg { button->setIconSize(QSize(iconSize, iconSize)); if (widgetToPopup) - setupPopupWidget(button, widgetToPopup, which, pinToggle); + setupPopupWidget(button, widgetToPopup, which); } (which == 1 ? impl_->toolBar1_ : impl_->toolBar2_)->addWidget(widget); diff --git a/src/Interface/Modules/Render/ViewScene.h b/src/Interface/Modules/Render/ViewScene.h index 634c557a7d..f433cfef62 100644 --- a/src/Interface/Modules/Render/ViewScene.h +++ b/src/Interface/Modules/Render/ViewScene.h @@ -238,7 +238,7 @@ namespace SCIRun { void addInputControlButton(); void addCameraLocksButton(); void addDeveloperControlButton(); - void addToolbarButton(QWidget* w, int which, QWidget* widgetToPopup = nullptr, QCheckBox* pinToggle = nullptr); + void addToolbarButton(QWidget* w, int which, ViewSceneControlPopupWidget* widgetToPopup = nullptr); void addConfigurationButton(); void addObjectSelectionButton(); void addLightButtons(); diff --git a/src/Interface/Modules/Render/ViewSceneControlsDock.cc b/src/Interface/Modules/Render/ViewSceneControlsDock.cc index 6da04c473a..e121752862 100644 --- a/src/Interface/Modules/Render/ViewSceneControlsDock.cc +++ b/src/Interface/Modules/Render/ViewSceneControlsDock.cc @@ -487,7 +487,7 @@ void ObjectSelectionControls::setupObjectListWidget() objectListWidget_->setItemDelegate(new FixMacCheckBoxes); } -AutoRotateControls::AutoRotateControls(ViewSceneDialog* parent) : QWidget(parent) +AutoRotateControls::AutoRotateControls(ViewSceneDialog* parent) : ViewSceneControlPopupWidget(parent) { setupUi(this); @@ -498,14 +498,14 @@ AutoRotateControls::AutoRotateControls(ViewSceneDialog* parent) : QWidget(parent connect(autoRotateSpeedSpinBox_, qOverload(&QDoubleSpinBox::valueChanged), parent, &ViewSceneDialog::setAutoRotateSpeed); } -ColorOptions::ColorOptions(ViewSceneDialog* parent) : QWidget(parent) +ColorOptions::ColorOptions(ViewSceneDialog* parent) : ViewSceneControlPopupWidget(parent) { setupUi(this); connect(setBackgroundColorPushButton_, &QPushButton::clicked, parent, &ViewSceneDialog::assignBackgroundColor); } -MaterialsControls::MaterialsControls(ViewSceneDialog* parent) : QWidget(parent) +MaterialsControls::MaterialsControls(ViewSceneDialog* parent) : ViewSceneControlPopupWidget(parent) { setupUi(this); @@ -516,7 +516,7 @@ MaterialsControls::MaterialsControls(ViewSceneDialog* parent) : QWidget(parent) } FogControls::FogControls(ViewSceneDialog* parent, QPushButton* toolbarButton) - : QWidget(parent), LightButtonUpdater(toolbarButton, [this]() { toggleFog(); }) + : ViewSceneControlPopupWidget(parent), LightButtonUpdater(toolbarButton, [this]() { toggleFog(); }) { setupUi(this); @@ -538,7 +538,7 @@ void FogControls::toggleFog() Q_EMIT setFogTo(toggle); } -ObjectSelectionControls::ObjectSelectionControls(ViewSceneDialog* parent) : QWidget(parent) +ObjectSelectionControls::ObjectSelectionControls(ViewSceneDialog* parent) : ViewSceneControlPopupWidget(parent) { setupUi(this); @@ -563,7 +563,7 @@ namespace } OrientationAxesControls::OrientationAxesControls(ViewSceneDialog* parent, QPushButton* toolbarButton) - : QWidget(parent), ButtonStylesheetToggler(toolbarButton, + : ViewSceneControlPopupWidget(parent), ButtonStylesheetToggler(toolbarButton, [this]() { toggleCheckable(orientationCheckableGroupBox_); }) { setupUi(this); @@ -587,7 +587,7 @@ void OrientationAxesControls::toggleButton() } ScreenshotControls::ScreenshotControls(ViewSceneDialog* parent) - : QWidget(parent) + : ViewSceneControlPopupWidget(parent) { setupUi(this); connect(saveScreenShotOnUpdateCheckBox_, &QCheckBox::stateChanged, parent, &ViewSceneDialog::saveNewGeometryChanged); @@ -596,7 +596,7 @@ ScreenshotControls::ScreenshotControls(ViewSceneDialog* parent) } ScaleBarControls::ScaleBarControls(ViewSceneDialog* parent, QPushButton* toolbarButton) - : QWidget(parent), ButtonStylesheetToggler(toolbarButton, [this]() { toggleCheckable(showScaleBarTextGroupBox_); }) + : ViewSceneControlPopupWidget(parent), ButtonStylesheetToggler(toolbarButton, [this]() { toggleCheckable(showScaleBarTextGroupBox_); }) { setupUi(this); @@ -613,7 +613,7 @@ ScaleBarControls::ScaleBarControls(ViewSceneDialog* parent, QPushButton* toolbar } ClippingPlaneControls::ClippingPlaneControls(ViewSceneDialog* parent, QPushButton* toolbarButton) - : QWidget(parent), + : ViewSceneControlPopupWidget(parent), ButtonStylesheetToggler(toolbarButton, [this]() { toggleCheckable(planeVisibleCheckBox_); }) { setupUi(this); @@ -646,7 +646,7 @@ ClippingPlaneControls::ClippingPlaneControls(ViewSceneDialog* parent, QPushButto connect(dValueHorizontalSlider_, &QSlider::valueChanged, parent, &ViewSceneDialog::setClippingPlaneD); } -InputControls::InputControls(ViewSceneDialog* parent) : QWidget(parent) +InputControls::InputControls(ViewSceneDialog* parent) : ViewSceneControlPopupWidget(parent) { setupUi(this); @@ -669,7 +669,7 @@ InputControls::InputControls(ViewSceneDialog* parent) : QWidget(parent) connect(zoomSpeedHorizontalSlider_, &QSlider::valueChanged, parent, &ViewSceneDialog::adjustZoomSpeed); } -CameraLockControls::CameraLockControls(ViewSceneDialog* parent) : QWidget(parent) +CameraLockControls::CameraLockControls(ViewSceneDialog* parent) : ViewSceneControlPopupWidget(parent) { setupUi(this); @@ -681,7 +681,7 @@ CameraLockControls::CameraLockControls(ViewSceneDialog* parent) : QWidget(parent groupRemoveSpinBox_->setRange(0, 0); } -DeveloperControls::DeveloperControls(ViewSceneDialog* parent) : QWidget(parent) +DeveloperControls::DeveloperControls(ViewSceneDialog* parent) : ViewSceneControlPopupWidget(parent) { setupUi(this); @@ -703,7 +703,7 @@ LightButtonUpdater::LightButtonUpdater(QPushButton* toolbarButton, std::function } LightControls::LightControls(ViewSceneDialog* viewScene, int lightNumber, QPushButton* toolbarButton) - : QWidget(viewScene), LightButtonUpdater(toolbarButton, [this]() { lightCheckBox_->toggle(); }), + : ViewSceneControlPopupWidget(viewScene), LightButtonUpdater(toolbarButton, [this]() { lightCheckBox_->toggle(); }), lightNumber_(lightNumber) { setupUi(this); @@ -829,7 +829,7 @@ void LightControls::setAdditionalLightState(int azimuth, int inclination, bool o updateLightColor(); } -ViewAxisChooserControls::ViewAxisChooserControls(ViewSceneDialog* parent) : QWidget(parent) +ViewAxisChooserControls::ViewAxisChooserControls(ViewSceneDialog* parent) : ViewSceneControlPopupWidget(parent) { setupUi(this); @@ -862,3 +862,18 @@ void ViewAxisChooserControls::viewAxisSelected(const QString& name) } upVectorComboBox_->setEnabled(true); } + +ViewSceneControlPopupWidget::ViewSceneControlPopupWidget(ViewSceneDialog* parent) : QWidget(parent) +{ + setContextMenuPolicy(Qt::CustomContextMenu); + connect(this, &QWidget::customContextMenuRequested, this, &ViewSceneControlPopupWidget::showContextMenu); + pinToggleAction_ = new QAction("Pin popup", this); + pinToggleAction_->setCheckable(true); +} + +void ViewSceneControlPopupWidget::showContextMenu(const QPoint& pos) +{ + QMenu contextMenu(tr("Context menu"), this); + contextMenu.addAction(pinToggleAction_); + contextMenu.exec(mapToGlobal(pos)); +} \ No newline at end of file diff --git a/src/Interface/Modules/Render/ViewSceneControlsDock.h b/src/Interface/Modules/Render/ViewSceneControlsDock.h index e9b1dffe0e..938b8500b2 100644 --- a/src/Interface/Modules/Render/ViewSceneControlsDock.h +++ b/src/Interface/Modules/Render/ViewSceneControlsDock.h @@ -90,11 +90,16 @@ namespace Gui { { Q_OBJECT - public: + public: explicit ViewSceneControlPopupWidget(ViewSceneDialog* parent); + QAction* pinToggleAction() { return pinToggleAction_; } + private Q_SLOTS: + void showContextMenu(const QPoint& pos); + private: + QAction* pinToggleAction_{ nullptr }; }; - class SCISHARE AutoRotateControls : public QWidget, public Ui::AutoRotateSettings + class SCISHARE AutoRotateControls : public ViewSceneControlPopupWidget, public Ui::AutoRotateSettings { Q_OBJECT @@ -102,7 +107,7 @@ namespace Gui { explicit AutoRotateControls(ViewSceneDialog* parent); }; - class SCISHARE ColorOptions : public QWidget, public Ui::ColorOptions + class SCISHARE ColorOptions : public ViewSceneControlPopupWidget, public Ui::ColorOptions { Q_OBJECT @@ -111,7 +116,7 @@ namespace Gui { void setSampleColor(const QColor& color); }; - class SCISHARE MaterialsControls : public QWidget, public Ui::Materials + class SCISHARE MaterialsControls : public ViewSceneControlPopupWidget, public Ui::Materials { Q_OBJECT @@ -146,7 +151,7 @@ namespace Gui { virtual void lightColorUpdated() = 0; }; - class SCISHARE FogControls : public QWidget, public Ui::Fog, public LightButtonUpdater + class SCISHARE FogControls : public ViewSceneControlPopupWidget, public Ui::Fog, public LightButtonUpdater { Q_OBJECT @@ -160,7 +165,7 @@ namespace Gui { void toggleFog(); }; - class SCISHARE ObjectSelectionControls : public QWidget, public Ui::ObjectSelection + class SCISHARE ObjectSelectionControls : public ViewSceneControlPopupWidget, public Ui::ObjectSelection { Q_OBJECT @@ -173,7 +178,7 @@ namespace Gui { std::unique_ptr visibleItems_; }; - class SCISHARE OrientationAxesControls : public QWidget, public Ui::OrientationAxes, public ButtonStylesheetToggler + class SCISHARE OrientationAxesControls : public ViewSceneControlPopupWidget, public Ui::OrientationAxes, public ButtonStylesheetToggler { Q_OBJECT @@ -186,7 +191,7 @@ namespace Gui { void setSliderCenterPos(); }; - class SCISHARE ScreenshotControls : public QWidget, public Ui::Screenshot + class SCISHARE ScreenshotControls : public ViewSceneControlPopupWidget, public Ui::Screenshot { Q_OBJECT @@ -208,7 +213,7 @@ namespace Gui { double projLength; }; - class SCISHARE ScaleBarControls : public QWidget, public Ui::ScaleBar, public ButtonStylesheetToggler + class SCISHARE ScaleBarControls : public ViewSceneControlPopupWidget, public Ui::ScaleBar, public ButtonStylesheetToggler { Q_OBJECT @@ -220,7 +225,7 @@ namespace Gui { static const QColor buttonOutlineColor; }; - class SCISHARE ClippingPlaneControls : public QWidget, public Ui::ClippingPlanes, public ButtonStylesheetToggler + class SCISHARE ClippingPlaneControls : public ViewSceneControlPopupWidget, public Ui::ClippingPlanes, public ButtonStylesheetToggler { Q_OBJECT @@ -230,7 +235,7 @@ namespace Gui { void updatePlaneControlDisplay(double x, double y, double z, double d); }; - class SCISHARE InputControls : public QWidget, public Ui::Input + class SCISHARE InputControls : public ViewSceneControlPopupWidget, public Ui::Input { Q_OBJECT @@ -239,7 +244,7 @@ namespace Gui { void updateZoomOptionVisibility(); }; - class SCISHARE CameraLockControls : public QWidget, public Ui::CameraLocks + class SCISHARE CameraLockControls : public ViewSceneControlPopupWidget, public Ui::CameraLocks { Q_OBJECT @@ -252,7 +257,7 @@ namespace Gui { void viewSceneTreeClicked(QTreeWidgetItem* widgetItem, int column); }; - class SCISHARE DeveloperControls : public QWidget, public Ui::Developer + class SCISHARE DeveloperControls : public ViewSceneControlPopupWidget, public Ui::Developer { Q_OBJECT @@ -266,7 +271,7 @@ namespace Gui { #define LightSliderType QSlider #endif - class SCISHARE LightControls : public QWidget, public Ui::LightControls, public LightButtonUpdater + class SCISHARE LightControls : public ViewSceneControlPopupWidget, public Ui::LightControls, public LightButtonUpdater { Q_OBJECT @@ -285,7 +290,7 @@ namespace Gui { void lightColorUpdated() override; }; - class SCISHARE ViewAxisChooserControls : public QWidget, public Ui::ViewAxisChooser + class SCISHARE ViewAxisChooserControls : public ViewSceneControlPopupWidget, public Ui::ViewAxisChooser { Q_OBJECT public: From 930997a1f4d8fa4f7ba1014c0bb68364c87c026e Mon Sep 17 00:00:00 2001 From: Dan White Date: Tue, 31 May 2022 09:54:41 -0600 Subject: [PATCH 15/36] Working on toolbar positioning --- src/Interface/Modules/Render/ViewScene.cc | 44 +++++++++++++++++------ src/Interface/Modules/Render/ViewScene.h | 4 +-- src/Modules/Render/ViewScene.cc | 6 +++- src/Modules/Render/ViewScene.h | 2 ++ 4 files changed, 43 insertions(+), 13 deletions(-) diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index 09cd58fd19..a02b93e319 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -445,8 +445,9 @@ ViewSceneDialog::ViewSceneDialog(const std::string& name, ModuleStateHandle stat setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred); addToolBar(); + setToolBarPositions(); glLayout->addWidget(impl_->mGLWidget, 1, 1); - glLayout->addWidget(impl_->toolBar2_, 1, 0); + glLayout->update(); addLineEditManager(impl_->screenshotControls_->defaultScreenshotPath_, Parameters::ScreenshotDirectory); @@ -480,11 +481,43 @@ std::string ViewSceneDialog::toString(std::string prefix) const return output; } +void ViewSceneDialog::showToolBarContextMenu(const QPoint& pos) +{ + auto toolbar = qobject_cast(sender()); + if (toolbar) + { + qDebug() << toolbar << toolbar->orientation(); + qDebug() << glLayout << glLayout->itemAtPosition(0, 0)->widget() << glLayout->itemAtPosition(1, 0)->widget(); + } + QMenu contextMenu("Context menu", this); + QAction switchPosition("Move toolbar"); + contextMenu.addAction(&switchPosition); + connect(&switchPosition, &QAction::triggered, [this]() { qDebug() << "need to switch toolbar position"; }); + contextMenu.exec(mapToGlobal(pos)); +} + +void ViewSceneDialog::setToolBarPositions() +{ + if (state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool()) + glLayout->addWidget(impl_->toolBar1_, 0, 0, 1, 2); + else + glLayout->addWidget(impl_->toolBar1_, 2, 0, 1, 2); + + if (state_->getValue(Parameters::VerticalToolBarPositionDefault).toBool()) + glLayout->addWidget(impl_->toolBar2_, 1, 0); + else + glLayout->addWidget(impl_->toolBar2_, 1, 2); +} + void ViewSceneDialog::addToolBar() { impl_->toolBar1_ = new QToolBar(this); + impl_->toolBar1_->setContextMenuPolicy(Qt::CustomContextMenu); + connect(impl_->toolBar1_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); WidgetStyleMixin::toolbarStyle(impl_->toolBar1_); impl_->toolBar2_ = new QToolBar(this); + impl_->toolBar2_->setContextMenuPolicy(Qt::CustomContextMenu); + connect(impl_->toolBar2_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); impl_->toolBar2_->setOrientation(Qt::Vertical); WidgetStyleMixin::toolbarStyle(impl_->toolBar2_); @@ -503,9 +536,6 @@ void ViewSceneDialog::addToolBar() addCameraLocksButton(); addDeveloperControlButton(); setupMaterials(); - - glLayout->addWidget(impl_->toolBar1_, 0, 0, 1, 2); - addViewBarButton(); addControlLockButton(); @@ -2786,9 +2816,3 @@ void ViewSceneDialog::initializeVisibleObjects() { impl_->objectSelectionControls_->visibleItems().initializeSavedStateMap(); } - -void ViewSceneDialog::moveEvent(QMoveEvent* event) -{ - qDebug() << event; - ModuleDialogGeneric::moveEvent(event); -} \ No newline at end of file diff --git a/src/Interface/Modules/Render/ViewScene.h b/src/Interface/Modules/Render/ViewScene.h index f433cfef62..47bfa2ead2 100644 --- a/src/Interface/Modules/Render/ViewScene.h +++ b/src/Interface/Modules/Render/ViewScene.h @@ -190,6 +190,8 @@ namespace SCIRun { void quickScreenshot(); void quickScreenshotClicked() { quickScreenshot(); } void setScreenshotDirectory(); + void showToolBarContextMenu(const QPoint& pos); + void setToolBarPositions(); protected: //---------------- Initialization ------------------------------------------------------------ @@ -214,8 +216,6 @@ namespace SCIRun { void focusInEvent(QFocusEvent* event) override; void closeEvent(QCloseEvent* evt) override; void contextMenuEvent(QContextMenuEvent*) override {} - void moveEvent(QMoveEvent* event) override; - private: //---------------- Initialization ------------------------------------------------------------ diff --git a/src/Modules/Render/ViewScene.cc b/src/Modules/Render/ViewScene.cc index c8b6fd01a8..071ef1115c 100644 --- a/src/Modules/Render/ViewScene.cc +++ b/src/Modules/Render/ViewScene.cc @@ -158,7 +158,8 @@ ALGORITHM_PARAMETER_DEF(Render, AxesSize); ALGORITHM_PARAMETER_DEF(Render, AxesX); ALGORITHM_PARAMETER_DEF(Render, AxesY); ALGORITHM_PARAMETER_DEF(Render, VisibleItemListState); - +ALGORITHM_PARAMETER_DEF(Render, HorizontalToolBarPositionDefault); +ALGORITHM_PARAMETER_DEF(Render, VerticalToolBarPositionDefault); ALGORITHM_PARAMETER_DEF(Render, ScreenshotDirectory); ViewScene::ViewScene() : ModuleWithAsyncDynamicPorts(staticInfo_, true) @@ -257,6 +258,9 @@ void ViewScene::setStateDefaults() state->setValue(Parameters::AxesX, 100); state->setValue(Parameters::AxesY, 100); + state->setValue(Parameters::HorizontalToolBarPositionDefault, true); + state->setValue(Parameters::VerticalToolBarPositionDefault, true); + state->setValue(Parameters::ScreenshotDirectory, Core::Preferences::Instance().screenshotDirectory().string()); diff --git a/src/Modules/Render/ViewScene.h b/src/Modules/Render/ViewScene.h index 58651cc71e..e7ba3a0a4f 100644 --- a/src/Modules/Render/ViewScene.h +++ b/src/Modules/Render/ViewScene.h @@ -105,6 +105,8 @@ namespace SCIRun ALGORITHM_PARAMETER_DECL(CameraDistanceMinimum); ALGORITHM_PARAMETER_DECL(CameraLookAt); ALGORITHM_PARAMETER_DECL(CameraRotation); + ALGORITHM_PARAMETER_DECL(HorizontalToolBarPositionDefault); + ALGORITHM_PARAMETER_DECL(VerticalToolBarPositionDefault); // save/load has issues. ALGORITHM_PARAMETER_DECL(HeadLightOn); From bbc35570eb0608ab0ee609ca1ddc9cc2c5e7e6d7 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Tue, 31 May 2022 12:10:08 -0600 Subject: [PATCH 16/36] Update ViewScene.cc --- src/Interface/Modules/Render/ViewScene.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index a02b93e319..e0f3d9f05d 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -447,7 +447,7 @@ ViewSceneDialog::ViewSceneDialog(const std::string& name, ModuleStateHandle stat addToolBar(); setToolBarPositions(); glLayout->addWidget(impl_->mGLWidget, 1, 1); - + glLayout->update(); addLineEditManager(impl_->screenshotControls_->defaultScreenshotPath_, Parameters::ScreenshotDirectory); @@ -492,7 +492,7 @@ void ViewSceneDialog::showToolBarContextMenu(const QPoint& pos) QMenu contextMenu("Context menu", this); QAction switchPosition("Move toolbar"); contextMenu.addAction(&switchPosition); - connect(&switchPosition, &QAction::triggered, [this]() { qDebug() << "need to switch toolbar position"; }); + connect(&switchPosition, &QAction::triggered, []() { qDebug() << "need to switch toolbar position"; }); contextMenu.exec(mapToGlobal(pos)); } From 06688354dce8772c76b11c69ee7ebdb592dd86a4 Mon Sep 17 00:00:00 2001 From: Dan White Date: Tue, 31 May 2022 14:44:35 -0600 Subject: [PATCH 17/36] Update ViewScene.cc --- src/Interface/Modules/Render/ViewScene.cc | 44 +++++++++++++++++------ 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index e0f3d9f05d..048d3007a8 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -484,20 +484,43 @@ std::string ViewSceneDialog::toString(std::string prefix) const void ViewSceneDialog::showToolBarContextMenu(const QPoint& pos) { auto toolbar = qobject_cast(sender()); - if (toolbar) - { - qDebug() << toolbar << toolbar->orientation(); - qDebug() << glLayout << glLayout->itemAtPosition(0, 0)->widget() << glLayout->itemAtPosition(1, 0)->widget(); - } + QMenu contextMenu("Context menu", this); - QAction switchPosition("Move toolbar"); + QAction switchPosition("Switch toolbar"); contextMenu.addAction(&switchPosition); - connect(&switchPosition, &QAction::triggered, []() { qDebug() << "need to switch toolbar position"; }); - contextMenu.exec(mapToGlobal(pos)); + connect(&switchPosition, &QAction::triggered, [this, toolbar]() + { + if (toolbar) + { + if (toolbar->orientation() == Qt::Horizontal) + state_->setValue(Parameters::HorizontalToolBarPositionDefault, !state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool()); + else + state_->setValue(Parameters::VerticalToolBarPositionDefault, !state_->getValue(Parameters::VerticalToolBarPositionDefault).toBool()); + } + setToolBarPositions(); + }); + qDebug() << pos << mapToGlobal(pos); + auto actualPos = mapToGlobal(pos); + if (toolbar->orientation() == Qt::Horizontal && !state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool()) + { + actualPos += QPoint(0, size().height()); + } + else if (toolbar->orientation() == Qt::Vertical && !state_->getValue(Parameters::VerticalToolBarPositionDefault).toBool()) + { + actualPos += QPoint(size().width(), 0); + } + + + contextMenu.exec(actualPos); } void ViewSceneDialog::setToolBarPositions() { + glLayout->removeWidget(impl_->toolBar1_); + glLayout->removeWidget(impl_->toolBar2_); + disconnect(impl_->toolBar1_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); + disconnect(impl_->toolBar2_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); + if (state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool()) glLayout->addWidget(impl_->toolBar1_, 0, 0, 1, 2); else @@ -507,17 +530,18 @@ void ViewSceneDialog::setToolBarPositions() glLayout->addWidget(impl_->toolBar2_, 1, 0); else glLayout->addWidget(impl_->toolBar2_, 1, 2); + + connect(impl_->toolBar1_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); + connect(impl_->toolBar2_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); } void ViewSceneDialog::addToolBar() { impl_->toolBar1_ = new QToolBar(this); impl_->toolBar1_->setContextMenuPolicy(Qt::CustomContextMenu); - connect(impl_->toolBar1_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); WidgetStyleMixin::toolbarStyle(impl_->toolBar1_); impl_->toolBar2_ = new QToolBar(this); impl_->toolBar2_->setContextMenuPolicy(Qt::CustomContextMenu); - connect(impl_->toolBar2_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); impl_->toolBar2_->setOrientation(Qt::Vertical); WidgetStyleMixin::toolbarStyle(impl_->toolBar2_); From 51412239d58db1a7cccd3f719a2ed21e49e41816 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Tue, 31 May 2022 16:34:28 -0600 Subject: [PATCH 18/36] Change to buttons --- src/Interface/Modules/Render/ViewScene.cc | 63 +++++++++-------------- src/Interface/Modules/Render/ViewScene.h | 1 - 2 files changed, 25 insertions(+), 39 deletions(-) diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index 048d3007a8..e7d177e13b 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -223,6 +223,8 @@ namespace Gui { QPushButton* controlLock_ {nullptr}; QPushButton* autoViewButton_ {nullptr}; QPushButton* viewBarBtn_ {nullptr}; + QPushButton* toolBar1Position_ {nullptr}; + QPushButton* toolBar2Position_ {nullptr}; std::vector viewScenesToUpdate {}; @@ -481,45 +483,10 @@ std::string ViewSceneDialog::toString(std::string prefix) const return output; } -void ViewSceneDialog::showToolBarContextMenu(const QPoint& pos) -{ - auto toolbar = qobject_cast(sender()); - - QMenu contextMenu("Context menu", this); - QAction switchPosition("Switch toolbar"); - contextMenu.addAction(&switchPosition); - connect(&switchPosition, &QAction::triggered, [this, toolbar]() - { - if (toolbar) - { - if (toolbar->orientation() == Qt::Horizontal) - state_->setValue(Parameters::HorizontalToolBarPositionDefault, !state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool()); - else - state_->setValue(Parameters::VerticalToolBarPositionDefault, !state_->getValue(Parameters::VerticalToolBarPositionDefault).toBool()); - } - setToolBarPositions(); - }); - qDebug() << pos << mapToGlobal(pos); - auto actualPos = mapToGlobal(pos); - if (toolbar->orientation() == Qt::Horizontal && !state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool()) - { - actualPos += QPoint(0, size().height()); - } - else if (toolbar->orientation() == Qt::Vertical && !state_->getValue(Parameters::VerticalToolBarPositionDefault).toBool()) - { - actualPos += QPoint(size().width(), 0); - } - - - contextMenu.exec(actualPos); -} - void ViewSceneDialog::setToolBarPositions() { glLayout->removeWidget(impl_->toolBar1_); glLayout->removeWidget(impl_->toolBar2_); - disconnect(impl_->toolBar1_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); - disconnect(impl_->toolBar2_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); if (state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool()) glLayout->addWidget(impl_->toolBar1_, 0, 0, 1, 2); @@ -530,9 +497,6 @@ void ViewSceneDialog::setToolBarPositions() glLayout->addWidget(impl_->toolBar2_, 1, 0); else glLayout->addWidget(impl_->toolBar2_, 1, 2); - - connect(impl_->toolBar1_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); - connect(impl_->toolBar2_, &QWidget::customContextMenuRequested, this, &ViewSceneDialog::showToolBarContextMenu); } void ViewSceneDialog::addToolBar() @@ -563,6 +527,29 @@ void ViewSceneDialog::addToolBar() addViewBarButton(); addControlLockButton(); + { + impl_->toolBar1Position_ = new QPushButton(); + impl_->toolBar1Position_->setToolTip("Switch toolbar 1 position"); + impl_->toolBar1Position_->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowDown)); + addToolbarButton(impl_->toolBar1Position_, 1); + connect(impl_->toolBar1Position_, &QPushButton::clicked, [this]() + { + state_->setValue(Parameters::HorizontalToolBarPositionDefault, !state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool()); + setToolBarPositions(); + }); + } + { + impl_->toolBar2Position_ = new QPushButton(); + impl_->toolBar2Position_->setToolTip("Switch toolbar 2 position"); + impl_->toolBar2Position_->setIcon(QApplication::style()->standardIcon(QStyle::SP_ArrowRight)); + addToolbarButton(impl_->toolBar2Position_, 2); + connect(impl_->toolBar2Position_, &QPushButton::clicked, [this]() + { + state_->setValue(Parameters::VerticalToolBarPositionDefault, !state_->getValue(Parameters::VerticalToolBarPositionDefault).toBool()); + setToolBarPositions(); + }); + } + impl_->statusLabel_ = new QLabel(""); impl_->toolBar1_->addWidget(impl_->statusLabel_); } diff --git a/src/Interface/Modules/Render/ViewScene.h b/src/Interface/Modules/Render/ViewScene.h index 47bfa2ead2..0e7c9e79b6 100644 --- a/src/Interface/Modules/Render/ViewScene.h +++ b/src/Interface/Modules/Render/ViewScene.h @@ -190,7 +190,6 @@ namespace SCIRun { void quickScreenshot(); void quickScreenshotClicked() { quickScreenshot(); } void setScreenshotDirectory(); - void showToolBarContextMenu(const QPoint& pos); void setToolBarPositions(); protected: From 72629f46d50302d40a0512004cf57e110564f1d1 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Tue, 31 May 2022 16:42:12 -0600 Subject: [PATCH 19/36] Buttons working nicely --- src/Interface/Modules/Render/ViewScene.cc | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index e7d177e13b..c87bdc0806 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -494,9 +494,17 @@ void ViewSceneDialog::setToolBarPositions() glLayout->addWidget(impl_->toolBar1_, 2, 0, 1, 2); if (state_->getValue(Parameters::VerticalToolBarPositionDefault).toBool()) + { + glLayout->removeWidget(impl_->mGLWidget); + glLayout->addWidget(impl_->mGLWidget, 1, 1); glLayout->addWidget(impl_->toolBar2_, 1, 0); + } else - glLayout->addWidget(impl_->toolBar2_, 1, 2); + { + glLayout->removeWidget(impl_->mGLWidget); + glLayout->addWidget(impl_->mGLWidget, 1, 0); + glLayout->addWidget(impl_->toolBar2_, 1, 1); + } } void ViewSceneDialog::addToolBar() @@ -535,6 +543,11 @@ void ViewSceneDialog::addToolBar() connect(impl_->toolBar1Position_, &QPushButton::clicked, [this]() { state_->setValue(Parameters::HorizontalToolBarPositionDefault, !state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool()); + impl_->toolBar1Position_->setIcon( + state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool() ? + QApplication::style()->standardIcon(QStyle::SP_ArrowDown) : + QApplication::style()->standardIcon(QStyle::SP_ArrowUp) + ); setToolBarPositions(); }); } @@ -546,6 +559,11 @@ void ViewSceneDialog::addToolBar() connect(impl_->toolBar2Position_, &QPushButton::clicked, [this]() { state_->setValue(Parameters::VerticalToolBarPositionDefault, !state_->getValue(Parameters::VerticalToolBarPositionDefault).toBool()); + impl_->toolBar2Position_->setIcon( + state_->getValue(Parameters::VerticalToolBarPositionDefault).toBool() ? + QApplication::style()->standardIcon(QStyle::SP_ArrowRight) : + QApplication::style()->standardIcon(QStyle::SP_ArrowLeft) + ); setToolBarPositions(); }); } From 54b7089d294f1c10adc9f7396fadf0c7e4821694 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Tue, 31 May 2022 21:29:05 -0600 Subject: [PATCH 20/36] Continue popup placement --- src/Interface/Modules/Render/ViewScene.cc | 54 ++++++++++++++--------- src/Interface/Modules/Render/ViewScene.h | 3 ++ 2 files changed, 37 insertions(+), 20 deletions(-) diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index c87bdc0806..11c0d21ef2 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -434,6 +434,12 @@ ViewSceneDialog::ViewSceneDialog(const std::string& name, ModuleStateHandle stat state->connectSpecificStateChanged(Parameters::CameraDistance,[this](){Q_EMIT cameraDistanceChangeForwarder();}); connect(this, &ViewSceneDialog::cameraDistanceChangeForwarder, this, &ViewSceneDialog::pullCameraDistance); + state->connectSpecificStateChanged(Parameters::HorizontalToolBarPositionDefault, + [this]() {Q_EMIT horizontalToolBarPopupChanged(state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool());}); + + state->connectSpecificStateChanged(Parameters::VerticalToolBarPositionDefault, + [this]() {Q_EMIT verticalToolBarPopupChanged(state_->getValue(Parameters::VerticalToolBarPositionDefault).toBool());}); + lockMutex(); const std::string filesystemRoot = Application::Instance().executablePath().string(); @@ -572,28 +578,36 @@ void ViewSceneDialog::addToolBar() impl_->toolBar1_->addWidget(impl_->statusLabel_); } -namespace -{ - void setupPopupWidget(QPushButton* button, ViewSceneControlPopupWidget* underlyingWidget, int which) - { - auto* popup = new ctkPopupWidget(button); - auto* popupLayout = new QVBoxLayout(popup); - const auto dir = which == 1 ? ctkBasePopupWidget::VerticalDirection::BottomToTop - : ctkBasePopupWidget::VerticalDirection::TopToBottom; - const auto alignment = which == 1 ? Qt::AlignTop | Qt::AlignHCenter : Qt::AlignLeft | Qt::AlignVCenter; - const auto orientation = which == 1 ? Qt::Vertical : Qt::Horizontal; - popup->setAlignment(alignment); - popup->setOrientation(orientation); - popup->setVerticalDirection(dir); - popup->setHorizontalDirection(Qt::LayoutDirectionAuto); // open outside the parent - popup->setShowDelay(500); - popup->setHideDelay(20); - QObject::connect(underlyingWidget->pinToggleAction(), &QAction::toggled, popup, &ctkPopupWidget::pinPopup); - popupLayout->addWidget(underlyingWidget); - popupLayout->setContentsMargins(4,4,4,4); - } +void ViewSceneDialog::setupPopupWidget(QPushButton* button, ViewSceneControlPopupWidget* underlyingWidget, int which) +{ + auto* popup = new ctkPopupWidget(button); + auto* popupLayout = new QVBoxLayout(popup); + const bool isHorizontalBar = which == 1; + const auto dir = isHorizontalBar ? ctkBasePopupWidget::VerticalDirection::BottomToTop + : ctkBasePopupWidget::VerticalDirection::TopToBottom; + + const auto alignment = isHorizontalBar ? Qt::AlignTop | Qt::AlignHCenter : Qt::AlignLeft | Qt::AlignVCenter; + const auto orientation = isHorizontalBar ? Qt::Vertical : Qt::Horizontal; + popup->setAlignment(alignment); + popup->setOrientation(orientation); + popup->setVerticalDirection(dir); + popup->setHorizontalDirection(Qt::LayoutDirectionAuto); // open outside the parent + popup->setShowDelay(500); + popup->setHideDelay(20); + QObject::connect(underlyingWidget->pinToggleAction(), &QAction::toggled, popup, &ctkPopupWidget::pinPopup); + if (isHorizontalBar) + connect(this, &ViewSceneDialog::horizontalToolBarPopupChanged, [popup](bool isDef) + { + popup->setAlignment(isDef ? Qt::AlignTop | Qt::AlignHCenter : Qt::AlignBottom | Qt::AlignHCenter); + qDebug() << "horiz popup change" << popup->alignment(); + }); + else + connect(this, &ViewSceneDialog::verticalToolBarPopupChanged, [popup](bool isDef) { popup->setAlignment(isDef ? Qt::AlignLeft | Qt::AlignVCenter : Qt::AlignRight | Qt::AlignVCenter);}); + popupLayout->addWidget(underlyingWidget); + popupLayout->setContentsMargins(4,4,4,4); } + void ViewSceneDialog::addConfigurationButton() { auto* configurationButton = new QPushButton(); diff --git a/src/Interface/Modules/Render/ViewScene.h b/src/Interface/Modules/Render/ViewScene.h index 0e7c9e79b6..9101323776 100644 --- a/src/Interface/Modules/Render/ViewScene.h +++ b/src/Interface/Modules/Render/ViewScene.h @@ -89,6 +89,8 @@ namespace SCIRun { void cameraDistanceChangeForwarder(); void lockMutexForwarder(); void mousePressSignalForGeometryObjectFeedback(int x, int y, const std::string& selName); + void horizontalToolBarPopupChanged(bool state); + void verticalToolBarPopupChanged(bool state); public Q_SLOTS: void printToString() const {std::cout << toString("");} @@ -250,6 +252,7 @@ namespace SCIRun { bool clickedInViewer(QMouseEvent* e) const; void initializeAxes(); void initializeVisibleObjects(); + void setupPopupWidget(QPushButton* button, ViewSceneControlPopupWidget* underlyingWidget, int which); //---------------- Widgets ------------------------------------------------------------------- bool needToWaitForWidgetSelection(); From 1f58b4919bd050c6c557037071edf49b2cabf97d Mon Sep 17 00:00:00 2001 From: Daniel White Date: Wed, 1 Jun 2022 09:36:47 -0600 Subject: [PATCH 21/36] Relative popup positioning works --- src/Interface/Modules/Render/ViewScene.cc | 12 +++++++++--- .../Modules/Render/ViewSceneControlsDock.cc | 4 +++- src/Interface/Modules/Render/ViewSceneControlsDock.h | 2 ++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index 11c0d21ef2..fec55852bb 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -594,15 +594,21 @@ void ViewSceneDialog::setupPopupWidget(QPushButton* button, ViewSceneControlPopu popup->setHorizontalDirection(Qt::LayoutDirectionAuto); // open outside the parent popup->setShowDelay(500); popup->setHideDelay(20); - QObject::connect(underlyingWidget->pinToggleAction(), &QAction::toggled, popup, &ctkPopupWidget::pinPopup); + connect(underlyingWidget->pinToggleAction(), &QAction::toggled, popup, &ctkPopupWidget::pinPopup); + connect(underlyingWidget->closeAction(), &QAction::triggered, popup, &QWidget::close); if (isHorizontalBar) connect(this, &ViewSceneDialog::horizontalToolBarPopupChanged, [popup](bool isDef) { popup->setAlignment(isDef ? Qt::AlignTop | Qt::AlignHCenter : Qt::AlignBottom | Qt::AlignHCenter); - qDebug() << "horiz popup change" << popup->alignment(); + popup->setVerticalDirection(isDef ? ctkBasePopupWidget::VerticalDirection::BottomToTop + : ctkBasePopupWidget::VerticalDirection::TopToBottom); }); else - connect(this, &ViewSceneDialog::verticalToolBarPopupChanged, [popup](bool isDef) { popup->setAlignment(isDef ? Qt::AlignLeft | Qt::AlignVCenter : Qt::AlignRight | Qt::AlignVCenter);}); + connect(this, &ViewSceneDialog::verticalToolBarPopupChanged, [popup](bool isDef) + { + popup->setAlignment(isDef ? Qt::AlignLeft | Qt::AlignVCenter : Qt::AlignRight | Qt::AlignVCenter); + popup->setHorizontalDirection(isDef ? Qt::LayoutDirectionAuto : Qt::LeftToRight); + }); popupLayout->addWidget(underlyingWidget); popupLayout->setContentsMargins(4,4,4,4); } diff --git a/src/Interface/Modules/Render/ViewSceneControlsDock.cc b/src/Interface/Modules/Render/ViewSceneControlsDock.cc index e121752862..3d4f05e6bf 100644 --- a/src/Interface/Modules/Render/ViewSceneControlsDock.cc +++ b/src/Interface/Modules/Render/ViewSceneControlsDock.cc @@ -869,11 +869,13 @@ ViewSceneControlPopupWidget::ViewSceneControlPopupWidget(ViewSceneDialog* parent connect(this, &QWidget::customContextMenuRequested, this, &ViewSceneControlPopupWidget::showContextMenu); pinToggleAction_ = new QAction("Pin popup", this); pinToggleAction_->setCheckable(true); + closeAction_ = new QAction("Close popup", this); } void ViewSceneControlPopupWidget::showContextMenu(const QPoint& pos) { QMenu contextMenu(tr("Context menu"), this); contextMenu.addAction(pinToggleAction_); + contextMenu.addAction(closeAction_); contextMenu.exec(mapToGlobal(pos)); -} \ No newline at end of file +} diff --git a/src/Interface/Modules/Render/ViewSceneControlsDock.h b/src/Interface/Modules/Render/ViewSceneControlsDock.h index 938b8500b2..3cf59242b4 100644 --- a/src/Interface/Modules/Render/ViewSceneControlsDock.h +++ b/src/Interface/Modules/Render/ViewSceneControlsDock.h @@ -93,10 +93,12 @@ namespace Gui { public: explicit ViewSceneControlPopupWidget(ViewSceneDialog* parent); QAction* pinToggleAction() { return pinToggleAction_; } + QAction* closeAction() { return closeAction_; } private Q_SLOTS: void showContextMenu(const QPoint& pos); private: QAction* pinToggleAction_{ nullptr }; + QAction* closeAction_{ nullptr }; }; class SCISHARE AutoRotateControls : public ViewSceneControlPopupWidget, public Ui::AutoRotateSettings From 9e8e5ed0c99652061e7a4d21be8adfcba21996f6 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Wed, 1 Jun 2022 10:49:13 -0600 Subject: [PATCH 22/36] Hotkey for auto-rotate pref --- src/Interface/Application/SCIRunMainWindow.cc | 3 +++ src/Interface/Application/SCIRunMainWindow.ui | 13 ++++++++++++- src/Interface/Modules/Render/ViewScene.cc | 1 - 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/src/Interface/Application/SCIRunMainWindow.cc b/src/Interface/Application/SCIRunMainWindow.cc index 88f7c40383..14683914c8 100644 --- a/src/Interface/Application/SCIRunMainWindow.cc +++ b/src/Interface/Application/SCIRunMainWindow.cc @@ -336,6 +336,9 @@ SCIRunMainWindow::SCIRunMainWindow() actionTagManager_->setChecked(!tagManagerWindow_->isHidden()); + connect(actionAutoRotateViewScene_, &QAction::triggered, prefsWindow_->autoRotateViewerOnMouseReleaseCheckbox_, &QCheckBox::toggle); + connect(actionAutoRotateViewScene_, &QAction::triggered, [this]() { showStatusMessage(QString("ViewScene auto-rotate toggled."), 3000); }); + moduleSelectorDockWidget_->setStyleSheet("QDockWidget {background: rgb(66,66,69); background-color: rgb(66,66,69) }" "QToolTip { color: #ffffff; background - color: #2a82da; border: 1px solid white; }" "QHeaderView::section { background: rgb(66,66,69);} " diff --git a/src/Interface/Application/SCIRunMainWindow.ui b/src/Interface/Application/SCIRunMainWindow.ui index b698c6cb89..635a4a01e8 100644 --- a/src/Interface/Application/SCIRunMainWindow.ui +++ b/src/Interface/Application/SCIRunMainWindow.ui @@ -119,6 +119,7 @@ + @@ -442,7 +443,6 @@ - 75 true true @@ -1347,6 +1347,17 @@ Clear frequent modules + + + Toggle Auto-rotate ViewScene + + + Toggle auto-rotate ViewScene + + + Meta+Ctrl+Alt+R + + diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index fec55852bb..24936ceb4d 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -613,7 +613,6 @@ void ViewSceneDialog::setupPopupWidget(QPushButton* button, ViewSceneControlPopu popupLayout->setContentsMargins(4,4,4,4); } - void ViewSceneDialog::addConfigurationButton() { auto* configurationButton = new QPushButton(); From 8a1285e1998f9b5e8449b7f0bd21052a2b388490 Mon Sep 17 00:00:00 2001 From: Dan White Date: Wed, 1 Jun 2022 15:46:58 -0600 Subject: [PATCH 23/36] Fix windows package --- src/CMakeLists.txt | 4 ++++ src/Externals/pugixml/CMakeLists.txt | 2 +- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 0c539005e7..3efa2a070c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -752,6 +752,9 @@ SET_PROPERTY(TARGET Modules_Factory PROPERTY FOLDER "Modules") SET_PROPERTY(TARGET Graphics_Glyphs PROPERTY FOLDER "Graphics") SET_PROPERTY(TARGET Graphics_Widgets PROPERTY FOLDER "Graphics") SET_PROPERTY(TARGET Graphics_Datatypes PROPERTY FOLDER "Graphics") +SET_PROPERTY(TARGET spire PROPERTY FOLDER "Graphics") + +SET_PROPERTY(TARGET pugixml PROPERTY FOLDER "Externals") IF(BUILD_TESTING) SET_PROPERTY(TARGET gmock PROPERTY FOLDER "Testing Support") @@ -796,6 +799,7 @@ IF(BUILD_TESTING) SET_PROPERTY(TARGET Core_ImportExport_Tests PROPERTY FOLDER "Core/Tests") SET_PROPERTY(TARGET Core_IEPlugin_Tests PROPERTY FOLDER "Core/Tests") SET_PROPERTY(TARGET Graphics_Widgets_Tests PROPERTY FOLDER "Graphics/Tests") + SET_PROPERTY(TARGET Graphics_Datatypes_Tests PROPERTY FOLDER "Graphics/Tests") SET_PROPERTY(TARGET Engine_Network_Tests PROPERTY FOLDER "Dataflow/Engine/Tests") SET_PROPERTY(TARGET Engine_Scheduler_Tests PROPERTY FOLDER "Dataflow/Engine/Tests") diff --git a/src/Externals/pugixml/CMakeLists.txt b/src/Externals/pugixml/CMakeLists.txt index 4c882f4da7..96ef532bda 100644 --- a/src/Externals/pugixml/CMakeLists.txt +++ b/src/Externals/pugixml/CMakeLists.txt @@ -57,7 +57,7 @@ set(PUGIXML_PUBLIC_DEFINITIONS $<$:PUGIXML_NO_EXCEPTIONS>) if (BUILD_SHARED_LIBS) - add_library(pugixml SHARED + SCIRUN_ADD_LIBRARY(pugixml SHARED #${PROJECT_SOURCE_DIR}/scripts/pugixml_dll.rc ${PROJECT_SOURCE_DIR}/pugixml.cpp) endif() From 077499425713d47b3390f53a01c957364af7e557 Mon Sep 17 00:00:00 2001 From: Dan White Date: Wed, 1 Jun 2022 18:07:09 -0600 Subject: [PATCH 24/36] enable/disable connections not modules --- src/Dataflow/Engine/Controller/PythonImpl.cc | 13 +++++++++++++ src/Dataflow/Engine/Controller/PythonImpl.h | 1 + .../Engine/Python/NetworkEditorPythonAPI.cc | 18 ++++-------------- .../Engine/Python/NetworkEditorPythonAPI.h | 4 ++-- .../Python/NetworkEditorPythonInterface.h | 1 + .../Engine/Python/SCIRunPythonModule.h | 4 ++-- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/Dataflow/Engine/Controller/PythonImpl.cc b/src/Dataflow/Engine/Controller/PythonImpl.cc index 09bbca441d..4d5177c525 100644 --- a/src/Dataflow/Engine/Controller/PythonImpl.cc +++ b/src/Dataflow/Engine/Controller/PythonImpl.cc @@ -623,6 +623,19 @@ std::string PythonImpl::disconnect(const std::string& moduleIdFrom, int fromInde } } +std::string PythonImpl::setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable) +{ + auto id = impl_->connectionIdLookup_[moduleIdFrom][fromIndex][moduleIdTo][toIndex]; + if (!id.empty()) + { + return "setConnectionStatus" + std::to_string(enable); + } + else + { + return "Connection not found"; + } +} + std::string PythonImpl::saveNetwork(const std::string& filename) { auto save = cmdFactory_->create(GlobalCommands::SaveNetworkFile); diff --git a/src/Dataflow/Engine/Controller/PythonImpl.h b/src/Dataflow/Engine/Controller/PythonImpl.h index 05f25c2d00..ae196cf385 100644 --- a/src/Dataflow/Engine/Controller/PythonImpl.h +++ b/src/Dataflow/Engine/Controller/PythonImpl.h @@ -64,6 +64,7 @@ namespace Engine { std::string importNetwork(const std::string& filename) override; std::string runScript(const std::string& filename) override; std::string quit(bool force) override; + std::string setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable) override; void setUnlockFunc(boost::function unlock) override; void setModuleContext(bool inModule) override { inModule_ = inModule; } bool isModuleContext() const override { return inModule_; } diff --git a/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.cc b/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.cc index 16b928a2c3..d9bb8d26a5 100644 --- a/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.cc +++ b/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.cc @@ -483,24 +483,14 @@ boost::python::object NetworkEditorPythonAPI::scirun_get_module_input_value(cons return {}; } -std::string NetworkEditorPythonAPI::scirun_enable_module(const std::string& moduleId) +std::string NetworkEditorPythonAPI::scirun_enable_connection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) { - auto module = impl_->findModule(moduleId); - if (module) - { - module->setEnabled(true); - } - return "TODO: " + moduleId + " enabled."; + return impl_->setConnectionStatus(moduleIdFrom, fromIndex, moduleIdTo, toIndex, true); } -std::string NetworkEditorPythonAPI::scirun_disable_module(const std::string& moduleId) +std::string NetworkEditorPythonAPI::scirun_disable_connection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) { - auto module = impl_->findModule(moduleId); - if (module) - { - module->setEnabled(false); - } - return "TODO: " + moduleId + " disabled."; + return impl_->setConnectionStatus(moduleIdFrom, fromIndex, moduleIdTo, toIndex, false); } boost::python::object SimplePythonAPI::scirun_module_ids() diff --git a/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.h b/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.h index 1f871cefd0..3adf09aa5a 100644 --- a/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.h +++ b/src/Dataflow/Engine/Python/NetworkEditorPythonAPI.h @@ -72,8 +72,8 @@ namespace SCIRun { static boost::python::dict get_output_data(const std::string& moduleId); static std::string set_output_data(const std::string& moduleId, const boost::python::dict& outputMap); - static std::string scirun_enable_module(const std::string& moduleId); - static std::string scirun_disable_module(const std::string& moduleId); + static std::string scirun_enable_connection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex); + static std::string scirun_disable_connection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex); static std::string executeAll(); static std::string saveNetwork(const std::string& filename); diff --git a/src/Dataflow/Engine/Python/NetworkEditorPythonInterface.h b/src/Dataflow/Engine/Python/NetworkEditorPythonInterface.h index a04cd3a9b8..15346ae92a 100644 --- a/src/Dataflow/Engine/Python/NetworkEditorPythonInterface.h +++ b/src/Dataflow/Engine/Python/NetworkEditorPythonInterface.h @@ -131,6 +131,7 @@ namespace SCIRun virtual SharedPointer findModule(const std::string& id) const = 0; virtual std::string connect(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) = 0; virtual std::string disconnect(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) = 0; + virtual std::string setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable) = 0; virtual std::string executeAll() = 0; virtual std::string saveNetwork(const std::string& filename) = 0; virtual std::string loadNetwork(const std::string& filename) = 0; diff --git a/src/Dataflow/Engine/Python/SCIRunPythonModule.h b/src/Dataflow/Engine/Python/SCIRunPythonModule.h index 886a9574b2..ae43818c43 100644 --- a/src/Dataflow/Engine/Python/SCIRunPythonModule.h +++ b/src/Dataflow/Engine/Python/SCIRunPythonModule.h @@ -100,8 +100,8 @@ BOOST_PYTHON_MODULE(SCIRunPythonAPI) boost::python::def("get_output_data", &NetworkEditorPythonAPI::get_output_data); boost::python::def("set_output_data", &NetworkEditorPythonAPI::set_output_data); - boost::python::def("scirun_enable_module", &NetworkEditorPythonAPI::scirun_enable_module); - boost::python::def("scirun_disable_module", &NetworkEditorPythonAPI::scirun_disable_module); + boost::python::def("scirun_enable_connection", &NetworkEditorPythonAPI::scirun_enable_connection); + boost::python::def("scirun_disable_connection", &NetworkEditorPythonAPI::scirun_disable_connection); boost::python::def("scirun_save_network", &NetworkEditorPythonAPI::saveNetwork); boost::python::def("scirun_load_network", &NetworkEditorPythonAPI::loadNetwork); From 48d8730dee59e782991701093e414f732ad9ef6d Mon Sep 17 00:00:00 2001 From: Dan White Date: Wed, 1 Jun 2022 22:22:53 -0600 Subject: [PATCH 25/36] New NEC method --- src/Dataflow/Engine/Controller/PythonImpl.cc | 1 + src/Dataflow/Network/Network.cc | 2 +- src/Dataflow/Network/Network.h | 2 +- src/Dataflow/Network/NetworkInterface.h | 2 +- src/Dataflow/Network/Tests/MockNetwork.h | 2 +- 5 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/Dataflow/Engine/Controller/PythonImpl.cc b/src/Dataflow/Engine/Controller/PythonImpl.cc index 4d5177c525..82ba08effe 100644 --- a/src/Dataflow/Engine/Controller/PythonImpl.cc +++ b/src/Dataflow/Engine/Controller/PythonImpl.cc @@ -628,6 +628,7 @@ std::string PythonImpl::setConnectionStatus(const std::string& moduleIdFrom, int auto id = impl_->connectionIdLookup_[moduleIdFrom][fromIndex][moduleIdTo][toIndex]; if (!id.empty()) { + nec_.getNetwork()->setConnectionStatus(id, enable); return "setConnectionStatus" + std::to_string(enable); } else diff --git a/src/Dataflow/Network/Network.cc b/src/Dataflow/Network/Network.cc index 339b594dd7..ee5b0fc236 100644 --- a/src/Dataflow/Network/Network.cc +++ b/src/Dataflow/Network/Network.cc @@ -140,7 +140,7 @@ bool Network::disconnect(const ConnectionId& id) return false; } -void Network::disable_connection(const ConnectionId&) +void Network::setConnectionStatus(const ConnectionId& cid, bool status) { /// @todo } diff --git a/src/Dataflow/Network/Network.h b/src/Dataflow/Network/Network.h index 6fe4cac61f..36c32c377d 100644 --- a/src/Dataflow/Network/Network.h +++ b/src/Dataflow/Network/Network.h @@ -61,7 +61,7 @@ namespace Networks { ConnectionId connect(const ConnectionOutputPort&, const ConnectionInputPort&) override; bool disconnect(const ConnectionId&) override; size_t nconnections() const override; - void disable_connection(const ConnectionId&) override; + void setConnectionStatus(const ConnectionId& cid, bool status) override; ConnectionDescriptionList connections(bool includeVirtual) const override; int errorCode() const override; void incrementErrorCode(const ModuleId& moduleId) override; diff --git a/src/Dataflow/Network/NetworkInterface.h b/src/Dataflow/Network/NetworkInterface.h index dbd7f2bbd4..0113a8bb6a 100644 --- a/src/Dataflow/Network/NetworkInterface.h +++ b/src/Dataflow/Network/NetworkInterface.h @@ -88,7 +88,7 @@ namespace Networks { virtual ConnectionId connect(const ConnectionOutputPort&, const ConnectionInputPort&) = 0; virtual bool disconnect(const ConnectionId&) = 0; virtual size_t nconnections() const = 0; - virtual void disable_connection(const ConnectionId&) = 0; + virtual void setConnectionStatus(const ConnectionId& cid, bool status) = 0; virtual ConnectionDescriptionList connections(bool includeVirtual) const = 0; virtual void incrementErrorCode(const ModuleId& moduleId) = 0; virtual NetworkGlobalSettings& settings() = 0; diff --git a/src/Dataflow/Network/Tests/MockNetwork.h b/src/Dataflow/Network/Tests/MockNetwork.h index 298656f1e5..80c2ba40b2 100644 --- a/src/Dataflow/Network/Tests/MockNetwork.h +++ b/src/Dataflow/Network/Tests/MockNetwork.h @@ -52,7 +52,6 @@ namespace SCIRun { MOCK_METHOD2(connect, ConnectionId(const ConnectionOutputPort&, const ConnectionInputPort&)); MOCK_METHOD1(disconnect, bool(const ConnectionId&)); MOCK_CONST_METHOD0(nconnections, size_t()); - MOCK_METHOD1(disable_connection, void(const ConnectionId&)); MOCK_CONST_METHOD0(toString, std::string()); MOCK_CONST_METHOD1(connections, ConnectionDescriptionList(bool)); MOCK_CONST_METHOD0(errorCode, int()); @@ -63,6 +62,7 @@ namespace SCIRun { MOCK_CONST_METHOD0(moduleExecutionStates, std::vector()); MOCK_METHOD0(clear, void()); MOCK_CONST_METHOD0(containsViewScene, bool()); + MOCK_METHOD2(setConnectionStatus, void(const ConnectionId&, bool)); }; typedef SharedPointer MockNetworkPtr; From fa0f67f6c2eed4dec5b584975978ae3dcf422890 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Thu, 2 Jun 2022 11:38:02 -0600 Subject: [PATCH 26/36] Update Network.cc --- src/Dataflow/Network/Network.cc | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Dataflow/Network/Network.cc b/src/Dataflow/Network/Network.cc index ee5b0fc236..5317cb79ac 100644 --- a/src/Dataflow/Network/Network.cc +++ b/src/Dataflow/Network/Network.cc @@ -142,6 +142,8 @@ bool Network::disconnect(const ConnectionId& id) void Network::setConnectionStatus(const ConnectionId& cid, bool status) { + (void)cid; + (void)status; /// @todo } From 23bfc7a7eb77ec6e8a443ca736d39cd84dc5a588 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Thu, 2 Jun 2022 22:26:17 -0600 Subject: [PATCH 27/36] Working on connection access --- src/Dataflow/Engine/Controller/PythonImpl.cc | 49 ++++++++------------ src/Dataflow/Engine/Controller/PythonImpl.h | 1 - src/Dataflow/Network/Network.cc | 10 ++-- src/Dataflow/Network/Network.h | 2 +- src/Dataflow/Network/NetworkInterface.h | 2 +- src/Dataflow/Network/Tests/MockNetwork.h | 2 +- 6 files changed, 28 insertions(+), 38 deletions(-) diff --git a/src/Dataflow/Engine/Controller/PythonImpl.cc b/src/Dataflow/Engine/Controller/PythonImpl.cc index 82ba08effe..bc7d3096a1 100644 --- a/src/Dataflow/Engine/Controller/PythonImpl.cc +++ b/src/Dataflow/Engine/Controller/PythonImpl.cc @@ -36,6 +36,7 @@ #include #include #include +#include #include #include #include @@ -492,19 +493,8 @@ namespace }; } -namespace SCIRun { - namespace Dataflow { - namespace Engine { - class PythonImplImpl - { - public: - std::map>>> connectionIdLookup_; - }; - } - } -} - -PythonImpl::PythonImpl(NetworkEditorController& nec, GlobalCommandFactoryHandle cmdFactory) : impl_(new PythonImplImpl), nec_(nec), cmdFactory_(cmdFactory) +PythonImpl::PythonImpl(NetworkEditorController& nec, GlobalCommandFactoryHandle cmdFactory) : + nec_(nec), cmdFactory_(cmdFactory) { connections_.push_back(nec_.connectStaticNetworkExecutionFinished([this](int) { executionFromPythonFinish(0); })); connections_.push_back(nec_.connectModuleAdded([this](const std::string& id, ModuleHandle m, ModuleCounter mc) { pythonModuleAddedSlot(id, m, mc); })); @@ -600,36 +590,35 @@ std::string PythonImpl::connect(const std::string& moduleIdFrom, int fromIndex, auto modTo = network->lookupModule(ModuleId(moduleIdTo)); auto inputPort = modTo->inputPorts().at(toIndex); auto id = nec_.requestConnection(outputPort.get(), inputPort.get()); - if (id) - { - impl_->connectionIdLookup_[moduleIdFrom][fromIndex][moduleIdTo][toIndex] = id->id_; - } - return "PythonImpl::connect success"; } std::string PythonImpl::disconnect(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) { + (void)moduleIdFrom; + (void)fromIndex; + (void)moduleIdTo; + (void)toIndex; //TODO: doesn't work at all since there is no GUI connection to this network change event. Issue is #... - auto id = impl_->connectionIdLookup_[moduleIdFrom][fromIndex][moduleIdTo][toIndex]; - if (!id.empty()) + //auto id = impl_->connectionIdLookup_[moduleIdFrom][fromIndex][moduleIdTo][toIndex]; + //if (!id.empty()) { - nec_.removeConnection(id); + //nec_.removeConnection(id); return "PythonImpl::disconnect IS NOT IMPLEMENTED"; } - else - { - return "PythonImpl::disconnect: connection not found"; - } + // else + // { + // return "PythonImpl::disconnect: connection not found"; + // } } -std::string PythonImpl::setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable) +std::string PythonImpl::setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable) { - auto id = impl_->connectionIdLookup_[moduleIdFrom][fromIndex][moduleIdTo][toIndex]; - if (!id.empty()) + auto conn = nec_.getNetwork()->lookupConnection(moduleIdFrom, fromIndex, moduleIdTo, toIndex); + if (conn) { - nec_.getNetwork()->setConnectionStatus(id, enable); - return "setConnectionStatus" + std::to_string(enable); + conn->setDisable(!enable); + return "setConnectionStatus " + std::to_string(enable); } else { diff --git a/src/Dataflow/Engine/Controller/PythonImpl.h b/src/Dataflow/Engine/Controller/PythonImpl.h index ae196cf385..3bc242b6e8 100644 --- a/src/Dataflow/Engine/Controller/PythonImpl.h +++ b/src/Dataflow/Engine/Controller/PythonImpl.h @@ -73,7 +73,6 @@ namespace Engine { void pythonModuleRemovedSlot(const Networks::ModuleId&); void executionFromPythonStart(); void executionFromPythonFinish(int); - SharedPointer impl_; std::map> modules_; NetworkEditorController& nec_; Core::Commands::GlobalCommandFactoryHandle cmdFactory_; diff --git a/src/Dataflow/Network/Network.cc b/src/Dataflow/Network/Network.cc index 5317cb79ac..a2eff053d0 100644 --- a/src/Dataflow/Network/Network.cc +++ b/src/Dataflow/Network/Network.cc @@ -140,11 +140,13 @@ bool Network::disconnect(const ConnectionId& id) return false; } -void Network::setConnectionStatus(const ConnectionId& cid, bool status) +ConnectionHandle Network::lookupConnection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) const { - (void)cid; - (void)status; - /// @todo + (void)moduleIdFrom; + (void)fromIndex; + (void)moduleIdTo; + (void)toIndex; + return {}; } size_t Network::nmodules() const diff --git a/src/Dataflow/Network/Network.h b/src/Dataflow/Network/Network.h index 36c32c377d..1342416b07 100644 --- a/src/Dataflow/Network/Network.h +++ b/src/Dataflow/Network/Network.h @@ -61,7 +61,7 @@ namespace Networks { ConnectionId connect(const ConnectionOutputPort&, const ConnectionInputPort&) override; bool disconnect(const ConnectionId&) override; size_t nconnections() const override; - void setConnectionStatus(const ConnectionId& cid, bool status) override; + ConnectionHandle lookupConnection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) const override; ConnectionDescriptionList connections(bool includeVirtual) const override; int errorCode() const override; void incrementErrorCode(const ModuleId& moduleId) override; diff --git a/src/Dataflow/Network/NetworkInterface.h b/src/Dataflow/Network/NetworkInterface.h index 0113a8bb6a..ce6cf25026 100644 --- a/src/Dataflow/Network/NetworkInterface.h +++ b/src/Dataflow/Network/NetworkInterface.h @@ -88,7 +88,7 @@ namespace Networks { virtual ConnectionId connect(const ConnectionOutputPort&, const ConnectionInputPort&) = 0; virtual bool disconnect(const ConnectionId&) = 0; virtual size_t nconnections() const = 0; - virtual void setConnectionStatus(const ConnectionId& cid, bool status) = 0; + virtual ConnectionHandle lookupConnection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) const = 0; virtual ConnectionDescriptionList connections(bool includeVirtual) const = 0; virtual void incrementErrorCode(const ModuleId& moduleId) = 0; virtual NetworkGlobalSettings& settings() = 0; diff --git a/src/Dataflow/Network/Tests/MockNetwork.h b/src/Dataflow/Network/Tests/MockNetwork.h index 80c2ba40b2..319114210f 100644 --- a/src/Dataflow/Network/Tests/MockNetwork.h +++ b/src/Dataflow/Network/Tests/MockNetwork.h @@ -51,6 +51,7 @@ namespace SCIRun { MOCK_CONST_METHOD1(lookupExecutable, ExecutableObject*(const ModuleId&)); MOCK_METHOD2(connect, ConnectionId(const ConnectionOutputPort&, const ConnectionInputPort&)); MOCK_METHOD1(disconnect, bool(const ConnectionId&)); + MOCK_CONST_METHOD4(lookupConnection, ConnectionHandle(const std::string&, int, const std::string&, int)); MOCK_CONST_METHOD0(nconnections, size_t()); MOCK_CONST_METHOD0(toString, std::string()); MOCK_CONST_METHOD1(connections, ConnectionDescriptionList(bool)); @@ -62,7 +63,6 @@ namespace SCIRun { MOCK_CONST_METHOD0(moduleExecutionStates, std::vector()); MOCK_METHOD0(clear, void()); MOCK_CONST_METHOD0(containsViewScene, bool()); - MOCK_METHOD2(setConnectionStatus, void(const ConnectionId&, bool)); }; typedef SharedPointer MockNetworkPtr; From 8a7b14562edb04c7e0244e87026afcbb3f5585ce Mon Sep 17 00:00:00 2001 From: Daniel White Date: Fri, 3 Jun 2022 16:35:13 -0600 Subject: [PATCH 28/36] Implement --- src/Dataflow/Engine/Controller/PythonImpl.cc | 14 +++++++------- src/Dataflow/Network/Network.cc | 18 +++++++++++++----- src/Dataflow/Network/Port.h | 1 - 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/src/Dataflow/Engine/Controller/PythonImpl.cc b/src/Dataflow/Engine/Controller/PythonImpl.cc index bc7d3096a1..05aebb84ac 100644 --- a/src/Dataflow/Engine/Controller/PythonImpl.cc +++ b/src/Dataflow/Engine/Controller/PythonImpl.cc @@ -600,16 +600,16 @@ std::string PythonImpl::disconnect(const std::string& moduleIdFrom, int fromInde (void)moduleIdTo; (void)toIndex; //TODO: doesn't work at all since there is no GUI connection to this network change event. Issue is #... - //auto id = impl_->connectionIdLookup_[moduleIdFrom][fromIndex][moduleIdTo][toIndex]; - //if (!id.empty()) + auto conn = nec_.getNetwork()->lookupConnection(moduleIdFrom, fromIndex, moduleIdTo, toIndex); + if (conn) { - //nec_.removeConnection(id); + nec_.removeConnection(conn->id()); return "PythonImpl::disconnect IS NOT IMPLEMENTED"; } - // else - // { - // return "PythonImpl::disconnect: connection not found"; - // } + else + { + return "PythonImpl::disconnect: connection not found"; + } } std::string PythonImpl::setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable) diff --git a/src/Dataflow/Network/Network.cc b/src/Dataflow/Network/Network.cc index a2eff053d0..08cdfe18cc 100644 --- a/src/Dataflow/Network/Network.cc +++ b/src/Dataflow/Network/Network.cc @@ -142,11 +142,19 @@ bool Network::disconnect(const ConnectionId& id) ConnectionHandle Network::lookupConnection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) const { - (void)moduleIdFrom; - (void)fromIndex; - (void)moduleIdTo; - (void)toIndex; - return {}; + const auto outputPortId = lookupModule(ModuleId(moduleIdFrom))->outputPorts()[fromIndex]->externalId(); + const auto inputPortId = lookupModule(ModuleId(moduleIdTo))->inputPorts()[toIndex]->externalId(); + + const ConnectionId id = ConnectionId::create(ConnectionDescription( + OutgoingConnectionDescription(ModuleId(moduleIdFrom), outputPortId), + IncomingConnectionDescription(ModuleId(moduleIdTo), inputPortId))); + const auto connIter = connections_.find(id); + if (connIter != connections_.end()) + { + return connIter->second; + } + + return nullptr; } size_t Network::nmodules() const diff --git a/src/Dataflow/Network/Port.h b/src/Dataflow/Network/Port.h index 4ef66a254c..948ef058f8 100644 --- a/src/Dataflow/Network/Port.h +++ b/src/Dataflow/Network/Port.h @@ -62,7 +62,6 @@ class SCISHARE Port : virtual public PortInterface, boost::noncopyable Connection* connection(size_t) const override; bool hasConnectionCountIncreased() const override; - PortId internalId() const override { return internalId_; } void setId_DynamicCase(const PortId& id) override { internalId_ = externalId_ = id; } void setInternalId(const PortId& id) override { internalId_ = id; } From 9dff96e3d95d389cc1978c0fdd3f96f887ccdcc5 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Fri, 3 Jun 2022 18:41:14 -0600 Subject: [PATCH 29/36] signal/slots almost hooked up --- .../Engine/Controller/ControllerInterfaces.h | 1 + .../Controller/NetworkEditorController.cc | 20 +++++++++++++++++++ .../Controller/NetworkEditorController.h | 5 +++-- src/Dataflow/Engine/Controller/PythonImpl.cc | 19 +++--------------- src/Interface/Application/Connection.cc | 8 ++++++++ .../NetworkEditorControllerGuiProxy.cc | 2 ++ .../NetworkEditorControllerGuiProxy.h | 1 + 7 files changed, 38 insertions(+), 18 deletions(-) diff --git a/src/Dataflow/Engine/Controller/ControllerInterfaces.h b/src/Dataflow/Engine/Controller/ControllerInterfaces.h index e4af8a44ad..e2012a71d2 100644 --- a/src/Dataflow/Engine/Controller/ControllerInterfaces.h +++ b/src/Dataflow/Engine/Controller/ControllerInterfaces.h @@ -80,6 +80,7 @@ namespace Engine { typedef boost::signals2::signal ConnectionAddedSignalType; typedef boost::signals2::signal InvalidConnectionSignalType; typedef boost::signals2::signal ConnectionRemovedSignalType; + typedef boost::signals2::signal ConnectionStatusChangedSignalType; typedef boost::signals2::signal PortAddedSignalType; typedef boost::signals2::signal PortRemovedSignalType; typedef boost::signals2::signal NetworkDoneLoadingSignalType; diff --git a/src/Dataflow/Engine/Controller/NetworkEditorController.cc b/src/Dataflow/Engine/Controller/NetworkEditorController.cc index 4650083af2..435f6468cb 100644 --- a/src/Dataflow/Engine/Controller/NetworkEditorController.cc +++ b/src/Dataflow/Engine/Controller/NetworkEditorController.cc @@ -524,6 +524,26 @@ boost::signals2::connection NetworkEditorController::connectNetworkDoneLoading(c return signals_.networkDoneLoading_.connect(subscriber); } +boost::signals2::connection NetworkEditorController::connectConnectionStatusChanged(const ConnectionStatusChangedSignalType::slot_type& subscriber) +{ + return signals_.connectionStatusChanged_.connect(subscriber); +} + +std::string NetworkEditorController::setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable) +{ + auto conn = getNetwork()->lookupConnection(moduleIdFrom, fromIndex, moduleIdTo, toIndex); + if (conn) + { + conn->setDisable(!enable); + signals_.connectionStatusChanged_(conn->id_, enable); + return "setConnectionStatus " + conn->id_.id_ + " " + std::to_string(enable); + } + else + { + return "Connection not found"; + } +} + NetworkFileHandle NetworkEditorController::serializeNetworkFragment(ModuleFilter modFilter, ConnectionFilter connFilter) const { NetworkToXML conv(collabs_.serializationManager_); diff --git a/src/Dataflow/Engine/Controller/NetworkEditorController.h b/src/Dataflow/Engine/Controller/NetworkEditorController.h index ad0d86253a..c9f25b86f2 100644 --- a/src/Dataflow/Engine/Controller/NetworkEditorController.h +++ b/src/Dataflow/Engine/Controller/NetworkEditorController.h @@ -78,11 +78,10 @@ namespace Engine { ConnectionRemovedSignalType connectionRemoved_; InvalidConnectionSignalType invalidConnection_; NetworkDoneLoadingSignalType networkDoneLoading_; - + ConnectionStatusChangedSignalType connectionStatusChanged_; bool signalSwitch_, loadingContext_; - struct LoadingContext { explicit LoadingContext(bool& load); @@ -121,6 +120,7 @@ namespace Engine { std::optional requestConnection(const Networks::PortDescriptionInterface* from, const Networks::PortDescriptionInterface* to) override; void removeConnection(const Networks::ConnectionId& id); + std::string setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable); std::future executeAll() override; void executeModule(const Networks::ModuleHandle& module, bool executeUpstream); @@ -146,6 +146,7 @@ namespace Engine { boost::signals2::connection connectInvalidConnection(const InvalidConnectionSignalType::slot_type& subscriber); boost::signals2::connection connectPortAdded(const PortAddedSignalType::slot_type& subscriber); boost::signals2::connection connectPortRemoved(const PortRemovedSignalType::slot_type& subscriber); + boost::signals2::connection connectConnectionStatusChanged(const ConnectionStatusChangedSignalType::slot_type& subscriber); boost::signals2::connection connectStaticNetworkExecutionStarts(const ExecuteAllStartsSignalType::slot_type& subscriber); boost::signals2::connection connectStaticNetworkExecutionFinished(const ExecuteAllFinishesSignalType::slot_type& subscriber); diff --git a/src/Dataflow/Engine/Controller/PythonImpl.cc b/src/Dataflow/Engine/Controller/PythonImpl.cc index 05aebb84ac..1716772a47 100644 --- a/src/Dataflow/Engine/Controller/PythonImpl.cc +++ b/src/Dataflow/Engine/Controller/PythonImpl.cc @@ -590,21 +590,17 @@ std::string PythonImpl::connect(const std::string& moduleIdFrom, int fromIndex, auto modTo = network->lookupModule(ModuleId(moduleIdTo)); auto inputPort = modTo->inputPorts().at(toIndex); auto id = nec_.requestConnection(outputPort.get(), inputPort.get()); - return "PythonImpl::connect success"; + return "PythonImpl::connect success: " + id->id_; } std::string PythonImpl::disconnect(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) { - (void)moduleIdFrom; - (void)fromIndex; - (void)moduleIdTo; - (void)toIndex; //TODO: doesn't work at all since there is no GUI connection to this network change event. Issue is #... auto conn = nec_.getNetwork()->lookupConnection(moduleIdFrom, fromIndex, moduleIdTo, toIndex); if (conn) { nec_.removeConnection(conn->id()); - return "PythonImpl::disconnect IS NOT IMPLEMENTED"; + return "PythonImpl::disconnect is not connected to GUI"; } else { @@ -614,16 +610,7 @@ std::string PythonImpl::disconnect(const std::string& moduleIdFrom, int fromInde std::string PythonImpl::setConnectionStatus(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex, bool enable) { - auto conn = nec_.getNetwork()->lookupConnection(moduleIdFrom, fromIndex, moduleIdTo, toIndex); - if (conn) - { - conn->setDisable(!enable); - return "setConnectionStatus " + std::to_string(enable); - } - else - { - return "Connection not found"; - } + return nec_.setConnectionStatus(moduleIdFrom, fromIndex, moduleIdTo, toIndex, enable); } std::string PythonImpl::saveNetwork(const std::string& filename) diff --git a/src/Interface/Application/Connection.cc b/src/Interface/Application/Connection.cc index ba371e8ce0..b9d748f6c1 100644 --- a/src/Interface/Application/Connection.cc +++ b/src/Interface/Application/Connection.cc @@ -292,6 +292,14 @@ ConnectionLine::ConnectionLine(PortWidget* fromPort, PortWidget* toPort, const C connectUpdateNote(this); NeedsScenePositionProvider::setPositionObject(makeShared(fromPort_, toPort_)); connect(menu_->disableAction_, &QAction::triggered, this, &ConnectionLine::toggleDisabled); + #if 0 + connect(nec..., &NetworkEditorControllerGuiProxy::connectionStatusChanged, + [this] (const Networks::ConnectionId& id, bool enable) + { + if (id.id_ == id_.id_) + setDisabled(!enable); + }); + #endif connect(this, &ConnectionLine::requestInsertNewModule, [this](const QMap& m) { fromPort_->insertNewModule(m); }); menu_->setStyleSheet(fromPort->styleSheet()); diff --git a/src/Interface/Application/NetworkEditorControllerGuiProxy.cc b/src/Interface/Application/NetworkEditorControllerGuiProxy.cc index a1c39e0fb2..6d2723440c 100644 --- a/src/Interface/Application/NetworkEditorControllerGuiProxy.cc +++ b/src/Interface/Application/NetworkEditorControllerGuiProxy.cc @@ -53,6 +53,8 @@ NetworkEditorControllerGuiProxy::NetworkEditorControllerGuiProxy(SharedPointerconnectPortRemoved([this](const ModuleId& mid, const PortId& pid) { portRemoved(mid, pid); })); + connections_.emplace_back(controller_->connectConnectionStatusChanged([this](const ConnectionId& id, bool status) + { connectionStatusChanged(id, status); qDebug() << "connectionStatusChanged" << id.id_.c_str() << status; })); connections_.emplace_back(controller_->connectStaticNetworkExecutionStarts([this]() { executionStarted(); })); connections_.emplace_back(controller_->connectStaticNetworkExecutionFinished([this](int ret) diff --git a/src/Interface/Application/NetworkEditorControllerGuiProxy.h b/src/Interface/Application/NetworkEditorControllerGuiProxy.h index ccd3b12589..903ab953c1 100644 --- a/src/Interface/Application/NetworkEditorControllerGuiProxy.h +++ b/src/Interface/Application/NetworkEditorControllerGuiProxy.h @@ -80,6 +80,7 @@ namespace Gui { void moduleRemoved(const SCIRun::Dataflow::Networks::ModuleId& id); void connectionAdded(const SCIRun::Dataflow::Networks::ConnectionDescription& cd); void connectionRemoved(const SCIRun::Dataflow::Networks::ConnectionId& id); + void connectionStatusChanged(const SCIRun::Dataflow::Networks::ConnectionId& id, bool status); void portAdded(const SCIRun::Dataflow::Networks::ModuleId& mid, const SCIRun::Dataflow::Networks::PortId& pid); void portRemoved(const SCIRun::Dataflow::Networks::ModuleId& mid, const SCIRun::Dataflow::Networks::PortId& pid); void executionStarted(); From e3fe7ed7d4b281eb530fe0348a864a8bfea914df Mon Sep 17 00:00:00 2001 From: Daniel White Date: Fri, 3 Jun 2022 21:06:20 -0600 Subject: [PATCH 30/36] Can disable/enable connections from python --- .../Engine/Controller/NetworkEditorController.cc | 4 ++-- src/Dataflow/Network/Network.cc | 1 + src/Interface/Application/Connection.cc | 14 ++++++-------- src/Interface/Application/Connection.h | 1 + src/Interface/Application/ModuleWidget.cc | 1 + src/Interface/Application/ModuleWidget.h | 1 + src/Interface/Application/NetworkEditor.cc | 4 ++++ src/Interface/Application/NetworkEditor.h | 1 + .../Application/NetworkEditorControllerGuiProxy.cc | 2 +- src/Interface/Application/Port.cc | 1 + src/Interface/Application/Port.h | 1 + 11 files changed, 20 insertions(+), 11 deletions(-) diff --git a/src/Dataflow/Engine/Controller/NetworkEditorController.cc b/src/Dataflow/Engine/Controller/NetworkEditorController.cc index 435f6468cb..9506536473 100644 --- a/src/Dataflow/Engine/Controller/NetworkEditorController.cc +++ b/src/Dataflow/Engine/Controller/NetworkEditorController.cc @@ -536,11 +536,11 @@ std::string NetworkEditorController::setConnectionStatus(const std::string& modu { conn->setDisable(!enable); signals_.connectionStatusChanged_(conn->id_, enable); - return "setConnectionStatus " + conn->id_.id_ + " " + std::to_string(enable); + return std::string("Connection status ") + (enable ? "enabled" : "disabled") + ": " + moduleIdFrom + "(" + std::to_string(fromIndex) + ")->" + moduleIdTo + "(" + std::to_string(toIndex) + ")"; } else { - return "Connection not found"; + return "Connection not found: " + moduleIdFrom + "(" + std::to_string(fromIndex) + ")->" + moduleIdTo + "(" + std::to_string(toIndex) + ")"; } } diff --git a/src/Dataflow/Network/Network.cc b/src/Dataflow/Network/Network.cc index 08cdfe18cc..da4f882cdf 100644 --- a/src/Dataflow/Network/Network.cc +++ b/src/Dataflow/Network/Network.cc @@ -142,6 +142,7 @@ bool Network::disconnect(const ConnectionId& id) ConnectionHandle Network::lookupConnection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) const { + //TODO: error checking const auto outputPortId = lookupModule(ModuleId(moduleIdFrom))->outputPorts()[fromIndex]->externalId(); const auto inputPortId = lookupModule(ModuleId(moduleIdTo))->inputPorts()[toIndex]->externalId(); diff --git a/src/Interface/Application/Connection.cc b/src/Interface/Application/Connection.cc index b9d748f6c1..0433019be3 100644 --- a/src/Interface/Application/Connection.cc +++ b/src/Interface/Application/Connection.cc @@ -292,14 +292,6 @@ ConnectionLine::ConnectionLine(PortWidget* fromPort, PortWidget* toPort, const C connectUpdateNote(this); NeedsScenePositionProvider::setPositionObject(makeShared(fromPort_, toPort_)); connect(menu_->disableAction_, &QAction::triggered, this, &ConnectionLine::toggleDisabled); - #if 0 - connect(nec..., &NetworkEditorControllerGuiProxy::connectionStatusChanged, - [this] (const Networks::ConnectionId& id, bool enable) - { - if (id.id_ == id_.id_) - setDisabled(!enable); - }); - #endif connect(this, &ConnectionLine::requestInsertNewModule, [this](const QMap& m) { fromPort_->insertNewModule(m); }); menu_->setStyleSheet(fromPort->styleSheet()); @@ -308,6 +300,12 @@ ConnectionLine::ConnectionLine(PortWidget* fromPort, PortWidget* toPort, const C guiLogDebug("Connection made: {}", id_.id_); } +void ConnectionLine::changeConnectionStatus(const SCIRun::Dataflow::Networks::ConnectionId& id, bool status) +{ + if (id.id_ == id_.id_) + setDisabled(!status); +} + ConnectionLine::~ConnectionLine() { destroyConnection(); diff --git a/src/Interface/Application/Connection.h b/src/Interface/Application/Connection.h index 787aee28f6..c8c4eb9316 100644 --- a/src/Interface/Application/Connection.h +++ b/src/Interface/Application/Connection.h @@ -99,6 +99,7 @@ public Q_SLOTS: void updateNote(const Note& note); void toggleDisabled(); void insertNewModule(); + void changeConnectionStatus(const SCIRun::Dataflow::Networks::ConnectionId& id, bool status); Q_SIGNALS: void deleted(const SCIRun::Dataflow::Networks::ConnectionId& id); diff --git a/src/Interface/Application/ModuleWidget.cc b/src/Interface/Application/ModuleWidget.cc index bc85584eef..b38f1993ec 100644 --- a/src/Interface/Application/ModuleWidget.cc +++ b/src/Interface/Application/ModuleWidget.cc @@ -675,6 +675,7 @@ class PortBuilder widget->hookUpGeneralPortSignals(w); QObject::connect(widget, &ModuleWidget::connectionAdded, w, &InputPortWidget::makeConnection); QObject::connect(w, &InputPortWidget::incomingConnectionStateChange, widget, &ModuleWidget::incomingConnectionStateChanged); + QObject::connect(widget, &ModuleWidget::connectionStatusChanged, w, &InputPortWidget::connectionStatusChanged); widget->ports_->addPort(w); ++i; if (widget->dialogManager_.hasOptions() && port->isDynamic()) diff --git a/src/Interface/Application/ModuleWidget.h b/src/Interface/Application/ModuleWidget.h index df9962592e..9d97e5571a 100644 --- a/src/Interface/Application/ModuleWidget.h +++ b/src/Interface/Application/ModuleWidget.h @@ -223,6 +223,7 @@ public Q_SLOTS: void replaceModuleWith(const SCIRun::Dataflow::Networks::ModuleHandle& moduleToReplace, const std::string& newModuleName); void backgroundColorUpdated(const QString& color); void dynamicPortChanged(const std::string& portID, bool adding); + void connectionStatusChanged(const SCIRun::Dataflow::Networks::ConnectionId& id, bool status); void noteChanged(); void moduleStateUpdated(int state); void moduleSelected(bool selected); diff --git a/src/Interface/Application/NetworkEditor.cc b/src/Interface/Application/NetworkEditor.cc index 4ade133244..78a96b07e5 100644 --- a/src/Interface/Application/NetworkEditor.cc +++ b/src/Interface/Application/NetworkEditor.cc @@ -152,6 +152,9 @@ void NetworkEditor::setNetworkEditorController(SharedPointersetExecutableLookup(this); } } @@ -456,6 +459,7 @@ ModuleProxyWidget* NetworkEditor::setupModuleWidget(ModuleWidget* module) connect(module, &ModuleWidget::replaceModuleWith, this, &NetworkEditor::replaceModuleWith); connect(module, &ModuleWidget::disableWidgetDisabling, this, &NetworkEditor::disableWidgetDisabling); connect(module, &ModuleWidget::reenableWidgetDisabling, this, &NetworkEditor::reenableWidgetDisabling); + connect(this, &NetworkEditor::connectionStatusChanged, module, &ModuleWidget::connectionStatusChanged); if (module->hasDynamicPorts()) { diff --git a/src/Interface/Application/NetworkEditor.h b/src/Interface/Application/NetworkEditor.h index 92bca8ecb8..8bb1c05ff3 100644 --- a/src/Interface/Application/NetworkEditor.h +++ b/src/Interface/Application/NetworkEditor.h @@ -395,6 +395,7 @@ namespace Gui { void newModule(const QString& modId, bool hasUI); void newSubnetworkCopied(const QString& xml); void requestLoadNetwork(const QString& file); + void connectionStatusChanged(const SCIRun::Dataflow::Networks::ConnectionId& id, bool status); private Q_SLOTS: void bringToFront(); void sendToBack(); diff --git a/src/Interface/Application/NetworkEditorControllerGuiProxy.cc b/src/Interface/Application/NetworkEditorControllerGuiProxy.cc index 6d2723440c..ec5eda5679 100644 --- a/src/Interface/Application/NetworkEditorControllerGuiProxy.cc +++ b/src/Interface/Application/NetworkEditorControllerGuiProxy.cc @@ -54,7 +54,7 @@ NetworkEditorControllerGuiProxy::NetworkEditorControllerGuiProxy(SharedPointerconnectPortRemoved([this](const ModuleId& mid, const PortId& pid) { portRemoved(mid, pid); })); connections_.emplace_back(controller_->connectConnectionStatusChanged([this](const ConnectionId& id, bool status) - { connectionStatusChanged(id, status); qDebug() << "connectionStatusChanged" << id.id_.c_str() << status; })); + { connectionStatusChanged(id, status); })); connections_.emplace_back(controller_->connectStaticNetworkExecutionStarts([this]() { executionStarted(); })); connections_.emplace_back(controller_->connectStaticNetworkExecutionFinished([this](int ret) diff --git a/src/Interface/Application/Port.cc b/src/Interface/Application/Port.cc index 4884db533f..315d92d719 100644 --- a/src/Interface/Application/Port.cc +++ b/src/Interface/Application/Port.cc @@ -510,6 +510,7 @@ void PortWidget::makeConnection(const ConnectionDescription& cd) connect(c, &ConnectionLine::noteChanged, this, &PortWidget::connectionNoteChanged); connect(out, &PortWidget::portMoved, c, &ConnectionLine::trackNodes); connect(in, &PortWidget::portMoved, c, &ConnectionLine::trackNodes); + connect(in, &PortWidget::connectionStatusChanged, c, &ConnectionLine::changeConnectionStatus); setConnected(true); } } diff --git a/src/Interface/Application/Port.h b/src/Interface/Application/Port.h index 5adb3303fc..bd2e177bfb 100644 --- a/src/Interface/Application/Port.h +++ b/src/Interface/Application/Port.h @@ -186,6 +186,7 @@ public Q_SLOTS: void connectionNoteChanged(); void highlighted(bool highlighted); void incomingConnectionStateChange(bool disabled, int index); + void connectionStatusChanged(const SCIRun::Dataflow::Networks::ConnectionId& id, bool status); protected: void mousePressEvent(QMouseEvent* event) override; void mouseReleaseEvent(QMouseEvent* event) override; From b81c827c44f7e7bba0f9eb0f7f752fa15ec673f8 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Fri, 3 Jun 2022 21:19:31 -0600 Subject: [PATCH 31/36] Closes #2288 --- src/Dataflow/Network/Network.cc | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/Dataflow/Network/Network.cc b/src/Dataflow/Network/Network.cc index da4f882cdf..06f0664f33 100644 --- a/src/Dataflow/Network/Network.cc +++ b/src/Dataflow/Network/Network.cc @@ -142,9 +142,21 @@ bool Network::disconnect(const ConnectionId& id) ConnectionHandle Network::lookupConnection(const std::string& moduleIdFrom, int fromIndex, const std::string& moduleIdTo, int toIndex) const { - //TODO: error checking - const auto outputPortId = lookupModule(ModuleId(moduleIdFrom))->outputPorts()[fromIndex]->externalId(); - const auto inputPortId = lookupModule(ModuleId(moduleIdTo))->inputPorts()[toIndex]->externalId(); + auto fromMod = lookupModule(ModuleId(moduleIdFrom)); + if (!fromMod) + return nullptr; + auto fromPorts = fromMod->outputPorts(); + if (fromIndex < 0 || fromIndex >= fromPorts.size()) + return nullptr; + const auto outputPortId = fromPorts[fromIndex]->externalId(); + + auto toMod = lookupModule(ModuleId(moduleIdTo)); + if (!toMod) + return nullptr; + auto toPorts = toMod->inputPorts(); + if (toIndex < 0 || toIndex >= toPorts.size()) + return nullptr; + const auto inputPortId = toPorts[toIndex]->externalId(); const ConnectionId id = ConnectionId::create(ConnectionDescription( OutgoingConnectionDescription(ModuleId(moduleIdFrom), outputPortId), From 70bea70cf55625f40e563c197e8db23339335c7f Mon Sep 17 00:00:00 2001 From: Daniel White Date: Sat, 4 Jun 2022 18:55:51 -0600 Subject: [PATCH 32/36] Closes #2346 --- .../Application/ModuleOptionsDialogConfiguration.cc | 2 +- src/Interface/Modules/Base/ModuleDialogGeneric.cc | 9 ++++++++- src/Interface/Modules/Base/ModuleDialogGeneric.h | 4 ++-- src/Interface/Modules/Render/OsprayViewerDialog.cc | 4 ++-- src/Interface/Modules/Render/OsprayViewerDialog.h | 2 +- src/Interface/Modules/Render/ViewScene.cc | 6 +++--- src/Interface/Modules/Render/ViewScene.h | 2 +- 7 files changed, 18 insertions(+), 11 deletions(-) diff --git a/src/Interface/Application/ModuleOptionsDialogConfiguration.cc b/src/Interface/Application/ModuleOptionsDialogConfiguration.cc index b5b282cc64..66394d0ffe 100644 --- a/src/Interface/Application/ModuleOptionsDialogConfiguration.cc +++ b/src/Interface/Application/ModuleOptionsDialogConfiguration.cc @@ -81,7 +81,7 @@ ModuleDialogDockWidget* ModuleOptionsDialogConfiguration::config(ModuleDialogGen } if (ModuleWidget::highResolutionExpandFactor_ > 1 && moduleWidget_->isViewScene_) - options->adjustToolbar(); + options->adjustToolbar(ModuleWidget::highResolutionExpandFactor_); options->pull(); diff --git a/src/Interface/Modules/Base/ModuleDialogGeneric.cc b/src/Interface/Modules/Base/ModuleDialogGeneric.cc index 54f482e82a..929f0b268b 100644 --- a/src/Interface/Modules/Base/ModuleDialogGeneric.cc +++ b/src/Interface/Modules/Base/ModuleDialogGeneric.cc @@ -1095,7 +1095,7 @@ std::vector SCIRun::Gui::toQStringVector(const std::vector return qv; } -void ModuleDialogGeneric::adjustToolbarForHighResolution(QToolBar* toolbar) +void ModuleDialogGeneric::adjustToolbarForHighResolution(QToolBar* toolbar, double factor) { for (const auto& child : toolbar->children()) { @@ -1104,6 +1104,13 @@ void ModuleDialogGeneric::adjustToolbarForHighResolution(QToolBar* toolbar) { button->setFixedSize(button->size() * 2); button->setIconSize(button->iconSize() * 2); + for (const auto& child2 : button->children()) + { + auto* popup = qobject_cast(child2); + auto popupWidgetSize = popup->layout()->itemAt(0)->widget()->size(); + popup->setFixedHeight(popupWidgetSize.height() * factor); + popup->setFixedWidth(popupWidgetSize.width() * (((factor - 1) * 0.5) + 1)); + } } } } diff --git a/src/Interface/Modules/Base/ModuleDialogGeneric.h b/src/Interface/Modules/Base/ModuleDialogGeneric.h index 3bbe8149c1..271cd95d10 100644 --- a/src/Interface/Modules/Base/ModuleDialogGeneric.h +++ b/src/Interface/Modules/Base/ModuleDialogGeneric.h @@ -90,7 +90,7 @@ namespace Gui { void setupButtonBar(); bool isCollapsed() const { return collapsed_; } virtual void createStartupNote() {} - virtual void adjustToolbar() {} + virtual void adjustToolbar(double /*factor*/) {} static void setExecutionDisablingServiceFunctionAdd(ExecutionDisablingServiceFunction add) { disablerAdd_ = add; } static void setExecutionDisablingServiceFunctionRemove(ExecutionDisablingServiceFunction remove) { disablerRemove_ = remove; } static const std::set& instances() { return instances_; } @@ -131,7 +131,7 @@ namespace Gui { void connectComboToExecuteSignal(QComboBox* box); void connectSpinBoxToExecuteSignal(QSpinBox* box); void connectSpinBoxToExecuteSignal(QDoubleSpinBox* box); - void adjustToolbarForHighResolution(QToolBar* toolbar); + void adjustToolbarForHighResolution(QToolBar* toolbar, double factor); void pullManagedWidgets(); // Dialog classes should override this method to provide pull behavior not available from the widget managers. diff --git a/src/Interface/Modules/Render/OsprayViewerDialog.cc b/src/Interface/Modules/Render/OsprayViewerDialog.cc index 623ff6e10b..cbee77b261 100644 --- a/src/Interface/Modules/Render/OsprayViewerDialog.cc +++ b/src/Interface/Modules/Render/OsprayViewerDialog.cc @@ -182,10 +182,10 @@ void OsprayViewerDialog::addToolBar() addControlLockButton(); } -void OsprayViewerDialog::adjustToolbar() +void OsprayViewerDialog::adjustToolbar(double factor) { if (toolBar_) - adjustToolbarForHighResolution(toolBar_); + adjustToolbarForHighResolution(toolBar_, factor); } void OsprayViewerDialog::addConfigurationButton() diff --git a/src/Interface/Modules/Render/OsprayViewerDialog.h b/src/Interface/Modules/Render/OsprayViewerDialog.h index 8f2ccfcfae..acc8e7e182 100644 --- a/src/Interface/Modules/Render/OsprayViewerDialog.h +++ b/src/Interface/Modules/Render/OsprayViewerDialog.h @@ -56,7 +56,7 @@ class SCISHARE OsprayViewerDialog : public ModuleDialogGeneric, public Ui::Ospra Dataflow::Networks::ModuleStateHandle state, QWidget* parent = nullptr); ~OsprayViewerDialog(); - void adjustToolbar() override; + void adjustToolbar(double factor) override; Q_SIGNALS: void newGeometryValueForwarder(); diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index 24936ceb4d..62b14d78a8 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -1125,10 +1125,10 @@ void ViewSceneDialog::pullSpecial() } } -void ViewSceneDialog::adjustToolbar() +void ViewSceneDialog::adjustToolbar(double factor) { - adjustToolbarForHighResolution(impl_->toolBar1_); - adjustToolbarForHighResolution(impl_->toolBar2_); + adjustToolbarForHighResolution(impl_->toolBar1_, factor); + adjustToolbarForHighResolution(impl_->toolBar2_, factor); } QColor ViewSceneDialog::checkColorSetting(const std::string& rgb, const QColor& defaultColor) diff --git a/src/Interface/Modules/Render/ViewScene.h b/src/Interface/Modules/Render/ViewScene.h index 9101323776..3b0b3b5d3c 100644 --- a/src/Interface/Modules/Render/ViewScene.h +++ b/src/Interface/Modules/Render/ViewScene.h @@ -67,7 +67,7 @@ namespace SCIRun { ~ViewSceneDialog() override; std::string toString(std::string prefix) const; - void adjustToolbar() override; + void adjustToolbar(double factor) override; static ViewSceneManager viewSceneManager; void inputMouseDownHelper(float x, float y); From 7a455fda716357cac08c94a135af853499a6d74d Mon Sep 17 00:00:00 2001 From: Daniel White Date: Wed, 8 Jun 2022 12:21:25 -0600 Subject: [PATCH 33/36] Tiny popup workaround --- src/Interface/Application/ModuleWidget.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Interface/Application/ModuleWidget.cc b/src/Interface/Application/ModuleWidget.cc index b38f1993ec..1b9d877a54 100644 --- a/src/Interface/Application/ModuleWidget.cc +++ b/src/Interface/Application/ModuleWidget.cc @@ -1272,7 +1272,7 @@ void ModuleWidget::toggleOptionsDialog() } else { - dockable_->move(400, 200); + dockable_->move(700, 400); } positions_.append(dockable_->pos()); } From c204d8e736c543b6ca05c97d80412ec40a593e00 Mon Sep 17 00:00:00 2001 From: Daniel White Date: Thu, 9 Jun 2022 12:33:23 -0600 Subject: [PATCH 34/36] Fix for full screen viewscene --- .../ModuleOptionsDialogConfiguration.cc | 1 + src/Interface/Application/ModuleWidget.cc | 2 +- .../Modules/Base/ModuleDialogGeneric.cc | 2 + .../Modules/Base/ModuleDialogGeneric.h | 3 + src/Interface/Modules/Render/ViewScene.cc | 190 +++++++++--------- src/Interface/Modules/Render/ViewScene.h | 3 +- 6 files changed, 105 insertions(+), 96 deletions(-) diff --git a/src/Interface/Application/ModuleOptionsDialogConfiguration.cc b/src/Interface/Application/ModuleOptionsDialogConfiguration.cc index 66394d0ffe..978ab88da5 100644 --- a/src/Interface/Application/ModuleOptionsDialogConfiguration.cc +++ b/src/Interface/Application/ModuleOptionsDialogConfiguration.cc @@ -95,6 +95,7 @@ ModuleDialogDockWidget* ModuleOptionsDialogConfiguration::configDockable(ModuleD dockable->setObjectName(options->windowTitle()); dockable->setWidget(options); options->setDockable(dockable); + QObject::connect(dockable, &ModuleDialogDockWidget::movedToFullScreen, options, &ModuleDialogGeneric::adaptToFullScreenView); dockable->setMinimumSize(options->minimumSize()); dockable->setAllowedAreas(moduleWidget_->allowedDockArea()); diff --git a/src/Interface/Application/ModuleWidget.cc b/src/Interface/Application/ModuleWidget.cc index 1b9d877a54..5bd8cd8ccb 100644 --- a/src/Interface/Application/ModuleWidget.cc +++ b/src/Interface/Application/ModuleWidget.cc @@ -1272,7 +1272,7 @@ void ModuleWidget::toggleOptionsDialog() } else { - dockable_->move(700, 400); + dockable_->move(isViewScene_ ? 700 : 400, isViewScene_ ? 400 : 200); } positions_.append(dockable_->pos()); } diff --git a/src/Interface/Modules/Base/ModuleDialogGeneric.cc b/src/Interface/Modules/Base/ModuleDialogGeneric.cc index 929f0b268b..78069cbfe4 100644 --- a/src/Interface/Modules/Base/ModuleDialogGeneric.cc +++ b/src/Interface/Modules/Base/ModuleDialogGeneric.cc @@ -1133,6 +1133,8 @@ void ModuleDialogDockWidget::moveEvent(QMoveEvent* e) { moduleDialog->postMoveEventCallback(e->pos()); } + + Q_EMIT movedToFullScreen(e->pos() == QPoint{0,0}); } ModuleDialogFactoryInterfaceHandle ModuleDialogGeneric::factory() diff --git a/src/Interface/Modules/Base/ModuleDialogGeneric.h b/src/Interface/Modules/Base/ModuleDialogGeneric.h index 271cd95d10..117d1dc02c 100644 --- a/src/Interface/Modules/Base/ModuleDialogGeneric.h +++ b/src/Interface/Modules/Base/ModuleDialogGeneric.h @@ -69,6 +69,8 @@ namespace Gui { Q_OBJECT public: using QDockWidget::QDockWidget; + Q_SIGNALS: + void movedToFullScreen(bool fullScreen); protected: void moveEvent(QMoveEvent* e) override; }; @@ -107,6 +109,7 @@ namespace Gui { void collapse() { if (!collapsed_) toggleCollapse(); } void expand() { if (collapsed_) toggleCollapse(); } virtual void updateFromPortChange(int, const std::string&, DynamicPortChange) {} + virtual void adaptToFullScreenView(bool /*fullScreen*/) {} Q_SIGNALS: void pullSignal(); void executionTimeChanged(int time); diff --git a/src/Interface/Modules/Render/ViewScene.cc b/src/Interface/Modules/Render/ViewScene.cc index 62b14d78a8..f7f31d14c4 100644 --- a/src/Interface/Modules/Render/ViewScene.cc +++ b/src/Interface/Modules/Render/ViewScene.cc @@ -156,85 +156,86 @@ namespace Gui { class ViewSceneDialogImpl { public: - - GLWidget* mGLWidget {nullptr}; ///< GL widget containing context. - Render::RendererWeakPtr mSpire {}; ///< Instance of Spire. - QToolBar* toolBar1_ {nullptr}; ///< Tool bar. - QToolBar* toolBar2_ {nullptr}; ///< Tool bar. - QComboBox* mDownViewBox {nullptr}; ///< Combo box for Down axis options. - QComboBox* mUpVectorBox {nullptr}; ///< Combo box for Up Vector options. - ColorOptions* colorOptions_{ nullptr }; - FogControls* fogControls_{ nullptr }; - MaterialsControls* materialsControls_{ nullptr }; - ViewAxisChooserControls* viewAxisChooser_{nullptr}; - ObjectSelectionControls* objectSelectionControls_{nullptr}; - OrientationAxesControls* orientationAxesControls_{nullptr}; - ScreenshotControls* screenshotControls_{nullptr}; - ScaleBarControls* scaleBarControls_{nullptr}; - ClippingPlaneControls* clippingPlaneControls_{nullptr}; - InputControls* inputControls_{nullptr}; - CameraLockControls* cameraLockControls_{nullptr}; - DeveloperControls* developerControls_{nullptr}; - static constexpr int NUM_LIGHTS = 4; - LightControls* lightControls_[NUM_LIGHTS]; - QLabel* statusLabel_{nullptr}; - QPushButton* autoRotateButton_{nullptr}; - QPushButton* fogButton_{nullptr}; - - SharedPointer widgetColorChanger_ {}; - Render::PreviousWidgetSelectionInfo previousWidgetInfo_; - - bool shown_ {false}; - bool delayGC_ {false}; - bool delayedGCRequested_ {false}; - bool invertZoom_ {}; - bool shiftdown_ {false}; - bool mouseButtonPressed_ {false}; - Graphics::Datatypes::WidgetHandle selectedWidget_; - Core::Datatypes::WidgetMovement movementType_ {Core::Datatypes::NONE}; - - bool initializeClippingPlanes_{true}; - - const static int delayAfterModuleExecution_ {200}; - const static int delayAfterWidgetColorRestored_ {50}; - int delayAfterLastSelection_ {50}; - float clippingPlaneColors_[6][3] {{0.7f, 0.2f, 0.1f}, {0.8f, 0.5f, 0.3f}, - {0.8f, 0.8f, 0.5f}, {0.4f, 0.7f, 0.3f}, - {0.2f, 0.4f, 0.5f}, {0.5f, 0.3f, 0.5f}}; - - std::optional savedPos_; - QColor bgColor_ {}; - ScaleBarData scaleBar_ {}; - Render::ClippingPlaneManagerPtr clippingPlaneManager_; - class Screenshot* screenshotTaker_ {nullptr}; - bool saveScreenshotOnNewGeometry_ {false}; - bool pulledSavedVisibility_ {false}; - QTimer resizeTimer_ {}; - std::atomic pushingCameraState_ {false}; - glm::vec2 previousAutoRotate_ {0,0}; - - Modules::Visualization::TextBuilder textBuilder_ {}; - Graphics::Datatypes::GeometryHandle scaleBarGeom_ {}; - std::vector clippingPlaneGeoms_ {}; - std::vector widgetHandles_ {}; - QAction* lockRotation_ {nullptr}; - QAction* lockPan_ {nullptr}; - QAction* lockZoom_ {nullptr}; - QPushButton* controlLock_ {nullptr}; - QPushButton* autoViewButton_ {nullptr}; - QPushButton* viewBarBtn_ {nullptr}; - QPushButton* toolBar1Position_ {nullptr}; - QPushButton* toolBar2Position_ {nullptr}; - - std::vector viewScenesToUpdate {}; - - std::unique_ptr gid_; - std::string name_; - - std::unique_ptr visibleItems_; - - static const int DIMENSIONS_ = 3; - static const int QUATERNION_SIZE_ = 4; + GLWidget* mGLWidget {nullptr}; ///< GL widget containing context. + Render::RendererWeakPtr mSpire {}; ///< Instance of Spire. + QToolBar* toolBar1_ {nullptr}; ///< Tool bar. + QToolBar* toolBar2_ {nullptr}; ///< Tool bar. + QComboBox* mDownViewBox {nullptr}; ///< Combo box for Down axis options. + QComboBox* mUpVectorBox {nullptr}; ///< Combo box for Up Vector options. + ColorOptions* colorOptions_{ nullptr }; + FogControls* fogControls_{ nullptr }; + MaterialsControls* materialsControls_{ nullptr }; + ViewAxisChooserControls* viewAxisChooser_{nullptr}; + ObjectSelectionControls* objectSelectionControls_{nullptr}; + OrientationAxesControls* orientationAxesControls_{nullptr}; + ScreenshotControls* screenshotControls_{nullptr}; + ScaleBarControls* scaleBarControls_{nullptr}; + ClippingPlaneControls* clippingPlaneControls_{nullptr}; + InputControls* inputControls_{nullptr}; + CameraLockControls* cameraLockControls_{nullptr}; + DeveloperControls* developerControls_{nullptr}; + static constexpr int NUM_LIGHTS = 4; + LightControls* lightControls_[NUM_LIGHTS]; + QLabel* statusLabel_{nullptr}; + QPushButton* autoRotateButton_{nullptr}; + QPushButton* fogButton_{nullptr}; + + SharedPointer widgetColorChanger_ {}; + Render::PreviousWidgetSelectionInfo previousWidgetInfo_; + + bool shown_ {false}; + bool delayGC_ {false}; + bool delayedGCRequested_ {false}; + bool invertZoom_ {}; + bool shiftdown_ {false}; + bool mouseButtonPressed_ {false}; + Graphics::Datatypes::WidgetHandle selectedWidget_; + Core::Datatypes::WidgetMovement movementType_ {Core::Datatypes::NONE}; + + bool initializeClippingPlanes_{true}; + + const static int delayAfterModuleExecution_ {200}; + const static int delayAfterWidgetColorRestored_ {50}; + int delayAfterLastSelection_ {50}; + float clippingPlaneColors_[6][3] {{0.7f, 0.2f, 0.1f}, {0.8f, 0.5f, 0.3f}, + {0.8f, 0.8f, 0.5f}, {0.4f, 0.7f, 0.3f}, + {0.2f, 0.4f, 0.5f}, {0.5f, 0.3f, 0.5f}}; + + std::optional savedPos_; + QColor bgColor_ {}; + ScaleBarData scaleBar_ {}; + Render::ClippingPlaneManagerPtr clippingPlaneManager_; + class Screenshot* screenshotTaker_ {nullptr}; + bool saveScreenshotOnNewGeometry_ {false}; + bool pulledSavedVisibility_ {false}; + QTimer resizeTimer_ {}; + std::atomic pushingCameraState_ {false}; + glm::vec2 previousAutoRotate_ {0,0}; + + Modules::Visualization::TextBuilder textBuilder_ {}; + Graphics::Datatypes::GeometryHandle scaleBarGeom_ {}; + std::vector clippingPlaneGeoms_ {}; + std::vector widgetHandles_ {}; + QAction* lockRotation_ {nullptr}; + QAction* lockPan_ {nullptr}; + QAction* lockZoom_ {nullptr}; + QPushButton* controlLock_ {nullptr}; + QPushButton* autoViewButton_ {nullptr}; + QPushButton* viewBarBtn_ {nullptr}; + QPushButton* toolBar1Position_ {nullptr}; + QPushButton* toolBar2Position_ {nullptr}; + + std::vector viewScenesToUpdate {}; + + std::unique_ptr gid_; + std::string name_; + + std::unique_ptr visibleItems_; + bool isFullScreen_ {false}; + std::function fullScreenSwitcher_ = [this](bool b) { return isFullScreen_ ? !b : b; }; + + static const int DIMENSIONS_ = 3; + static const int QUATERNION_SIZE_ = 4; }; @@ -594,34 +595,26 @@ void ViewSceneDialog::setupPopupWidget(QPushButton* button, ViewSceneControlPopu popup->setHorizontalDirection(Qt::LayoutDirectionAuto); // open outside the parent popup->setShowDelay(500); popup->setHideDelay(20); + connect(this, &ViewSceneDialog::closeAllNonPinnedPopups, [popup, underlyingWidget]() { if (!underlyingWidget->pinToggleAction()->isChecked()) popup->close(); }); connect(underlyingWidget->pinToggleAction(), &QAction::toggled, popup, &ctkPopupWidget::pinPopup); connect(underlyingWidget->closeAction(), &QAction::triggered, popup, &QWidget::close); if (isHorizontalBar) - connect(this, &ViewSceneDialog::horizontalToolBarPopupChanged, [popup](bool isDef) + connect(this, &ViewSceneDialog::horizontalToolBarPopupChanged, [this, popup](bool isDef) { - popup->setAlignment(isDef ? Qt::AlignTop | Qt::AlignHCenter : Qt::AlignBottom | Qt::AlignHCenter); - popup->setVerticalDirection(isDef ? ctkBasePopupWidget::VerticalDirection::BottomToTop + popup->setAlignment(impl_->fullScreenSwitcher_(isDef) ? Qt::AlignTop | Qt::AlignHCenter : Qt::AlignBottom | Qt::AlignHCenter); + popup->setVerticalDirection(impl_->fullScreenSwitcher_(isDef) ? ctkBasePopupWidget::VerticalDirection::BottomToTop : ctkBasePopupWidget::VerticalDirection::TopToBottom); }); else - connect(this, &ViewSceneDialog::verticalToolBarPopupChanged, [popup](bool isDef) + connect(this, &ViewSceneDialog::verticalToolBarPopupChanged, [this, popup](bool isDef) { - popup->setAlignment(isDef ? Qt::AlignLeft | Qt::AlignVCenter : Qt::AlignRight | Qt::AlignVCenter); - popup->setHorizontalDirection(isDef ? Qt::LayoutDirectionAuto : Qt::LeftToRight); + popup->setAlignment(impl_->fullScreenSwitcher_(isDef) ? Qt::AlignLeft | Qt::AlignVCenter : Qt::AlignRight | Qt::AlignVCenter); + popup->setHorizontalDirection(impl_->fullScreenSwitcher_(isDef) ? Qt::LayoutDirectionAuto : Qt::LeftToRight); }); popupLayout->addWidget(underlyingWidget); popupLayout->setContentsMargins(4,4,4,4); } -void ViewSceneDialog::addConfigurationButton() -{ - auto* configurationButton = new QPushButton(); - configurationButton->setToolTip("Open/Close Configuration Menu (F5)"); - configurationButton->setIcon(QPixmap(":/general/Resources/ViewScene/configure.png")); - configurationButton->setShortcut(Qt::Key_F5); - addToolbarButton(configurationButton, 1); -} - void ViewSceneDialog::addObjectSelectionButton() { auto* objectSelectionButton = new QPushButton(); @@ -1564,6 +1557,7 @@ bool ViewSceneDialog::clickedInViewer(QMouseEvent* e) const void ViewSceneDialog::mousePressEvent(QMouseEvent* event) { + Q_EMIT closeAllNonPinnedPopups(); if (!clickedInViewer(event)) { return; @@ -2864,3 +2858,11 @@ void ViewSceneDialog::initializeVisibleObjects() { impl_->objectSelectionControls_->visibleItems().initializeSavedStateMap(); } + +void ViewSceneDialog::adaptToFullScreenView(bool fullScreen) +{ + impl_->isFullScreen_ = fullScreen; + + Q_EMIT horizontalToolBarPopupChanged(state_->getValue(Parameters::HorizontalToolBarPositionDefault).toBool()); + Q_EMIT verticalToolBarPopupChanged(state_->getValue(Parameters::VerticalToolBarPositionDefault).toBool()); +} diff --git a/src/Interface/Modules/Render/ViewScene.h b/src/Interface/Modules/Render/ViewScene.h index 3b0b3b5d3c..9fbe707437 100644 --- a/src/Interface/Modules/Render/ViewScene.h +++ b/src/Interface/Modules/Render/ViewScene.h @@ -91,6 +91,7 @@ namespace SCIRun { void mousePressSignalForGeometryObjectFeedback(int x, int y, const std::string& selName); void horizontalToolBarPopupChanged(bool state); void verticalToolBarPopupChanged(bool state); + void closeAllNonPinnedPopups(); public Q_SLOTS: void printToString() const {std::cout << toString("");} @@ -99,6 +100,7 @@ namespace SCIRun { void saveNewGeometryChanged(int state); void invertZoomClicked(bool value); void menuMouseControlChanged(int index); + void adaptToFullScreenView(bool fullScreen) override; protected Q_SLOTS: //---------------- New Geometry -------------------------------------------------------------- void updateModifiedGeometriesAndSendScreenShot(); @@ -240,7 +242,6 @@ namespace SCIRun { void addCameraLocksButton(); void addDeveloperControlButton(); void addToolbarButton(QWidget* w, int which, ViewSceneControlPopupWidget* widgetToPopup = nullptr); - void addConfigurationButton(); void addObjectSelectionButton(); void addLightButtons(); QColor checkColorSetting(const std::string& rgb, const QColor& defaultColor); From 04f78f64742cfe5cb2e6903596c3ebb5751b7d6a Mon Sep 17 00:00:00 2001 From: Dan White Date: Fri, 10 Jun 2022 00:09:12 -0600 Subject: [PATCH 35/36] Fix bar size for DisplayHistogram --- .../Base/CustomWidgets/QtHistogramGraph.cc | 34 +++++++++++-------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/Interface/Modules/Base/CustomWidgets/QtHistogramGraph.cc b/src/Interface/Modules/Base/CustomWidgets/QtHistogramGraph.cc index d60a010b56..2d0d3576f4 100644 --- a/src/Interface/Modules/Base/CustomWidgets/QtHistogramGraph.cc +++ b/src/Interface/Modules/Base/CustomWidgets/QtHistogramGraph.cc @@ -67,25 +67,34 @@ void QtHistogramGraph::paintEvent(QPaintEvent*) painter.setRenderHint( QPainter::Antialiasing, true ); style()->drawPrimitive(QStyle::PE_Widget, &opt, &painter, this); - if ( ! this->histogram_.is_valid() ) return; + if ( ! this->histogram_.is_valid() ) + return; - double histogram_width = this->width(); - double bins_size = this->histogram_.get_size(); - const std::vector& bins = this->histogram_.get_bins(); + const double histogram_width = this->width(); + + const std::vector& allBins = this->histogram_.get_bins(); + std::vector nonZeroBins; + std::copy_if(allBins.begin(), allBins.end(), std::back_inserter(nonZeroBins), [](auto b) { return b != 0; }); + + if (nonZeroBins.empty()) + return; + + const size_t bins_size = nonZeroBins.size() - 1; + const int rect_width = histogram_width / bins_size; if( !logarithmic_ ) { - double percent_of_max = this->height() / + const double percent_of_max = this->height() / static_cast< double >( this->histogram_.get_max_bin() ); for( int i = 0; i < bins_size; ++i ) { // Break it down so it's easier to understand - int adjusted_bin_size = static_cast< double >( bins[ i ] ) * percent_of_max; - int rect_left = i * ( histogram_width / bins_size ); - int rect_top = this->height() - adjusted_bin_size; - int rect_width = histogram_width / bins_size; - int rect_height = adjusted_bin_size; + const int adjusted_bin_size = static_cast< double >( nonZeroBins[ i ] ) * percent_of_max; + const int rect_left = i * ( histogram_width / bins_size ); + const int rect_top = this->height() - adjusted_bin_size; + + const int rect_height = adjusted_bin_size; QLinearGradient linearGradient( QPointF( rect_left, rect_top ), QPointF( rect_left+rect_width, this->height() ) ); @@ -104,10 +113,9 @@ void QtHistogramGraph::paintEvent(QPaintEvent*) for( int i = 0; i < bins_size; ++i ) { // Break it down so it's easier to understand - int adjusted_bin_size = std::log( static_cast< double >( bins[ i ] ) + 1 ) * percent_of_max; + int adjusted_bin_size = std::log( static_cast< double >( nonZeroBins[ i ] ) + 1 ) * percent_of_max; int rect_left = i * ( histogram_width / bins_size ); int rect_top = this->height() - adjusted_bin_size; - int rect_width = histogram_width / bins_size; int rect_height = adjusted_bin_size; QLinearGradient linearGradient( QPointF( rect_left, rect_top ), @@ -118,9 +126,7 @@ void QtHistogramGraph::paintEvent(QPaintEvent*) painter.setBrush( linearGradient ); painter.drawRect( rect_left, rect_top, rect_width, rect_height ); } - } - } void QtHistogramGraph::mousePressEvent( QMouseEvent* e ) From bfba14627d2c326614ed988fe5b83e62c1723458 Mon Sep 17 00:00:00 2001 From: Dan White Date: Tue, 14 Jun 2022 08:32:37 -0600 Subject: [PATCH 36/36] Fixes #2387 --- src/Interface/Application/NetworkEditor.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Interface/Application/NetworkEditor.cc b/src/Interface/Application/NetworkEditor.cc index 78a96b07e5..ec9e477a69 100644 --- a/src/Interface/Application/NetworkEditor.cc +++ b/src/Interface/Application/NetworkEditor.cc @@ -1911,7 +1911,7 @@ void NetworkEditor::wheelEvent(QWheelEvent* event) { setTransformationAnchor(AnchorUnderMouse); - if (event->angleDelta().x() > 0) + if (event->angleDelta().y() > 0) { zoomIn(); }