File size: 43,734 Bytes
985c397 | 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 | // SPDX-License-Identifier: LGPL-2.1-or-later
/***************************************************************************
* Copyright (c) 2016 Victor Titov (DeepSOIC) <vv.titov@gmail.com> *
* *
* This file is part of the FreeCAD CAx development system. *
* *
* This library is free software; you can redistribute it and/or *
* modify it under the terms of the GNU Library General Public *
* License as published by the Free Software Foundation; either *
* version 2 of the License, or (at your option) any later version. *
* *
* This library 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 Library General Public License for more details. *
* *
* You should have received a copy of the GNU Library General Public *
* License along with this library; see the file COPYING.LIB. If not, *
* write to the Free Software Foundation, Inc., 59 Temple Place, *
* Suite 330, Boston, MA 02111-1307, USA *
* *
***************************************************************************/
#include <QApplication>
#include <Base/Console.h>
#include "AttacherTexts.h"
using namespace Attacher;
namespace AttacherGui
{
TextSet TwoStrings(QString str1, QString str2)
{
std::vector<QString> v;
v.resize(2);
v[0] = str1;
v[1] = str2;
return v;
}
TextSet getUIStrings(Base::Type attacherType, eMapMode mmode)
{
if (attacherType.isDerivedFrom(AttachEngine3D::getClassTypeId())) {
//---- coordinate system attacher ----
switch (mmode) {
case mmDeactivated:
return TwoStrings(
qApp->translate("Attacher3D", "Deactivated", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Attachment is disabled. Object can be moved by editing Placement "
"property.",
"Attachment3D mode tooltip"
)
);
case mmTranslate:
return TwoStrings(
qApp->translate("Attacher3D", "Translate origin", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Origin is aligned to match Vertex. Orientation is controlled by Placement "
"property.",
"Attachment3D mode tooltip"
)
);
case mmObjectXY:
return TwoStrings(
qApp->translate("Attacher3D", "Object's X Y Z", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Placement is made equal to Placement of linked object.",
"Attachment3D mode tooltip"
)
);
case mmObjectXZ:
return TwoStrings(
qApp->translate("Attacher3D", "Object's X Z Y", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"X', Y', Z' axes are matched with object's local X, Z, -Y, respectively.",
"Attachment3D mode tooltip"
)
);
case mmObjectYZ:
return TwoStrings(
qApp->translate("Attacher3D", "Object's Y Z X", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"X', Y', Z' axes are matched with object's local Y, Z, X, respectively.",
"Attachment3D mode tooltip"
)
);
case mmParallelPlane:
return TwoStrings(
qApp->translate("Attacher3D", "XY parallel to plane", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"X' Y' plane is parallel to the plane (object's XY) and passes through the "
"vertex.",
"Attachment3D mode tooltip"
)
);
case mmFlatFace:
return TwoStrings(
qApp->translate("Attacher3D", "XY on plane", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"X' Y' plane is aligned to coincide planar face.",
"Attachment3D mode tooltip"
)
);
case mmTangentPlane:
return TwoStrings(
qApp->translate("Attacher3D", "XY tangent to surface", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"X' Y' plane is made tangent to surface at vertex.",
"Attachment3D mode tooltip"
)
);
case mmNormalToPath:
return TwoStrings(
qApp->translate("Attacher3D", "Z tangent to edge", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Z' axis is aligned to be tangent to edge. Optional vertex link defines "
"where.",
"Attachment3D mode tooltip"
)
);
case mmFrenetNB:
return TwoStrings(
qApp->translate("Attacher3D", "Frenet NBT", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Align to Frenet-Serret coordinate system of curved edge. Optional vertex "
"link defines where.",
"Attachment3D mode tooltip"
)
);
case mmFrenetTN:
return TwoStrings(
qApp->translate("Attacher3D", "Frenet TNB", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Align to Frenet-Serret coordinate system of curved edge. Optional vertex "
"link defines where.",
"Attachment3D mode tooltip"
)
);
case mmFrenetTB:
return TwoStrings(
qApp->translate("Attacher3D", "Frenet TBN", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Align to Frenet-Serret coordinate system of curved edge. Optional vertex "
"link defines where.",
"Attachment3D mode tooltip"
)
);
case mmConcentric:
return TwoStrings(
qApp->translate("Attacher3D", "Concentric", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Align XY-plane to osculating circle of an edge. Optional vertex link "
"defines where.",
"Attachment3D mode tooltip"
)
);
case mmRevolutionSection:
return TwoStrings(
qApp->translate("Attacher3D", "Revolution Section", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Align Y' axis to match axis of osculating circle of an edge. Optional "
"vertex link defines where.",
"Attachment3D mode tooltip"
)
);
case mmThreePointsPlane:
return TwoStrings(
qApp->translate("Attacher3D", "XY-plane by 3 points", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Align XY-plane to pass through three vertices.",
"Attachment3D mode tooltip"
)
);
case mmThreePointsNormal:
return TwoStrings(
qApp->translate("Attacher3D", "XZ-plane by 3 points", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Align XZ-plane to pass through 3 points; X axis will pass through two "
"first points.",
"Attachment3D mode tooltip"
)
);
case mmFolding:
return TwoStrings(
qApp->translate("Attacher3D", "Folding", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Specialty mode for folding polyhedra. Select 4 edges in order: foldable "
"edge, fold line, other fold line, other foldable edge. XY-plane will be "
"aligned to folding the first edge.",
"Attachment3D mode tooltip"
)
);
case mmInertialCS:
return TwoStrings(
qApp->translate("Attacher3D", "Inertial CS", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Inertial coordinate system, constructed on principal axes of inertia and "
"center of mass.",
"Attachment3D mode tooltip"
)
);
case mmOZX:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-Z-X", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align Z' and X' axes towards vertex/along "
"line.",
"Attachment3D mode tooltip"
)
);
case mmOZY:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-Z-Y", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align Z' and Y' axes towards vertex/along "
"line.",
"Attachment3D mode tooltip"
)
);
case mmOXY:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-X-Y", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align X' and Y' axes towards vertex/along "
"line.",
"Attachment3D mode tooltip"
)
);
case mmOXZ:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-X-Z", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align X' and Z' axes towards vertex/along "
"line.",
"Attachment3D mode tooltip"
)
);
case mmOYZ:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-Y-Z", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align Y' and Z' axes towards vertex/along "
"line.",
"Attachment3D mode tooltip"
)
);
case mmOYX:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-Y-X", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align Y' and X' axes towards vertex/along "
"line.",
"Attachment3D mode tooltip"
)
);
default:
break;
}
}
else if (attacherType.isDerivedFrom(AttachEnginePlane::getClassTypeId())) {
//---- Plane/sketch attacher ----
switch (mmode) {
case mmDeactivated:
return TwoStrings(
qApp->translate("Attacher2D", "Deactivated", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Attachment is disabled. Object can be moved by editing Placement "
"property.",
"AttachmentPlane mode tooltip"
)
);
case mmTranslate:
return TwoStrings(
qApp->translate("Attacher2D", "Translate origin", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Origin is aligned to match Vertex. Orientation is controlled by Placement "
"property.",
"AttachmentPlane mode tooltip"
)
);
case mmObjectXY:
return TwoStrings(
qApp->translate("Attacher2D", "Object's XY", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Plane is aligned to XY local plane of linked object.",
"AttachmentPlane mode tooltip"
)
);
case mmObjectXZ:
return TwoStrings(
qApp->translate("Attacher2D", "Object's XZ", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Plane is aligned to XZ local plane of linked object.",
"AttachmentPlane mode tooltip"
)
);
case mmObjectYZ:
return TwoStrings(
qApp->translate("Attacher2D", "Object's YZ", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Plane is aligned to YZ local plane of linked object.",
"AttachmentPlane mode tooltip"
)
);
case mmParallelPlane:
return TwoStrings(
qApp->translate("Attacher2D", "XY parallel to plane", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"X' Y' plane is parallel to the plane (object's XY) and passes through the "
"vertex",
"AttachmentPlane mode tooltip"
)
);
case mmFlatFace:
return TwoStrings(
qApp->translate("Attacher2D", "Plane face", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Plane is aligned to coincide planar face.",
"AttachmentPlane mode tooltip"
)
);
case mmTangentPlane:
return TwoStrings(
qApp->translate("Attacher2D", "Tangent to surface", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Plane is made tangent to surface at vertex.",
"AttachmentPlane mode tooltip"
)
);
case mmNormalToPath:
return TwoStrings(
qApp->translate("Attacher2D", "Normal to edge", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Plane is made tangent to edge. Optional vertex link defines where.",
"AttachmentPlane mode tooltip"
)
);
case mmFrenetNB:
return TwoStrings(
qApp->translate("Attacher2D", "Frenet NB", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Align to Frenet-Serret coordinate system of curved edge. Optional vertex "
"link defines where.",
"AttachmentPlane mode tooltip"
)
);
case mmFrenetTN:
return TwoStrings(
qApp->translate("Attacher2D", "Frenet TN", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Align to Frenet-Serret coordinate system of curved edge. Optional vertex "
"link defines where.",
"AttachmentPlane mode tooltip"
)
);
case mmFrenetTB:
return TwoStrings(
qApp->translate("Attacher2D", "Frenet TB", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Align to Frenet-Serret coordinate system of curved edge. Optional vertex "
"link defines where.",
"AttachmentPlane mode tooltip"
)
);
case mmConcentric:
return TwoStrings(
qApp->translate("Attacher2D", "Concentric", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Align to plane to osculating circle of an edge. Origin is aligned to "
"point of curvature. Optional vertex link defines where.",
"AttachmentPlane mode tooltip"
)
);
case mmRevolutionSection:
return TwoStrings(
qApp->translate("Attacher2D", "Revolution Section", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Plane is perpendicular to edge, and Y axis is matched with axis of "
"osculating circle. Optional vertex link defines where.",
"AttachmentPlane mode tooltip"
)
);
case mmThreePointsPlane:
return TwoStrings(
qApp->translate("Attacher2D", "Plane by 3 points", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Align plane to pass through three vertices.",
"AttachmentPlane mode tooltip"
)
);
case mmThreePointsNormal:
return TwoStrings(
qApp->translate("Attacher2D", "Normal to 3 points", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Plane will pass through first two vertices, and perpendicular to plane "
"that passes through three vertices.",
"AttachmentPlane mode tooltip"
)
);
case mmFolding:
return TwoStrings(
qApp->translate("Attacher2D", "Folding", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Specialty mode for folding polyhedra. Select 4 edges in order: foldable "
"edge, fold line, other fold line, other foldable edge. Plane will be "
"aligned to folding the first edge.",
"AttachmentPlane mode tooltip"
)
);
case mmInertialCS:
return TwoStrings(
qApp->translate("Attacher2D", "Inertia 2-3", "AttachmentPlane mode caption"),
qApp->translate(
"Attacher2D",
"Plane constructed on second and third principal axes of inertia (passes "
"through center of mass).",
"AttachmentPlane mode tooltip"
)
);
case mmOZX:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-N-X", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align normal and horizontal plane axis "
"towards vertex/along line.",
"Attachment3D mode tooltip"
)
);
case mmOZY:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-N-Y", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align normal and vertical plane axis "
"towards vertex/along line.",
"Attachment3D mode tooltip"
)
);
case mmOXY:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-X-Y", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align horizontal and vertical plane axes "
"towards vertex/along line.",
"Attachment3D mode tooltip"
)
);
case mmOXZ:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-X-N", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align horizontal plane axis and normal "
"towards vertex/along line.",
"Attachment3D mode tooltip"
)
);
case mmOYZ:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-Y-N", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align vertical plane axis and normal "
"towards vertex/along line.",
"Attachment3D mode tooltip"
)
);
case mmOYX:
return TwoStrings(
qApp->translate("Attacher3D", "Align O-Y-X", "Attachment3D mode caption"),
qApp->translate(
"Attacher3D",
"Match origin with first Vertex. Align vertical and horizontal plane axes "
"towards vertex/along line.",
"Attachment3D mode tooltip"
)
);
default:
break;
}
}
else if (attacherType.isDerivedFrom(AttachEngineLine::getClassTypeId())) {
//---- Line attacher ----
switch (mmode) {
case mmDeactivated:
return TwoStrings(
qApp->translate("Attacher1D", "Deactivated", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Attachment is disabled. Line can be moved by editing Placement property.",
"AttachmentLine mode tooltip"
)
);
case mm1AxisX:
return TwoStrings(
qApp->translate("Attacher1D", "Object's X", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Line is aligned along local X axis of object. Works on objects with "
"placements, and ellipse/parabola/hyperbola edges.",
"AttachmentLine mode tooltip"
)
);
case mm1AxisY:
return TwoStrings(
qApp->translate("Attacher1D", "Object's Y", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Line is aligned along local Y axis of object. Works on objects with "
"placements, and ellipse/parabola/hyperbola edges.",
"AttachmentLine mode tooltip"
)
);
case mm1AxisZ:
return TwoStrings(
qApp->translate("Attacher1D", "Object's Z", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Line is aligned along local X axis of object. Works on objects with "
"placements, and ellipse/parabola/hyperbola edges.",
"AttachmentLine mode tooltip"
)
);
case mm1AxisCurv:
return TwoStrings(
qApp->translate("Attacher1D", "Axis of curvature", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Line that is an axis of osculating circle of curved edge. Optional vertex "
"defines where.",
"AttachmentLine mode tooltip"
)
);
case mm1Directrix1:
return TwoStrings(
qApp->translate("Attacher1D", "Directrix1", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Directrix line for ellipse, parabola, hyperbola.",
"AttachmentLine mode tooltip"
)
);
case mm1Directrix2:
return TwoStrings(
qApp->translate("Attacher1D", "Directrix2", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Second directrix line for ellipse and hyperbola.",
"AttachmentLine mode tooltip"
)
);
case mm1Asymptote1:
return TwoStrings(
qApp->translate("Attacher1D", "Asymptote1", "AttachmentLine mode caption"),
qApp->translate("Attacher1D", "Asymptote of a hyperbola.", "AttachmentLine mode tooltip")
);
case mm1Asymptote2:
return TwoStrings(
qApp->translate("Attacher1D", "Asymptote2", "AttachmentLine mode caption"),
qApp->translate("Attacher1D", "Second asymptote of hyperbola.", "AttachmentLine mode tooltip")
);
case mm1Tangent:
return TwoStrings(
qApp->translate("Attacher1D", "Tangent", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Line tangent to an edge. Optional vertex link defines where.",
"AttachmentLine mode tooltip"
)
);
case mm1Normal:
return TwoStrings(
qApp->translate("Attacher1D", "Normal to edge", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Align to N vector of Frenet-Serret coordinate system of curved edge. "
"Optional vertex link defines where.",
"AttachmentLine mode tooltip"
)
);
case mm1Binormal:
return TwoStrings(
qApp->translate("Attacher1D", "Binormal", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Align to B vector of Frenet-Serret coordinate system of curved edge. "
"Optional vertex link defines where.",
"AttachmentLine mode tooltip"
)
);
case mm1TangentU:
return TwoStrings(
qApp->translate("Attacher1D", "Tangent to surface (U)", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Tangent to surface, along U parameter. Vertex link defines where.",
"AttachmentLine mode tooltip"
)
);
case mm1TangentV:
return TwoStrings(
qApp->translate("Attacher1D", "Tangent to surface (V)", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Tangent to surface, along U parameter. Vertex link defines where.",
"AttachmentLine mode tooltip"
)
);
case mm1TwoPoints:
return TwoStrings(
qApp->translate("Attacher1D", "Through two points", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Line that passes through two vertices.",
"AttachmentLine mode tooltip"
)
);
case mm1Intersection:
return TwoStrings(
qApp->translate("Attacher1D", "Intersection", "AttachmentLine mode caption"),
qApp->translate("Attacher1D", "Intersection of two faces.", "AttachmentLine mode tooltip")
);
case mm1Proximity:
return TwoStrings(
qApp->translate("Attacher1D", "Proximity line", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Line that spans the shortest distance between shapes.",
"AttachmentLine mode tooltip"
)
);
case mm1AxisInertia1:
return TwoStrings(
qApp->translate("Attacher1D", "1st principal axis", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Line follows first principal axis of inertia.",
"AttachmentLine mode tooltip"
)
);
case mm1AxisInertia2:
return TwoStrings(
qApp->translate("Attacher1D", "2nd principal axis", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Line follows second principal axis of inertia.",
"AttachmentLine mode tooltip"
)
);
case mm1AxisInertia3:
return TwoStrings(
qApp->translate("Attacher1D", "3rd principal axis", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Line follows third principal axis of inertia.",
"AttachmentLine mode tooltip"
)
);
case mm1FaceNormal:
return TwoStrings(
qApp->translate("Attacher1D", "Normal to surface", "AttachmentLine mode caption"),
qApp->translate(
"Attacher1D",
"Line perpendicular to surface at point set by vertex.",
"AttachmentLine mode tooltip"
)
);
default:
break;
}
}
else if (attacherType.isDerivedFrom(AttachEnginePoint::getClassTypeId())) {
//---- Point attacher ----
switch (mmode) {
case mmDeactivated:
return TwoStrings(
qApp->translate("Attacher0D", "Deactivated", "AttachmentPoint mode caption"),
qApp->translate(
"Attacher0D",
"Attachment is disabled. Point can be moved by editing Placement property.",
"AttachmentPoint mode tooltip"
)
);
case mm0Origin:
return TwoStrings(
qApp->translate("Attacher0D", "Object's origin", "AttachmentPoint mode caption"),
qApp->translate(
"Attacher0D",
"Point is put at object's placement position. Works on objects with "
"placements, and ellipse/parabola/hyperbola edges.",
"AttachmentPoint mode tooltip"
)
);
case mm0Focus1:
return TwoStrings(
qApp->translate("Attacher0D", "Focus1", "AttachmentPoint mode caption"),
qApp->translate(
"Attacher0D",
"Focus of ellipse, parabola, hyperbola.",
"AttachmentPoint mode tooltip"
)
);
case mm0Focus2:
return TwoStrings(
qApp->translate("Attacher0D", "Focus2", "AttachmentPoint mode caption"),
qApp->translate(
"Attacher0D",
"Second focus of ellipse and hyperbola.",
"AttachmentPoint mode tooltip"
)
);
case mm0OnEdge:
return TwoStrings(
qApp->translate("Attacher0D", "On edge", "AttachmentPoint mode caption"),
qApp->translate(
"Attacher0D",
"Point is put on edge, MapPathParameter controls where. Additionally, "
"vertex can be linked in for making a projection.",
"AttachmentPoint mode tooltip"
)
);
case mm0CenterOfCurvature:
return TwoStrings(
qApp->translate("Attacher0D", "Center of curvature", "AttachmentPoint mode caption"),
qApp->translate(
"Attacher0D",
"Center of osculating circle of an edge. Optional vertex link defines "
"where.",
"AttachmentPoint mode tooltip"
)
);
case mm0CenterOfMass:
return TwoStrings(
qApp->translate("Attacher0D", "Center of mass", "AttachmentPoint mode caption"),
qApp->translate(
"Attacher0D",
"Center of mass of all references (equal densities are assumed).",
"AttachmentPoint mode tooltip"
)
);
case mm0Intersection:
return TwoStrings(
qApp->translate("Attacher0D", "Intersection", "AttachmentPoint mode caption"),
qApp->translate("Attacher0D", "Not implemented", "AttachmentPoint mode tooltip")
);
case mm0Vertex:
return TwoStrings(
qApp->translate("Attacher0D", "Vertex", "AttachmentPoint mode caption"),
qApp->translate(
"Attacher0D",
"Put Datum point coincident with another vertex.",
"AttachmentPoint mode tooltip"
)
);
case mm0ProximityPoint1:
return TwoStrings(
qApp->translate("Attacher0D", "Proximity point 1", "AttachmentPoint mode caption"),
qApp->translate(
"Attacher0D",
"Point on first reference that is closest to second reference.",
"AttachmentPoint mode tooltip"
)
);
case mm0ProximityPoint2:
return TwoStrings(
qApp->translate("Attacher0D", "Proximity point 2", "AttachmentPoint mode caption"),
qApp->translate(
"Attacher0D",
"Point on second reference that is closest to first reference.",
"AttachmentPoint mode tooltip"
)
);
default:
break;
}
}
Base::Console().warning(
"No user-friendly string defined for this attachment mode and attacher type: %s %s \n",
AttachEngine::getModeName(mmode).c_str(),
attacherType.getName()
);
return TwoStrings(QString::fromStdString(AttachEngine::getModeName(mmode)), QString());
}
// Note: this list must be in sync with eRefType enum
static struct
{
const char* txt;
const char* comment;
} eRefTypeStrings[] = {
QT_TRANSLATE_NOOP3("Attacher", "Any", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Vertex", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Edge", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Face", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Line", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Curve", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Circle", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Conic", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Ellipse", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Parabola", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Hyperbola", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Plane", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Sphere", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Revolve", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Cylinder", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Torus", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Cone", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Object", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Solid", "Attacher reference type"),
QT_TRANSLATE_NOOP3("Attacher", "Wire", "Attacher reference type"),
{nullptr, nullptr},
{nullptr, nullptr},
{nullptr, nullptr}
};
QString getShapeTypeText(eRefType type)
{
// get rid of flags in type
type = eRefType(type & (rtFlagHasPlacement - 1));
if (type >= 0 && type < rtDummy_numberOfShapeTypes) {
if (eRefTypeStrings[int(type)].txt) {
return qApp->translate(
"Attacher",
eRefTypeStrings[int(type)].txt,
eRefTypeStrings[int(type)].comment
);
}
}
throw Base::TypeError("getShTypeText: type value is wrong, or a string is missing in the list");
}
QStringList getRefListForMode(AttachEngine& attacher, eMapMode mmode)
{
refTypeStringList list = attacher.modeRefTypes[mmode];
QStringList strlist;
for (refTypeString& rts : list) {
QStringList buf;
for (eRefType rt : rts) {
buf.append(getShapeTypeText(rt));
}
strlist.append(buf.join(QStringLiteral(", ")));
}
return strlist;
}
// --------------------Py interface---------------------
PyObject* AttacherGuiPy::sGetModeStrings(PyObject* /*self*/, PyObject* args)
{
int modeIndex = 0;
char* attacherType;
if (!PyArg_ParseTuple(args, "si", &attacherType, &modeIndex)) {
return nullptr;
}
try {
Base::Type t = Base::Type::fromName(attacherType);
if (!t.isDerivedFrom(AttachEngine::getClassTypeId())) {
std::stringstream ss;
ss << "Object of this type is not derived from AttachEngine: ";
ss << attacherType;
throw Py::TypeError(ss.str());
}
TextSet strs = getUIStrings(t, eMapMode(modeIndex));
Py::List result;
for (QString& s : strs) {
QByteArray ba_utf8 = s.toUtf8();
result.append(Py::String(ba_utf8.data(), "utf-8"));
}
return Py::new_reference_to(result);
}
catch (const Py::Exception&) {
return nullptr;
}
catch (const Base::Exception& e) {
e.setPyException();
return nullptr;
}
}
PyObject* AttacherGuiPy::sGetRefTypeUserFriendlyName(PyObject* /*self*/, PyObject* args)
{
int refTypeIndex = 0;
if (!PyArg_ParseTuple(args, "i", &refTypeIndex)) {
return nullptr;
}
try {
QByteArray ba_utf8 = getShapeTypeText(eRefType(refTypeIndex)).toUtf8();
return Py::new_reference_to(Py::String(ba_utf8.data(), "utf-8"));
}
catch (const Py::Exception&) {
return nullptr;
}
catch (const Base::Exception& e) {
e.setPyException();
return nullptr;
}
}
PyMethodDef AttacherGuiPy::Methods[] = {
{"getModeStrings",
(PyCFunction)AttacherGuiPy::sGetModeStrings,
METH_VARARGS,
"getModeStrings(attacher_type, mode_index) - gets mode user-friendly name and brief "
"description."},
{"getRefTypeUserFriendlyName",
(PyCFunction)AttacherGuiPy::sGetRefTypeUserFriendlyName,
METH_VARARGS,
"getRefTypeUserFriendlyName(type_index) - gets user-friendly name of AttachEngine's shape "
"type."},
{nullptr, nullptr, 0, nullptr} /* Sentinel */
};
} // namespace AttacherGui
|