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_quickinfopointsdata.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/entity_info/lc_quickinfopointsdata.cpp
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
| 9 | |
| 10 | |
| 11 | |
| 12 | |
| 13 | |
| 14 | |
| 15 | |
| 16 | |
| 17 | |
| 18 | |
| 19 | |
| 20 | |
| 21 | |
| 22 | |
| 23 | #include "lc_quickinfopointsdata.h" |
| 24 | |
| 25 | #include "lc_graphicviewport.h" |
| 26 | |
| 27 | LC_QuickInfoPointsData::LC_QuickInfoPointsData() = default; |
| 28 | |
| 29 | LC_QuickInfoPointsData::~LC_QuickInfoPointsData(){ |
| 30 | LC_QuickInfoPointsData::clear(); |
| 31 | } |
| 32 | |
| 33 | |
| 34 | |
| 35 | |
| 36 | |
| 37 | bool LC_QuickInfoPointsData::hasData() const{ |
| 38 | return !m_collectedPoints.isEmpty(); |
| 39 | } |
| 40 | |
| 41 | |
| 42 | |
| 43 | |
| 44 | |
| 45 | |
| 46 | bool LC_QuickInfoPointsData::removeCoordinate(const int index){ |
| 47 | const int size = m_collectedPoints.size(); |
| 48 | if (index >= 0 && index < size){ |
| 49 | m_collectedPoints.remove(index); |
| 50 | doUpdatePointsAttributes(); |
| 51 | return true; |
| 52 | } |
| 53 | return false; |
| 54 | } |
| 55 | |
| 56 | |
| 57 | |
| 58 | |
| 59 | |
| 60 | void LC_QuickInfoPointsData::processCoordinate(const RS_Vector &wcsPoint){ |
| 61 | |
| 62 | const int pointsCount = m_collectedPoints.size(); |
| 63 | PointInfo *pointInfo = nullptr; |
| 1 | 'pointInfo' initialized to a null pointer value | |
|
| 64 | const int index = pointsCount + 1; |
| 65 | QString idxValue; |
| 66 | idxValue.setNum(index); |
| 67 | |
| 68 | const RS_Vector relZero = getRelativeZero(); |
| 69 | |
| 70 | switch (m_coordinatesMode){ |
| 2 | | Control jumps to the 'default' case at line 116 | |
|
| 71 | case COORD_ABSOLUTE: |
| 72 | |
| 73 | pointInfo = createPointInfo(wcsPoint, wcsPoint, idxValue, false); |
| 74 | break; |
| 75 | case COORD_RELATIVE:{ |
| 76 | |
| 77 | if (relZero.valid){ |
| 78 | |
| 79 | const RS_Vector wcsRelative = wcsPoint - relZero; |
| 80 | pointInfo = createPointInfo(wcsPoint, wcsRelative, idxValue, true); |
| 81 | } |
| 82 | else{ |
| 83 | pointInfo = createPointInfo(wcsPoint, wcsPoint, idxValue, false); |
| 84 | } |
| 85 | break; |
| 86 | } |
| 87 | case COORD_RELATIVE_TO_FIRST:{ |
| 88 | if (pointsCount == 0){ |
| 89 | |
| 90 | const RS_Vector dummyWCSZero = m_viewport->toWorld(RS_Vector(0, 0, 0)); |
| 91 | pointInfo = createPointInfo(wcsPoint, dummyWCSZero, idxValue, false); |
| 92 | } |
| 93 | else{ |
| 94 | |
| 95 | const RS_Vector firstPoint = m_collectedPoints.at(0)->data; |
| 96 | |
| 97 | const RS_Vector wcsRelative = wcsPoint - firstPoint; |
| 98 | pointInfo = createPointInfo(wcsPoint, wcsRelative, idxValue, true); |
| 99 | } |
| 100 | break; |
| 101 | } |
| 102 | case COORD_RELATIVE_TO_PREVIOUS:{ |
| 103 | if (pointsCount == 0){ |
| 104 | const RS_Vector dummyWCSZero = m_viewport->toWorld(RS_Vector(0, 0, 0)); |
| 105 | pointInfo = createPointInfo(wcsPoint, dummyWCSZero, idxValue, false); |
| 106 | } |
| 107 | else{ |
| 108 | |
| 109 | const RS_Vector prevPoint = m_collectedPoints.at(pointsCount - 1)->data; |
| 110 | |
| 111 | const RS_Vector wcsRelative = wcsPoint - prevPoint; |
| 112 | pointInfo = createPointInfo(wcsPoint, wcsRelative, idxValue, true); |
| 113 | } |
| 114 | break; |
| 115 | } |
| 116 | default: |
| 117 | Q_ASSERT(false); |
| 118 | } |
| 119 | |
| 120 | |
| 121 | if (m_collectedPointsInsertionIndex < 0){ |
| 3 | | Assuming field 'm_collectedPointsInsertionIndex' is < 0 | |
|
| |
| 122 | |
| 123 | m_collectedPoints << pointInfo; |
| 124 | } |
| 125 | else{ |
| 126 | |
| 127 | m_collectedPoints.insert(m_collectedPointsInsertionIndex, pointInfo); |
| 128 | m_collectedPointsInsertionIndex++; |
| 129 | } |
| 130 | |
| 131 | |
| 132 | |
| 133 | |
| 134 | if (m_collectedPointsInsertionIndex >= 0){ |
| 5 | | Assuming field 'm_collectedPointsInsertionIndex' is >= 0 | |
|
| |
| 135 | const int size = m_collectedPoints.size(); |
| 136 | for (int i = 0; i < size; i++) { |
| 7 | | Assuming 'i' is < 'size' | |
|
| 8 | | Loop condition is true. Entering loop body | |
|
| 137 | PointInfo *info = m_collectedPoints.at(i); |
| 138 | const int pointIndex = i + 1; |
| 139 | QString indexValue; |
| 140 | indexValue.setNum(pointIndex); |
| 141 | info->label = indexValue; |
| 142 | if (m_coordinatesMode == COORD_RELATIVE_TO_PREVIOUS){ |
| 9 | | Assuming field 'm_coordinatesMode' is equal to COORD_RELATIVE_TO_PREVIOUS | |
|
| |
| 143 | QString angleValue; |
| 144 | QString lengthValue; |
| 145 | if (i == 0){ |
| |
| 146 | angleValue.clear(); |
| 147 | lengthValue.clear(); |
| 148 | } |
| 149 | else{ |
| 150 | RS_Vector prevPoint = m_collectedPoints.at(i - 1)->data; |
| 151 | RS_Vector ucsViewCoordinate; |
| 152 | ucsViewCoordinate = wcsPoint - prevPoint; |
| 153 | ucsViewCoordinate = m_viewport->toUCSDelta(ucsViewCoordinate); |
| 154 | const double ucsAngleToPrevious = ucsViewCoordinate.angle(); |
| 155 | const double lenToPrevious = ucsViewCoordinate.magnitude(); |
| 156 | |
| 157 | angleValue = formatUCSAngle(ucsAngleToPrevious); |
| 158 | lengthValue = formatLinear(lenToPrevious); |
| 159 | } |
| 160 | pointInfo->angle = angleValue; |
| 12 | | Called C++ object pointer is null |
|
| 161 | pointInfo->distance = lengthValue; |
| 162 | } |
| 163 | } |
| 164 | } |
| 165 | } |
| 166 | |
| 167 | LC_QuickInfoPointsData::PointInfo* LC_QuickInfoPointsData::createPointInfo(const RS_Vector &point, const RS_Vector &viewCoordinate, const QString &idxValue, const bool relative) const { |
| 168 | QString value; |
| 169 | RS_Vector viewCoord; |
| 170 | QString angleVal; |
| 171 | if (relative){ |
| 172 | viewCoord = m_viewport->toUCSDelta(viewCoordinate); |
| 173 | value = formatWCSDeltaVector(viewCoordinate); |
| 174 | const double ucsAngle = viewCoord.angle(); |
| 175 | angleVal = formatUCSAngle(ucsAngle); |
| 176 | } |
| 177 | else{ |
| 178 | viewCoord = viewCoordinate; |
| 179 | value = formatWCSVector(viewCoordinate); |
| 180 | const double angle = viewCoord.angle(); |
| 181 | angleVal = formatWCSAngle(angle); |
| 182 | } |
| 183 | |
| 184 | |
| 185 | auto* pointInfo = new PointInfo(point, idxValue, value); |
| 186 | |
| 187 | const double len = viewCoord.magnitude(); |
| 188 | |
| 189 | const QString lengthVal = formatLinear(len); |
| 190 | |
| 191 | pointInfo->angle = angleVal; |
| 192 | pointInfo->distance = lengthVal; |
| 193 | return pointInfo; |
| 194 | } |
| 195 | |
| 196 | |
| 197 | |
| 198 | |
| 199 | |
| 200 | |
| 201 | |
| 202 | QString LC_QuickInfoPointsData::generateView(const bool showDistanceAndAngle, const bool forceUpdate){ |
| 203 | |
| 204 | const int pointsCount = m_collectedPoints.size(); |
| 205 | QString data = "<body>"; |
| 206 | if (pointsCount > 0){ |
| 207 | if (forceUpdate){ |
| 208 | doUpdatePointsAttributes(); |
| 209 | } |
| 210 | |
| 211 | const PointInfo *firstPoint = m_collectedPoints.at(0); |
| 212 | const auto zero = RS_Vector(0,0,0); |
| 213 | switch (m_coordinatesMode) { |
| 214 | case COORD_ABSOLUTE:{ |
| 215 | data.append(tr("Zero")).append(": <b>").append(formatUCSVector(zero)).append("</b><hr>"); |
| 216 | break; |
| 217 | } |
| 218 | case COORD_RELATIVE:{ |
| 219 | const RS_Vector wcsRelZero = getRelativeZero(); |
| 220 | QString vectorStr; |
| 221 | if (wcsRelZero.valid) { |
| 222 | vectorStr = formatWCSVector(wcsRelZero); |
| 223 | } else { |
| 224 | vectorStr = formatUCSVector(zero); |
| 225 | } |
| 226 | data.append(tr("Relative Zero")).append(": <b>").append(vectorStr).append("</b><hr>"); |
| 227 | break; |
| 228 | } |
| 229 | case COORD_RELATIVE_TO_FIRST: |
| 230 | case COORD_RELATIVE_TO_PREVIOUS: { |
| 231 | const QString label = tr("First point").append(": "); |
| 232 | const QString value = formatWCSVector(firstPoint->data); |
| 233 | createLink(data, "zero", 0, tr("Set Relative Zero"), label); |
| 234 | data.append(" <b>"); |
| 235 | createLink(data, "coord", 0, tr("To Cmd"), value); |
| 236 | data.append(" </b>"); |
| 237 | data.append("<hr>"); |
| 238 | break; |
| 239 | } |
| 240 | default: |
| 241 | break; |
| 242 | } |
| 243 | |
| 244 | double totalDistance = 0.0; |
| 245 | |
| 246 | |
| 247 | RS_Vector prevPoint = firstPoint->data; |
| 248 | for (int i = 0; i < pointsCount; i++){ |
| 249 | const PointInfo* pointInfo = m_collectedPoints.at(i); |
| 250 | createLink(data, "zero", i, tr("Set Relative Zero"), pointInfo->label); |
| 251 | data.append(" | "); |
| 252 | createLink(data, "coord", i, tr("To Cmd"), pointInfo->value); |
| 253 | if (showDistanceAndAngle){ |
| 254 | data.append(" | "); |
| 255 | data.append(pointInfo->distance).append(", < ").append(pointInfo->angle); |
| 256 | } |
| 257 | |
| 258 | if (i < (pointsCount-1)){ |
| 259 | data.append("<br>"); |
| 260 | } |
| 261 | RS_Vector coord = pointInfo->data; |
| 262 | |
| 263 | const double distance = coord.distanceTo(prevPoint); |
| 264 | totalDistance += distance; |
| 265 | |
| 266 | prevPoint = coord; |
| 267 | |
| 268 | } |
| 269 | |
| 270 | data.append(" <hr>").append(tr("Points Path Distance:")).append(" <b>").append(formatLinear(totalDistance)).append("</b>"); |
| 271 | |
| 272 | } |
| 273 | else{ |
| 274 | data = tr("No data - select coordinates first..."); |
| 275 | } |
| 276 | data.append("</body>"); |
| 277 | return data; |
| 278 | } |
| 279 | |
| 280 | |
| 281 | |
| 282 | |
| 283 | |
| 284 | |
| 285 | bool LC_QuickInfoPointsData::updateForCoordinateViewMode(const int mode){ |
| 286 | if (m_coordinatesMode != mode){ |
| 287 | m_coordinatesMode = mode; |
| 288 | doUpdatePointsAttributes(); |
| 289 | return true; |
| 290 | } |
| 291 | return false; |
| 292 | } |
| 293 | |
| 294 | |
| 295 | |
| 296 | |
| 297 | void LC_QuickInfoPointsData::doUpdatePointsAttributes() const { |
| 298 | int pointsCount = m_collectedPoints.size(); |
| 299 | |
| 300 | RS_Vector relZero = getRelativeZero(); |
| 301 | |
| 302 | QString value; |
| 303 | QString angleVal; |
| 304 | QString lengthVal; |
| 305 | |
| 306 | for (int i = 0; i < pointsCount; i++) { |
| 307 | PointInfo *pointInfo = m_collectedPoints.at(i); |
| 308 | RS_Vector &wcsPoint = pointInfo->data; |
| 309 | switch (m_coordinatesMode) { |
| 310 | case COORD_ABSOLUTE:{ |
| 311 | value = formatWCSVector(wcsPoint); |
| 312 | angleVal = formatWCSAngle(wcsPoint.angle()); |
| 313 | lengthVal = formatLinear(wcsPoint.magnitude()); |
| 314 | break; |
| 315 | } |
| 316 | case COORD_RELATIVE: { |
| 317 | if (relZero.valid){ |
| 318 | RS_Vector wcsRelative = wcsPoint - relZero; |
| 319 | RS_Vector viewCoord = m_viewport->toUCSDelta(wcsRelative); |
| 320 | value = formatWCSDeltaVector(viewCoord); |
| 321 | double ucsAngle = viewCoord.angle(); |
| 322 | angleVal = formatUCSAngle(ucsAngle); |
| 323 | lengthVal = formatLinear(viewCoord.magnitude()); |
| 324 | } else { |
| 325 | value = formatWCSVector(wcsPoint); |
| 326 | angleVal = formatWCSAngle(wcsPoint.angle()); |
| 327 | lengthVal = formatLinear(wcsPoint.magnitude()); |
| 328 | } |
| 329 | break; |
| 330 | } |
| 331 | case COORD_RELATIVE_TO_FIRST: { |
| 332 | if (pointsCount == 0){ |
| 333 | value = formatUCSVector(RS_Vector(0, 0, 0)); |
| 334 | angleVal.clear(); |
| 335 | lengthVal.clear(); |
| 336 | } else { |
| 337 | RS_Vector firstPoint = m_collectedPoints.at(0)->data; |
| 338 | RS_Vector wcsRelative = wcsPoint - firstPoint; |
| 339 | RS_Vector viewCoord = m_viewport->toUCSDelta(wcsRelative); |
| 340 | value = formatWCSDeltaVector(viewCoord); |
| 341 | double ucsAngle = viewCoord.angle(); |
| 342 | angleVal = formatUCSAngle(ucsAngle); |
| 343 | lengthVal = formatLinear(viewCoord.magnitude()); |
| 344 | } |
| 345 | break; |
| 346 | } |
| 347 | case COORD_RELATIVE_TO_PREVIOUS: { |
| 348 | if (i == 0){ |
| 349 | value = formatUCSVector(RS_Vector(0, 0, 0)); |
| 350 | angleVal.clear(); |
| 351 | lengthVal.clear(); |
| 352 | } else { |
| 353 | RS_Vector prevPoint = m_collectedPoints.at(i - 1)->data; |
| 354 | RS_Vector wcsRelative = wcsPoint - prevPoint; |
| 355 | RS_Vector viewCoord = m_viewport->toUCSDelta(wcsRelative); |
| 356 | value = formatWCSDeltaVector(viewCoord); |
| 357 | double ucsAngle = viewCoord.angle(); |
| 358 | angleVal = formatUCSAngle(ucsAngle); |
| 359 | lengthVal = formatLinear(viewCoord.magnitude()); |
| 360 | } |
| 361 | break; |
| 362 | } |
| 363 | default: |
| 364 | break; |
| 365 | } |
| 366 | |
| 367 | pointInfo->value = value; |
| 368 | pointInfo->distance = lengthVal; |
| 369 | pointInfo->angle = angleVal; |
| 370 | |
| 371 | QString index; |
| 372 | index.setNum(i+1); |
| 373 | pointInfo->label = index; |
| 374 | } |
| 375 | } |
| 376 | |
| 377 | |
| 378 | |
| 379 | |
| 380 | |
| 381 | |
| 382 | RS_Vector LC_QuickInfoPointsData::getVectorForIndex(const int index) const{ |
| 383 | auto result = RS_Vector(false); |
| 384 | if (index < m_collectedPoints.size()){ |
| 385 | result = m_collectedPoints.at(index)->data; |
| 386 | } |
| 387 | return result; |
| 388 | } |
| 389 | |
| 390 | |
| 391 | |
| 392 | |
| 393 | void LC_QuickInfoPointsData::clear(){ |
| 394 | qDeleteAll(m_collectedPoints.begin(), m_collectedPoints.end()); |
| 395 | m_collectedPoints.clear(); |
| 396 | } |