clang -cc1 -cc1 -triple x86_64-pc-linux-gnu -analyze -disable-free -clear-ast-before-backend -disable-llvm-verifier -discard-value-names -main-file-name lc_propertysheetwidget.cpp -analyzer-checker=core -analyzer-checker=apiModeling -analyzer-checker=unix -analyzer-checker=deadcode -analyzer-checker=cplusplus -analyzer-checker=security.insecureAPI.UncheckedReturn -analyzer-checker=security.insecureAPI.getpw -analyzer-checker=security.insecureAPI.gets -analyzer-checker=security.insecureAPI.mktemp -analyzer-checker=security.insecureAPI.mkstemp -analyzer-checker=security.insecureAPI.vfork -analyzer-checker=nullability.NullPassedToNonnull -analyzer-checker=nullability.NullReturnedFromNonnull -analyzer-output plist -w -setup-static-analyzer -mrelocation-model pic -pic-level 2 -fhalf-no-semantic-interposition -mframe-pointer=none -fmath-errno -ffp-contract=on -fno-rounding-math -mconstructor-aliases -funwind-tables=2 -target-cpu x86-64 -tune-cpu generic -debugger-tuning=gdb -fdebug-compilation-dir=/home/runner/work/LibreCAD/LibreCAD/librecad/src -fcoverage-compilation-dir=/home/runner/work/LibreCAD/LibreCAD/librecad/src -resource-dir /usr/lib/llvm-18/lib/clang/18 -D _REENTRANT -D DWGSUPPORT -D MUPARSER_STATIC -D QC_APPDIR="librecad" -D LC_VERSION=2.2.2_alpha1-607-g330d41cec -D LC_PRERELEASE=true; -D QT_NO_DEBUG -D QT_SVG_LIB -D QT_PRINTSUPPORT_LIB -D QT_WIDGETS_LIB -D QT_GUI_LIB -D QT_NETWORK_LIB -D QT_CORE_LIB -I . -I /usr/include -I ../../libraries/lciconengine -I ../../libraries/libdxfrw/src -I ../../libraries/jwwlib/src -I ../../libraries/shapelib/src -I cmd -I lib/actions -I lib/actions/visual_snap -I lib/actions/options -I lib/creation -I lib/debug -I lib/engine -I lib/engine/document -I lib/engine/document/blocks -I lib/engine/document/container -I lib/engine/document/dimstyles -I lib/engine/document/entities -I lib/engine/document/entities/support -I lib/engine/document/fonts -I lib/engine/document/io -I lib/engine/document/layers -I lib/engine/document/patterns -I lib/engine/document/selection -I lib/engine/document/textstyles -I lib/engine/document/ucs -I lib/engine/document/variables -I lib/engine/document/views -I lib/engine/clipboard -I lib/engine/overlays -I lib/engine/overlays/angles_base -I lib/engine/overlays/highlight -I lib/engine/overlays/preview -I lib/engine/overlays/references -I lib/engine/overlays/crosshair -I lib/engine/overlays/info_cursor -I lib/engine/overlays/overlay_box -I lib/engine/overlays/ucs_mark -I lib/engine/undo -I lib/engine/utils -I lib/engine/settings -I lib/fileio -I lib/filters -I lib/generators -I lib/generators/makercamsvg -I lib/generators/layers -I lib/generators/image -I lib/gui -I lib/gui/grid -I lib/gui/render -I lib/gui/render/headless -I lib/gui/render/widget -I lib/information -I lib/math -I lib/modification -I lib/selection -I lib/selection/metaentity -I lib/selection/metaentity/entities -I lib/printing -I lib/properties -I actions -I actions/dock_widgets -I actions/dock_widgets/block -I actions/dock_widgets/entity_info -I actions/dock_widgets/layer -I actions/dock_widgets/library -I actions/dock_widgets/ucs_list -I actions/drawing -I actions/drawing/draw -I actions/drawing/draw/arc -I actions/drawing/draw/circle -I actions/drawing/draw/curve -I actions/drawing/draw/spline -I actions/drawing/draw/dimensions -I actions/drawing/draw/ellipse -I actions/drawing/draw/hatch -I actions/drawing/draw/image -I actions/drawing/draw/line -I actions/drawing/draw/point -I actions/drawing/draw/rect -I actions/drawing/draw/polygon -I actions/drawing/draw/misc -I actions/drawing/draw/line/shapes -I actions/drawing/draw/line/misc -I actions/drawing/draw/line/shapes/rect -I actions/drawing/draw/line/shapes/polygon -I actions/drawing/draw/polyline -I actions/drawing/draw/text -I actions/drawing/edit -I actions/drawing/info -I actions/drawing/pick -I actions/drawing/modify -I actions/drawing/pen -I actions/drawing/rel_zero -I actions/drawing/selection -I actions/drawing/snap -I actions/drawing/zoom -I actions/file -I actions/options -I actions/print_preview -I ui -I ui/action_options -I ui/action_options/circle -I ui/action_options/curve -I ui/action_options/spline -I ui/action_options/dimensions -I ui/action_options/edit -I ui/action_options/image -I ui/action_options/info -I ui/action_options/insert -I ui/action_options/line -I ui/action_options/rect -I ui/action_options/polygon -I ui/action_options/misc -I ui/action_options/modify -I ui/action_options/ellipse -I ui/action_options/other -I ui/action_options/polyline -I ui/action_options/point -I ui/action_options/print_preview -I ui/action_options/selection -I ui/action_options/snap -I ui/action_options/text -I ui/actions -I ui/components -I ui/components/relative_position_assistant -I ui/components/comboboxes -I ui/components/containers -I ui/components/creators -I ui/components/layouts -I ui/components/pen -I ui/components/status_bar -I ui/components/toolbars -I ui/components/utils -I ui/dialogs -I ui/dialogs/actions -I ui/dialogs/actions/modify -I ui/dialogs/actions/quick_selection -I ui/dialogs/modify -I ui/dialogs/entity -I ui/dialogs/creators -I ui/dialogs/file -I ui/dialogs/file/export -I ui/dialogs/file/export/layers -I ui/dialogs/file/export/image -I ui/dialogs/file/export/makercam -I ui/dialogs/main -I ui/dialogs/settings -I ui/dialogs/settings/dimstyles -I ui/dialogs/settings/dimstyles/dimstyle_manager -I ui/dialogs/settings/dimstyles/dimstyle_manager/support -I ui/dialogs/settings/options_device -I ui/dialogs/settings/options_drawing -I ui/dialogs/settings/options_general -I ui/dialogs/settings/options_widget -I ui/dialogs/settings/shortcuts -I ui/dock_widgets -I ui/dock_widgets/block_widget -I ui/dock_widgets/command_line -I ui/dock_widgets/entity_info -I ui/dock_widgets/layer_widget -I ui/dock_widgets/layers_tree -I ui/dock_widgets/library_widget -I ui/dock_widgets/pen_palette -I ui/dock_widgets/pen_wizard -I ui/dock_widgets/property_sheet -I ui/dock_widgets/property_sheet/lib -I ui/dock_widgets/property_sheet/lib/properties -I ui/dock_widgets/property_sheet/lib/view -I ui/dock_widgets/property_sheet/lib/view/edit -I ui/dock_widgets/property_sheet/lib/widgets -I ui/dock_widgets/property_sheet/lib/widgets/sheet -I ui/dock_widgets/property_sheet/metaentity -I ui/dock_widgets/property_sheet/metaentity/entities -I ui/dock_widgets/property_sheet/metaentity/entities/document -I ui/dock_widgets/property_sheet/properties -I ui/dock_widgets/property_sheet/properties/action -I ui/dock_widgets/property_sheet/properties/bool -I ui/dock_widgets/property_sheet/properties/color -I ui/dock_widgets/property_sheet/properties/double -I ui/dock_widgets/property_sheet/properties/enum -I ui/dock_widgets/property_sheet/properties/int -I ui/dock_widgets/property_sheet/properties/layer -I ui/dock_widgets/property_sheet/properties/linetype -I ui/dock_widgets/property_sheet/properties/linewidth -I ui/dock_widgets/property_sheet/properties/rect -I ui/dock_widgets/property_sheet/properties/rsvector -I ui/dock_widgets/property_sheet/properties/string -I ui/dock_widgets/views_list -I ui/dock_widgets/ucs_list -I ui/dock_widgets/workspaces -I ui/dock_widgets/cad -I ui/main -I ui/main/init -I ui/main/persistence -I ui/main/release_check -I ui/main/support -I ui/main/fontviewer -I ui/main/workspaces -I ui/view -I main -I main/console_dxf2pdf -I test -I plugins -I ../res -I ../res/arrows -I ../res/controls -I ../res/dxf -I ../res/gdt -I ../res/icons -I ../res/images -I ../../../Qt/6.9.0/gcc_64/include -I ../../../Qt/6.9.0/gcc_64/include/QtSvg -I ../../../Qt/6.9.0/gcc_64/include/QtPrintSupport -I ../../../Qt/6.9.0/gcc_64/include/QtWidgets -I ../../../Qt/6.9.0/gcc_64/include/QtGui -I ../../../Qt/6.9.0/gcc_64/include/QtNetwork -I ../../../Qt/6.9.0/gcc_64/include/QtCore -I ../../generated/librecad/moc -I ../../generated/librecad/ui -I ../../../Qt/6.9.0/gcc_64/mkspecs/linux-g++ -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/x86_64-linux-gnu/c++/14 -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../include/c++/14/backward -internal-isystem /usr/lib/llvm-18/lib/clang/18/include -internal-isystem /usr/local/include -internal-isystem /usr/bin/../lib/gcc/x86_64-linux-gnu/14/../../../../x86_64-linux-gnu/include -internal-externc-isystem /usr/include/x86_64-linux-gnu -internal-externc-isystem /include -internal-externc-isystem /usr/include -O2 -std=gnu++1z -fdeprecated-macro -ferror-limit 19 -fgnuc-version=4.2.1 -fskip-odr-check-in-gmf -fcxx-exceptions -fexceptions -vectorize-loops -vectorize-slp -analyzer-output=html -faddrsig -D__GCC_HAVE_DWARF2_CFI_ASM=1 -o /home/runner/work/LibreCAD/LibreCAD/out/2026-08-04-154929-5069-1 -x c++ ui/dock_widgets/property_sheet/lc_propertysheetwidget.cpp
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | |
| 24 | #include "lc_propertysheetwidget.h" |
| 25 | |
| 26 | #include <QMenu> |
| 27 | |
| 28 | #include "lc_actioncontext.h" |
| 29 | #include "lc_actiongroupmanager.h" |
| 30 | #include "lc_dlg_propertysheet_widget_options.h" |
| 31 | #include "lc_entity_property_containerprovider.h" |
| 32 | #include "lc_entitymetauiutils.h" |
| 33 | #include "lc_graphicviewport.h" |
| 34 | #include "lc_properties_sheet.h" |
| 35 | #include "lc_property_container.h" |
| 36 | #include "lc_property_double.h" |
| 37 | #include "lc_property_layer.h" |
| 38 | #include "lc_property_multi.h" |
| 39 | #include "lc_property_rsvector.h" |
| 40 | #include "lc_property_view_registrator.h" |
| 41 | #include "lc_propertysheet_widget_options.h" |
| 42 | #include "lc_shortcuts_manager.h" |
| 43 | #include "qg_graphicview.h" |
| 44 | #include "rs_debug.h" |
| 45 | #include "rs_document.h" |
| 46 | #include "rs_graphicview.h" |
| 47 | #include "rs_selection.h" |
| 48 | #include "rs_settings.h" |
| 49 | #include "ui_lc_propertysheetwidget.h" |
| 50 | |
| 51 | class LC_ToolOptionsPropertiesContainerProvider; |
| 52 | |
| 53 | void LC_PropertySheetWidget::setupSelectionButton(QToolButton* selectionButton, QAction* selectionPointerAction, |
| 54 | LC_ActionGroupManager* actionGroupManager) { |
| 55 | selectionButton->setDefaultAction(selectionPointerAction); |
| 56 | selectionButton->setPopupMode(QToolButton::MenuButtonPopup); |
| 57 | auto* menu = new QMenu(); |
| 58 | QList<QAction*> actions; |
| 59 | actions.push_back(actionGroupManager->getActionByName("SelectAll")); |
| 60 | actions.push_back(actionGroupManager->getActionByName("SelectSingle")); |
| 61 | actions.push_back(actionGroupManager->getActionByName("SelectContour")); |
| 62 | actions.push_back(actionGroupManager->getActionByName("SelectWindow")); |
| 63 | actions.push_back(actionGroupManager->getActionByName("DeselectWindow")); |
| 64 | actions.push_back(actionGroupManager->getActionByName("SelectIntersected")); |
| 65 | actions.push_back(actionGroupManager->getActionByName("DeselectIntersected")); |
| 66 | actions.push_back(actionGroupManager->getActionByName("SelectLayer")); |
| 67 | actions.push_back(actionGroupManager->getActionByName("SelectPoints")); |
| 68 | actions.push_back(actionGroupManager->getActionByName("SelectInvert")); |
| 69 | menu->addActions(actions); |
| 70 | selectionButton->setMenu(menu); |
| 71 | } |
| 72 | |
| 73 | LC_PropertySheetWidget::LC_PropertySheetWidget(QWidget* parent, LC_ActionContext* actionContext, LC_ActionGroupManager* actionGroupManager) |
| 74 | : LC_GraphicViewAwareWidget(parent), ui(new Ui::LC_PropertySheetWidget), m_actionContext{actionContext}, |
| 75 | m_propertySheetOptions{std::make_unique<LC_PropertySheetWidgetOptions>()} { |
| 76 | const auto viewFactory = LC_PropertyViewFactory::staticInstance(); |
| 77 | LC_PropertyViewRegistrator registrator(*viewFactory); |
| 78 | registrator.registerViews(); |
| 79 | |
| 80 | ui->setupUi(this); |
| 81 | |
| 82 | const auto propertiesSheet = ui->propertySheet->propertiesSheet(); |
| 83 | connect(propertiesSheet, &LC_PropertiesSheet::propertyEdited, this, &LC_PropertySheetWidget::onPropertyEdited); |
| 84 | connect(propertiesSheet, &LC_PropertiesSheet::beforePropertyEdited, this, &LC_PropertySheetWidget::onBeforePropertyEdited); |
| 85 | connect(propertiesSheet, &LC_PropertiesSheet::activePropertyChanged, this, &LC_PropertySheetWidget::onActivePropertyChanged); |
| 86 | connect(ui->cbSelection, &QComboBox::currentIndexChanged, this, &LC_PropertySheetWidget::onSelectionIndexChanged); |
| 87 | |
| 88 | connect(ui->tbSettings, &QToolButton::clicked, this, &LC_PropertySheetWidget::onSettingsClicked); |
| 89 | |
| 90 | ui->propertySheet->setParts(PROPERTY_WIDGET_AREA_INFO); |
| 91 | |
| 92 | QAction* quickSelectAction = actionGroupManager->getActionByName("SelectQuick"); |
| 93 | QAction* toggleSelectModeAction = actionGroupManager->getActionByName("SelectionModeToggle"); |
| 94 | QAction* selectEntitiesAction = actionGroupManager->getActionByName("SelectionGeneric"); |
| 95 | QAction* selectionPointerAction = actionGroupManager->getActionByName("EditKillAllActions"); |
| 96 | |
| 97 | ui->tbSelectQuick->setDefaultAction(quickSelectAction); |
| 98 | ui->tbPickAddSwitch->setDefaultAction(toggleSelectModeAction); |
| 99 | ui->tbSelectObjects->setDefaultAction(selectEntitiesAction); |
| 100 | |
| 101 | ui->tbSelectQuickLeft->setDefaultAction(quickSelectAction); |
| 102 | ui->tbPickAddSwitchLeft->setDefaultAction(toggleSelectModeAction); |
| 103 | ui->tbSelectObjectsLeft->setDefaultAction(selectEntitiesAction); |
| 104 | |
| 105 | setupSelectionButton(ui->tbSelectionGeneral, selectionPointerAction, actionGroupManager); |
| 106 | setupSelectionButton(ui->tbSelectionGeneralLeft, selectionPointerAction, actionGroupManager); |
| 107 | |
| 108 | ui->tbCancel->setDefaultAction(selectionPointerAction); |
| 109 | |
| 110 | m_entityContainerProvider = std::make_unique<LC_EntityPropertyContainerProvider>(); |
| 111 | m_entityContainerProvider->init(this, actionContext); |
| 112 | |
| 113 | loadCollapsedSections(); |
| 114 | m_propertySheetOptions->load(); |
| 115 | updatePropertiesSheetFont(); |
| 116 | |
| 117 | ui->tbSelectionGeneral->setVisible(m_propertySheetOptions->duplicateSelectionAction); |
| 118 | ui->tbSelectionGeneralLeft->setVisible(m_propertySheetOptions->duplicateSelectionAction); |
| 119 | |
| 120 | ui->headerAction->setVisible(false); |
| 121 | updateWidgetSettings(); |
| 122 | } |
| 123 | |
| 124 | LC_PropertySheetWidget::~LC_PropertySheetWidget() { |
| 125 | delete ui; |
| 126 | } |
| 127 | |
| 128 | void LC_PropertySheetWidget::updatePropertiesSheetFont() const { |
| 129 | int fontSize = m_propertySheetOptions->fontSize; |
| 130 | ui->propertySheet->setFontSize(fontSize); |
| 131 | } |
| 132 | |
| 133 | void LC_PropertySheetWidget::loadCollapsedSections() { |
| 134 | const QString sectionsList = LC_GET_ONE_STR("PropertySheet", "CollapsedSections", ""); |
| 135 | if (!sectionsList.isEmpty()) { |
| 136 | QStringList parts = sectionsList.split(",", Qt::SkipEmptyParts); |
| 137 | for (const auto& sectionName : std::as_const(parts)) { |
| 138 | m_collapsedContainerNames << sectionName; |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | |
| 143 | void LC_PropertySheetWidget::saveCollapsedSections() { |
| 144 | QString settingsValue; |
| 145 | for (const auto& sectionName : std::as_const(m_collapsedContainerNames)) { |
| 146 | settingsValue = settingsValue + "," + sectionName; |
| 147 | } |
| 148 | LC_SET_ONE("PropertySheet", "CollapsedSections", settingsValue); |
| 149 | } |
| 150 | |
| 151 | void LC_PropertySheetWidget::setGraphicView(RS_GraphicView* gv) { |
| 152 | |
| 153 | if (m_graphicView != nullptr) { |
| 1 | Assuming the condition is false | |
|
| |
| 154 | disconnect(m_graphicView, &RS_GraphicView::relativeZeroChanged, this, &LC_PropertySheetWidget::onRelativeZeroChanged); |
| 155 | disconnect(m_graphicView, &RS_GraphicView::ucsChanged, this, &LC_PropertySheetWidget::onUcsChanged); |
| 156 | disconnect(m_graphicView, &RS_GraphicView::defaultActionActivated, this, &LC_PropertySheetWidget::onViewDefaultActionActivated); |
| 157 | if (m_document != nullptr) { |
| 158 | m_document->getSelection()->removeListener(this); |
| 159 | if (!m_document->is(RS2::EntityBlock)) { |
| 160 | m_document->getUCSList()->removeListener(this); |
| 161 | m_document->getLayerList()->removeListener(this); |
| 162 | m_document->getViewList()->removeListener(this); |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | m_graphicView = gv; |
| 168 | |
| 169 | |
| 170 | if (gv != nullptr) { |
| 3 | | Assuming the condition is true | |
|
| |
| 171 | RS_Document* doc = nullptr; |
| 172 | LC_GraphicViewport* viewport = nullptr; |
| 173 | connect(m_graphicView, &RS_GraphicView::relativeZeroChanged, this, &LC_PropertySheetWidget::onRelativeZeroChanged); |
| 174 | connect(m_graphicView, &RS_GraphicView::ucsChanged, this, &LC_PropertySheetWidget::onUcsChanged); |
| 175 | connect(m_graphicView, &RS_GraphicView::defaultActionActivated, this, &LC_PropertySheetWidget::onViewDefaultActionActivated); |
| 176 | viewport = gv->getViewPort(); |
| 177 | doc = gv->getDocument(); |
| |
| 178 | m_document = doc; |
| 6 | | The value of 'doc' is assigned to field 'm_document' | |
|
| 179 | if (doc != nullptr) { |
| 7 | | Assuming pointer value is null | |
|
| |
| 180 | m_document->getSelection()->addListener(this); |
| 181 | if (!m_document->is(RS2::EntityBlock)) { |
| 182 | m_document->getUCSList()->addListener(this); |
| 183 | m_document->getLayerList()->addListener(this); |
| 184 | m_document->getViewList()->addListener(this); |
| 185 | } |
| 186 | } |
| 187 | |
| 188 | m_viewport = viewport; |
| 189 | |
| 190 | m_entityContainerProvider->setGraphicView(gv); |
| 191 | |
| 192 | initPropertySheet(); |
| 193 | setupSelectionTypeCombobox(RS2::EntityContainer, ""); |
| 9 | | Calling 'LC_PropertySheetWidget::setupSelectionTypeCombobox' | |
|
| 194 | setEnabled(true); |
| 195 | } |
| 196 | else { |
| 197 | m_viewport = nullptr; |
| 198 | m_document = nullptr; |
| 199 | ui->cbSelection->blockSignals(true); |
| 200 | ui->propertySheet->blockSignals(true); |
| 201 | ui->cbSelection->clear(); |
| 202 | const auto previousContainer = ui->propertySheet->propertyContainer(); |
| 203 | if (previousContainer != nullptr) { |
| 204 | m_entityContainerProvider->clearEntities(); |
| 205 | previousContainer->clearChildProperties(); |
| 206 | previousContainer->deleteLater(); |
| 207 | ui->propertySheet->setPropertyContainer(nullptr); |
| 208 | } |
| 209 | ui->cbSelection->blockSignals(false); |
| 210 | ui->propertySheet->blockSignals(false); |
| 211 | setEnabled(false); |
| 212 | } |
| 213 | } |
| 214 | |
| 215 | void LC_PropertySheetWidget::stopInplaceEdit() const { |
| 216 | ui->propertySheet->stopInplaceEdit(); |
| 217 | } |
| 218 | |
| 219 | void LC_PropertySheetWidget::refill() { |
| 220 | |
| 221 | stopInplaceEdit(); |
| 222 | if (m_actionContext->getDocument() == nullptr) { |
| 223 | return; |
| 224 | } |
| 225 | if (m_operationMode == MODE_SELECTION) { |
| 226 | if (m_handleSelectionChange) { |
| 227 | const int selectionIndex = ui->cbSelection->currentIndex(); |
| 228 | if (selectionIndex >= 0) { |
| 229 | |
| 230 | int itemEntityType = getCurrentlySelectedEntityType(selectionIndex); |
| 231 | const auto entityType = static_cast<RS2::EntityType>(itemEntityType); |
| 232 | const auto activeProperty = ui->propertySheet->propertiesSheet()->activeProperty(); |
| 233 | const QString propertyName = activeProperty != nullptr ? activeProperty->getName() : ""; |
| 234 | |
| 235 | setupSelectionTypeCombobox(entityType, propertyName); |
| 236 | } |
| 237 | else { |
| 238 | |
| 239 | setupSelectionTypeCombobox(RS2::EntityContainer, ""); |
| 240 | } |
| 241 | } |
| 242 | } |
| 243 | else { |
| 244 | LC_PropertyContainer* container = prepareToolOptionsContainer(m_toolOptionsPropertiesContainerProvider); |
| 245 | replaceTopLevelContainer(container); |
| 246 | } |
| 247 | |
| 248 | if (!m_activePropertyName.isEmpty()) { |
| 249 | const auto propertiesSheet = ui->propertySheet->propertiesSheet(); |
| 250 | const QString propertyName = m_activePropertyName; |
| 251 | const auto foundProperty = propertiesSheet->getPropertyWithName(propertyName); |
| 252 | if (foundProperty != nullptr) { |
| 253 | propertiesSheet->setActiveProperty(foundProperty, true); |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | |
| 258 | void LC_PropertySheetWidget::showToolOptions(LC_ToolOptionsPropertiesContainerProvider* provider) { |
| 259 | m_toolOptionsPropertiesContainerProvider = provider; |
| 260 | m_operationMode = MODE_TOOL_OPTIONS; |
| 261 | refill(); |
| 262 | } |
| 263 | |
| 264 | void LC_PropertySheetWidget::setShouldHandleSelectionChange(const bool value) { |
| 265 | m_handleSelectionChange = value; |
| 266 | } |
| 267 | |
| 268 | void LC_PropertySheetWidget::updateFormats() { |
| 269 | refill(); |
| 270 | } |
| 271 | |
| 272 | void LC_PropertySheetWidget::doProcessLateRequest(const LC_ActionContext::InteractiveInputInfo& interactiveInputInfo) { |
| 273 | const auto inputType = interactiveInputInfo.inputType; |
| 274 | switch (inputType) { |
| 275 | case LC_ActionContext::InteractiveInputInfo::DISTANCE: { |
| 276 | setPickedPropertyValue(interactiveInputInfo.requestorTag, interactiveInputInfo.distance, inputType); |
| 277 | break; |
| 278 | } |
| 279 | case LC_ActionContext::InteractiveInputInfo::ANGLE: { |
| 280 | setPickedPropertyValue(interactiveInputInfo.requestorTag, interactiveInputInfo.angleRad, inputType); |
| 281 | break; |
| 282 | } |
| 283 | case LC_ActionContext::InteractiveInputInfo::POINT: { |
| 284 | const RS_Vector ucsVector = m_viewport->toUCS(interactiveInputInfo.wcsPoint); |
| 285 | setPickedPointPropertyValue(interactiveInputInfo.requestorTag, ucsVector); |
| 286 | break; |
| 287 | } |
| 288 | case LC_ActionContext::InteractiveInputInfo::POINT_X: { |
| 289 | const RS_Vector ucsVector = m_viewport->toUCS(interactiveInputInfo.wcsPoint); |
| 290 | setPickedPropertyCoordinateValue(interactiveInputInfo.requestorTag, ucsVector.x, true); |
| 291 | break; |
| 292 | } |
| 293 | case LC_ActionContext::InteractiveInputInfo::POINT_Y: { |
| 294 | const RS_Vector ucsVector = m_viewport->toUCS(interactiveInputInfo.wcsPoint); |
| 295 | setPickedPropertyCoordinateValue(interactiveInputInfo.requestorTag, ucsVector.y, false); |
| 296 | break; |
| 297 | } |
| 298 | default: |
| 299 | break; |
| 300 | } |
| 301 | } |
| 302 | |
| 303 | void LC_PropertySheetWidget::onLateRequestCompleted(const bool shouldBeSkipped) { |
| 304 | if (shouldBeSkipped) { |
| 305 | const auto interactiveInput = m_actionContext->getInteractiveInputInfo(); |
| 306 | interactiveInput->requestor = nullptr; |
| 307 | interactiveInput->state = LC_ActionContext::InteractiveInputInfo::NONE; |
| 308 | |
| 309 | } |
| 310 | else { |
| 311 | const auto interactiveInputInfo = m_actionContext->getInteractiveInputInfo(); |
| 312 | const bool updateInteractiveInputValues = interactiveInputInfo->state == LC_ActionContext::InteractiveInputInfo::REQUESTED; |
| 313 | if (updateInteractiveInputValues) { |
| 314 | if (m_operationMode == MODE_SELECTION) { |
| 315 | doProcessLateRequest(*interactiveInputInfo); |
| 316 | } |
| 317 | else { |
| 318 | |
| 319 | LC_ActionContext::InteractiveInputInfo inputCopy; |
| 320 | interactiveInputInfo->copyTo(inputCopy); |
| 321 | QTimer::singleShot(10, [inputCopy, this]() -> void { |
| 322 | doProcessLateRequest(inputCopy); |
| 323 | }); |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | } |
| 328 | |
| 329 | void LC_PropertySheetWidget::onUcsChanged([[maybe_unused]] LC_UCS* ucs) { |
| 330 | m_handleSelectionChange = true; |
| 331 | refill(); |
| 332 | } |
| 333 | |
| 334 | void LC_PropertySheetWidget::onViewDefaultActionActivated(const bool defaultActionActivated, |
| 335 | [[maybe_unused]] const RS2::ActionType actionRtti, |
| 336 | const RS2::ActionType prevActionRtti) { |
| 337 | setShouldHandleSelectionChange(defaultActionActivated); |
| 338 | if (defaultActionActivated) { |
| 339 | |
| 340 | |
| 341 | const bool shouldRefill = !RS2::isInteractiveInputAction(prevActionRtti) && (prevActionRtti != RS2::ActionDefault && prevActionRtti != RS2::ActionNone); |
| 342 | if (shouldRefill) { |
| 343 | refill(); |
| 344 | } |
| 345 | } |
| 346 | } |
| 347 | |
| 348 | void LC_PropertySheetWidget::onRelativeZeroChanged(const RS_Vector&) { |
| 349 | } |
| 350 | |
| 351 | void LC_PropertySheetWidget::setupSelectionTypeCombobox(const RS2::EntityType entityTypeTryToSet, |
| 352 | [[maybe_unused]] QString propertyTryToSet) { |
| 353 | ui->cbSelection->blockSignals(true); |
| 354 | ui->cbSelection->clear(); |
| 355 | int entityTypesCount = 0; |
| 356 | if (m_document != nullptr) { |
| |
| 357 | const auto selection = RS_Selection(m_document, m_viewport); |
| 358 | QMap<RS2::EntityType, int> selectedEntityTypesMap; |
| 359 | selection.countSelectedEntities(selectedEntityTypesMap); |
| 360 | LC_EntityMetaUIUtils::setupSelectionEntityTypesCombobox(ui->cbSelection, selectedEntityTypesMap); |
| 361 | entityTypesCount = selectedEntityTypesMap.count(); |
| 362 | } |
| 363 | ui->cbSelection->blockSignals(false); |
| 364 | |
| 365 | int indexToSet = 0; |
| 366 | |
| 367 | if (entityTypesCount == 1) { |
| |
| 368 | indexToSet = 1; |
| 369 | } |
| 370 | else { |
| 371 | if (entityTypeTryToSet != RS2::EntityContainer) { |
| |
| 372 | const int indexForEntityType = ui->cbSelection->findData(entityTypeTryToSet, Qt::UserRole); |
| 373 | if (indexForEntityType != -1) { |
| 374 | indexToSet = indexForEntityType; |
| 375 | } |
| 376 | } |
| 377 | } |
| 378 | |
| 379 | const int currentIndex = ui->cbSelection->currentIndex(); |
| 380 | if (currentIndex == indexToSet) { |
| 13 | | Assuming 'currentIndex' is equal to 'indexToSet' | |
|
| |
| 381 | onSelectionIndexChanged(currentIndex); |
| 15 | | Calling 'LC_PropertySheetWidget::onSelectionIndexChanged' | |
|
| 382 | } |
| 383 | else { |
| 384 | ui->cbSelection->setCurrentIndex(indexToSet); |
| 385 | } |
| 386 | } |
| 387 | |
| 388 | void LC_PropertySheetWidget::entityModified([[maybe_unused]] RS_Entity* originalEntity, [[maybe_unused]] RS_Entity* entityClone) { |
| 389 | |
| 390 | m_orginalEntities.push_back(originalEntity); |
| 391 | m_modifiedEntities.push_back(entityClone); |
| 392 | } |
| 393 | |
| 394 | void LC_PropertySheetWidget::clearContextEntities() { |
| 395 | for (const auto e : std::as_const(m_orginalEntities)) { |
| 396 | if (RS2::isDimensionalEntity(e->rtti())) { |
| 397 | auto* d = static_cast<RS_Dimension*>(e); |
| 398 | d->clearCachedDimStyle(); |
| 399 | } |
| 400 | } |
| 401 | for (const auto e : std::as_const(m_modifiedEntities)) { |
| 402 | if (RS2::isDimensionalEntity(e->rtti())) { |
| 403 | const auto d = static_cast<RS_Dimension*>(e); |
| 404 | d->clearCachedDimStyle(); |
| 405 | } |
| 406 | } |
| 407 | m_orginalEntities.clear(); |
| 408 | m_modifiedEntities.clear(); |
| 409 | } |
| 410 | |
| 411 | void LC_PropertySheetWidget::initPropertySheet() { |
| 412 | } |
| 413 | |
| 414 | void LC_PropertySheetWidget::onBeforePropertyEdited([[maybe_unused]] LC_Property* property, |
| 415 | [[maybe_unused]] LC_Property::PropertyValuePtr newValue, [[maybe_unused]] int typeId) { |
| 416 | |
| 417 | } |
| 418 | |
| 419 | void LC_PropertySheetWidget::onPropertyEdited(LC_Property* property) { |
| 420 | const bool propertyIsVirtual = isVirtualProperty(property); |
| 421 | if (propertyIsVirtual) { |
| 422 | return; |
| 423 | } |
| 424 | |
| 425 | const QString propertyName = property->getName(); |
| 426 | bool layerHidden = false; |
| 427 | if (propertyName == "layer") { |
| 428 | LC_PropertyAtomic* p = property->asAtomic(); |
| 429 | const auto* multiProperty = dynamic_cast<LC_PropertyMulti*>(p); |
| 430 | if (multiProperty != nullptr) { |
| 431 | const auto layerAtomic = multiProperty->getFirstProperty(); |
| 432 | const auto layerProperty = dynamic_cast<LC_PropertyLayer*>(layerAtomic); |
| 433 | if (layerProperty != nullptr) { |
| 434 | const RS_Layer* layer = layerProperty->value(); |
| 435 | if (layer != nullptr) { |
| 436 | layerHidden = layer->isFrozen(); |
| 437 | } |
| 438 | } |
| 439 | } |
| 440 | } |
| 441 | |
| 442 | |
| 443 | QTimer::singleShot(30, [this, layerHidden]()-> void { |
| 444 | |
| 445 | m_document->undoableModify(m_viewport, [this](LC_DocumentModificationBatch& ctx)-> bool { |
| 446 | ctx.entitiesToAdd.append(m_modifiedEntities); |
| 447 | ctx.entitiesToDelete.append(m_orginalEntities); |
| 448 | ctx.dontSetActiveLayerAndPen(); |
| 449 | clearContextEntities(); |
| 450 | return true; |
| 451 | }, [layerHidden](const LC_DocumentModificationBatch& ctx, RS_Document* doc)-> void { |
| 452 | if (!layerHidden) { |
| 453 | doc->select(ctx.entitiesToAdd); |
| 454 | } |
| 455 | }); |
| 456 | }); |
| 457 | } |
| 458 | |
| 459 | int LC_PropertySheetWidget::getCurrentlySelectedEntityType(const int index) const { |
| 460 | const int itemEntityType = ui->cbSelection->itemData(index, Qt::UserRole).toInt(); |
| 461 | return itemEntityType; |
| 462 | } |
| 463 | |
| 464 | QLayout* LC_PropertySheetWidget::getTopLevelLayout() const { |
| 465 | return ui->gridLayout; |
| 466 | } |
| 467 | |
| 468 | void LC_PropertySheetWidget::replaceTopLevelContainer(LC_PropertyContainer* const newContainer) { |
| 469 | const auto previousContainer = ui->propertySheet->propertyContainer(); |
| 470 | ui->propertySheet->setPropertyContainer(newContainer); |
| 471 | if (previousContainer != nullptr) { |
| 472 | destroyContainer(previousContainer); |
| 473 | } |
| 474 | } |
| 475 | |
| 476 | void LC_PropertySheetWidget::onSelectionIndexChanged(const int index) { |
| 477 | int itemEntityType = getCurrentlySelectedEntityType(index); |
| 478 | const auto entityType = static_cast<RS2::EntityType>(itemEntityType); |
| 479 | const auto newContainer = preparePropertiesContainer(entityType); |
| 16 | | Calling 'LC_PropertySheetWidget::preparePropertiesContainer' | |
|
| 480 | replaceTopLevelContainer(newContainer); |
| 481 | } |
| 482 | |
| 483 | LC_PropertyContainer* LC_PropertySheetWidget::preparePropertiesContainer(const RS2::EntityType entityType) { |
| 484 | QList<RS_Entity*> entitiesToModify; |
| 485 | collectEntitiesToModify(entityType, entitiesToModify); |
| 17 | | Calling 'LC_PropertySheetWidget::collectEntitiesToModify' | |
|
| 486 | LC_PropertyContainer* result = createPropertiesContainer(entityType, entitiesToModify); |
| 487 | return result; |
| 488 | } |
| 489 | |
| 490 | LC_PropertyContainer* LC_PropertySheetWidget::prepareToolOptionsContainer( |
| 491 | LC_ToolOptionsPropertiesContainerProvider* toolOptionsContainerProvider) { |
| 492 | LC_PropertyContainer* result = nullptr; |
| 493 | if (isVisible()) { |
| 494 | result = new LC_PropertyContainer(this); |
| 495 | } |
| 496 | m_entityContainerProvider->fillPropertyContainerToolOptions(m_document, result, toolOptionsContainerProvider, m_propertySheetOptions->showToolOptions); |
| 497 | return result; |
| 498 | } |
| 499 | |
| 500 | void LC_PropertySheetWidget::collectEntitiesToModify(RS2::EntityType entityType, QList<RS_Entity*>& entitiesToModify) const { |
| 501 | if (entityType == RS2::EntityUnknown || entityType == RS2::EntityContainer) { |
| 18 | | Assuming 'entityType' is equal to EntityUnknown | |
|
| 502 | m_document->collectSelected(entitiesToModify); |
| 19 | | Called C++ object pointer is null |
|
| 503 | } |
| 504 | else { |
| 505 | m_document->collectSelected(entitiesToModify, false, {entityType}); |
| 506 | } |
| 507 | } |
| 508 | |
| 509 | LC_PropertyContainer* LC_PropertySheetWidget::createPropertiesContainer(const RS2::EntityType entityType, const QList<RS_Entity*>& list) { |
| 510 | LC_PropertyContainer* result = nullptr; |
| 511 | if (isVisible()) { |
| 512 | result = new LC_PropertyContainer(this); |
| 513 | } |
| 514 | if (list.isEmpty()) { |
| 515 | m_entityContainerProvider->fillPropertyContainerForNoSelection(m_document, result); |
| 516 | } |
| 517 | else { |
| 518 | m_entityContainerProvider->fillPropertyContainerForSelection(m_document, result, entityType, list); |
| 519 | } |
| 520 | return result; |
| 521 | } |
| 522 | |
| 523 | void LC_PropertySheetWidget::destroyContainer(LC_PropertyContainer* previousContainer) const { |
| 524 | m_entityContainerProvider->cleanup(); |
| 525 | m_viewport->clearLocationsHighlight(); |
| 526 | previousContainer->deleteLater(); |
| 527 | } |
| 528 | |
| 529 | void LC_PropertySheetWidget::setPickedPropertyValue(const QString& propertyName, const double interactiveInputValue, |
| 530 | [[maybe_unused]] LC_ActionContext::InteractiveInputInfo::InputType input) const { |
| 531 | const auto propertyContainer = ui->propertySheet->propertyContainer(); |
| 532 | auto propertiesByName = propertyContainer->findChildProperties(propertyName); |
| 533 | const auto propertiesSheet = ui->propertySheet->propertiesSheet(); |
| 534 | if (propertiesByName.isEmpty()) { |
| 535 | LC_ERR << "Unable to find property by name " << propertyName; |
| 536 | } |
| 537 | else { |
| 538 | const auto sheetModel = propertiesSheet->getModel(); |
| 539 | for (const auto p : std::as_const(propertiesByName)) { |
| 540 | auto* valueMultiProperty = dynamic_cast<LC_PropertyMulti*>(p); |
| 541 | if (valueMultiProperty != nullptr) { |
| 542 | const auto propertyItem = sheetModel->findItem(sheetModel->getRootItem(), valueMultiProperty); |
| 543 | const auto valuePropertyAtomic = valueMultiProperty->getFirstProperty(); |
| 544 | const auto valuePropertyDouble = dynamic_cast<LC_PropertyDouble*>(valuePropertyAtomic); |
| 545 | if (valuePropertyDouble != nullptr) { |
| 546 | const auto coordinatePropertyView = propertyItem->view.get(); |
| 547 | valueMultiProperty->markEdited(true); |
| 548 | propertiesSheet->connectOnPropertyChange(valueMultiProperty, true); |
| 549 | valuePropertyDouble->setValue(interactiveInputValue, coordinatePropertyView->changeReasonDueToEdit()); |
| 550 | propertiesSheet->connectOnPropertyChange(valueMultiProperty, false); |
| 551 | } |
| 552 | } |
| 553 | else { |
| 554 | const auto valuePropertyDouble = dynamic_cast<LC_PropertyDouble*>(p); |
| 555 | if (valuePropertyDouble != nullptr) { |
| 556 | valuePropertyDouble->setValue(interactiveInputValue, PropertyChangeReasonEdit); |
| 557 | } |
| 558 | } |
| 559 | } |
| 560 | } |
| 561 | } |
| 562 | |
| 563 | void LC_PropertySheetWidget::setPickedPropertyCoordinateValue(const QString& propertyName, const double interactiveInputValue, |
| 564 | const bool forX) const { |
| 565 | const auto propertyContainer = ui->propertySheet->propertyContainer(); |
| 566 | auto propertiesByName = propertyContainer->findChildProperties(propertyName); |
| 567 | const auto propertiesSheet = ui->propertySheet->propertiesSheet(); |
| 568 | |
| 569 | if (propertiesByName.isEmpty()) { |
| 570 | LC_ERR << "Unable to find property by name " << propertyName; |
| 571 | } |
| 572 | else { |
| 573 | const auto sheetModel = propertiesSheet->getModel(); |
| 574 | for (const auto p : std::as_const(propertiesByName)) { |
| 575 | const auto* vectorMultiProperty = dynamic_cast<LC_PropertyMulti*>(p); |
| 576 | if (vectorMultiProperty == nullptr) { |
| 577 | const auto vectorProperty = dynamic_cast<LC_PropertyRSVector*>(p); |
| 578 | if (vectorProperty != nullptr) { |
| 579 | |
| 580 | const int subPropertyIdx = forX ? 0 : 1; |
| 581 | const auto propertyItem = sheetModel->findItem(sheetModel->getRootItem(), vectorProperty); |
| 582 | const auto coordinatePropertyItem = propertyItem->children.at(subPropertyIdx).get(); |
| 583 | const auto coordinatePropertyView = coordinatePropertyItem->view.get(); |
| 584 | |
| 585 | const auto coordinateProperty = static_cast<LC_PropertyDouble*>(coordinatePropertyView->getProperty()); |
| 586 | |
| 587 | propertiesSheet->connectOnPropertyChange(vectorProperty, true); |
| 588 | coordinateProperty->setValue(interactiveInputValue, propertyItem->view->changeReasonDueToEdit()); |
| 589 | propertiesSheet->connectOnPropertyChange(vectorProperty, false); |
| 590 | } |
| 591 | } |
| 592 | else { |
| 593 | |
| 594 | const auto propertyItem = sheetModel->findItem(sheetModel->getRootItem(), vectorMultiProperty); |
| 595 | if (propertyItem != nullptr) { |
| 596 | const auto vectorMultiPropertyView = propertyItem->view.get(); |
| 597 | const int subPropertyIdx = forX ? 0 : 1; |
| 598 | const auto coordinateSubProperty = vectorMultiPropertyView->getSubProperty(subPropertyIdx); |
| 599 | auto* coordinateMultiProperty = dynamic_cast<LC_PropertyMulti*>(coordinateSubProperty); |
| 600 | if (coordinateMultiProperty != nullptr) { |
| 601 | const auto coordinateFirstAtomic = coordinateMultiProperty->getFirstProperty(); |
| 602 | const auto coordinateDoubleProperty = dynamic_cast<LC_PropertyDouble*>(coordinateFirstAtomic); |
| 603 | if (coordinateDoubleProperty != nullptr) { |
| 604 | const auto coordinatePropertyItem = propertyItem->children.at(subPropertyIdx).get(); |
| 605 | const auto coordinatePropertyView = coordinatePropertyItem->view.get(); |
| 606 | coordinateMultiProperty->markEdited(true); |
| 607 | propertiesSheet->connectOnPropertyChange(vectorMultiProperty, true); |
| 608 | coordinateDoubleProperty->setValue(interactiveInputValue, coordinatePropertyView->changeReasonDueToEdit()); |
| 609 | propertiesSheet->connectOnPropertyChange(vectorMultiProperty, false); |
| 610 | } |
| 611 | } |
| 612 | } |
| 613 | } |
| 614 | } |
| 615 | } |
| 616 | } |
| 617 | |
| 618 | void LC_PropertySheetWidget::setPickedPointPropertyValue(const QString& propertyName, const RS_Vector& ucsVector) const { |
| 619 | const auto propertyContainer = ui->propertySheet->propertyContainer(); |
| 620 | |
| 621 | auto lcProperties = propertyContainer->findChildProperties(propertyName); |
| 622 | if (lcProperties.isEmpty()) { |
| 623 | LC_ERR << "Unable to find property by name " << propertyName; |
| 624 | } |
| 625 | else { |
| 626 | const auto propertiesSheet = ui->propertySheet->propertiesSheet(); |
| 627 | const auto sheetModel = propertiesSheet->getModel(); |
| 628 | for (const auto p : std::as_const(lcProperties)) { |
| 629 | const auto vectorPropertyMulti = dynamic_cast<LC_PropertyMulti*>(p); |
| 630 | if (vectorPropertyMulti == nullptr) { |
| 631 | const auto vectorProperty = dynamic_cast<LC_PropertyRSVector*>(p); |
| 632 | if (vectorProperty != nullptr) { |
| 633 | |
| 634 | propertiesSheet->connectOnPropertyChange(vectorProperty, true); |
| 635 | const auto propertyItem = sheetModel->findItem(sheetModel->getRootItem(), vectorProperty); |
| 636 | vectorProperty->setValue(ucsVector, propertyItem->view->changeReasonDueToEdit()); |
| 637 | propertiesSheet->connectOnPropertyChange(vectorProperty, false); |
| 638 | } |
| 639 | } |
| 640 | else { |
| 641 | |
| 642 | const auto propertyItem = sheetModel->findItem(sheetModel->getRootItem(), vectorPropertyMulti); |
| 643 | if (propertyItem != nullptr) { |
| 644 | const auto vectorAtomic = vectorPropertyMulti->getFirstProperty(); |
| 645 | const auto vectorProperty = dynamic_cast<LC_PropertyRSVector*>(vectorAtomic); |
| 646 | if (vectorProperty != nullptr) { |
| 647 | vectorPropertyMulti->markEdited(true); |
| 648 | propertiesSheet->connectOnPropertyChange(vectorPropertyMulti, true); |
| 649 | vectorProperty->setValue(ucsVector, propertyItem->view->changeReasonDueToEdit()); |
| 650 | propertiesSheet->connectOnPropertyChange(vectorPropertyMulti, false); |
| 651 | } |
| 652 | } |
| 653 | } |
| 654 | } |
| 655 | } |
| 656 | } |
| 657 | |
| 658 | bool LC_PropertySheetWidget::isVirtualProperty(const LC_Property* property) { |
| 659 | const auto descriptor = property->getViewDescriptor(); |
| 660 | bool result = false; |
| 661 | if (descriptor != nullptr) { |
| 662 | descriptor->load(LC_PropertyView::ATTR_VIRTUAL, result); |
| 663 | } |
| 664 | return result; |
| 665 | } |
| 666 | |
| 667 | bool LC_PropertySheetWidget::isCollapsedSection(const QString& name) const { |
| 668 | return m_collapsedContainerNames.contains(name); |
| 669 | } |
| 670 | |
| 671 | void LC_PropertySheetWidget::markContainerCollapsed(const QString& name, const bool collapse) { |
| 672 | if (collapse) { |
| 673 | m_collapsedContainerNames << name; |
| 674 | } |
| 675 | else { |
| 676 | m_collapsedContainerNames.remove(name); |
| 677 | } |
| 678 | saveCollapsedSections(); |
| 679 | } |
| 680 | |
| 681 | void LC_PropertySheetWidget::checkSectionCollapsed(LC_PropertyContainer* result) { |
| 682 | const QString name = result->getName(); |
| 683 | const bool containerCollapsed = isCollapsedSection(name); |
| 684 | if (containerCollapsed) { |
| 685 | result->collapse(); |
| 686 | } |
| 687 | connect(result, &LC_Property::afterPropertyChange, this, &LC_PropertySheetWidget::onSectionPropertyChanged); |
| 688 | } |
| 689 | |
| 690 | void LC_PropertySheetWidget::onSectionPropertyChanged(const LC_PropertyChangeReason reason) { |
| 691 | if (reason.testFlag(PropertyChangeReasonStateLocal)) { |
| 692 | const auto property = qobject_cast<LC_Property*>(sender()); |
| 693 | const QString name = property->getName(); |
| 694 | const bool collapsed = property->isCollapsed(); |
| 695 | markContainerCollapsed(name, collapsed); |
| 696 | } |
| 697 | } |
| 698 | |
| 699 | void LC_PropertySheetWidget::onActivePropertyChanged(LC_Property* activeProperty) { |
| 700 | if (m_viewport == nullptr) { |
| 701 | return; |
| 702 | } |
| 703 | m_viewport->clearLocationsHighlight(); |
| 704 | if (activeProperty == nullptr) { |
| 705 | return; |
| 706 | } |
| 707 | const auto masterProperty = activeProperty->getPrimaryProperty(); |
| 708 | if (masterProperty != nullptr) { |
| 709 | checkIfVectorAndGetLocation(masterProperty); |
| 710 | } |
| 711 | else { |
| 712 | checkIfVectorAndGetLocation(activeProperty); |
| 713 | } |
| 714 | |
| 715 | m_activePropertyName = activeProperty->getName(); |
| 716 | } |
| 717 | |
| 718 | void LC_PropertySheetWidget::highlightVectorPropertyPosition(const LC_PropertyRSVector* vectorProperty) const { |
| 719 | if (!vectorProperty->isMultiValue()) { |
| 720 | const RS_Vector ucsPosition = vectorProperty->value(); |
| 721 | const auto wcsPosition = m_viewport->toWorld(ucsPosition); |
| 722 | m_viewport->highlightLocation(wcsPosition); |
| 723 | } |
| 724 | } |
| 725 | |
| 726 | void LC_PropertySheetWidget::checkIfVectorAndGetLocation(LC_Property* property) { |
| 727 | auto vectorProperty = dynamic_cast<LC_PropertyRSVector*>(property); |
| 728 | if (vectorProperty == nullptr) { |
| 729 | const auto multiCandidate = dynamic_cast<LC_PropertyMulti*>(property); |
| 730 | if (multiCandidate != nullptr) { |
| 731 | const auto firstProperty = multiCandidate->getFirstProperty(); |
| 732 | if (firstProperty != nullptr) { |
| 733 | vectorProperty = dynamic_cast<LC_PropertyRSVector*>(firstProperty); |
| 734 | if (vectorProperty != nullptr) { |
| 735 | highlightVectorPropertyPosition(vectorProperty); |
| 736 | } |
| 737 | } |
| 738 | } |
| 739 | } |
| 740 | else { |
| 741 | highlightVectorPropertyPosition(vectorProperty); |
| 742 | } |
| 743 | } |
| 744 | |
| 745 | void LC_PropertySheetWidget::invalidateCached() const { |
| 746 | const auto propertiesSheet = ui->propertySheet->propertiesSheet(); |
| 747 | const auto sheetModel = propertiesSheet->getModel(); |
| 748 | sheetModel->invalidateCached(); |
| 749 | } |
| 750 | |
| 751 | void LC_PropertySheetWidget::onDockVisibilityChanged(const bool visible) { |
| 752 | |
| 753 | if (visible) { |
| 754 | m_handleSelectionChange = true; |
| 755 | refill(); |
| 756 | } |
| 757 | else { |
| 758 | m_handleSelectionChange = false; |
| 759 | } |
| 760 | } |
| 761 | |
| 762 | void LC_PropertySheetWidget::onActivePenChanged(RS_Pen) { |
| 763 | const auto container = ui->propertySheet->propertyContainer(); |
| 764 | if (container != nullptr) { |
| 765 | const int tag = container->getTag(); |
| 766 | if (tag == LC_EntityPropertyContainerProvider::TAG_CONTAINER_NO_SELECTION) { |
| 767 | refill(); |
| 768 | } |
| 769 | } |
| 770 | } |
| 771 | |
| 772 | void LC_PropertySheetWidget::onSettingsClicked() { |
| 773 | LC_DlgPropertySheetWidgetOptions dlg(this, m_propertySheetOptions.get()); |
| 774 | if (dlg.exec() == QDialog::Accepted) { |
| 775 | const bool showSelectionButton = m_propertySheetOptions->duplicateSelectionAction; |
| 776 | ui->tbSelectionGeneral->setVisible(showSelectionButton); |
| 777 | ui->tbSelectionGeneralLeft->setVisible(showSelectionButton); |
| 778 | updatePropertiesSheetFont(); |
| 779 | refill(); |
| 780 | } |
| 781 | } |
| 782 | |
| 783 | void LC_PropertySheetWidget::doAdjustForDockLocation(Qt::DockWidgetArea area) { |
| 784 | LC_GraphicViewAwareWidget::doAdjustForDockLocation(area); |
| 785 | switch (area) { |
| 786 | case Qt::DockWidgetArea::LeftDockWidgetArea: { |
| 787 | ui->wCommandsForLeft->setVisible(true); |
| 788 | ui->wCommandsForRight->setVisible(false); |
| 789 | break; |
| 790 | } |
| 791 | case Qt::DockWidgetArea::RightDockWidgetArea: { |
| 792 | ui->wCommandsForLeft->setVisible(false); |
| 793 | ui->wCommandsForRight->setVisible(true); |
| 794 | break; |
| 795 | } |
| 796 | default: |
| 797 | |
| 798 | break; |
| 799 | } |
| 800 | } |
| 801 | |
| 802 | void LC_PropertySheetWidget::setCurrentQAction(const QAction* a) { |
| 803 | bool showIcon = a != nullptr ; |
| 804 | if (showIcon) { |
| 805 | |
| 806 | const auto property = a->property("_SetAsCurrentActionInView"); |
| 807 | if (property.isValid()) { |
| 808 | showIcon = property.toBool(); |
| 809 | } |
| 810 | } |
| 811 | if (showIcon) { |
| 812 | const QIcon icon = a->icon(); |
| 813 | const QString text = LC_ShortcutsManager::getPlainActionToolTip(a); |
| 814 | ui->lblActionIcon->setVisible(!icon.isNull()); |
| 815 | constexpr int m_iconSize = 24; |
| 816 | ui->lblActionIcon->setPixmap(icon.pixmap(m_iconSize)); |
| 817 | ui->lblActionName->setText(text); |
| 818 | ui->headerAction->setVisible(true); |
| 819 | ui->headerSelection->setVisible(false); |
| 820 | m_operationMode = MODE_TOOL_OPTIONS; |
| 821 | } |
| 822 | else { |
| 823 | ui->headerAction->setVisible(false); |
| 824 | ui->headerSelection->setVisible(true); |
| 825 | m_operationMode = MODE_SELECTION; |
| 826 | |
| 827 | |
| 828 | |
| 829 | |
| 830 | |
| 831 | |
| 832 | |
| 833 | |
| 834 | |
| 835 | |
| 836 | |
| 837 | |
| 838 | |
| 839 | } |
| 840 | } |