File size: 42,336 Bytes
a5ffdcd | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 | /*
* ********************************************************************************
* This file is part of the LibreCAD project, a 2D CAD program
*
* Copyright (C) 2025 LibreCAD.org
* Copyright (C) 2025 sand1024
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* ********************************************************************************
*/
#include "lc_actionhandlerfactory.h"
#include "lc_actioncontext.h"
#include "lc_actiondimarc.h"
#include "lc_actiondimordinate.h"
#include "lc_actiondimordinaterebase.h"
#include "lc_actiondimstyleapply.h"
#include "lc_actiondrawarc2pointsangle.h"
#include "lc_actiondrawarc2pointsheight.h"
#include "lc_actiondrawarc2pointslength.h"
#include "lc_actiondrawarc2pointsradius.h"
#include "lc_actiondrawboundingbox.h"
#include "lc_actiondrawcircle2pr.h"
#include "lc_actiondrawcirclebyarc.h"
#include "lc_actiondrawcross.h"
#include "lc_actiondrawdimbaseline.h"
#include "lc_actiondrawellipse1point.h"
#include "lc_actiondrawgdtfeaturecontrolframe.h"
#include "lc_actiondrawlineanglerel.h"
#include "lc_actiondrawlinefrompointtoline.h"
#include "lc_actiondrawlinepoints.h"
#include "lc_actiondrawlinepolygon3.h"
#include "lc_actiondrawlinepolygon4.h"
#include "lc_actiondrawlinesnake.h"
#include "lc_actiondrawmidline.h"
#include "lc_actiondrawparabola4points.h"
#include "lc_actiondrawparabolaFD.h"
#include "lc_actiondrawhyperbolafp.h"
#include "lc_actiondrawpointslattice.h"
#include "lc_actiondrawrectangle1point.h"
#include "lc_actiondrawrectangle2points.h"
#include "lc_actiondrawrectangle3points.h"
#include "lc_actiondrawslicedivide.h"
#include "lc_actiondrawsplinepoints.h"
#include "lc_actiondrawstar.h"
#include "lc_actioneditpastetransform.h"
#include "lc_actionentitylayertoggle.h"
#include "lc_actionfileexportmakercam.h"
#include "lc_actioninfo3pointsangle.h"
#include "lc_actioninfopickcoordinates.h"
#include "lc_actioninfopoint.h"
#include "lc_actioninfoproperties.h"
#include "lc_actioninteractivepickangle.h"
#include "lc_actioninteractivepickdistance.h"
#include "lc_actioninteractivepickposition.h"
#include "lc_actionlayerscmd.h"
#include "lc_actionlayersexport.h"
#include "lc_actionlayerstoggleconstruction.h"
#include "lc_actionmodifyalign.h"
#include "lc_actionmodifyalignref.h"
#include "lc_actionmodifyalignsingle.h"
#include "lc_actionmodifybreakdivide.h"
#include "lc_actionmodifyduplicate.h"
#include "lc_actionmodifylinegap.h"
#include "lc_actionmodifylinejoin.h"
#include "lc_actionmodifymoveadjust.h"
#include "lc_actionpastetopoints.h"
#include "lc_actionpenapply.h"
#include "lc_actionpenpick.h"
#include "lc_actionpensyncactivebylayer.h"
#include "lc_actionpolylinearcstolines.h"
#include "lc_actionpolylinechangesegmenttype.h"
#include "lc_actionremovesplinepoints.h"
#include "lc_actionselectdimordinatesameorigin.h"
#include "lc_actionselectpoints.h"
#include "lc_actionsnapmiddlemanual.h"
#include "lc_actionsplineaddpoint.h"
#include "lc_actionsplineappendpoint.h"
#include "lc_actionsplineexplode.h"
#include "lc_actionsplinefrompolyline.h"
#include "lc_actionsplineremovebetween.h"
#include "lc_actionucsbydimordinate.h"
#include "lc_actionucscreate.h"
#include "pick/lc_actioninteractivepickposition.h"
#include "rs_actionblocksadd.h"
#include "rs_actionblocksattributes.h"
#include "rs_actionblockscreate.h"
#include "rs_actionblocksedit.h"
#include "rs_actionblocksexplode.h"
#include "rs_actionblocksfreezeall.h"
#include "rs_actionblocksinsert.h"
#include "rs_actionblocksremove.h"
#include "rs_actionblockssave.h"
#include "rs_actionblockstoggleview.h"
#include "rs_actiondimaligned.h"
#include "rs_actiondimangular.h"
#include "rs_actiondimdiametric.h"
#include "rs_actiondimleader.h"
#include "rs_actiondimlinear.h"
#include "rs_actiondimradial.h"
#include "rs_actiondrawarc.h"
#include "rs_actiondrawarc3p.h"
#include "rs_actiondrawarctangential.h"
#include "rs_actiondrawcircle.h"
#include "rs_actiondrawcircle2p.h"
#include "rs_actiondrawcircle3p.h"
#include "rs_actiondrawcirclecr.h"
#include "rs_actiondrawcircleinscribe.h"
#include "rs_actiondrawcircletan1_2p.h"
#include "rs_actiondrawcircletan2.h"
#include "rs_actiondrawcircletan2_1p.h"
#include "rs_actiondrawcircletan3.h"
#include "rs_actiondrawellipse4points.h"
#include "rs_actiondrawellipseaxis.h"
#include "rs_actiondrawellipsecenter3points.h"
#include "rs_actiondrawellipsefocipoint.h"
#include "rs_actiondrawellipseinscribe.h"
#include "rs_actiondrawhatch.h"
#include "rs_actiondrawimage.h"
#include "rs_actiondrawline.h"
#include "rs_actiondrawlineangle.h"
#include "rs_actiondrawlinebisector.h"
#include "rs_actiondrawlinefree.h"
#include "rs_actiondrawlinehorvert.h"
#include "rs_actiondrawlineorthtan.h"
#include "rs_actiondrawlineparallel.h"
#include "rs_actiondrawlineparallelthrough.h"
#include "rs_actiondrawlinepolygon.h"
#include "rs_actiondrawlinepolygon2.h"
#include "rs_actiondrawlinerectangle.h"
#include "rs_actiondrawlinerelangle.h"
#include "rs_actiondrawlinetangent1.h"
#include "rs_actiondrawlinetangent2.h"
#include "rs_actiondrawmtext.h"
#include "rs_actiondrawpoint.h"
#include "rs_actiondrawpolyline.h"
#include "rs_actiondrawspline.h"
#include "rs_actiondrawtext.h"
#include "rs_actioneditcopy.h"
#include "rs_actioneditundo.h"
#include "rs_actioninfoangle.h"
#include "rs_actioninfoarea.h"
#include "rs_actioninfodist.h"
#include "rs_actioninfodist2.h"
#include "rs_actioninfoinside.h"
#include "rs_actioninfototallength.h"
#include "rs_actioninterface.h"
#include "rs_actionlayersadd.h"
#include "rs_actionlayersedit.h"
#include "rs_actionlayersfreezeall.h"
#include "rs_actionlayerslockall.h"
#include "rs_actionlayersremove.h"
#include "rs_actionlayerstogglelock.h"
#include "rs_actionlayerstoggleprint.h"
#include "rs_actionlayerstoggleview.h"
#include "rs_actionlibraryinsert.h"
#include "rs_actionlockrelativezero.h"
#include "rs_actionmodifyattributes.h"
#include "rs_actionmodifybevel.h"
#include "rs_actionmodifycut.h"
#include "rs_actionmodifydelete.h"
#include "rs_actionmodifydeletefree.h"
#include "rs_actionmodifyentity.h"
#include "rs_actionmodifyexplodetext.h"
#include "rs_actionmodifymirror.h"
#include "rs_actionmodifymove.h"
#include "rs_actionmodifymoverotate.h"
#include "rs_actionmodifyoffset.h"
#include "rs_actionmodifyrevertdirection.h"
#include "rs_actionmodifyrotate.h"
#include "rs_actionmodifyrotate2.h"
#include "rs_actionmodifyround.h"
#include "rs_actionmodifyscale.h"
#include "rs_actionmodifystretch.h"
#include "rs_actionmodifytrim.h"
#include "rs_actionmodifytrimamount.h"
#include "rs_actionoptionsdrawing.h"
#include "rs_actionorder.h"
#include "rs_actionpolylineadd.h"
#include "rs_actionpolylineappend.h"
#include "rs_actionpolylinedel.h"
#include "rs_actionpolylinedelbetween.h"
#include "rs_actionpolylineequidistant.h"
#include "rs_actionpolylinesegment.h"
#include "rs_actionpolylinetrim.h"
#include "rs_actionselectall.h"
#include "rs_actionselectcontour.h"
#include "rs_actionselectintersected.h"
#include "rs_actionselectinvert.h"
#include "rs_actionselectlayer.h"
#include "rs_actionselectsingle.h"
#include "rs_actionselectwindow.h"
#include "rs_actionsetrelativezero.h"
#include "rs_actiontoolregeneratedimensions.h"
#include "rs_actionzoomauto.h"
#include "rs_actionzoomin.h"
#include "rs_actionzoompan.h"
#include "rs_actionzoomprevious.h"
#include "rs_actionzoomredraw.h"
#include "rs_actionzoomwindow.h"
#include "rs_debug.h"
#include "rs_dialogfactory.h"
#include "rs_dialogfactoryinterface.h"
#include "rs_graphicview.h"
#include "rs_layerlist.h"
#include "rs_selection.h"
RS_Layer* obtainLayer(LC_ActionContext* m_actionContext, void* data) {
RS_Layer* layer{nullptr};
if (data != nullptr) {
layer = static_cast<RS_Layer*>(data);
}
else {
RS_Document* document = m_actionContext->getEntityContainer()->getDocument();
layer = (document->getLayerList() != nullptr) ? document->getLayerList()->getActive() : nullptr;
}
return layer;
}
bool hasSelection(LC_ActionContext* m_actionContext) {
return m_actionContext->getEntityContainer()->countSelected() > 0;
// fixme - sand - think about moving to the action context
}
bool hasNoSelection(LC_ActionContext* m_actionContext) {
return m_actionContext->getEntityContainer()->countSelected() == 0;
// fixme - sand - think about moving to the action context
}
namespace InnerFactory{
RS_ActionInterface* doCreateActionInstance(RS2::ActionType actionType, LC_ActionContext* ctx, void* data) {
auto view = ctx->getGraphicView();
switch (actionType) {
case RS2::ActionEditKillAllActions: {
if (view != nullptr) {
// DO we need to call some form of a 'clean' function?
view->killAllActions();
auto document = ctx->getEntityContainer();
RS_Selection s(static_cast<RS_EntityContainer&>(*document), view->getViewPort());
s.selectAll(false);
auto selectionInfo = document->getSelectionInfo();
ctx->updateSelectionWidget(selectionInfo.count, selectionInfo.length);
// RS_DIALOGFACTORY->updateSelectionWidget(document->countSelected(), document->totalSelectedLength());
}
return nullptr;
}
case RS2::ActionEditUndo: {
//to avoid operation on deleted entities, Undo action invalid all suspended
//actions
view->killAllActions();
return new RS_ActionEditUndo(true, ctx);
}
case RS2::ActionEditRedo: {
return new RS_ActionEditUndo(false, ctx);
}
case RS2::ActionEditCut: {
return new RS_ActionEditCopyPaste(ctx, RS2::ActionEditCut);
}
case RS2::ActionEditCutQuick: {
return new RS_ActionEditCopyPaste(ctx, RS2::ActionEditCutQuick);
}
case RS2::ActionEditCopy: {
return new RS_ActionEditCopyPaste(ctx, RS2::ActionEditCopy);
}
case RS2::ActionEditCopyQuick: {
return new RS_ActionEditCopyPaste(ctx, RS2::ActionEditCopyQuick);
}
case RS2::ActionEditPaste: {
return new RS_ActionEditCopyPaste(ctx, RS2::ActionEditPaste);
}
case RS2::ActionEditPasteTransform: {
return new LC_ActionEditPasteTransform(ctx);
}
case RS2::ActionPasteToPoints: {
return new LC_ActionPasteToPoints(ctx);
}
case RS2::ActionOrderBottom: {
return new RS_ActionOrder(ctx, RS2::ActionOrderBottom);
}
case RS2::ActionOrderLower: {
return new RS_ActionOrder(ctx, RS2::ActionOrderLower);
}
case RS2::ActionOrderRaise: {
return new RS_ActionOrder(ctx, RS2::ActionOrderRaise);
}
case RS2::ActionOrderTop: {
return new RS_ActionOrder(ctx, RS2::ActionOrderTop);
}
case RS2::ActionSelectSingle: {
// fixme - sand - files - that's suspicious implementation, check it again for plugins
RS_ActionInterface* currentAction = ctx->getCurrentAction();
if (currentAction->rtti() != RS2::ActionSelectSingle) {
return new RS_ActionSelectSingle(ctx, currentAction);
}
break;
}
case RS2::ActionSelectContour: {
return new RS_ActionSelectContour(ctx);
}
case RS2::ActionSelectAll: {
return new RS_ActionSelectAll(ctx, true);
}
case RS2::ActionDeselectAll: {
return new RS_ActionSelectAll(ctx, false);
}
case RS2::ActionSelectWindow: {
return new RS_ActionSelectWindow(view->getTypeToSelect(), ctx, true);
}
case RS2::ActionSelectPoints: {
return new LC_ActionSelectPoints(ctx);
}
case RS2::ActionDeselectWindow: {
return new RS_ActionSelectWindow(ctx, false);
}
case RS2::ActionSelectInvert: {
return new RS_ActionSelectInvert(ctx);
}
case RS2::ActionSelectIntersected: {
return new RS_ActionSelectIntersected(ctx, true);
}
case RS2::ActionDeselectIntersected: {
return new RS_ActionSelectIntersected(ctx, false);
}
case RS2::ActionSelectLayer: {
return new RS_ActionSelectLayer(ctx);
}
case RS2::ActionDimRegenerate: {
return new RS_ActionToolRegenerateDimensions(ctx);
}
case RS2::ActionZoomIn: {
return new RS_ActionZoomIn(ctx, RS2::In, RS2::Both);
}
case RS2::ActionZoomOut: {
return new RS_ActionZoomIn(ctx, RS2::Out, RS2::Both);
}
case RS2::ActionZoomAuto: {
return new RS_ActionZoomAuto(ctx);
}
case RS2::ActionZoomWindow: {
return new RS_ActionZoomWindow(ctx);
}
case RS2::ActionZoomPan:{
return new RS_ActionZoomPan(ctx);
}
case RS2::ActionZoomPrevious: {
return new RS_ActionZoomPrevious(ctx);
}
case RS2::ActionZoomRedraw: {
return new RS_ActionZoomRedraw(ctx);
}
case RS2::ActionDrawPoint: {
return new RS_ActionDrawPoint(ctx);
}
case RS2::ActionDrawLine: {
return new RS_ActionDrawLine(ctx);
}
case RS2::ActionDrawLineAngle: {
return new RS_ActionDrawLineAngle(ctx, false);
}
case RS2::ActionDrawLineHorizontal: {
return new RS_ActionDrawLineAngle(ctx, true,RS2::ActionDrawLineHorizontal);
}
case RS2::ActionDrawLineHorVert: {
return new RS_ActionDrawLineHorVert(ctx);
}
case RS2::ActionDrawLineVertical: {
return new RS_ActionDrawLineAngle(ctx, true,RS2::ActionDrawLineVertical);
}
case RS2::ActionDrawLineFree: {
return new RS_ActionDrawLineFree(ctx);
}
case RS2::ActionDrawLineParallel: {
return new RS_ActionDrawLineParallel(ctx, RS2::ActionDrawLineParallel);
}
case RS2::ActionDrawCircleParallel: {
return new RS_ActionDrawLineParallel(ctx, RS2::ActionDrawCircleParallel);
}
case RS2::ActionDrawArcParallel: {
return new RS_ActionDrawLineParallel(ctx, RS2::ActionDrawArcParallel);
}
case RS2::ActionDrawLineParallelThrough: {
return new RS_ActionDrawLineParallelThrough(ctx);
}
case RS2::ActionDrawLineRectangle: {
return new RS_ActionDrawLineRectangle(ctx);
}
case RS2::ActionDrawRectangle3Points: {
return new LC_ActionDrawRectangle3Points(ctx);
}
case RS2::ActionDrawRectangle2Points: {
return new LC_ActionDrawRectangle2Points(ctx);
}
case RS2::ActionDrawRectangle1Point: {
return new LC_ActionDrawRectangle1Point(ctx);
}
case RS2::ActionDrawCross: {
return new LC_ActionDrawCross(ctx);
}
case RS2::ActionDrawBoundingBox: {
return new LC_ActionDrawBoundingBox(ctx);
}
case RS2::ActionDrawSnakeLine: {
return new LC_ActionDrawLineSnake(ctx, RS2::ActionDrawSnakeLine);
}
case RS2::ActionDrawSnakeLineX: {
return new LC_ActionDrawLineSnake(ctx, RS2::ActionDrawSnakeLineX);
}
case RS2::ActionDrawSnakeLineY: {
return new LC_ActionDrawLineSnake(ctx, RS2::ActionDrawSnakeLineY);
}
case RS2::ActionDrawSliceDivideLine: {
return new LC_ActionDrawSliceDivide(ctx, false);
}
case RS2::ActionDrawSliceDivideCircle: {
return new LC_ActionDrawSliceDivide(ctx, true);
}
case RS2::ActionDrawLinePoints: {
return new LC_ActionDrawLinePoints(ctx, false);
}
case RS2::ActionDrawPointsMiddle: {
return new LC_ActionDrawLinePoints(ctx, true);
}
case RS2::ActionDrawPointsLattice: {
return new LC_ActionDrawPointsLattice(ctx);
}
case RS2::ActionDrawLineBisector: {
return new RS_ActionDrawLineBisector(ctx);
}
case RS2::ActionDrawLineOrthTan: {
return new RS_ActionDrawLineOrthTan(ctx);
}
case RS2::ActionDrawLineTangent1: {
return new RS_ActionDrawLineTangent1(ctx);
}
case RS2::ActionDrawLineTangent2: {
return new RS_ActionDrawLineTangent2(ctx);
}
case RS2::ActionDrawLineOrthogonal: {
return new RS_ActionDrawLineRelAngle(ctx, M_PI_2, true);
}
case RS2::ActionDrawLineRelAngle: {
return new RS_ActionDrawLineRelAngle(ctx, M_PI_2, false);
}
case RS2::ActionDrawPolyline: {
return new RS_ActionDrawPolyline(ctx);
}
case RS2::ActionDrawLineOrthogonalRel: {
return new LC_ActionDrawLineAngleRel(ctx, 90.0, true);
}
case RS2::ActionDrawLineAngleRel: {
return new LC_ActionDrawLineAngleRel(ctx, 0.0, false);
}
case RS2::ActionDrawLineFromPointToLine: {
return new LC_ActionDrawLineFromPointToLine(ctx);
}
case RS2::ActionDrawLineMiddle: {
return new LC_ActionDrawMidLine(ctx);
}
case RS2::ActionDrawStar: {
return new LC_ActionDrawStar(ctx);
}
case RS2::ActionPolylineAdd: {
return new RS_ActionPolylineAdd(ctx);
}
case RS2::ActionPolylineAppend: {
return new RS_ActionPolylineAppend(ctx);
}
case RS2::ActionPolylineDel: {
return new RS_ActionPolylineDel(ctx);
}
case RS2::ActionPolylineDelBetween: {
return new RS_ActionPolylineDelBetween(ctx);
}
case RS2::ActionPolylineTrim: {
return new RS_ActionPolylineTrim(ctx);
}
case RS2::ActionPolylineEquidistant: {
return new RS_ActionPolylineEquidistant(ctx);
}
case RS2::ActionPolylineSegment: {
if (data == nullptr) {
return new RS_ActionPolylineSegment(ctx);
}
else {
return new RS_ActionPolylineSegment(ctx, static_cast<RS_Entity*>(data));
}
}
case RS2::ActionPolylineArcsToLines: {
return new LC_ActionPolylineArcsToLines(ctx);
}
case RS2::ActionPolylineChangeSegmentType: {
return new LC_ActionPolylineChangeSegmentType(ctx);
}
case RS2::ActionDrawLinePolygonCenCor: {
return new RS_ActionDrawLinePolygonCenCor(ctx);
}
case RS2::ActionDrawLinePolygonCenTan: {
//20161223 added by txmy
return new LC_ActionDrawLinePolygonCenTan(ctx);
}
case RS2::ActionDrawLinePolygonSideSide: {
return new LC_ActionDrawLinePolygon4(ctx);
}
case RS2::ActionDrawLinePolygonCorCor: {
return new RS_ActionDrawLinePolygonCorCor(ctx);
}
case RS2::ActionDrawCircle: {
return new RS_ActionDrawCircle(ctx);
}
case RS2::ActionDrawCircleCR: {
return new RS_ActionDrawCircleCR(ctx);
}
case RS2::ActionDrawCircleByArc: {
return new LC_ActionDrawCircleByArc(ctx);
}
case RS2::ActionDrawCircle2P: {
return new RS_ActionDrawCircle2P(ctx);
}
case RS2::ActionDrawCircle2PR: {
return new LC_ActionDrawCircle2PR(ctx);
}
case RS2::ActionDrawCircle3P: {
return new RS_ActionDrawCircle3P(ctx);
}
case RS2::ActionDrawCircleTan1_2P: {
return new RS_ActionDrawCircleTan1_2P(ctx);
}
case RS2::ActionDrawCircleTan2_1P: {
return new RS_ActionDrawCircleTan2_1P(ctx);
}
case RS2::ActionDrawCircleInscribe: {
return new RS_ActionDrawCircleInscribe(ctx);
}
case RS2::ActionDrawCircleTan2: {
return new RS_ActionDrawCircleTan2(ctx);
}
case RS2::ActionDrawCircleTan3: {
return new RS_ActionDrawCircleTan3(ctx);
}
case RS2::ActionDrawArc: {
return new RS_ActionDrawArc(ctx, RS2::ActionDrawArc);
}
case RS2::ActionDrawArcChord: {
return new RS_ActionDrawArc(ctx, RS2::ActionDrawArcChord);
}
case RS2::ActionDrawArcAngleLen: {
return new RS_ActionDrawArc(ctx, RS2::ActionDrawArcAngleLen);
}
case RS2::ActionDrawArc3P: {
return new RS_ActionDrawArc3P(ctx);
}
case RS2::ActionDrawArcTangential: {
return new RS_ActionDrawArcTangential(ctx);
}
case RS2::ActionDrawArc2PRadius: {
return new LC_ActionDrawArc2PointsRadius(ctx);
}
case RS2::ActionDrawArc2PAngle: {
return new LC_ActionDrawArc2PointsAngle(ctx);
}
case RS2::ActionDrawArc2PHeight: {
return new LC_ActionDrawArc2PointsHeight(ctx);
}
case RS2::ActionDrawArc2PLength: {
return new LC_ActionDrawArc2PointsLength(ctx);
}
case RS2::ActionDrawEllipseAxis: {
return new RS_ActionDrawEllipseAxis(ctx, false);
}
case RS2::ActionDrawEllipseArcAxis: {
return new RS_ActionDrawEllipseAxis(ctx, true);
}
case RS2::ActionDrawEllipse1Point: {
return new LC_ActionDrawEllipse1Point(ctx, false);
}
case RS2::ActionDrawEllipseArc1Point: {
return new LC_ActionDrawEllipse1Point(ctx, true);
}
case RS2::ActionDrawParabola4Points: {
return new LC_ActionDrawParabola4Points(ctx);
}
case RS2::ActionDrawParabolaFD: {
return new LC_ActionDrawParabolaFD(ctx);
}
case RS2::ActionDrawHyperbolaFP: {
return new LC_ActionDrawHyperbolaFP(ctx);
}
case RS2::ActionDrawEllipseFociPoint: {
return new RS_ActionDrawEllipseFociPoint(ctx);
}
case RS2::ActionDrawEllipse4Points: {
return new RS_ActionDrawEllipse4Points(ctx);
}
case RS2::ActionDrawEllipseCenter3Points: {
return new RS_ActionDrawEllipseCenter3Points(ctx);
}
case RS2::ActionDrawEllipseInscribe: {
return new RS_ActionDrawEllipseInscribe(ctx);
}
case RS2::ActionDrawSpline: {
return new RS_ActionDrawSpline(ctx);
}
case RS2::ActionDrawSplinePoints: {
return new LC_ActionDrawSplinePoints(ctx);
}
case RS2::ActionDrawSplinePointRemove: {
return new LC_ActionRemoveSplinePoints(ctx);
}
case RS2::ActionDrawSplinePointDelTwo: {
return new LC_ActionSplineRemoveBetween(ctx);
}
case RS2::ActionDrawSplinePointAppend: {
return new LC_ActionSplineAppendPoint(ctx);
}
case RS2::ActionDrawSplinePointAdd: {
return new LC_ActionSplineAddPoint(ctx);
}
case RS2::ActionDrawSplineExplode: {
return new LC_ActionSplineExplode(ctx);
}
case RS2::ActionDrawSplineFromPolyline: {
return new LC_ActionSplineFromPolyline(ctx);
}
case RS2::ActionDrawMText: {
return new RS_ActionDrawMText(ctx);
}
case RS2::ActionDrawText: {
return new RS_ActionDrawText(ctx);
}
case RS2::ActionDrawHatch: {
return new RS_ActionDrawHatch(ctx);
}
case RS2::ActionDrawImage: {
return new RS_ActionDrawImage(ctx);
}
case RS2::ActionDimAligned: {
return new RS_ActionDimAligned(ctx);
}
case RS2::ActionDimLinear: {
return new RS_ActionDimLinear(ctx);
}
case RS2::ActionDimOrdinate: {
return new LC_ActionDimOrdinate(ctx);
}
case RS2::ActionGTDFCFrame: {
return new LC_ActionDrawGDTFeatureControlFrame(ctx);
}
case RS2::ActionDimLinearHor: {
return new RS_ActionDimLinear(ctx, 0.0, true, RS2::ActionDimLinearHor);
}
case RS2::ActionDimLinearVer: {
return new RS_ActionDimLinear(ctx, M_PI_2, true, RS2::ActionDimLinearVer);
}
case RS2::ActionDimRadial: {
return new RS_ActionDimRadial(ctx);
}
case RS2::ActionDimDiametric: {
return new RS_ActionDimDiametric(ctx);
}
case RS2::ActionDimAngular: {
return new RS_ActionDimAngular(ctx);
}
case RS2::ActionDimArc: {
return new LC_ActionDimArc(ctx);
}
case RS2::ActionDimLeader: {
return new RS_ActionDimLeader(ctx);
}
case RS2::ActionDimBaseline: {
return new LC_ActionDrawDimBaseline(ctx, RS2::ActionDimBaseline);
}
case RS2::ActionDimContinue: {
return new LC_ActionDrawDimBaseline(ctx, RS2::ActionDimContinue);
}
case RS2::ActionDimStyleApply: {
return new LC_ActionDimStyleApply(ctx);
}
case RS2::ActionModifyLineJoin: {
return new LC_ActionModifyLineJoin(ctx);
}
case RS2::ActionModifyDuplicate: {
return new LC_ActionModifyDuplicate(ctx);
}
case RS2::ActionModifyBreakDivide: {
return new LC_ActionModifyBreakDivide(ctx);
}
case RS2::ActionModifyLineGap: {
return new LC_ActionModifyLineGap(ctx);
}
case RS2::ActionModifyAttributes: {
return new RS_ActionModifyAttributes(ctx);
}
case RS2::ActionModifyDelete:
[[fallthrough]];
case RS2::ActionModifyDeleteQuick: {
return new RS_ActionModifyDelete(ctx);
}
case RS2::ActionModifyDeleteFree: {
return new RS_ActionModifyDeleteFree(ctx);
}
case RS2::ActionModifyMove: {
return new RS_ActionModifyMove(ctx);
}
case RS2::ActionModifyRevertDirection: {
return new RS_ActionModifyRevertDirection(ctx);
}
case RS2::ActionModifyRotate: {
return new RS_ActionModifyRotate(ctx);
}
case RS2::ActionModifyScale: {
return new RS_ActionModifyScale(ctx);
}
case RS2::ActionModifyMirror: {
return new RS_ActionModifyMirror(ctx);
}
case RS2::ActionModifyMoveRotate: {
return new RS_ActionModifyMoveRotate(ctx);
}
case RS2::ActionModifyRotate2: {
return new RS_ActionModifyRotate2(ctx);
}
case RS2::ActionModifyEntity: {
return new RS_ActionModifyEntity(ctx);
}
case RS2::ActionModifyTrim: {
return new RS_ActionModifyTrim(ctx, false);
}
case RS2::ActionModifyTrim2: {
return new RS_ActionModifyTrim(ctx, true);
}
case RS2::ActionModifyTrimAmount: {
return new RS_ActionModifyTrimAmount(ctx);
}
case RS2::ActionModifyCut: {
return new RS_ActionModifyCut(ctx);
}
case RS2::ActionModifyStretch: {
return new RS_ActionModifyStretch(ctx);
}
case RS2::ActionModifyBevel: {
return new RS_ActionModifyBevel(ctx);
}
case RS2::ActionModifyRound: {
return new RS_ActionModifyRound(ctx);
}
case RS2::ActionModifyOffset: {
return new RS_ActionModifyOffset(ctx);
}
case RS2::ActionModifyExplodeText: {
return new RS_ActionModifyExplodeText(ctx);
}
case RS2::ActionModifyAlign: {
return new LC_ActionModifyAlign(ctx);
}
case RS2::ActionModifyAlignOne: {
return new LC_ActionModifyAlignSingle(ctx);
}
case RS2::ActionModifyAlignRef: {
return new LC_ActionModifyAlignRef(ctx);
}
case RS2::ActionSetRelativeZero: {
return new RS_ActionSetRelativeZero(ctx);
}
case RS2::ActionLockRelativeZero: {
return new RS_ActionLockRelativeZero(ctx, true);
}
case RS2::ActionUnlockRelativeZero: {
return new RS_ActionLockRelativeZero(ctx, false);
}
case RS2::ActionPenPick: {
return new LC_ActionPenPick(ctx, false);
}
case RS2::ActionPenPickResolved: {
return new LC_ActionPenPick(ctx, true);
}
case RS2::ActionPenApply: {
return new LC_ActionPenApply(ctx, false);
}
case RS2::ActionPenCopy: {
return new LC_ActionPenApply(ctx, true);
}
case RS2::ActionPenSyncFromLayer: {
return new LC_ActionPenSyncActiveByLayer(ctx);
}
case RS2::ActionInfoInside: {
return new RS_ActionInfoInside(ctx);
}
case RS2::ActionInfoDistPoint2Point: {
return new RS_ActionInfoDist(ctx);
}
case RS2::ActionInfoDistEntity2Point: {
return new RS_ActionInfoDist2(ctx);
}
case RS2::ActionInfoDistPoint2Entity: {
return new RS_ActionInfoDist2(ctx, true);
}
case RS2::ActionInfoPoint: {
return new LC_ActionInfoPoint(ctx);
}
case RS2::ActionInfoAngle: {
return new RS_ActionInfoAngle(ctx);
}
case RS2::ActionInfoAngle3Points: {
return new LC_ActionInfo3PointsAngle(ctx);
}
case RS2::ActionInfoTotalLength: {
return new RS_ActionInfoTotalLength(ctx);
}
case RS2::ActionInfoArea: {
return new RS_ActionInfoArea(ctx);
}
case RS2::ActionInfoProperties: {
return new LC_ActionInfoProperties(ctx);
}
case RS2::ActionInfoPickCoordinates: {
return new LC_ActionInfoPickCoordinates(ctx);
}
case RS2::ActionLayersDefreezeAll: {
return new RS_ActionLayersFreezeAll(false, ctx);
}
case RS2::ActionLayersFreezeAll: {
return new RS_ActionLayersFreezeAll(true, ctx);
}
case RS2::ActionLayersUnlockAll: {
return new RS_ActionLayersLockAll(false, ctx);
}
case RS2::ActionLayersLockAll: {
return new RS_ActionLayersLockAll(true, ctx);
}
case RS2::ActionLayersAdd: {
return new RS_ActionLayersAdd(ctx);
}
case RS2::ActionLayersAddCmd: {
return new LC_ActionLayersCmd(ctx, RS2::ActionLayersAddCmd);
}
case RS2::ActionLayersActivateCmd: {
return new LC_ActionLayersCmd(ctx, RS2::ActionLayersActivateCmd);
}
case RS2::ActionLayersRemove: {
return new RS_ActionLayersRemove(ctx);
}
case RS2::ActionLayersEdit: {
return new RS_ActionLayersEdit(ctx);
}
case RS2::ActionLayersToggleView: {
auto a_layer = obtainLayer(ctx, data);
if (a_layer != nullptr) {
return new RS_ActionLayersToggleView(ctx, a_layer);
}
break;
}
case RS2::ActionLayersToggleLock: {
auto a_layer = obtainLayer(ctx, data);
if (a_layer != nullptr) {
return new RS_ActionLayersToggleLock(ctx, a_layer);
}
break;
}
case RS2::ActionLayersTogglePrint: {
auto a_layer = obtainLayer(ctx, data);
if (a_layer != nullptr) {
return new RS_ActionLayersTogglePrint(ctx, a_layer);
}
break;
}
case RS2::ActionLayersToggleConstruction: {
auto a_layer = obtainLayer(ctx, data);
if (a_layer != nullptr) {
return new LC_ActionLayersToggleConstruction(ctx, a_layer);
}
break;
}
case RS2::ActionLayersExportSelected: {
return new LC_ActionLayersExport(ctx, LC_ActionLayersExport::SelectedMode);
}
case RS2::ActionLayersExportVisible: {
return new LC_ActionLayersExport(ctx, LC_ActionLayersExport::VisibleMode);
}
case RS2::ActionBlocksDefreezeAll: {
return new RS_ActionBlocksFreezeAll(false, ctx);
}
case RS2::ActionBlocksFreezeAll: {
return new RS_ActionBlocksFreezeAll(true, ctx);
}
case RS2::ActionBlocksAdd: {
return new RS_ActionBlocksAdd(ctx);
}
case RS2::ActionBlocksRemove: {
return new RS_ActionBlocksRemove(ctx);
}
case RS2::ActionBlocksAttributes: {
return new RS_ActionBlocksAttributes(ctx);
}
case RS2::ActionBlocksEdit: {
return new RS_ActionBlocksEdit(ctx);
}
case RS2::ActionBlocksSave: {
return new RS_ActionBlocksSave(ctx);
}
case RS2::ActionBlocksInsert: {
return new RS_ActionBlocksInsert(ctx);
}
case RS2::ActionBlocksToggleView: {
return new RS_ActionBlocksToggleView(ctx);
}
case RS2::ActionBlocksCreate: {
return new RS_ActionBlocksCreate(ctx);
}
case RS2::ActionBlocksExplode: {
return new RS_ActionBlocksExplode(ctx);
}
case RS2::ActionLibraryInsert: {
return new RS_ActionLibraryInsert(ctx);
}
case RS2::ActionOptionsDrawing: {
return new RS_ActionOptionsDrawing(ctx);
}
case RS2::ActionOptionsDrawingGrid: {
return new RS_ActionOptionsDrawing(ctx, 2);
}
case RS2::ActionOptionsDrawingUnits: {
return new RS_ActionOptionsDrawing(ctx, 1);
}
case RS2::ActionUCSCreate: {
return new LC_ActionUCSCreate(ctx);
}
case RS2::ActionUCSSetByDimOrdinate: {
return new LC_ActionUCSByDimOrdinate(ctx);
}
case RS2::ActionFileExportMakerCam: {
return new LC_ActionFileExportMakerCam(ctx);
}
case RS2::ActionSnapMiddleManual: {
auto currentAction = ctx->getCurrentAction();
if (currentAction != nullptr) {
if (currentAction->rtti() == RS2::ActionSnapMiddleManual) {
currentAction->init(-1);
return nullptr;
}
return new LC_ActionSnapMiddleManual(ctx);
}
break;
}
case RS2::ActionLayerEntityActivate:
[[fallthrough]];
case RS2::ActionLayerEntityToggleView:
[[fallthrough]];
case RS2::ActionLayerEntityToggleConstruction:
[[fallthrough]];
case RS2::ActionLayerEntityTogglePrint:
[[fallthrough]];
case RS2::ActionLayerEntityHideOthers:
[[fallthrough]];
case RS2::ActionLayerEntityToggleLock: {
return new LC_ActionLayerToggle(ctx, actionType);
}
case RS2::ActionDimOrdByOriginSelect: {
return new LC_ActionSelectDimOrdinateSameOrigin(ctx);
}
case RS2::ActionDimOrdRebase: {
return new LC_ActionDimOrdinateRebase(ctx);
}
case RS2::ActionInteractivePickPoint: {
return new LC_ActionInteractivePickPosition(ctx);
}
case RS2::ActionInteractivePickLength: {
return new LC_ActionInteractivePickDistance(ctx);
}
case RS2::ActionInteractivePickAngle: {
return new LC_ActionInteractivePickAngle(ctx);
}
case RS2::ActionModifyMoveAdjust: {
if (data != nullptr) {
LC_ActionModifyMoveAdjust::MovementInfo* movementInfo = static_cast<LC_ActionModifyMoveAdjust::MovementInfo*>(data);
return new LC_ActionModifyMoveAdjust(ctx, *movementInfo);
}
break;
}
default:
RS_DEBUG->print(RS_Debug::D_WARNING,
&"LC_ActionsHandlerFactory::createActionInstance: No such action found. Type "[
actionType]);
break;
}
return nullptr;
}
}
/*
* Usage of raw pointers in factory is intentional. The reason for this is as follows:
* 1) shared_ptr is actually just a template.
* 2) the preprocessor expands that template, and since the amount of different classes wrapped by shared_ptr within the same
* comiplation unit is big, the resulting file is also big - something like 20MB (maybe even bigger).
* 3) While MSVC compiler handles this generated file, the GCC compiler fails after achieving some limiting amount of shared_ptr templates
* (at least with MinGW), and returns the following compilation error
*
*
\generated\librecad\obj\lc_actionhandlerfactory.o ..\..\..\..\librecad\src\ui\lc_actionhandlerfactory.cpp
D:/Qt/QT6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/as.exe: ..\..\generated\librecad\obj\lc_actionhandlerfactory.o: too many sections (38292)
C:\Users\sand1\AppData\Local\Temp\ccayHcyJ.s: Assembler messages:
C:\Users\sand1\AppData\Local\Temp\ccayHcyJ.s: Fatal error: can't write 42 bytes to section .text of ..\..\generated\librecad\obj\lc_actionhandlerfactory.o: 'file too big'
D:/Qt/QT6/Tools/mingw1120_64/bin/../lib/gcc/x86_64-w64-mingw32/11.2.0/../../../../x86_64-w64-mingw32/bin/as.exe: ..\..\generated\librecad\obj\lc_actionhandlerfactory.o: too many sections (38292)
C:\Users\sand1\AppData\Local\Temp\ccayHcyJ.s: Fatal error: ..\..\generated\librecad\obj\lc_actionhandlerfactory.o: file too big
mingw32-make[3]: *** [Makefile.Debug:88797: ../../generated/librecad/obj/lc_actionhandlerfactory.o] Error 1
*
* So either this factory should be split on several ones, or wrapping of raw pointer to shared one is performed only once.
* The later case is also fine, and shared_ptr to base type is returned and all actions has virtual destructors
*
*/
std::shared_ptr<RS_ActionInterface> LC_ActionsHandlerFactory::createActionInstance(
RS2::ActionType actionType, LC_ActionContext* ctx, void* data) {
RS_ActionInterface* actionInstance = InnerFactory::doCreateActionInstance(actionType, ctx, data);
std::shared_ptr<RS_ActionInterface> result{actionInstance};
return result;
}
|