diff --git a/.gitignore b/.gitignore
deleted file mode 100644
index 501f6a74..00000000
--- a/.gitignore
+++ /dev/null
@@ -1,16 +0,0 @@
-# SVN
-*.svn
-
-# ECLIPSE
-*.settings
-*.project
-*.pydevproject
-
-# COMPILED PYTHON
-*.pyc
-
-# debug
-qad_debug.*
-
-Thumbs.db
-*.psproj
\ No newline at end of file
diff --git a/.project b/.project
new file mode 100644
index 00000000..d2a6e666
--- /dev/null
+++ b/.project
@@ -0,0 +1,17 @@
+
+
+ QAD
+
+
+
+
+
+ org.python.pydev.PyDevBuilder
+
+
+
+
+
+ org.python.pydev.pythonNature
+
+
diff --git a/.pydevproject b/.pydevproject
new file mode 100644
index 00000000..f1d2317b
--- /dev/null
+++ b/.pydevproject
@@ -0,0 +1,8 @@
+
+
+
+ Default
+
+ python interpreter
+
+
diff --git a/Appunti per QAD.docx b/Appunti per QAD.docx
deleted file mode 100644
index ab97923d..00000000
Binary files a/Appunti per QAD.docx and /dev/null differ
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 00000000..818433ec
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+ GNU GENERAL PUBLIC LICENSE
+ Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc.
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users. We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors. You can apply it to
+your programs, too.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights. Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+ For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received. You must make sure that they, too, receive
+or can get the source code. And you must show them these terms so they
+know their rights.
+
+ Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+ For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software. For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+ Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so. This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software. The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable. Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products. If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+ Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary. To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Use with the GNU Affero General Public License.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time. Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+
+ Copyright (C)
+
+ 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 3 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, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+ Copyright (C)
+ This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+ This is free software, and you are welcome to redistribute it
+ under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License. Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+.
+
+ The GNU General Public License does not permit incorporating your program
+into proprietary programs. If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library. If this is what you want to do, use the GNU Lesser General
+Public License instead of this License. But first, please read
+.
diff --git a/Makefile b/Makefile
index 8ee6592c..8202a42f 100644
--- a/Makefile
+++ b/Makefile
@@ -1,32 +1,32 @@
-
-###### EDIT #####################
-
-
-#UI files to compile
-#UI_FILES = qad.ui qad_dsettings.ui qad_dimstyle.ui
-#Qt resource files to compile
-RESOURCES = qad.qrc qad_dsettings.qrc
-
-
-#################################
-# DO NOT EDIT FOLLOWING
-
-#COMPILED_UI = $(UI_FILES:%.ui=%_ui.py)
-COMPILED_RESOURCES = $(RESOURCES:%.qrc=%_rc.py)
-
-all : resources
-#all : resources ui
-
-resources : $(COMPILED_RESOURCES)
-
-#ui : $(COMPILED_UI)
-
-#%_ui.py : %.ui
-# pyuic4 $< -o $@
-
-%_rc.py : %.qrc
- pyrcc4 $< -o $@
-
-clean :
- #$(RM) $(COMPILED_UI) $(COMPILED_RESOURCES) $(COMPILED_UI:.py=.pyc) $(COMPILED_RESOURCES:.py=.pyc)
- $(RM) $(COMPILED_RESOURCES) $(COMPILED_RESOURCES:.py=.pyc)
+
+###### EDIT #####################
+
+
+#UI files to compile
+#UI_FILES = qad.ui qad_dsettings.ui qad_dimstyle.ui
+#Qt resource files to compile
+RESOURCES = qad.qrc qad_dsettings.qrc
+
+
+#################################
+# DO NOT EDIT FOLLOWING
+
+#COMPILED_UI = $(UI_FILES:%.ui=%_ui.py)
+COMPILED_RESOURCES = $(RESOURCES:%.qrc=%_rc.py)
+
+all : resources
+#all : resources ui
+
+resources : $(COMPILED_RESOURCES)
+
+#ui : $(COMPILED_UI)
+
+#%_ui.py : %.ui
+# pyuic4 $< -o $@
+
+%_rc.py : %.qrc
+ pyrcc4 $< -o $@
+
+clean :
+ #$(RM) $(COMPILED_UI) $(COMPILED_RESOURCES) $(COMPILED_UI:.py=.pyc) $(COMPILED_RESOURCES:.py=.pyc)
+ $(RM) $(COMPILED_RESOURCES) $(COMPILED_RESOURCES:.py=.pyc)
diff --git a/README.md b/README.md
index 2d034de6..c7fdbdca 100644
--- a/README.md
+++ b/README.md
@@ -1,10 +1,28 @@
#QAD#
+
+
+----------
+Quantum Aided Design - Cad Tools plugin for QGIS 3.
-----------
+###Developers###
-Quantum Aided Design - Cad Tools plugin for QGIS 2.
+gam17
-###Developers###
###User Interface Designers:##
+
+gam17
+
+em-rezende
+
###Documentation:##
+
+gam17
+
+###Testers:##
+
+Aitor Gil (jaitor1)
+
+Gabriel De Luca
+
+Tony Shepherd
diff --git a/__init__.py b/__init__.py
index 34c7d135..ec1d5b3b 100644
--- a/__init__.py
+++ b/__init__.py
@@ -1,39 +1,29 @@
-"""
-/***************************************************************************
- QAD
- A QGIS plugin
- Selezione di layer attraverso gli oggetti grafici
- -------------------
- begin : 2012-01-12
- copyright : iiiii
- email : hhhhh
- developers : bbbbb aaaaa ggggg
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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 script initializes the plugin, making it known to QGIS.
-"""
-
-
-def name():
- return "Quantum Aided Design"
-def description():
- return "Comandi di editazione grafica in stile CAD"
-def version():
- return "Version 2.0"
-def icon():
- return ":/plugins/qad/icons/qad.png"
-def qgisMinimumVersion():
- return "2.0"
-def classFactory(iface):
-
- # load Qad class from file qad
- from qad import Qad
- return Qad(iface)
+"""
+/***************************************************************************
+ QAD
+ A QGIS plugin
+ Selezione di layer attraverso gli oggetti grafici
+ -------------------
+ begin : 2019-09-16
+ copyright : iiiii
+ email : hhhhh
+ developers : bbbbb aaaaa ggggg
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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 script initializes the plugin, making it known to QGIS.
+"""
+
+
+def classFactory(iface):
+
+ # load Qad class from file qad
+ from .qad import Qad
+ return Qad(iface)
diff --git a/auth.ini b/auth.ini
new file mode 100644
index 00000000..4090b91c
--- /dev/null
+++ b/auth.ini
@@ -0,0 +1 @@
+N=1 >1=O10/1@01 =
\ No newline at end of file
diff --git a/changelog b/changelog
new file mode 100644
index 00000000..605ea05c
--- /dev/null
+++ b/changelog
@@ -0,0 +1,160 @@
+version 3.0.8
+---------------------------
+* 2024-10-07 Fixed bug on m2p option (reported by Fabrice DEMIEL)
+
+
+version 3.0.7
+---------------------------
+
+* 2024-10-07 Fixed bug on stretching last segment of a polygon
+* 2024-09-19 New set of icons for menus and buttons (proposed and edited by em-rezende)
+* 2024-08-28 Fixed bug on label size calculation (reported by em-rezende)
+* 2024-08-28 Fixed bug on Fedora linux version (reported by Jesper Reenberg)
+* 2024-08-28 Fixed bug on intersection snap mode
+* 2024-08-28 Fixed bug on stretching and saving dimension
+
+
+version 3.0.6
+---------------------------
+
+* 2024-05-27 Fixed calculation to find intersections between 2 ellipses and between a circle and an ellipse
+* 2024-05-16 Fixed bug on draw a line from tangent to tangent
+* 2024-05-16 Fixed bug on dimension (reported by em-rezende)
+* 2024-05-16 Full support for curved type layer (compoundCurve, multiCurve, curvePolygon, multiSurface)
+* 2024-02-14 Selecting a point you can choose the "Midpoint between 2 points" option
+* 2024-01-19 Fixed bug on selection options (reported by Justin Ralston)
+* 2023-10-17 Added Polar Tracking options: additional angles. (inspired by Jonathan GUILLERM)
+* 2023-09-29 The form to fill the data does not appear, now it does. (proposed by franksalas1965)
+* 2023-09-29 qad offset command now use the native offset function provided by qgis api
+* 2023-04-07 pedit now can join multilinestring if composed by only one part.
+* 2022-07-27 Fixed bug on intersections between circle and ellipse
+* 2022-07-27 Changed algorithm to auto-detect arc and circle
+* 2022-07-27 Fixed bug on delete last vertex of a polyline
+* 2022-06-20 Fixed bug on OFFSET-tool creates wrong calculations with PLINE-vectors (reported by Atol2022)
+* 2022-03-28 Fixed bug on problems using vector layers having a "scale based" visibility (reported by TheLooka)
+* 2022-05-29 Fixed bug on Trimming a circle into an arc (reported by Jopie01)
+* 2022-05-29 Fixed bug on Error when trying to trim a line to a circle (reported by Jopie01)
+* 2022-05-29 Fixed bug on MPOLYGON-tool crashes when trying to use trace-function (reported by Atol2022)
+
+
+version 3.0.5
+---------------------------
+
+* 2021-08-30 Fixed bug on pedit -> join option
+
+
+version 3.0.4
+---------------------------
+
+* 2020-09-10 Fixed bug when rotating, scaling or mirroring symbol entities (reported by Camilo Corredor)
+* 2020-09-10 Now QAD honors QGIS's snap settings (ALL LAYERS, ACTIVE LAYER, ADVANCED) (by Olivier Dalang)
+
+
+version 3.0.3
+---------------------------
+
+* 2020-08-12 Fixed bug when changing drafting tool config (e.g. colors, etc.) (reported by sdnxgr)
+* 2020-08-12 Fixed bug on selected object which gets deselected when the mouse moves on any vertex of that object (reported by reancris)
+* 2020-06-29 Fixed bug on and command (reported by Gabriel De Luca)
+
+
+version 3.0.2
+---------------------------
+
+* 2020-05-15 Fixed bug on command (reported by Gabriel De Luca)
+
+
+version 3.0.1
+---------------------------
+
+* 2020-03-05 Fixed bug on command
+
+
+version 2.14.5:
+---------------------------
+
+* 2018-10-11 Fixed bug on offset command when custom coordinate reference system is used (reported by Dave Burkholder)
+
+* 2018-10-11 Added command
+
+* 2018-10-11 Added right click control in options dialog
+
+* 2018-10-11 Added , system variables
+
+
+version 2.14.4:
+---------------------------
+
+* 2018-05-11 Added French localization (by dobriseb)
+
+* 2018-05-11 Added Dynamic Input
+
+* 2018-05-11 Added , , , , , , , system variables
+
+* 2017-03-01 Fixed bug "If you want to draw a circle with a given diameter it draws instead a circle with the radius specified as diameter" (reported by Mazur93)
+
+* 2017-03-01 F2 key to toggle the text command windows visibility
+
+* 2017-02-08 Added command (inspired by Simon Haufe)
+
+* 2017-02-08 Added property for DIM commands (inspired by Simon Haufe)
+
+If you want to draw a circle with a given diameter it draws instead a circle with the radius specified as diameter
+
+
+version 2.14.2:
+---------------------------
+
+* 2017-07-24 Fixed bug on offset algorithm (reported by peter-shr)
+
+* 2017-05-08 Fixed bug on duplicating dimension layers (reported by Benni5K)
+
+* 2017-04-28 Fixed error on traceback when moving circle in a linestring layer (reported by Benni5K)
+
+
+version 2.14.1:
+---------------------------
+
+* 2017-03-13 Added contextual menu on right click event for command options
+
+* 2017-03-13 Fixed bug on new feature creation when id is a db sequence result (reported by Benni5K)
+
+
+version 2.8.14:
+---------------------------
+
+* 2016-12-12 Fixed bug on command (Spanish localization only, reported by dortegat)
+
+* 2016-12-12 Fixed bug on "OSNAP is enabled only if polar snapping is also enabled" (reported by sdnxgr)
+
+* 2016-12-12 Fixed bug on "user defined coordinate reference system. Like USER:100000" (reported by AndreyMai)
+
+* 2016-12-12 Fixed bug on "The zoom (scroll wheel) isn't working when using QAD" (reported by patricev)
+
+
+version 2.8.13:
+---------------------------
+
+* 2016-10-14 Added "hold Ctrl to switch direction" option on and commands
+
+* 2016-10-12 Added spanish localization
+
+* 2016-09-12 Added command
+
+* 2016-06-09 Distinction between project variables and global variables (inspired by sdnxgr)
+
+* 2016-09-09 Added command
+
+* 2016-06-30 Added command
+
+* 2016-06-30 Removed system variable (used as dim style property)
+
+* 2016-06-16 Added system variable
+
+* 2016-06-13 Fixed bug on dimension saving
+
+* 2016-05-05 Added , , , commands
+
+* 2016-05-05 Added and system variables
+
+* 2016-05-05 Added and in MAPMPEDIT command
\ No newline at end of file
diff --git a/qad_arc_cmd.py b/cmd/qad_arc_cmd.py
similarity index 81%
rename from qad_arc_cmd.py
rename to cmd/qad_arc_cmd.py
index 3f489e12..db5f4ada 100644
--- a/qad_arc_cmd.py
+++ b/cmd/qad_arc_cmd.py
@@ -1,1057 +1,1114 @@
-# -*- coding: utf-8 -*-
-"""
-/***************************************************************************
- QAD Quantum Aided Design plugin
-
- comando ARC per disegnare un arco
-
- -------------------
- begin : 2013-05-22
- copyright : iiiii
- email : hhhhh
- developers : bbbbb aaaaa ggggg
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-"""
-
-
-# Import the PyQt and QGIS libraries
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
-from qgis.core import *
-import math
-
-
-from qad_getpoint import *
-from qad_arc_maptool import *
-from qad_generic_cmd import QadCommandClass
-from qad_msg import QadMsg
-from qad_textwindow import *
-import qad_utils
-import qad_layer
-import qad_grip
-
-
-# Classe che gestisce il comando ARC
-class QadARCCommandClass(QadCommandClass):
-
- def instantiateNewCmd(self):
- """ istanzia un nuovo comando dello stesso tipo """
- return QadARCCommandClass(self.plugIn)
-
- def getName(self):
- return QadMsg.translate("Command_list", "ARC")
-
- def getEnglishName(self):
- return "ARC"
-
- def connectQAction(self, action):
- QObject.connect(action, SIGNAL("triggered()"), self.plugIn.runARCCommand)
-
- def getIcon(self):
- return QIcon(":/plugins/qad/icons/arc.png")
-
- def getNote(self):
- # impostare le note esplicative del comando
- return QadMsg.translate("Command_ARC", "Draws an arc by many methods.")
-
- def __init__(self, plugIn):
- QadCommandClass.__init__(self, plugIn)
- self.vertices = []
-
- def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
- if (self.plugIn is not None):
- if self.PointMapTool is None:
- self.PointMapTool = Qad_arc_maptool(self.plugIn)
- return self.PointMapTool
- else:
- return None
-
- def run(self, msgMapTool = False, msg = None):
- self.isValidPreviousInput = True # per gestire il comando anche in macro
-
- if self.plugIn.canvas.mapRenderer().destinationCrs().geographicFlag():
- self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
- return True # fine comando
-
- currLayer, errMsg = qad_layer.getCurrLayerEditable(self.plugIn.canvas, QGis.Line)
- if currLayer is None:
- self.showErr(errMsg)
- return True # fine comando
-
- #=========================================================================
- # RICHIESTA PRIMO PUNTO o CENTRO
- if self.step == 0: # inizio del comando
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_START_PT)
- keyWords = QadMsg.translate("Command_ARC", "Center")
-
- prompt = QadMsg.translate("Command_ARC", "Specify the start point of the arc or [{0}]:").format(keyWords)
-
- englishKeyWords = "Center"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o enter o una parola chiave
- # msg, inputType, default, keyWords, nessun controllo di modo
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
- None, \
- keyWords, QadInputModeEnum.NONE)
- self.step = 1
-
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA PRIMO PUNTO o CENTRO
- elif self.step == 1: # dopo aver atteso un punto o enter o una parola chiave si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if value is None:
- if self.plugIn.lastPoint is not None:
- value = self.plugIn.lastPoint
- else:
- return True # fine comando
-
- if type(value) == QgsPoint: # se é stato inserito il punto iniziale dell'arco
- self.startPt = value
- self.plugIn.setLastPoint(value)
-
- # imposto il map tool
- self.getPointMapTool().arcStartPt = self.startPt
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_PT_KNOWN_ASK_FOR_SECOND_PT)
-
- keyWords = QadMsg.translate("Command_ARC", "Center") + "/" + \
- QadMsg.translate("Command_ARC", "End")
-
- prompt = QadMsg.translate("Command_ARC", "Specify second point of the arc or [{0}]:").format(keyWords)
-
- englishKeyWords = "Center" + "/" + "End"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o una parola chiave
- # msg, inputType, default, keyWords
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
- None, \
- keyWords, QadInputModeEnum.NONE)
-
- self.step = 2
- return False
- else: # si vuole inserire il centro dell'arco
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_CENTER_PT)
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the center of the arc: "))
-
- self.step = 13
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA SECONDO PUNTO o CENTRO o FINE
- elif self.step == 2: # dopo aver atteso un punto o una parola chiave si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == unicode:
- if value == QadMsg.translate("Command_ARC", "Center") or value == "Center":
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_PT_KNOWN_ASK_FOR_CENTER_PT)
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the center of the arc: "))
- self.step = 4
- elif value == QadMsg.translate("Command_ARC", "End") or value == "End":
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_PT_KNOWN_ASK_FOR_END_PT)
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the final point of the arc: "))
- self.step = 8
- elif type(value) == QgsPoint: # se é stato inserito il secondo punto dell'arco
- self.secondPt = value
- # imposto il map tool
- self.getPointMapTool().arcSecondPt = self.secondPt
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_SECOND_PT_KNOWN_ASK_FOR_END_PT)
-
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the final point of the arc: "))
- self.step = 3
-
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA PUNTO FINALE DELL'ARCO (da step = 2)
- elif self.step == 3: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- self.endPt = value
-
- arc = QadArc()
- if arc.fromStartSecondEndPts(self.startPt, self.secondPt, self.endPt) == True:
- self.plugIn.setLastPoint(arc.getEndPt())
- points = arc.asPolyline()
- if points is not None:
- # se i punti sono così vicini da essere considerati uguali
- if qad_utils.ptNear(self.startPt, arc.getStartPt()):
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
- else:
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
-
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the final point of the arc: "))
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA CENTRO DELL'ARCO (da step = 2)
- elif self.step == 4: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- self.centerPt = value
- self.plugIn.setLastPoint(value)
-
- # imposto il map tool
- self.getPointMapTool().arcCenterPt = self.centerPt
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_END_PT)
-
- keyWords = QadMsg.translate("Command_ARC", "Angle") + "/" + \
- QadMsg.translate("Command_ARC", "chord Length")
-
- prompt = QadMsg.translate("Command_ARC", "Specify the final point of the arc or [{0}]: ").format(keyWords)
-
- englishKeyWords = "Angle" + "/" + "chord Length"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o una parola chiave
- # msg, inputType, default, keyWords, valori nulli non ammessi
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
- None, \
- keyWords, QadInputModeEnum.NOT_NULL)
-
- self.step = 5
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA "Specificare punto finale dell'arco o [Angolo/Lunghezza corda]: " (da step = 4)
- elif self.step == 5: # dopo aver atteso un punto o una parola chiave si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == unicode:
- if value == QadMsg.translate("Command_ARC", "Angle") or value == "Angle":
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_ANGLE)
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, valori nulli non ammessi
- self.waitFor(QadMsg.translate("Command_ARC", "Specify the included angle: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
- None, "", \
- QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO)
- self.step = 6
- return False
- elif value == QadMsg.translate("Command_ARC", "chord Length") or value == "chord Length":
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_CHORD)
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, valori positivi
- self.waitFor(QadMsg.translate("Command_ARC", "Specify the chord length: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
- None, "", \
- QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
- self.step = 7
- return False
- elif type(value) == QgsPoint: # se é stato inserito il punto finale dell'arco
- self.endPt = value
-
- arc = QadArc()
- if arc.fromStartCenterEndPts(self.startPt, self.centerPt, self.endPt) == True:
- self.plugIn.setLastPoint(arc.getEndPt())
- points = arc.asPolyline()
- if points is not None:
- # se i punti sono così vicini da essere considerati uguali
- if qad_utils.ptNear(self.startPt, arc.getStartPt()):
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
- else:
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
-
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- keyWords = QadMsg.translate("Command_ARC", "Angle") + "/" + \
- QadMsg.translate("Command_ARC", "chord Length")
- prompt = QadMsg.translate("Command_ARC", "Specify the final point of the arc or [{0}]: ").format(keyWords)
-
- englishKeyWords = "Angle" + "/" + "chord Length"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o una parola chiave
- # msg, inputType, default, keyWords, valori nulli non ammessi
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
- None, \
- keyWords, QadInputModeEnum.NOT_NULL)
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA "Specificare angolo inscritto: " (da step = 5)
- elif self.step == 6: # dopo aver atteso un punto o un numero reale si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == QgsPoint:
- self.angle = qad_utils.getAngleBy2Pts(self.centerPt, value)
- else:
- self.angle = value
-
- arc = QadArc()
- if arc.fromStartCenterPtsAngle(self.startPt, self.centerPt, self.angle) == True:
- self.plugIn.setLastPoint(arc.getEndPt())
- points = arc.asPolyline()
- if points is not None:
- # se i punti sono così vicini da essere considerati uguali
- if qad_utils.ptNear(self.startPt, arc.getStartPt()):
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
- else:
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
-
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, valori nulli non ammessi
- self.waitFor(QadMsg.translate("Command_ARC", "Specify the included angle: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
- None, "", \
- QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO)
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA "Specificare lunghezza della corda: " (da step = 5)
- elif self.step == 7: # dopo aver atteso un punto o un numero reale si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == QgsPoint:
- self.chord = qad_utils.getDistance(self.startPt, value)
- else:
- self.chord = value
-
- arc = QadArc()
- if arc.fromStartCenterPtsChord(self.startPt, self.centerPt, self.chord) == True:
- self.plugIn.setLastPoint(arc.getEndPt())
- points = arc.asPolyline()
- if points is not None:
- # se i punti sono così vicini da essere considerati uguali
- if qad_utils.ptNear(self.startPt, arc.getStartPt()):
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
- else:
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
-
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, valori positivi ammessi
- self.waitFor(QadMsg.translate("Command_ARC", "Specify the chord length: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
- None, "", \
- QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA "Specificare punto finale dell'arco: " (da step = 1)
- elif self.step == 8: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- self.endPt = value
- self.plugIn.setLastPoint(self.endPt)
-
- # imposto il map tool
- self.getPointMapTool().arcEndPt = self.endPt
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_CENTER)
-
- keyWords = QadMsg.translate("Command_ARC", "Angle") + "/" + \
- QadMsg.translate("Command_ARC", "Direction") + "/" + \
- QadMsg.translate("Command_ARC", "Radius")
-
- prompt = QadMsg.translate("Command_ARC", "Specify the center point of the arc or [{0}]: ").format(keyWords)
-
- englishKeyWords = "Angle" + "/" + "Direction" + "/" + "Radius"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o una parola chiave
- # msg, inputType, default, keyWords, valori nulli non ammessi
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
- None, \
- keyWords, QadInputModeEnum.NOT_NULL)
-
- self.step = 9
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA "Specificare centro dell'arco o [Angolo/Direzione/Raggio]: " (da step = 8)
- elif self.step == 9: # dopo aver atteso un punto o una parola chiave si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == unicode:
- if value == QadMsg.translate("Command_ARC", "Angle") or value == "Angle":
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_ANGLE)
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, isNullable
- self.waitFor(QadMsg.translate("Command_ARC", "Specify the included angle: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
- None, "", QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO)
- self.step = 10
- return False
- elif value == QadMsg.translate("Command_ARC", "Direction") or value == "Direction":
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_TAN)
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, isNullable
- self.waitFor(QadMsg.translate("Command_ARC", "Specify the tangent direction for the start point of the arc: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
- None, "", QadInputModeEnum.NOT_NULL)
- self.step = 11
- return False
- elif value == QadMsg.translate("Command_ARC", "Radius") or value == "Radius":
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_RADIUS)
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, isNullable
- self.waitFor(QadMsg.translate("Command_ARC", "Specify the radius of the arc: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
- None, "", \
- QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
- self.step = 12
- return False
- elif type(value) == QgsPoint: # se é stato inserito il centro dell'arco
- self.centerPt = value
-
- arc = QadArc()
- if arc.fromStartCenterEndPts(self.startPt, self.centerPt, self.endPt) == True:
- self.plugIn.setLastPoint(arc.getEndPt())
- points = arc.asPolyline()
- if points is not None:
- # se i punti sono così vicini da essere considerati uguali
- if qad_utils.ptNear(self.startPt, arc.getStartPt()):
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
- else:
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
-
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- keyWords = QadMsg.translate("Command_ARC", "Angle") + "/" + \
- QadMsg.translate("Command_ARC", "Direction") + "/" + \
- QadMsg.translate("Command_ARC", "Radius")
-
- prompt = QadMsg.translate("Command_ARC", "Specify the center point of the arc or [{0}]: ").format(keyWords)
-
- englishKeyWords = "Angle" + "/" + "Direction" + "/" + "Radius"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o una parola chiave
- # msg, inputType, default, keyWords, isNullable
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
- None, \
- keyWords, QadInputModeEnum.NOT_NULL)
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA "Specificare angolo inscritto: " (da step = 9)
- elif self.step == 10: # dopo aver atteso un punto o un numero reale si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == QgsPoint:
- self.angle = qad_utils.getAngleBy2Pts(self.startPt, value)
- else:
- self.angle = value
-
- arc = QadArc()
- if arc.fromStartEndPtsAngle(self.startPt, self.endPt, self.angle) == True:
- self.plugIn.setLastPoint(arc.getEndPt())
- points = arc.asPolyline()
- if points is not None:
- # se i punti sono così vicini da essere considerati uguali
- if qad_utils.ptNear(self.startPt, arc.getStartPt()):
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
- else:
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
-
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, valori non nulli
- self.waitFor(QadMsg.translate("Command_ARC", "Specify the included angle: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
- None, "", \
- QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO)
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA "Specificare direzione tangente per il punto iniziale dell'arco: " (da step = 9)
- elif self.step == 11: # dopo aver atteso un punto o un numero reale si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == QgsPoint:
- self.angleTan = qad_utils.getAngleBy2Pts(self.startPt, value)
- else:
- self.angleTan = value
-
- arc = QadArc()
- if arc.fromStartEndPtsTan(self.startPt, self.endPt, self.angleTan) == True:
- self.plugIn.setLastPoint(arc.getEndPt())
- points = arc.asPolyline()
- if points is not None:
- # se i punti sono così vicini da essere considerati uguali
- if qad_utils.ptNear(self.startPt, arc.getStartPt()):
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
- else:
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
-
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, isNullable
- self.waitFor(QadMsg.translate("Command_ARC", "Specify the tangent direction for the start point of the arc: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
- None, "", QadInputModeEnum.NOT_NULL)
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA "Specificare raggio dell'arco: " (da step = 9)
- elif self.step == 12: # dopo aver atteso un punto o un numero reale si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == QgsPoint:
- self.radius = qad_utils.getDistance(self.endPt, value)
- else:
- self.radius = value
-
- self.plugIn.setLastRadius(self.radius)
-
- arc = QadArc()
- if arc.fromStartEndPtsRadius(self.startPt, self.endPt, self.radius) == True:
- self.plugIn.setLastPoint(arc.getEndPt())
- points = arc.asPolyline()
- if points is not None:
- # se i punti sono così vicini da essere considerati uguali
- if qad_utils.ptNear(self.startPt, arc.getStartPt()):
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
- else:
- self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
-
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, valori positivi
- self.waitFor(QadMsg.translate("Command_ARC", "Specify the radius of the arc: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
- None, "", \
- QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA CENTRO DELL'ARCO (da step = 1)
- elif self.step == 13: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- self.centerPt = value
- self.plugIn.setLastPoint(value)
-
- # imposto il map tool
- self.getPointMapTool().arcCenterPt = self.centerPt
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_START_PT)
-
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the start point of the arc: "))
- self.step = 14
-
- return False
-
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA PUNTO INIZIALE DELL'ARCO (da step = 13)
- elif self.step == 14: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- self.startPt = value
- self.plugIn.setLastPoint(value)
-
- # imposto il map tool
- self.getPointMapTool().arcStartPt = self.startPt
- self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_END_PT)
-
- keyWords = QadMsg.translate("Command_ARC", "Angle") + "/" + \
- QadMsg.translate("Command_ARC", "chord Length")
-
- prompt = QadMsg.translate("Command_ARC", "Specify the final point of the arc or [{0}]: ").format(keyWords)
-
- englishKeyWords = "Angle" + "/" + "chord Length"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o una parola chiave
- # msg, inputType, default, keyWords, isNullable
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
- None, \
- keyWords, QadInputModeEnum.NOT_NULL)
-
- self.step = 5
- return False
-
-
-#============================================================================
-# Classe che gestisce il comando per cambiare il raggio di un arco per i grip
-#============================================================================
-class QadGRIPCHANGEARCRADIUSCommandClass(QadCommandClass):
-
- def instantiateNewCmd(self):
- """ istanzia un nuovo comando dello stesso tipo """
- return QadGRIPCHANGEARCRADIUSCommandClass(self.plugIn)
-
-
- def __init__(self, plugIn):
- QadCommandClass.__init__(self, plugIn)
- self.entity = None
- self.skipToNextGripCommand = False
- self.copyEntities = False
- self.basePt = QgsPoint()
- self.nOperationsToUndo = 0
-
-
- def __del__(self):
- QadCommandClass.__del__(self)
-
-
- def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
- if (self.plugIn is not None):
- if self.PointMapTool is None:
- self.PointMapTool = Qad_gripChangeArcRadius_maptool(self.plugIn)
- return self.PointMapTool
- else:
- return None
-
-
- #============================================================================
- # setSelectedEntityGripPoints
- #============================================================================
- def setSelectedEntityGripPoints(self, entitySetGripPoints):
- # lista delle entityGripPoint con dei grip point selezionati
- # setta la prima entità con un grip selezionato
- self.entity = None
- for entityGripPoints in entitySetGripPoints.entityGripPoints:
- for gripPoint in entityGripPoints.gripPoints:
- # grip point selezionato
- if gripPoint.getStatus() == qad_grip.QadGripStatusEnum.SELECTED:
- # verifico se l'entità appartiene ad uno stile di quotatura
- if entityGripPoints.entity.isDimensionComponent():
- return False
- if entityGripPoints.entity.getEntityType() != QadEntityGeomTypeEnum.ARC:
- return False
-
- self.entity = entityGripPoints.entity
- arc = entityGripPoints.entity.getQadGeom() # arco in map coordinate
- self.basePt.set(arc.center.x(), arc.center.y())
- return True
- return False
-
-
- #============================================================================
- # changeRadius
- #============================================================================
- def changeRadius(self, radius):
- # radius = nuovo raggio dell'arco
- if radius <= 0:
- return False
- arc = self.entity.getQadGeom()
- arc.radius = radius
- points = arc.asPolyline()
- if points is None:
- return False
-
- g = QgsGeometry.fromPolyline(points)
- f = self.entity.getFeature()
- f.setGeometry(g)
-
- self.plugIn.beginEditCommand("Feature stretched", [self.entity.layer])
-
- if self.copyEntities == False:
- # plugIn, layer, feature, refresh, check_validity
- if qad_layer.updateFeatureToLayer(self.plugIn, self.entity.layer, f, False, False) == False:
- self.plugIn.destroyEditCommand()
- return False
- else:
- # plugIn, layer, features, coordTransform, refresh, check_validity
- if qad_layer.addFeatureToLayer(self.plugIn, self.entity.layer, f, None, False, False) == False:
- self.plugIn.destroyEditCommand()
- return False
-
- self.plugIn.setLastRadius(radius)
- self.plugIn.endEditCommand()
- self.nOperationsToUndo = self.nOperationsToUndo + 1
-
- return True
-
-
- #============================================================================
- # waitForRadius
- #============================================================================
- def waitForRadius(self):
- keyWords = QadMsg.translate("Command_GRIP", "Base point") + "/" + \
- QadMsg.translate("Command_GRIP", "Copy") + "/" + \
- QadMsg.translate("Command_GRIP", "Undo") + "/" + \
- QadMsg.translate("Command_GRIP", "eXit")
- prompt = QadMsg.translate("Command_GRIPCHANGEARCRADIUS", "Specify the radius or [{0}]: ").format(keyWords)
-
- englishKeyWords = "Base point" + "/" + "Copy" + "/" + "Undo" + "/" "eXit"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o enter o una parola chiave
- # msg, inputType, default, keyWords, valori positivi
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT | QadInputTypeEnum.KEYWORDS, \
- None, \
- keyWords, QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
- self.step = 1
- # imposto il map tool
- self.getPointMapTool().setEntity(self.entity) # setta basePt nel centro dell'arco
- self.getPointMapTool().basePt = self.basePt
- self.getPointMapTool().setMode(Qad_gripChangeArcRadius_maptool_ModeEnum.BASE_PT_KNOWN_ASK_FOR_RADIUS_PT)
-
-
- #============================================================================
- # waitForBasePt
- #============================================================================
- def waitForBasePt(self):
- self.step = 2
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_gripChangeArcRadius_maptool_ModeEnum.ASK_FOR_BASE_PT)
-
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_GRIP", "Specify base point: "))
-
-
- #============================================================================
- # run
- #============================================================================
- def run(self, msgMapTool = False, msg = None):
- if self.plugIn.canvas.mapRenderer().destinationCrs().geographicFlag():
- self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
- return True # fine comando
-
- #=========================================================================
- # RICHIESTA SELEZIONE OGGETTI
- if self.step == 0: # inizio del comando
- if self.entity is None: # non ci sono oggetti da stirare
- return True
- self.showMsg(QadMsg.translate("Command_GRIPCHANGEARCRADIUS", "\n** RADIUS **\n"))
- # si appresta ad attendere raggio
- self.waitForRadius()
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA DEL RAGGIO DI RACCORDO (da step = 1)
- elif self.step == 1:
- ctrlKey = False
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- if self.copyEntities == False:
- self.skipToNextGripCommand = True
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- ctrlKey = self.getPointMapTool().ctrlKey
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == unicode:
- if value == QadMsg.translate("Command_GRIP", "Base point") or value == "Base point":
- # si appresta ad attendere il punto base
- self.waitForBasePt()
- elif value == QadMsg.translate("Command_GRIP", "Copy") or value == "Copy":
- # Copia entità lasciando inalterate le originali
- self.copyEntities = True
- # si appresta ad attendere raggio
- self.waitForRadius()
- elif value == QadMsg.translate("Command_GRIP", "Undo") or value == "Undo":
- if self.nOperationsToUndo > 0:
- self.nOperationsToUndo = self.nOperationsToUndo - 1
- self.plugIn.undoEditCommand()
- else:
- self.showMsg(QadMsg.translate("QAD", "\nThe command has been canceled."))
- # si appresta ad attendere raggio
- self.waitForRadius()
- elif value == QadMsg.translate("Command_GRIP", "eXit") or value == "eXit":
- return True # fine comando
- elif type(value) == QgsPoint or type(value) == float: # se é stato inserito il raggio
- if type(value) == QgsPoint: # se é stato inserito il raggio con un punto
- if value == self.basePt:
- self.showMsg(QadMsg.translate("QAD", "\nThe value must be positive and not zero."))
- # si appresta ad attendere raggio
- self.waitForRadius()
- return False
-
- radius = qad_utils.getDistance(self.basePt, value)
- else:
- radius = value
-
- if ctrlKey:
- self.copyEntities = True
-
- self.changeRadius(radius)
-
- if self.copyEntities == False:
- return True
- # si appresta ad attendere raggio
- self.waitForRadius()
- else:
- if self.copyEntities == False:
- self.skipToNextGripCommand = True
- return True # fine comando
-
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA PUNTO BASE (da step = 1)
- elif self.step == 2: # dopo aver atteso un punto
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- pass # opzione di default
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == QgsPoint: # se é stato inserito il punto base
- self.basePt.set(value.x(), value.y())
- # imposto il map tool
- self.getPointMapTool().basePt = self.basePt
-
- # si appresta ad attendere raggio
- self.waitForRadius()
-
- return False
+# -*- coding: utf-8 -*-
+"""
+/***************************************************************************
+ QAD Quantum Aided Design plugin OK
+
+ comando ARC per disegnare un arco
+
+ -------------------
+ begin : 2013-05-22
+ copyright : iiiii
+ email : hhhhh
+ developers : bbbbb aaaaa ggggg
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+"""
+
+
+# Import the PyQt and QGIS libraries
+from qgis.PyQt.QtGui import QIcon
+from qgis.core import QgsWkbTypes, QgsGeometry, QgsPointXY
+import math
+
+
+from ..qad_arc import QadArc
+from ..qad_getpoint import QadGetPointDrawModeEnum
+from .qad_arc_maptool import Qad_arc_maptool, Qad_arc_maptool_ModeEnum, \
+ Qad_gripChangeArcRadius_maptool, Qad_gripChangeArcRadius_maptool_ModeEnum
+from .qad_generic_cmd import QadCommandClass
+from ..qad_msg import QadMsg
+from ..qad_textwindow import QadInputTypeEnum, QadInputModeEnum
+from .. import qad_utils
+from .. import qad_layer
+from ..qad_grip import QadGripStatusEnum
+from ..qad_dim import QadDimStyles
+
+
+# Classe che gestisce il comando ARC
+class QadARCCommandClass(QadCommandClass):
+
+ def instantiateNewCmd(self):
+ """ istanzia un nuovo comando dello stesso tipo """
+ return QadARCCommandClass(self.plugIn)
+
+ def getName(self):
+ return QadMsg.translate("Command_list", "ARC")
+
+ def getEnglishName(self):
+ return "ARC"
+
+ def connectQAction(self, action):
+ action.triggered.connect(self.plugIn.runARCCommand)
+
+ def getIcon(self):
+ return QIcon(":/plugins/qad/icons/arc.svg")
+
+ def getNote(self):
+ # impostare le note esplicative del comando
+ return QadMsg.translate("Command_ARC", "Draws an arc by many methods.")
+
+ def __init__(self, plugIn):
+ QadCommandClass.__init__(self, plugIn)
+ self.vertices = []
+
+ def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
+ if (self.plugIn is not None):
+ if self.PointMapTool is None:
+ self.PointMapTool = Qad_arc_maptool(self.plugIn)
+ return self.PointMapTool
+ else:
+ return None
+
+ def run(self, msgMapTool = False, msg = None):
+ self.isValidPreviousInput = True # per gestire il comando anche in macro
+
+ if self.plugIn.canvas.mapSettings().destinationCrs().isGeographic():
+ self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
+ return True # fine comando
+
+ currLayer, errMsg = qad_layer.getCurrLayerEditable(self.plugIn.canvas, QgsWkbTypes.LineGeometry)
+ if currLayer is None:
+ self.showErr(errMsg)
+ return True # fine comando
+
+ # =========================================================================
+ # RICHIESTA PRIMO PUNTO o CENTRO
+ if self.step == 0: # inizio del comando
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_START_PT)
+ keyWords = QadMsg.translate("Command_ARC", "Center")
+
+ prompt = QadMsg.translate("Command_ARC", "Specify the start point of the arc or [{0}]:").format(keyWords)
+
+ englishKeyWords = "Center"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o enter o una parola chiave
+ # msg, inputType, default, keyWords, nessun controllo di modo
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NONE)
+ self.step = 1
+
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA PRIMO PUNTO o CENTRO
+ elif self.step == 1: # dopo aver atteso un punto o enter o una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if value is None:
+ if self.plugIn.lastPoint is not None:
+ value = self.plugIn.lastPoint
+ else:
+ return True # fine comando
+
+ if type(value) == QgsPointXY: # se é stato inserito il punto iniziale dell'arco
+ self.startPt = value
+ self.plugIn.setLastPoint(value)
+
+ # imposto il map tool
+ self.getPointMapTool().arcStartPt = self.startPt
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_PT_KNOWN_ASK_FOR_SECOND_PT)
+
+ keyWords = QadMsg.translate("Command_ARC", "Center") + "/" + \
+ QadMsg.translate("Command_ARC", "End")
+
+ prompt = QadMsg.translate("Command_ARC", "Specify second point of the arc or [{0}]:").format(keyWords)
+
+ englishKeyWords = "Center" + "/" + "End"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o una parola chiave
+ # msg, inputType, default, keyWords
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NONE)
+
+ self.step = 2
+ return False
+ else: # si vuole inserire il centro dell'arco
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_CENTER_PT)
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the center of the arc: "))
+
+ self.step = 13
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA SECONDO PUNTO o CENTRO o FINE
+ elif self.step == 2: # dopo aver atteso un punto o una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == unicode:
+ if value == QadMsg.translate("Command_ARC", "Center") or value == "Center":
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_PT_KNOWN_ASK_FOR_CENTER_PT)
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the center of the arc: "))
+ self.step = 4
+ elif value == QadMsg.translate("Command_ARC", "End") or value == "End":
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_PT_KNOWN_ASK_FOR_END_PT)
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the final point of the arc: "))
+ self.step = 8
+ elif type(value) == QgsPointXY: # se é stato inserito il secondo punto dell'arco
+ self.secondPt = value
+ # imposto il map tool
+ self.getPointMapTool().arcSecondPt = self.secondPt
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_SECOND_PT_KNOWN_ASK_FOR_END_PT)
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the final point of the arc: "))
+ self.step = 3
+
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA PUNTO FINALE DELL'ARCO (da step = 2)
+ elif self.step == 3: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ self.endPt = value
+
+ arc = QadArc()
+ if arc.fromStartSecondEndPts(self.startPt, self.secondPt, self.endPt) == True:
+ self.plugIn.setLastPoint(arc.getEndPt())
+ geom = arc.asGeom(currLayer.wkbType())
+ if geom is not None:
+ # se i punti sono così vicini da essere considerati uguali
+ if qad_utils.ptNear(self.startPt, arc.getStartPt()):
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
+ else:
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
+
+ self.getPointMapTool().setPolarAngOffset(self.plugIn.lastSegmentAng)
+
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the final point of the arc: "))
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA CENTRO DELL'ARCO (da step = 2)
+ elif self.step == 4: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ self.centerPt = value
+ self.plugIn.setLastPoint(value)
+
+ # imposto il map tool
+ self.getPointMapTool().arcCenterPt = self.centerPt
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_END_PT)
+
+ keyWords = QadMsg.translate("Command_ARC", "Angle") + "/" + \
+ QadMsg.translate("Command_ARC", "chord Length")
+
+ prompt = QadMsg.translate("Command_ARC", "Specify the final point of the arc (hold Ctrl to switch direction) or [{0}]: ").format(keyWords)
+
+ englishKeyWords = "Angle" + "/" + "chord Length"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o una parola chiave
+ # msg, inputType, default, keyWords, valori nulli non ammessi
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NOT_NULL)
+
+ self.step = 5
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA "Specificare punto finale dell'arco o [Angolo/Lunghezza corda]: " (da step = 4)
+ elif self.step == 5: # dopo aver atteso un punto o una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ ctrlPressed = self.getPointMapTool().ctrlKey
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ ctrlPressed = False
+
+ if type(value) == unicode:
+ if value == QadMsg.translate("Command_ARC", "Angle") or value == "Angle":
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_ANGLE)
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, valori nulli non ammessi
+ self.waitFor(QadMsg.translate("Command_ARC", "Specify the included angle (hold Ctrl to switch direction): "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
+ None, "", \
+ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO)
+ self.step = 6
+ return False
+ elif value == QadMsg.translate("Command_ARC", "chord Length") or value == "chord Length":
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_CHORD)
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(QadMsg.translate("Command_ARC", "Specify the chord length (hold Ctrl to switch direction): "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
+ None, "", \
+ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+ self.step = 7
+ return False
+ elif type(value) == QgsPointXY: # se é stato inserito il punto finale dell'arco
+ self.endPt = value
+
+ arc = QadArc()
+ if arc.fromStartCenterEndPts(self.startPt, self.centerPt, self.endPt) == True:
+ if ctrlPressed: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+
+ self.plugIn.setLastPoint(arc.getEndPt())
+
+ geom = arc.asGeom(currLayer.wkbType())
+ if geom is not None:
+ # se i punti sono così vicini da essere considerati uguali
+ if qad_utils.ptNear(self.startPt, arc.getStartPt()):
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
+ else:
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
+
+ self.getPointMapTool().setPolarAngOffset(self.plugIn.lastSegmentAng)
+
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ keyWords = QadMsg.translate("Command_ARC", "Angle") + "/" + \
+ QadMsg.translate("Command_ARC", "chord Length")
+ prompt = QadMsg.translate("Command_ARC", "Specify the final point of the arc (hold Ctrl to switch direction) or [{0}]: ").format(keyWords)
+
+ englishKeyWords = "Angle" + "/" + "chord Length"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o una parola chiave
+ # msg, inputType, default, keyWords, valori nulli non ammessi
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NOT_NULL)
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA "Specificare angolo inscritto: " (da step = 5)
+ elif self.step == 6: # dopo aver atteso un punto o un numero reale si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ ctrlPressed = self.getPointMapTool().ctrlKey
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ ctrlPressed = False
+
+ if type(value) == QgsPointXY:
+ self.angle = qad_utils.getAngleBy2Pts(self.centerPt, value)
+ else:
+ self.angle = value
+
+ arc = QadArc()
+ if arc.fromStartCenterPtsAngle(self.startPt, self.centerPt, self.angle) == True:
+ if ctrlPressed: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+
+ self.plugIn.setLastPoint(arc.getEndPt())
+ geom = arc.asGeom(currLayer.wkbType())
+ if geom is not None:
+ # se i punti sono così vicini da essere considerati uguali
+ if qad_utils.ptNear(self.startPt, arc.getStartPt()):
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
+ else:
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
+
+ self.getPointMapTool().setPolarAngOffset(self.plugIn.lastSegmentAng)
+
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, valori nulli non ammessi
+ self.waitFor(QadMsg.translate("Command_ARC", "Specify the included angle (hold Ctrl to switch direction): "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
+ None, "", \
+ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO)
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA "Specificare lunghezza della corda: " (da step = 5)
+ elif self.step == 7: # dopo aver atteso un punto o un numero reale si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ ctrlPressed = self.getPointMapTool().ctrlKey
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ ctrlPressed = False
+
+ if type(value) == QgsPointXY:
+ self.chord = qad_utils.getDistance(self.startPt, value)
+ else:
+ self.chord = value
+
+ arc = QadArc()
+ if arc.fromStartCenterPtsChord(self.startPt, self.centerPt, self.chord) == True:
+ if ctrlPressed: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+
+ self.plugIn.setLastPoint(arc.getEndPt())
+ geom = arc.asGeom(currLayer.wkbType())
+ if geom is not None:
+ # se i punti sono così vicini da essere considerati uguali
+ if qad_utils.ptNear(self.startPt, arc.getStartPt()):
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
+ else:
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
+
+ self.getPointMapTool().setPolarAngOffset(self.plugIn.lastSegmentAng)
+
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, valori positivi ammessi
+ self.waitFor(QadMsg.translate("Command_ARC", "Specify the chord length (hold Ctrl to switch direction): "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
+ None, "", \
+ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA "Specificare punto finale dell'arco: " (da step = 1)
+ elif self.step == 8: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ self.endPt = value
+ self.plugIn.setLastPoint(self.endPt)
+
+ # imposto il map tool
+ self.getPointMapTool().arcEndPt = self.endPt
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_CENTER)
+
+ keyWords = QadMsg.translate("Command_ARC", "Angle") + "/" + \
+ QadMsg.translate("Command_ARC", "Direction") + "/" + \
+ QadMsg.translate("Command_ARC", "Radius")
+
+ prompt = QadMsg.translate("Command_ARC", "Specify the center point of the arc (hold Ctrl to switch direction) or [{0}]: ").format(keyWords)
+
+ englishKeyWords = "Angle" + "/" + "Direction" + "/" + "Radius"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o una parola chiave
+ # msg, inputType, default, keyWords, valori nulli non ammessi
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NOT_NULL)
+
+ self.step = 9
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA "Specificare centro dell'arco o [Angolo/Direzione/Raggio]: " (da step = 8)
+ elif self.step == 9: # dopo aver atteso un punto o una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ ctrlPressed = self.getPointMapTool().ctrlKey
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ ctrlPressed = False
+
+ if type(value) == unicode:
+ if value == QadMsg.translate("Command_ARC", "Angle") or value == "Angle":
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_ANGLE)
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, isNullable
+ self.waitFor(QadMsg.translate("Command_ARC", "Specify the included angle (hold Ctrl to switch direction): "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
+ None, "", QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO)
+ self.step = 10
+ return False
+ elif value == QadMsg.translate("Command_ARC", "Direction") or value == "Direction":
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_TAN)
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, isNullable
+ self.waitFor(QadMsg.translate("Command_ARC", "Specify the tangent direction for the start point of the arc (hold Ctrl to switch direction): "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
+ None, "", QadInputModeEnum.NOT_NULL)
+ self.step = 11
+ return False
+ elif value == QadMsg.translate("Command_ARC", "Radius") or value == "Radius":
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_RADIUS)
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, isNullable
+ self.waitFor(QadMsg.translate("Command_ARC", "Specify the radius of the arc (hold Ctrl to switch direction): "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
+ None, "", \
+ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+ self.step = 12
+ return False
+ elif type(value) == QgsPointXY: # se é stato inserito il centro dell'arco
+ self.centerPt = value
+
+ arc = QadArc()
+ if arc.fromStartCenterEndPts(self.startPt, self.centerPt, self.endPt) == True:
+ if ctrlPressed: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+
+ self.plugIn.setLastPoint(arc.getEndPt())
+ geom = arc.asGeom(currLayer.wkbType())
+ if geom is not None:
+ # se i punti sono così vicini da essere considerati uguali
+ if qad_utils.ptNear(self.startPt, arc.getStartPt()):
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
+ else:
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
+
+ self.getPointMapTool().setPolarAngOffset(self.plugIn.lastSegmentAng)
+
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ keyWords = QadMsg.translate("Command_ARC", "Angle") + "/" + \
+ QadMsg.translate("Command_ARC", "Direction") + "/" + \
+ QadMsg.translate("Command_ARC", "Radius")
+
+ prompt = QadMsg.translate("Command_ARC", "Specify the center point of the arc (hold Ctrl to switch direction) or [{0}]: ").format(keyWords)
+
+ englishKeyWords = "Angle" + "/" + "Direction" + "/" + "Radius"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o una parola chiave
+ # msg, inputType, default, keyWords, isNullable
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NOT_NULL)
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA "Specificare angolo inscritto: " (da step = 9)
+ elif self.step == 10: # dopo aver atteso un punto o un numero reale si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ ctrlPressed = self.getPointMapTool().ctrlKey
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ ctrlPressed = False
+
+ if type(value) == QgsPointXY:
+ self.angle = qad_utils.getAngleBy2Pts(self.startPt, value)
+ else:
+ self.angle = value
+
+ arc = QadArc()
+ if arc.fromStartEndPtsAngle(self.startPt, self.endPt, self.angle) == True:
+ if ctrlPressed: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+
+ self.plugIn.setLastPoint(arc.getEndPt())
+ geom = arc.asGeom(currLayer.wkbType())
+ if geom is not None:
+ # se i punti sono così vicini da essere considerati uguali
+ if qad_utils.ptNear(self.startPt, arc.getStartPt()):
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
+ else:
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
+
+ self.getPointMapTool().setPolarAngOffset(self.plugIn.lastSegmentAng)
+
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, valori non nulli
+ self.waitFor(QadMsg.translate("Command_ARC", "Specify the included angle (hold Ctrl to switch direction): "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
+ None, "", \
+ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO)
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA "Specificare direzione tangente per il punto iniziale dell'arco: " (da step = 9)
+ elif self.step == 11: # dopo aver atteso un punto o un numero reale si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ ctrlPressed = self.getPointMapTool().ctrlKey
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ ctrlPressed = False
+
+ if type(value) == QgsPointXY:
+ self.angleTan = qad_utils.getAngleBy2Pts(self.startPt, value)
+ else:
+ self.angleTan = value
+
+ arc = QadArc()
+ if arc.fromStartEndPtsTan(self.startPt, self.endPt, self.angleTan) == True:
+ if ctrlPressed: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+
+ self.plugIn.setLastPoint(arc.getEndPt())
+ geom = arc.asGeom(currLayer.wkbType())
+ if geom is not None:
+ # se i punti sono così vicini da essere considerati uguali
+ if qad_utils.ptNear(self.startPt, arc.getStartPt()):
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
+ else:
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
+
+ self.getPointMapTool().setPolarAngOffset(self.plugIn.lastSegmentAng)
+
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, isNullable
+ self.waitFor(QadMsg.translate("Command_ARC", "Specify the tangent direction for the start point of the arc (hold Ctrl to switch direction): "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.ANGLE, \
+ None, "", QadInputModeEnum.NOT_NULL)
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA "Specificare raggio dell'arco: " (da step = 9)
+ elif self.step == 12: # dopo aver atteso un punto o un numero reale si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ ctrlPressed = self.getPointMapTool().ctrlKey
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ ctrlPressed = False
+
+ if type(value) == QgsPointXY:
+ self.radius = qad_utils.getDistance(self.endPt, value)
+ else:
+ self.radius = value
+
+ self.plugIn.setLastRadius(self.radius)
+
+ arc = QadArc()
+ if arc.fromStartEndPtsRadius(self.startPt, self.endPt, self.radius) == True:
+ if ctrlPressed: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+
+ self.plugIn.setLastPoint(arc.getEndPt())
+ geom = arc.asGeom(currLayer.wkbType())
+ if geom is not None:
+ # se i punti sono così vicini da essere considerati uguali
+ if qad_utils.ptNear(self.startPt, arc.getStartPt()):
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnEndPt())
+ else:
+ self.plugIn.setLastSegmentAng(arc.getTanDirectionOnStartPt() + math.pi)
+
+ self.getPointMapTool().setPolarAngOffset(self.plugIn.lastSegmentAng)
+
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(QadMsg.translate("Command_ARC", "Specify the radius of the arc (hold Ctrl to switch direction): "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
+ None, "", \
+ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+
+ # ========================================================================
+ # RISPOSTA ALLA RICHIESTA CENTRO DELL'ARCO (da step = 1)
+ elif self.step == 13: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ self.centerPt = value
+ self.plugIn.setLastPoint(value)
+
+ # imposto il map tool
+ self.getPointMapTool().arcCenterPt = self.centerPt
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_START_PT)
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_ARC", "Specify the start point of the arc: "))
+ self.step = 14
+
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA PUNTO INIZIALE DELL'ARCO (da step = 13)
+ elif self.step == 14: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ self.startPt = value
+ self.plugIn.setLastPoint(value)
+
+ # imposto il map tool
+ self.getPointMapTool().arcStartPt = self.startPt
+ self.getPointMapTool().setMode(Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_END_PT)
+
+ keyWords = QadMsg.translate("Command_ARC", "Angle") + "/" + \
+ QadMsg.translate("Command_ARC", "chord Length")
+
+ prompt = QadMsg.translate("Command_ARC", "Specify the final point of the arc (hold Ctrl to switch direction) or [{0}]: ").format(keyWords)
+
+ englishKeyWords = "Angle" + "/" + "chord Length"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o una parola chiave
+ # msg, inputType, default, keyWords, isNullable
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NOT_NULL)
+
+ self.step = 5
+ return False
+
+
+# ============================================================================
+# Classe che gestisce il comando per cambiare il raggio di un arco per i grip
+# ============================================================================
+class QadGRIPCHANGEARCRADIUSCommandClass(QadCommandClass):
+
+ def instantiateNewCmd(self):
+ """ istanzia un nuovo comando dello stesso tipo """
+ return QadGRIPCHANGEARCRADIUSCommandClass(self.plugIn)
+
+
+ def __init__(self, plugIn):
+ QadCommandClass.__init__(self, plugIn)
+ self.entity = None
+ self.skipToNextGripCommand = False
+ self.copyEntities = False
+ self.basePt = QgsPointXY()
+ self.nOperationsToUndo = 0
+
+
+ def __del__(self):
+ QadCommandClass.__del__(self)
+
+
+ def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
+ if (self.plugIn is not None):
+ if self.PointMapTool is None:
+ self.PointMapTool = Qad_gripChangeArcRadius_maptool(self.plugIn)
+ return self.PointMapTool
+ else:
+ return None
+
+
+ # ============================================================================
+ # setSelectedEntityGripPoints
+ # ============================================================================
+ def setSelectedEntityGripPoints(self, entitySetGripPoints):
+ # lista delle entityGripPoint con dei grip point selezionati
+ # setta la prima entità con un grip selezionato
+ self.entity = None
+ for entityGripPoints in entitySetGripPoints.entityGripPoints:
+ for gripPoint in entityGripPoints.gripPoints:
+ # grip point selezionato
+ if gripPoint.getStatus() == QadGripStatusEnum.SELECTED:
+ # verifico se l'entità appartiene ad uno stile di quotatura
+ if QadDimStyles.isDimEntity(entityGripPoints.entity):
+ return False
+ if entityGripPoints.entity.getQadGeom().whatIs() != "ARC":
+ return False
+
+ self.entity = entityGripPoints.entity
+ arc = entityGripPoints.entity.getQadGeom() # arco in map coordinate
+ self.basePt.set(arc.center.x(), arc.center.y())
+ return True
+ return False
+
+
+ # ============================================================================
+ # changeRadius
+ # ============================================================================
+ def changeRadius(self, radius):
+ # radius = nuovo raggio dell'arco
+ if radius <= 0:
+ return False
+ arc = self.entity.getQadGeom()
+ arc.radius = radius
+ points = arc.asPolyline()
+ if points is None:
+ return False
+
+ g = QgsGeometry.fromPolylineXY(points)
+ f = self.entity.getFeature()
+ f.setGeometry(g)
+
+ self.plugIn.beginEditCommand("Feature stretched", [self.entity.layer])
+
+ if self.copyEntities == False:
+ # plugIn, layer, feature, refresh, check_validity
+ if qad_layer.updateFeatureToLayer(self.plugIn, self.entity.layer, f, False, False) == False:
+ self.plugIn.destroyEditCommand()
+ return False
+ else:
+ # plugIn, layer, features, coordTransform, refresh, check_validity
+ if qad_layer.addFeatureToLayer(self.plugIn, self.entity.layer, f, None, False, False) == False:
+ self.plugIn.destroyEditCommand()
+ return False
+
+ self.plugIn.setLastRadius(radius)
+ self.plugIn.endEditCommand()
+ self.nOperationsToUndo = self.nOperationsToUndo + 1
+
+ return True
+
+
+ # ============================================================================
+ # waitForRadius
+ # ============================================================================
+ def waitForRadius(self):
+ keyWords = QadMsg.translate("Command_GRIP", "Base point") + "/" + \
+ QadMsg.translate("Command_GRIP", "Copy") + "/" + \
+ QadMsg.translate("Command_GRIP", "Undo") + "/" + \
+ QadMsg.translate("Command_GRIP", "eXit")
+ prompt = QadMsg.translate("Command_GRIPCHANGEARCRADIUS", "Specify the radius or [{0}]: ").format(keyWords)
+
+ englishKeyWords = "Base point" + "/" + "Copy" + "/" + "Undo" + "/" "eXit"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o enter o una parola chiave
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+ self.step = 1
+ # imposto il map tool
+ self.getPointMapTool().setEntity(self.entity) # setta basePt nel centro dell'arco
+ self.getPointMapTool().basePt = self.basePt
+ self.getPointMapTool().setMode(Qad_gripChangeArcRadius_maptool_ModeEnum.BASE_PT_KNOWN_ASK_FOR_RADIUS_PT)
+
+
+ # ============================================================================
+ # waitForBasePt
+ # ============================================================================
+ def waitForBasePt(self):
+ self.step = 2
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_gripChangeArcRadius_maptool_ModeEnum.ASK_FOR_BASE_PT)
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_GRIP", "Specify base point: "))
+
+
+ # ============================================================================
+ # run
+ # ============================================================================
+ def run(self, msgMapTool = False, msg = None):
+ if self.plugIn.canvas.mapSettings().destinationCrs().isGeographic():
+ self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
+ return True # fine comando
+
+ # =========================================================================
+ # RICHIESTA SELEZIONE OGGETTI
+ if self.step == 0: # inizio del comando
+ if self.entity is None: # non ci sono oggetti da stirare
+ return True
+ self.showMsg(QadMsg.translate("Command_GRIPCHANGEARCRADIUS", "\n** RADIUS **\n"))
+ # si appresta ad attendere raggio
+ self.waitForRadius()
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL RAGGIO DI RACCORDO (da step = 1)
+ elif self.step == 1:
+ ctrlKey = False
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ if self.copyEntities == False:
+ self.skipToNextGripCommand = True
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ ctrlKey = self.getPointMapTool().ctrlKey
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == unicode:
+ if value == QadMsg.translate("Command_GRIP", "Base point") or value == "Base point":
+ # si appresta ad attendere il punto base
+ self.waitForBasePt()
+ elif value == QadMsg.translate("Command_GRIP", "Copy") or value == "Copy":
+ # Copia entità lasciando inalterate le originali
+ self.copyEntities = True
+ # si appresta ad attendere raggio
+ self.waitForRadius()
+ elif value == QadMsg.translate("Command_GRIP", "Undo") or value == "Undo":
+ if self.nOperationsToUndo > 0:
+ self.nOperationsToUndo = self.nOperationsToUndo - 1
+ self.plugIn.undoEditCommand()
+ else:
+ self.showMsg(QadMsg.translate("QAD", "\nThe command has been canceled."))
+ # si appresta ad attendere raggio
+ self.waitForRadius()
+ elif value == QadMsg.translate("Command_GRIP", "eXit") or value == "eXit":
+ return True # fine comando
+ elif type(value) == QgsPointXY or type(value) == float: # se é stato inserito il raggio
+ if type(value) == QgsPointXY: # se é stato inserito il raggio con un punto
+ if value == self.basePt:
+ self.showMsg(QadMsg.translate("QAD", "\nThe value must be positive and not zero."))
+ # si appresta ad attendere raggio
+ self.waitForRadius()
+ return False
+
+ radius = qad_utils.getDistance(self.basePt, value)
+ else:
+ radius = value
+
+ if ctrlKey:
+ self.copyEntities = True
+
+ self.changeRadius(radius)
+
+ if self.copyEntities == False:
+ return True
+ # si appresta ad attendere raggio
+ self.waitForRadius()
+ else:
+ if self.copyEntities == False:
+ self.skipToNextGripCommand = True
+ return True # fine comando
+
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA PUNTO BASE (da step = 1)
+ elif self.step == 2: # dopo aver atteso un punto
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ pass # opzione di default
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == QgsPointXY: # se é stato inserito il punto base
+ self.basePt.set(value.x(), value.y())
+ # imposto il map tool
+ self.getPointMapTool().basePt = self.basePt
+
+ # si appresta ad attendere raggio
+ self.waitForRadius()
+
+ return False
diff --git a/cmd/qad_arc_maptool.py b/cmd/qad_arc_maptool.py
new file mode 100644
index 00000000..82c7c653
--- /dev/null
+++ b/cmd/qad_arc_maptool.py
@@ -0,0 +1,466 @@
+# -*- coding: utf-8 -*-
+"""
+/***************************************************************************
+ QAD Quantum Aided Design plugin
+
+ classe per gestire il map tool di richiesta di un punto in ambito del comando arco
+
+ -------------------
+ begin : 2013-05-22
+ copyright : iiiii
+ email : hhhhh
+ developers : bbbbb aaaaa ggggg
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+"""
+
+
+from qgis.core import QgsCoordinateTransform, QgsGeometry, QgsProject, QgsWkbTypes
+
+
+from .. import qad_utils
+from ..qad_getpoint import QadGetPoint, QadGetPointDrawModeEnum
+from ..qad_line import QadLine
+from ..qad_polyline import QadPolyline
+from ..qad_arc import QadArc
+from ..qad_rubberband import QadRubberBand
+from ..qad_highlight import QadHighlight
+from ..qad_entity import QadEntity
+
+
+# ===============================================================================
+# Qad_arc_maptool_ModeEnum class.
+# ===============================================================================
+class Qad_arc_maptool_ModeEnum():
+ # noto niente si richiede il primo punto
+ NONE_KNOWN_ASK_FOR_START_PT = 1
+ # noto il punto iniziale dell'arco si richiede il secondo punto
+ START_PT_KNOWN_ASK_FOR_SECOND_PT = 2
+ # noti il punto iniziale e il secondo punto dell'arco si richiede il punto finale
+ START_SECOND_PT_KNOWN_ASK_FOR_END_PT = 3
+ # noto il punto iniziale dell'arco si richiede il centro
+ START_PT_KNOWN_ASK_FOR_CENTER_PT = 4
+ # noti il punto iniziale e il centro dell'arco si richiede il punto finale
+ START_CENTER_PT_KNOWN_ASK_FOR_END_PT = 5
+ # noti il punto iniziale e il centro dell'arco si richiede l'angolo inscritto
+ START_CENTER_PT_KNOWN_ASK_FOR_ANGLE = 6
+ # noti il punto iniziale e il centro dell'arco si richiede la lunghezza della corda
+ START_CENTER_PT_KNOWN_ASK_FOR_CHORD = 7
+ # noto il punto iniziale dell'arco si richiede il punto finale
+ START_PT_KNOWN_ASK_FOR_END_PT = 8
+ # noti il punto iniziale e finale dell'arco si richiede il centro
+ START_END_PT_KNOWN_ASK_FOR_CENTER = 9
+ # noti il punto iniziale e finale dell'arco si richiede l'angolo inscritto
+ START_END_PT_KNOWN_ASK_FOR_ANGLE = 10
+ # noti il punto iniziale e finale dell'arco si richiede la direzione della tangente al punto iniziale
+ START_END_PT_KNOWN_ASK_FOR_TAN = 11
+ # noti il punto iniziale e finale dell'arco si richiede il raggio
+ START_END_PT_KNOWN_ASK_FOR_RADIUS = 12
+ # noto niente si richiede il centro
+ NONE_KNOWN_ASK_FOR_CENTER_PT = 13
+ # noto il centro dell'arco si richiede il punto iniziale
+ CENTER_PT_KNOWN_ASK_FOR_START_PT = 14
+ # noti il punto iniziale e la tangente al punto iniziale si richiede il punto finale
+ START_PT_TAN_KNOWN_ASK_FOR_END_PT = 15
+ # noto il punto iniziale dell'arco si richiede l'angolo inscritto
+ START_PT_KNOWN_ASK_FOR_ANGLE = 16
+ # noti il punto iniziale e l'angolo inscritto dell'arco si richiede il punto finale
+ START_PT_ANGLE_KNOWN_ASK_FOR_END_PT = 17
+ # noti il punto iniziale e l'angolo inscritto dell'arco si richiede il centro
+ START_PT_ANGLE_KNOWN_ASK_FOR_CENTER_PT = 18
+ # noti il punto iniziale e l'angolo inscritto dell'arco si richiede il raggio
+ START_PT_ANGLE_KNOWN_ASK_FOR_RADIUS = 19
+ # noti il punto iniziale e l'angolo inscritto dell'arco si richiede il secondo punto per misurare il raggio
+ START_PT_ANGLE_KNOWN_ASK_FOR_SECONDPTRADIUS = 20
+ # noti il punto iniziale, l'angolo inscritto e il raggio dell'arco si richiede la direzione della corda
+ START_PT_ANGLE_RADIUS_KNOWN_ASK_FOR_CHORDDIRECTION = 21
+ # noti il punto iniziale e il raggio dell'arco si richiede il punto finale
+ START_PT_RADIUS_KNOWN_ASK_FOR_END_PT = 22
+
+
+# ===============================================================================
+# Qad_arc_maptool class
+# ===============================================================================
+class Qad_arc_maptool(QadGetPoint):
+
+ def __init__(self, plugIn, asToolForMPolygon = False):
+ QadGetPoint.__init__(self, plugIn)
+ self.arcStartPt = None
+ self.arcSecondPt = None
+ self.arcEndPt = None
+ self.arcCenterPt = None
+ self.arcTanOnStartPt = None
+ self.arcAngle = None
+ self.arcStartPtForRadius = None
+ self.arcRadius = None
+ self.__rubberBand = QadRubberBand(self.canvas)
+
+ self.asToolForMPolygon = asToolForMPolygon # se True significa che è usato per disegnare un poligono
+ if self.asToolForMPolygon:
+ self.__polygonRubberBand = QadRubberBand(self.plugIn.canvas, True)
+ self.endVertex = None # punta al vertice iniziale e finale del poligono di QadPLINECommandClass
+ else:
+ self.__polygonRubberBand = None
+
+ self.layer = None
+
+
+ def hidePointMapToolMarkers(self):
+ QadGetPoint.hidePointMapToolMarkers(self)
+ self.__rubberBand.hide()
+ if self.__polygonRubberBand is not None: self.__polygonRubberBand.hide()
+
+ def showPointMapToolMarkers(self):
+ QadGetPoint.showPointMapToolMarkers(self)
+ self.__rubberBand.show()
+ if self.__polygonRubberBand is not None: self.__polygonRubberBand.show()
+
+ def clear(self):
+ QadGetPoint.clear(self)
+ self.__rubberBand.reset()
+ if self.__polygonRubberBand is not None: self.__polygonRubberBand.reset()
+ self.mode = None
+
+
+ # ============================================================================
+ # removeItems
+ # ============================================================================
+ def removeItems(self):
+ QadGetPoint.removeItems(self)
+ # prima lo stacco dal canvas altrimenti non si rimuove perchè usato da canvas
+ if self.__rubberBand is not None:
+ del self.__rubberBand
+ self.__rubberBand = None
+
+ if self.__polygonRubberBand is not None:
+ del self.__polygonRubberBand
+ self.__polygonRubberBand = None
+
+
+ def canvasMoveEvent(self, event):
+ QadGetPoint.canvasMoveEvent(self, event)
+
+ self.__rubberBand.reset()
+ if self.__polygonRubberBand is not None: self.__polygonRubberBand.reset()
+
+ result = False
+ arc = QadArc()
+
+ # noti il primo e il secondo punto dell'arco si richiede il terzo punto
+ if self.mode == Qad_arc_maptool_ModeEnum.START_SECOND_PT_KNOWN_ASK_FOR_END_PT:
+ result = arc.fromStartSecondEndPts(self.arcStartPt, self.arcSecondPt, self.tmpPoint)
+ # noti il primo punto e il centro dell'arco si richiede il punto finale
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_END_PT:
+ result = arc.fromStartCenterEndPts(self.arcStartPt, self.arcCenterPt, self.tmpPoint)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+ # noti il primo punto e il centro dell'arco si richiede l'angolo inscritto
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_ANGLE:
+ angle = qad_utils.getAngleBy2Pts(self.arcCenterPt, self.tmpPoint)
+ result = arc.fromStartCenterPtsAngle(self.arcStartPt, self.arcCenterPt, angle)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+ # noti il primo punto e il centro dell'arco si richiede la lunghezza della corda
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_CHORD:
+ chord = qad_utils.getDistance(self.arcStartPt, self.tmpPoint)
+ result = arc.fromStartCenterPtsChord(self.arcStartPt, self.arcCenterPt, chord)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+ # noti il punto iniziale e finale dell'arco si richiede il centro
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_CENTER:
+ result = arc.fromStartCenterEndPts(self.arcStartPt, self.tmpPoint, self.arcEndPt)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+ # noti il punto iniziale e finale dell'arco si richiede l'angolo inscritto
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_ANGLE:
+ angle = qad_utils.getAngleBy2Pts(self.arcStartPt, self.tmpPoint)
+ result = arc.fromStartEndPtsAngle(self.arcStartPt, self.arcEndPt, angle)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+ # noti il punto iniziale e finale dell'arco si richiede la direzione della tangente
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_TAN:
+ tan = qad_utils.getAngleBy2Pts(self.arcStartPt, self.tmpPoint)
+ result = arc.fromStartEndPtsTan(self.arcStartPt, self.arcEndPt, tan)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+ # noti il punto iniziale e finale dell'arco si richiede il raggio
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_RADIUS:
+ radius = qad_utils.getDistance(self.arcEndPt, self.tmpPoint)
+ result = arc.fromStartEndPtsRadius(self.arcStartPt, self.arcEndPt, radius)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+ # noti il punto iniziale e la tangente al punto iniziale si richiede il punto finale
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_TAN_KNOWN_ASK_FOR_END_PT:
+ result = arc.fromStartEndPtsTan(self.arcStartPt, self.tmpPoint, self.arcTanOnStartPt)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+ # noti il punto iniziale e l'angolo inscritto dell'arco si richiede il punto finale
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_ANGLE_KNOWN_ASK_FOR_END_PT:
+ result = arc.fromStartEndPtsAngle(self.arcStartPt, self.tmpPoint, self.arcAngle)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+ # noti il punto iniziale e l'angolo inscritto dell'arco si richiede il centro
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_ANGLE_KNOWN_ASK_FOR_CENTER_PT:
+ result = arc.fromStartCenterPtsAngle(self.arcStartPt, self.tmpPoint, self.arcAngle)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+ # noti il punto iniziale, l'angolo inscritto e il raggio dell'arco si richiede la direzione della corda
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_ANGLE_RADIUS_KNOWN_ASK_FOR_CHORDDIRECTION:
+ chordDirection = qad_utils.getAngleBy2Pts(self.arcStartPt, self.tmpPoint)
+ result = arc.fromStartPtAngleRadiusChordDirection(self.arcStartPt, self.arcAngle, \
+ self.arcRadius, chordDirection)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+ # noti il punto iniziale e il raggio dell'arco si richiede il punto finale
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_RADIUS_KNOWN_ASK_FOR_END_PT:
+ result = arc.fromStartEndPtsRadius(self.arcStartPt, self.tmpPoint, self.arcRadius)
+ if result == True and self.tmpCtrlKey: # inverto angolo iniziale-finale
+ arc.inverseAngles()
+
+ if result == True:
+ if self.__polygonRubberBand is None: # significa che NON è usato per disegnare un poligono
+ if self.layer is not None:
+ g = arc.asGeom(self.layer.wkbType())
+ else:
+ g = arc.asGeom(QgsWkbTypes.CompoundCurve) # è un arco virtuale che non verrà salvato da questo comando
+
+ if g is not None: self.__rubberBand.setGeometry(g)
+ else: # significa che è usato per disegnare un poligono
+ pline = QadPolyline()
+ pline.append(arc)
+
+ if self.endVertex is not None:
+ line = QadLine()
+ line.set(arc.getEndPt(), self.endVertex)
+ pline.append(line)
+ line = QadLine()
+ line.set(self.endVertex, arc.getStartPt())
+ pline.append(line)
+ else:
+ line = QadLine()
+ line.set(arc.getEndPt(), arc.getStartPt())
+ pline.append(line)
+
+ if self.layer is not None:
+ g = pline.asGeom(self.layer.wkbType())
+ else:
+ g = pline.asGeom(QgsWkbTypes.CurvePolygon) # è un arco virtuale che non verrà salvato da questo comando
+
+ self.__polygonRubberBand.setGeometry(g)
+
+# points = arc.asPolyline()
+#
+# if points is not None:
+# self.__rubberBand.setLine(points)
+# if self.__polygonRubberBand is not None: # significa che è usato per disegnare un poligono
+# if self.endVertex is not None:
+# points.insert(0, self.endVertex)
+# self.__polygonRubberBand.setPolygon(points)
+
+
+ def activate(self):
+ QadGetPoint.activate(self)
+ self.__rubberBand.show()
+ if self.__polygonRubberBand is not None: self.__polygonRubberBand.show()
+
+ def deactivate(self):
+ try: # necessario perché se si chiude QGIS parte questo evento nonostante non ci sia più l'oggetto maptool !
+ QadGetPoint.deactivate(self)
+ self.__rubberBand.hide()
+ if self.__polygonRubberBand is not None: self.__polygonRubberBand.hide()
+ except:
+ pass
+
+ def setMode(self, mode):
+ self.mode = mode
+ # noto niente si richiede il primo punto
+ if self.mode == Qad_arc_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_START_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # noto il primo punto dell'arco si richiede il secondo punto
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_KNOWN_ASK_FOR_SECOND_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPt)
+ # noti il primo e il secondo punto dell'arco si richiede il terzo punto
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_SECOND_PT_KNOWN_ASK_FOR_END_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcSecondPt)
+ # noto il primo punto dell'arco si richiede il centro
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_KNOWN_ASK_FOR_CENTER_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPt)
+ # noti il primo punto e il centro dell'arco si richiede il punto finale
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_END_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcCenterPt)
+ # noti il primo punto e il centro dell'arco si richiede l'angolo inscritto
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_ANGLE:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcCenterPt)
+ # noti il primo punto e il centro dell'arco si richiede la lunghezza della corda
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_CENTER_PT_KNOWN_ASK_FOR_CHORD:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPt)
+ # noto il punto iniziale dell'arco si richiede il punto finale
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_KNOWN_ASK_FOR_END_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPt)
+ # noti il punto iniziale e finale dell'arco si richiede il centro
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_CENTER:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # noti il punto iniziale e finale dell'arco si richiede l'angolo inscritto
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_ANGLE:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPt)
+ # noti il punto iniziale e finale dell'arco si richiede la direzione della tangente
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_TAN:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPt)
+ # noti il punto iniziale e finale dell'arco si richiede il raggio
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_END_PT_KNOWN_ASK_FOR_RADIUS:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcEndPt)
+ # noto niente si richiede il centro
+ elif self.mode == Qad_arc_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_CENTER_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # noto il centro dell'arco si richiede il punto iniziale
+ elif self.mode == Qad_arc_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_START_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcCenterPt)
+ # noti il punto iniziale e la tangente al punto iniziale si richiede il punto finale
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_TAN_KNOWN_ASK_FOR_END_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPt)
+ # noto il punto iniziale dell'arco si richiede l'angolo inscritto
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_KNOWN_ASK_FOR_ANGLE:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPt)
+ # noti il punto iniziale e l'angolo inscritto dell'arco si richiede il punto finale
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_ANGLE_KNOWN_ASK_FOR_END_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPt)
+ # noti il punto iniziale e l'angolo inscritto dell'arco si richiede il centro
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_ANGLE_KNOWN_ASK_FOR_CENTER_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # noti il punto iniziale e l'angolo inscritto dell'arco si richiede il raggio
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_ANGLE_KNOWN_ASK_FOR_RADIUS:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # noti il punto iniziale e l'angolo inscritto dell'arco si richiede il secondo punto per misurare il raggio
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_ANGLE_KNOWN_ASK_FOR_SECONDPTRADIUS:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPtForRadius)
+ # noti il punto iniziale, l'angolo inscritto e il raggio dell'arco si richiede la direzione della corda
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_ANGLE_RADIUS_KNOWN_ASK_FOR_CHORDDIRECTION:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPt)
+ # noti il punto iniziale e il raggio dell'arco si richiede il punto finale
+ elif self.mode == Qad_arc_maptool_ModeEnum.START_PT_RADIUS_KNOWN_ASK_FOR_END_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.arcStartPt)
+
+
+
+# ===============================================================================
+# Qad_scale_maptool_ModeEnum class.
+# ===============================================================================
+class Qad_gripChangeArcRadius_maptool_ModeEnum():
+ # si richiede il punto base
+ ASK_FOR_BASE_PT = 1
+ # noto il punto base si richiede il secondo punto per il raggio
+ BASE_PT_KNOWN_ASK_FOR_RADIUS_PT = 2
+
+
+# ===============================================================================
+# Qad_gripChangeArcRadius_maptool class
+# ===============================================================================
+class Qad_gripChangeArcRadius_maptool(QadGetPoint):
+
+ def __init__(self, plugIn):
+ QadGetPoint.__init__(self, plugIn)
+
+ self.basePt = None
+ self.entity = None
+ self.arc = None
+ self.coordTransform = None
+ self.__highlight = QadHighlight(self.canvas)
+
+ def hidePointMapToolMarkers(self):
+ QadGetPoint.hidePointMapToolMarkers(self)
+ self.__highlight.hide()
+
+ def showPointMapToolMarkers(self):
+ QadGetPoint.showPointMapToolMarkers(self)
+ self.__highlight.show()
+
+ def clear(self):
+ QadGetPoint.clear(self)
+ self.__highlight.reset()
+ self.mode = None
+
+ def setEntity(self, entity):
+ self.entity = QadEntity(entity)
+ self.arc = self.entity.getQadGeom() # arco in map coordinate
+ self.basePt = self.arc.center
+ self.coordTransform = QgsCoordinateTransform(self.canvas.mapSettings().destinationCrs(), \
+ entity.layer.crs(), \
+ QgsProject.instance())
+
+
+ # ============================================================================
+ # stretch
+ # ============================================================================
+ def changeRadius(self, radius):
+ self.__highlight.reset()
+ # radius = nuovo raggio dell'arco
+ # tolerance2ApproxCurve = tolleranza per ricreare le curve
+ self.arc.radius = radius
+ points = self.arc.asPolyline()
+ if points is None:
+ return False
+
+ g = QgsGeometry.fromPolylineXY(points)
+ # trasformo la geometria nel crs del layer
+ g.transform(self.coordTransform)
+ self.__highlight.addGeometry(g, self.entity.layer)
+
+
+ def canvasMoveEvent(self, event):
+ QadGetPoint.canvasMoveEvent(self, event)
+
+ # noto il punto base si richiede il secondo punto per il raggio
+ if self.mode == Qad_gripChangeArcRadius_maptool_ModeEnum.BASE_PT_KNOWN_ASK_FOR_RADIUS_PT:
+ radius = qad_utils.getDistance(self.basePt, self.tmpPoint)
+ self.changeRadius(radius)
+
+
+ def activate(self):
+ QadGetPoint.activate(self)
+ self.__highlight.show()
+
+ def deactivate(self):
+ try: # necessario perché se si chiude QGIS parte questo evento nonostante non ci sia più l'oggetto maptool !
+ QadGetPoint.deactivate(self)
+ self.__highlight.hide()
+ except:
+ pass
+
+
+ def setMode(self, mode):
+ self.mode = mode
+ # noto niente si richiede il punto base
+ if self.mode == Qad_gripChangeArcRadius_maptool_ModeEnum.ASK_FOR_BASE_PT:
+ self.clear()
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ self.__highlight.reset()
+ # noto il punto base si richiede il secondo punto per il raggio
+ elif self.mode == Qad_gripChangeArcRadius_maptool_ModeEnum.BASE_PT_KNOWN_ASK_FOR_RADIUS_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.basePt)
+
\ No newline at end of file
diff --git a/cmd/qad_array_cmd.py b/cmd/qad_array_cmd.py
new file mode 100644
index 00000000..ff14396f
--- /dev/null
+++ b/cmd/qad_array_cmd.py
@@ -0,0 +1,2117 @@
+# -*- coding: utf-8 -*-
+"""
+/***************************************************************************
+ QAD Quantum Aided Design plugin ok
+
+ comando ARRAY per copiare serie di oggetti
+
+ -------------------
+ begin : 2016-05-03
+ copyright : iiiii
+ email : hhhhh
+ developers : bbbbb aaaaa ggggg
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+"""
+
+
+# Import the PyQt and QGIS libraries
+from qgis.PyQt.QtGui import QIcon
+from qgis.core import QgsPointXY
+
+
+import math
+
+
+from .. import qad_array_fun
+from .. import qad_layer
+from .. import qad_utils
+from .qad_array_maptool import Qad_array_maptool, Qad_array_maptool_ModeEnum
+from .qad_generic_cmd import QadCommandClass
+from ..qad_msg import QadMsg
+from ..qad_getpoint import QadGetPointDrawModeEnum
+from ..qad_polyline import QadPolyline
+from .qad_getdist_cmd import QadGetDistClass
+from .qad_getangle_cmd import QadGetAngleClass
+from .qad_entsel_cmd import QadEntSelClass
+from ..qad_textwindow import QadInputTypeEnum, QadInputModeEnum
+from .qad_ssget_cmd import QadSSGetClass
+from ..qad_entity import QadCacheEntitySet, QadCacheEntitySetIterator, QadEntityTypeEnum
+from ..qad_variables import QadVariables, QadDELOBJEnum
+from ..qad_dim import QadDimStyles, appendDimEntityIfNotExisting
+from ..qad_geom_relations import getQadGeomClosestPart
+from ..qad_multi_geom import getQadGeomAt
+
+
+# ===============================================================================
+# QadARRAYCommandClassSeriesTypeEnum class.
+# ===============================================================================
+class QadARRAYCommandClassSeriesTypeEnum():
+ RECTANGLE = 1 # serie rettangolare
+ PATH = 2 # serie lungo una traiettoria
+ POLAR = 3 # serie polare
+
+
+# ===============================================================================
+# QadARRAYCommandClassPathMethodTypeEnum class.
+# ===============================================================================
+class QadARRAYCommandClassPathMethodTypeEnum():
+ DIVIDE = 1 # metodo dividi
+ MEASURE = 2 # metodo misura
+
+
+# ===============================================================================
+# QadARRAYCommandClassStepEnum class.
+# ===============================================================================
+class QadARRAYCommandClassStepEnum():
+ ASK_FOR_SELSET = 0 # richiede il gruppo di selezione ogggetti (deve essere = 0 perchè è l'inizio del comando)
+ ASK_FOR_ARRAYTYPE = 1 # richiede il tipo di serie
+ ASK_FOR_ROW_N = 2 # richiede il numero di righe (per rettangolo, traiettoria, polare)
+ ASK_FOR_ROW_SPACE_OR_TOT = 3 # richiede la distanza tra le righe o il totale (per rettangolo, traiettoria, polare)
+ ASK_FOR_ROW_SPACE_TOT = 4 # richiede il totale della spaziatura delle righe (per rettangolo, traiettoria)
+ ASK_FOR_ROW_SPACE_2PT = 5 # richiede il secondo punto per misurare la distanza tra le righe
+ ASK_FOR_BASE_PT = 6 # richiede il punto base (per rettangolo, traiettoria, polare)
+ ASK_FOR_MAIN_OPTIONS = 7 # richiede di selezionare un'opzione (per rettangolo, traiettoria, polare)
+ ASK_FOR_ITEM_N = 8 # richiede il numero di elementi lungo la traiettoria (per traiettoria, polare)
+ ASK_FOR_ITEM_ROTATION = 9 # richiede se gli elementi devono essere allineati (per traiettoria, polare)
+ ASK_FOR_DEL_ORIG_OBJS = 10 # richiede se gli elementi originali devono essere cancellati (per rettangolo, traiettoria, polare)
+ ASK_FOR_BASE_PT_BEFORE_MAIN_OPTIONS = 29 # richiede il punto base prima delle opzioni (per polare)
+ # RETTANGOLO
+ ASK_FOR_ANGLE = 11 # richiede l'angolo di rotazione dell'asse delle righe
+ ASK_FOR_COLUMN_COUNT = 12 # richiede il numero di colonne dall'opzione COUNT
+ ASK_FOR_COLUMN_N = 13 # richiede il numero di colonne dall'opzione COLUMN
+ ASK_FOR_COLUMN_SPACE_OR_CELL = 14 # richiede la distanza tra le colonne o l'unità di cella
+ ASK_FOR_COLUMN_SPACE_2PT = 15 # richiede il secondo punto per misurare la distanza tra le colonne
+ ASK_FOR_ROW_COUNT = 16 # richiede il numero di righe dall'opzione COUNT
+ ASK_FOR_ROW_SPACE = 17 # richiede la distanza tra le righe
+ ASK_FOR_1PT_CELL = 18 # richiede il primo angolo della cella
+ ASK_FOR_2PT_CELL = 19 # richiede il secondo angolo della cella
+ ASK_FOR_COLUMN_SPACE_OR_TOT = 20 # richiede la distanza tra le colonne o il totale
+ ASK_FOR_COLUMN_SPACE_TOT = 21 # richiede il totale della spaziatura delle colonne
+ # TRAIETTORIA
+ ASK_FOR_PATH_OBJ = 22 # richiede la selezione dell'oggetto traiettoria
+ ASK_FOR_PATH_METHOD = 23 # richiede il metodo
+ ASK_FOR_TAN_DIRECTION = 24 # richiede la selezione della direzione della tangente
+ ASK_FOR_ITEM_SPACE = 25 # richiede la distanza tra gli elementi
+ # POLARE
+ ASK_FOR_CENTER_PT = 26 # richiede la selezione del punto centrale della serie
+ ASK_FOR_ANGLE_BETWEEN_ITEMS = 27 # richiede la selezione dell'angolo tra gli elementi
+ ASK_FOR_FULL_ANGLE = 28 # richiede la selezione dell'angolo da riempire
+
+
+
+# Classe che gestisce il comando ARRAY
+class QadARRAYCommandClass(QadCommandClass):
+
+ def instantiateNewCmd(self):
+ """ istanzia un nuovo comando dello stesso tipo """
+ return QadARRAYCommandClass(self.plugIn)
+
+ def getName(self):
+ return QadMsg.translate("Command_list", "ARRAY")
+
+ def getEnglishName(self):
+ return "ARRAY"
+
+ def connectQAction(self, action):
+ action.triggered.connect(self.plugIn.runARRAYCommand)
+
+ def getIcon(self):
+ return QIcon(":/plugins/qad/icons/arrayRect.svg")
+
+ def getNote(self):
+ # impostare le note esplicative del comando
+ return QadMsg.translate("Command_ARRAY", "Creates copies of objects in a regularly spaced rectangular, polar, or path array.")
+
+ def __init__(self, plugIn):
+ QadCommandClass.__init__(self, plugIn)
+ self.SSGetClass = QadSSGetClass(plugIn)
+ self.SSGetClass.onlyEditableLayers = True
+ self.entSelClass = None
+ self.cacheEntitySet = QadCacheEntitySet()
+ self.defaultValue = None
+
+ self.basePt = QgsPointXY()
+ self.arrayType = self.plugIn.lastArrayType_array
+ self.distanceBetweenRows = None
+ self.distanceBetweenCols = None
+ self.itemsRotation = self.plugIn.lastItemsRotation_array
+ self.delObj = QadVariables.get(QadMsg.translate("Environment variables", "DELOBJ"))
+ self.delOrigSelSet = False
+ if self.delObj == QadDELOBJEnum.DELETE_ALL: # Delete all defining geometry
+ self.delOrigSelSet = True
+
+ # serie rettangolare
+ self.rectangleAngle = self.plugIn.lastRectangleAngle_array
+ self.rectangleCols = self.plugIn.lastRectangleCols_array
+ self.rectangleRows = self.plugIn.lastRectangleRows_array
+ self.firstPt = QgsPointXY() # primo punto per misurare la distanza tra righe
+
+ # serie traiettoria
+ self.pathTangentDirection = self.plugIn.lastPathTangentDirection_array
+ self.pathRows = self.plugIn.lastPathRows_array
+ self.pathItemsNumber = 1
+ self.pathPolyline = QadPolyline()
+ self.pathMethod = QadARRAYCommandClassPathMethodTypeEnum.MEASURE
+ self.distanceFromStartPt = 0.0 # uso interno quando si imposta il metodo dividi
+
+ # serie polare
+ self.centerPt = QgsPointXY()
+ self.polarItemsNumber = self.plugIn.lastPolarItemsNumber_array
+ self.polarAngleBetween = self.plugIn.lastPolarAngleBetween_array
+ self.polarRows = self.plugIn.lastPolarRows_array
+
+ self.GetDistClass = None
+ self.GetAngleClass = None
+
+ self.featureCache = [] # lista di (layer, feature)
+
+ def __del__(self):
+ QadCommandClass.__del__(self)
+ if self.SSGetClass is not None:
+ del self.SSGetClass
+
+ def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # quando si é in fase di selezione entità
+ return self.SSGetClass.getPointMapTool()
+ # quando si é in fase di richiesta rotazione
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ANGLE or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_TAN_DIRECTION or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ANGLE_BETWEEN_ITEMS or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_FULL_ANGLE:
+ return self.GetAngleClass.getPointMapTool()
+ # quando si é in fase di richiesta distanza
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_2PT or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE_TOT or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_TOT or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ITEM_SPACE or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE_2PT:
+ return self.GetDistClass.getPointMapTool()
+ else:
+ if (self.plugIn is not None):
+ if self.PointMapTool is None:
+ self.PointMapTool = Qad_array_maptool(self.plugIn)
+ return self.PointMapTool
+ else:
+ return None
+
+
+ def getCurrentContextualMenu(self):
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # quando si é in fase di selezione entità
+ return None # return self.SSGetClass.getCurrentContextualMenu()
+ # quando si é in fase di richiesta rotazione
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ANGLE or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_TAN_DIRECTION or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ANGLE_BETWEEN_ITEMS or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_FULL_ANGLE:
+ return self.GetAngleClass.getCurrentContextualMenu()
+ # quando si é in fase di richiesta distanza
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_2PT or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE_TOT or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_TOT or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ITEM_SPACE or \
+ self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE_2PT:
+ return self.GetDistClass.getCurrentContextualMenu()
+ else:
+ return self.contextualMenu
+
+
+ # ============================================================================
+ # updatePointMapToolParams
+ # ============================================================================
+ def updatePointMapToolParams(self):
+ self.step = -1 * self.step # trucchetto per prendere il map tool base
+ self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato da altri maptool
+
+ self.getPointMapTool().cacheEntitySet = self.cacheEntitySet
+ self.getPointMapTool().basePt = self.basePt
+ self.getPointMapTool().arrayType = self.arrayType
+ self.getPointMapTool().distanceBetweenRows = self.distanceBetweenRows
+ self.getPointMapTool().distanceBetweenCols = self.distanceBetweenCols
+ self.getPointMapTool().itemsRotation = self.itemsRotation
+
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.RECTANGLE: # serie rettangolare
+ self.getPointMapTool().rectangleAngle = self.rectangleAngle
+ self.getPointMapTool().rectangleCols = self.rectangleCols
+ self.getPointMapTool().rectangleRows = self.rectangleRows
+ self.getPointMapTool().firstPt = self.firstPt
+ self.getPointMapTool().doRectangleArray()
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH: # serie traiettoria
+ self.getPointMapTool().pathTangentDirection = self.pathTangentDirection
+ self.getPointMapTool().pathRows = self.pathRows
+ self.getPointMapTool().pathItemsNumber = self.pathItemsNumber
+ self.getPointMapTool().pathPolyline = self.pathPolyline
+ self.getPointMapTool().distanceFromStartPt = self.distanceFromStartPt
+ self.getPointMapTool().doPathArray()
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR: # serie polare
+ self.getPointMapTool().centerPt = self.centerPt
+ self.getPointMapTool().polarItemsNumber = self.polarItemsNumber
+ self.getPointMapTool().polarAngleBetween = self.polarAngleBetween
+ self.getPointMapTool().polarRows = self.polarRows
+ self.getPointMapTool().doPolarArray()
+
+ self.step = -1 * self.step # trucchetto per prendere il map tool base
+
+
+ # ============================================================================
+ # setEntitySet
+ # ============================================================================
+ def setEntitySet(self, ss):
+ self.cacheEntitySet.clear()
+ self.cacheEntitySet.appendEntitySet(ss)
+ rect = self.cacheEntitySet.getBoundingBox()
+ self.distanceBetweenRows = rect.height() + (rect.height() / 2) if rect.height() != 0 else 1
+ self.distanceBetweenCols = rect.width() + (rect.width() / 2) if rect.width() != 0 else 1
+ center = rect.center()
+ self.basePt.setX(center.x())
+ self.basePt.setY(center.y())
+
+
+ # ============================================================================
+ # doRectangleArray
+ # ============================================================================
+ def doRectangleArray(self):
+ self.plugIn.beginEditCommand("Feature copied", self.cacheEntitySet.getLayerList())
+
+ dimElaboratedList = [] # lista delle quotature già elaborate
+ entityIterator = QadCacheEntitySetIterator(self.cacheEntitySet)
+ for entity in entityIterator:
+ qadGeom = entity.getQadGeom() # così inizializzo le info qad
+ # verifico se l'entità appartiene ad uno stile di quotatura
+ dimEntity = QadDimStyles.getDimEntity(entity)
+ if dimEntity is not None:
+ if appendDimEntityIfNotExisting(dimElaboratedList, dimEntity) == False: # quota già elaborata
+ continue
+ entity = dimEntity
+
+ if qad_array_fun.arrayRectangleEntity(self.plugIn, entity, self.basePt, self.rectangleRows, self.rectangleCols, \
+ self.distanceBetweenRows, self.distanceBetweenCols, self.rectangleAngle, self.itemsRotation,
+ True, None) == False:
+ self.plugIn.destroyEditCommand()
+ return
+
+ if self.delOrigSelSet: # se devo rimuovere gli oggetti originali
+ entityIterator = QadCacheEntitySetIterator(self.cacheEntitySet)
+ for entity in entityIterator:
+ if qad_layer.deleteFeatureToLayer(self.plugIn, entity.layer, entity.featureId, False) == False:
+ self.plugIn.destroyEditCommand()
+ return
+
+ self.plugIn.endEditCommand()
+
+
+ # ============================================================================
+ # doPathArray
+ # ============================================================================
+ def doPathArray(self):
+ self.plugIn.beginEditCommand("Feature copied", self.cacheEntitySet.getLayerList())
+
+ dimElaboratedList = [] # lista delle quotature già elaborate
+ entityIterator = QadCacheEntitySetIterator(self.cacheEntitySet)
+ for entity in entityIterator:
+ qadGeom = entity.getQadGeom() # così inizializzo le info qad
+ # verifico se l'entità appartiene ad uno stile di quotatura
+ dimEntity = QadDimStyles.getDimEntity(entity)
+ if dimEntity is not None:
+ if appendDimEntityIfNotExisting(dimElaboratedList, dimEntity) == False: # quota già elaborata
+ continue
+ entity = dimEntity
+
+ if qad_array_fun.arrayPathEntity(self.plugIn, entity, self.basePt, self.pathRows, self.pathItemsNumber, \
+ self.distanceBetweenRows, self.distanceBetweenCols, self.pathTangentDirection, self.itemsRotation, \
+ self.pathPolyline, self.distanceFromStartPt, True, None) == False:
+ self.plugIn.destroyEditCommand()
+ return
+
+ if self.delOrigSelSet: # se devo rimuovere gli oggetti originali
+ entityIterator = QadCacheEntitySetIterator(self.cacheEntitySet)
+ for entity in entityIterator:
+ if qad_layer.deleteFeatureToLayer(self.plugIn, entity.layer, entity.featureId, False) == False:
+ self.plugIn.destroyEditCommand()
+ return
+
+ self.plugIn.endEditCommand()
+
+
+ # ============================================================================
+ # doPolarArray
+ # ============================================================================
+ def doPolarArray(self):
+ self.plugIn.beginEditCommand("Feature copied", self.cacheEntitySet.getLayerList())
+
+ dimElaboratedList = [] # lista delle quotature già elaborate
+ entityIterator = QadCacheEntitySetIterator(self.cacheEntitySet)
+ for entity in entityIterator:
+ qadGeom = entity.getQadGeom() # così inizializzo le info qad
+ # verifico se l'entità appartiene ad uno stile di quotatura
+ dimEntity = QadDimStyles.getDimEntity(entity)
+ if dimEntity is not None:
+ if appendDimEntityIfNotExisting(dimElaboratedList, dimEntity) == False: # quota già elaborata
+ continue
+ entity = dimEntity
+
+ if qad_array_fun.arrayPolarEntity(self.plugIn, entity, self.basePt, self.centerPt, self.polarItemsNumber, \
+ self.polarAngleBetween, self.polarRows, self.distanceBetweenRows, self.itemsRotation, \
+ True, None) == False:
+ self.plugIn.destroyEditCommand()
+ return
+
+ if self.delOrigSelSet: # se devo rimuovere gli oggetti originali
+ entityIterator = QadCacheEntitySetIterator(self.cacheEntitySet)
+ for entity in entityIterator:
+ if qad_layer.deleteFeatureToLayer(self.plugIn, entity.layer, entity.featureId, False) == False:
+ self.plugIn.destroyEditCommand()
+ return
+
+ self.plugIn.endEditCommand()
+
+
+ # ============================================================================
+ # setPathPolyline
+ # ============================================================================
+ def setPathPolyline(self, entity, point):
+ """
+ Setta self.pathPolyline che definisce la traiettoria
+ """
+ qadGeom = entity.getQadGeom()
+ # la funzione ritorna una lista con
+ # (
+ #
+ #
+ #
+ # se geometria chiusa è tipo polyline la lista contiene anche
+ #
+ # <"a sinistra di" se il punto é alla sinista della parte (< 0 -> sinistra, > 0 -> destra)
+ dummy = getQadGeomClosestPart(qadGeom, point)
+ # ritorna la sotto-geometria
+ subGeom = getQadGeomAt(qadGeom, dummy[2], dummy[3])
+ self.pathPolyline = subGeom.copy()
+ return True
+
+
+ # ============================================================================
+ # setDistancesByPathItemNumberOnDivide
+ # ============================================================================
+ def setDistancesByPathItemNumberOnDivide(self):
+ # imposta le distanza dall'inizio della traccia e la distanza tra gli elementi
+ # quando gli elementi devono essere distribuiti uniformemente
+ self.distanceBetweenCols = self.pathPolyline.length() / (self.pathItemsNumber + 1)
+ self.distanceFromStartPt = self.distanceBetweenCols
+
+
+ # ============================================================================
+ # setItemNumberByDistanceBetweenColsOnMeasure
+ # ============================================================================
+ def setItemNumberByDistanceBetweenColsOnMeasure(self):
+ # imposta le distanza dall'inizio della traccia e il numero di elementi
+ # quando gli elementi non devono essere distribuiti uniformemente ma a partire dall'inizio della traccia
+ self.pathItemsNumber = int(self.pathPolyline.length() / self.distanceBetweenCols) + 1
+ self.distanceFromStartPt = 0.0
+
+
+ # ============================================================================
+ # waitForMainOptions
+ # ============================================================================
+ def waitForMainOptions(self):
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.RECTANGLE:
+ self.waitForRectangleArrayOptions()
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ self.waitForPathArrayOptions()
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ self.waitForPolarArrayOptions()
+
+ self.updatePointMapToolParams()
+
+
+ # ============================================================================
+ # waitForArrayType
+ # ============================================================================
+ def waitForArrayType(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_ARRAYTYPE
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.NONE)
+
+ keyWords = QadMsg.translate("Command_ARRAY", "Rectangular") + "/" + \
+ QadMsg.translate("Command_ARRAY", "PAth") + "/" + \
+ QadMsg.translate("Command_ARRAY", "POlar")
+ englishKeyWords = "Rectangular" + "/" + "PAth" + "/" + "POlar"
+
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.RECTANGLE:
+ self.defaultValue = QadMsg.translate("Command_ARRAY", "Rectangular")
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ self.defaultValue = QadMsg.translate("Command_ARRAY", "PAth")
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ self.defaultValue = QadMsg.translate("Command_ARRAY", "POlar")
+
+ prompt = QadMsg.translate("Command_ARRAY", "Enter array type [{0}] <{1}>: ").format(keyWords, self.defaultValue)
+
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o enter o una parola chiave
+ # msg, inputType, default, keyWords, nessun controllo
+ self.waitFor(prompt, \
+ QadInputTypeEnum.KEYWORDS, \
+ self.defaultValue, \
+ keyWords, QadInputModeEnum.NONE)
+
+
+ # ============================================================================
+ # waitForBasePt
+ # ============================================================================
+ def waitForBasePt(self, nextStep = QadARRAYCommandClassStepEnum.ASK_FOR_BASE_PT):
+ self.step = nextStep
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.ASK_FOR_BASE_PT)
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_ARRAY", "Specify base point: "))
+
+
+ # ============================================================================
+ # waitForItemsNumber
+ # ============================================================================
+ def waitForItemsNumber(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_ITEM_N
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.NONE)
+
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ self.defaultValue = self.pathItemsNumber
+ if self.pathMethod == QadARRAYCommandClassPathMethodTypeEnum.MEASURE:
+ keyWords = QadMsg.translate("Command_ARRAY", "Fill entire path")
+ englishKeyWords = "Fill entire path"
+ # si appresta ad attendere un numero intero
+ prompt = QadMsg.translate("Command_ARRAY", "Number of Items to Array or [{0}] <{1}>: ").format(keyWords, str(self.defaultValue))
+ keyWords += "_" + englishKeyWords
+ inputType = QadInputTypeEnum.INT | QadInputTypeEnum.KEYWORDS
+ else:
+ keyWords = ""
+ prompt = QadMsg.translate("Command_ARRAY", "Number of Items to Array <{0}>: ").format(str(self.defaultValue))
+ inputType = QadInputTypeEnum.INT
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ self.defaultValue = self.polarItemsNumber
+ # si appresta ad attendere un numero intero
+ keyWords = ""
+ prompt = QadMsg.translate("Command_ARRAY", "Number of Items to Array <{0}>: ").format(str(self.defaultValue))
+ inputType = QadInputTypeEnum.INT
+
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(prompt, \
+ inputType, \
+ self.defaultValue, \
+ keyWords, \
+ QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+
+
+ # ============================================================================
+ # waitForRows
+ # ============================================================================
+ def waitForRows(self, nextStep):
+ self.step = nextStep
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.NONE)
+
+ # si appresta ad attendere un numero intero
+ msg = QadMsg.translate("Command_ARRAY", "Specify number of rows <{0}>: ")
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.RECTANGLE:
+ self.defaultValue = self.rectangleRows
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ self.defaultValue = self.pathRows
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ self.defaultValue = self.polarRows
+ prompt = msg.format(str(self.defaultValue))
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(prompt, \
+ QadInputTypeEnum.INT, \
+ self.defaultValue, \
+ "", \
+ QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+
+
+ # ============================================================================
+ # waitForDistanceBetweenRows
+ # ============================================================================
+ def waitForDistanceBetweenRows(self, totalOption, nextStep):
+ self.step = nextStep
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.ASK_FOR_ROW_SPACE_FIRST_PT)
+
+ self.defaultValue = self.distanceBetweenRows
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.RECTANGLE:
+ inputMode = QadInputModeEnum.NOT_ZERO
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ inputMode = QadInputModeEnum.NOT_ZERO
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ inputMode = QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE
+
+ if totalOption:
+ keyWords = QadMsg.translate("Command_ARRAY", "Total")
+ englishKeyWords = "Total"
+ prompt = QadMsg.translate("Command_ARRAY", "Specify distance between rows or [{0}] <{1}>: ").format(keyWords, str(self.defaultValue))
+ keyWords += "_" + englishKeyWords
+ inputType = QadInputTypeEnum.FLOAT | QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS
+ else:
+ prompt = QadMsg.translate("Command_ARRAY", "Specify distance between rows <{0}>: ").format(str(self.defaultValue))
+ keyWords = ""
+ inputType = QadInputTypeEnum.FLOAT | QadInputTypeEnum.POINT2D
+
+ # si appresta ad attendere un punto, un numero reale o enter o una parola chiave
+ # msg, inputType, default, keyWords, inputMode
+ self.waitFor(prompt, \
+ inputType, \
+ self.defaultValue, \
+ keyWords, \
+ inputMode)
+
+
+ # =========================================================================
+ # waitForDistanceBetweenRows2Pt
+ # =========================================================================
+ def waitForDistanceBetweenRows2Pt(self, startPt):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE_2PT
+
+ if self.GetDistClass is not None:
+ del self.GetDistClass
+ self.GetDistClass = QadGetDistClass(self.plugIn)
+
+ self.GetDistClass.dist = self.distanceBetweenRows
+ self.GetDistClass.inputMode = QadInputModeEnum.NOT_ZERO
+ self.GetDistClass.startPt = startPt
+ self.GetDistClass.run()
+
+
+ # ============================================================================
+ # waitForTotalDistanceRows
+ # ============================================================================
+ def waitForTotalDistanceRows(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE_TOT
+
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.RECTANGLE:
+ default = self.rectangleRows * self.distanceBetweenRows
+ inputMode = QadInputModeEnum.NOT_ZERO
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ default = self.pathRows * self.distanceBetweenRows
+ inputMode = QadInputModeEnum.NOT_ZERO
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ default = self.polarRows * self.distanceBetweenRows
+ inputMode = QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE
+
+ if self.GetDistClass is not None:
+ del self.GetDistClass
+ self.GetDistClass = QadGetDistClass(self.plugIn)
+ prompt = QadMsg.translate("Command_ARRAY", "Specifies the total distance between the start and end row <{0}>: ")
+ self.GetDistClass.msg = prompt.format(str(default))
+ self.GetDistClass.dist = default
+ self.GetDistClass.inputMode = inputMode
+ self.GetDistClass.run()
+
+
+ # ============================================================================
+ # waitForDelOrigObjs
+ # ============================================================================
+ def waitForDelOrigObjs(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_DEL_ORIG_OBJS
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.NONE)
+
+ keyWords = QadMsg.translate("QAD", "Yes") + "/" + QadMsg.translate("QAD", "No")
+ self.defaultValue = QadMsg.translate("QAD", "Yes")
+ prompt = QadMsg.translate("Command_ARRAY", "Delete source objects of the array ? [{0}] <{1}>: ").format(keyWords, self.defaultValue)
+
+ englishKeyWords = "Yes" + "/" + "No"
+ keyWords += "_" + englishKeyWords
+
+ # msg, inputType, default, keyWords, nessun controllo
+ self.waitFor(prompt, \
+ QadInputTypeEnum.KEYWORDS, \
+ self.defaultValue, \
+ keyWords, QadInputModeEnum.NONE)
+
+
+ # ============================================================================
+ # waitForItemsRotation
+ # ============================================================================
+ def waitForItemsRotation(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_ITEM_ROTATION
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.NONE)
+
+ keyWords = QadMsg.translate("QAD", "Yes") + "/" + QadMsg.translate("QAD", "No")
+ if self.itemsRotation:
+ self.defaultValue = QadMsg.translate("QAD", "Yes")
+ else:
+ self.defaultValue = QadMsg.translate("QAD", "No")
+
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.RECTANGLE:
+ prompt = QadMsg.translate("Command_ARRAY", "Rotate objects as they are arrayed ? [{0}] <{1}>: ").format(keyWords, self.defaultValue)
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ prompt = QadMsg.translate("Command_ARRAY", "Align arrayed items to the path ? [{0}] <{1}>: ").format(keyWords, self.defaultValue)
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ prompt = QadMsg.translate("Command_ARRAY", "Rotate objects as they are arrayed ? [{0}] <{1}>: ").format(keyWords, self.defaultValue)
+
+ englishKeyWords = "Yes" + "/" + "No"
+ keyWords += "_" + englishKeyWords
+
+ # msg, inputType, default, keyWords, nessun controllo
+ self.waitFor(prompt, \
+ QadInputTypeEnum.KEYWORDS, \
+ self.defaultValue, \
+ keyWords, QadInputModeEnum.NONE)
+
+
+ # ============================================================================
+ # SERIE RETTANGOLARE - INIZIO
+ # ============================================================================
+
+
+ # ============================================================================
+ # waitForRectangleArrayOptions
+ # ============================================================================
+ def waitForRectangleArrayOptions(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_MAIN_OPTIONS
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.NONE)
+
+ keyWords = QadMsg.translate("Command_ARRAY", "Base point") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Angle") + "/" + \
+ QadMsg.translate("Command_ARRAY", "COUnt") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Spacing") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Columns") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Rows") + "/" + \
+ QadMsg.translate("Command_ARRAY", "rotate Items") + "/" + \
+ QadMsg.translate("Command_ARRAY", "eXit")
+ englishKeyWords = "Base point" + "/" + "Angle" + "/" + "COUnt" + "/" + "Spacing" + "/" + \
+ "Columns" + "/" + "Rows" + "/" + "rotate Items" + "/" + "eXit"
+
+ self.defaultValue = QadMsg.translate("Command_ARRAY", "eXit")
+ prompt = QadMsg.translate("Command_ARRAY", "Select an option to edit array [{0}] <{1}>: ").format(keyWords, self.defaultValue)
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o enter o una parola chiave
+ # msg, inputType, default, keyWords, nessun controllo
+ self.waitFor(prompt, \
+ QadInputTypeEnum.KEYWORDS, \
+ self.defaultValue, \
+ keyWords, QadInputModeEnum.NONE)
+
+
+ # ============================================================================
+ # waitForRectangleAngle
+ # ============================================================================
+ def waitForRectangleAngle(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_ANGLE
+ if self.GetAngleClass is not None:
+ del self.GetAngleClass
+ # si appresta ad attendere l'angolo di rotazione
+ self.GetAngleClass = QadGetAngleClass(self.plugIn)
+ prompt = QadMsg.translate("Command_ARRAY", "Specify the angle of rotation for the row axis <{0}>: ")
+ self.GetAngleClass.msg = prompt.format(str(qad_utils.toDegrees(self.rectangleAngle)))
+ self.GetAngleClass.angle = self.rectangleAngle
+ self.GetAngleClass.run()
+ return False
+
+
+ # ============================================================================
+ # waitForRectangleColumns
+ # ============================================================================
+ def waitForRectangleColumns(self, nextStep):
+ self.step = nextStep
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.NONE)
+
+ # optionFrom può essere ASK_FOR_COLUMN_COUNT o ASK_FOR_COLUMN_N
+ self.defaultValue = self.rectangleCols
+ # si appresta ad attendere un numero intero
+ msg = QadMsg.translate("Command_ARRAY", "Specify number of columns <{0}>: ")
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(msg.format(str(self.defaultValue)), \
+ QadInputTypeEnum.INT, \
+ self.defaultValue, \
+ "", \
+ QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+
+
+ # ============================================================================
+ # waitForRectangleColumnsSpacing
+ # ============================================================================
+ def waitForRectangleColumnsSpacing(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_OR_CELL
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.ASK_FOR_COLUMN_SPACE_FIRST_PT)
+
+ self.defaultValue = self.distanceBetweenCols
+ keyWords = QadMsg.translate("Command_ARRAY", "Unit cell")
+ englishKeyWords = "Unit cell"
+ prompt = QadMsg.translate("Command_ARRAY", "Specify distance between columns or [{0}] <{1}>: ")
+ prompt = prompt.format(keyWords, str(self.defaultValue))
+ keyWords += "_" + englishKeyWords
+
+ # si appresta ad attendere un punto, un numero reale o enter o una parola chiave
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(prompt, \
+ QadInputTypeEnum.FLOAT | QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ self.defaultValue, \
+ keyWords, \
+ QadInputModeEnum.NOT_ZERO)
+
+
+ # ============================================================================
+ # waitForRectangleColumnsSpacing2Pt
+ # ============================================================================
+ def waitForRectangleColumnsSpacing2Pt(self, startPt):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_2PT
+
+ if self.GetDistClass is not None:
+ del self.GetDistClass
+ self.GetDistClass = QadGetDistClass(self.plugIn)
+ self.GetDistClass.dist = self.distanceBetweenCols
+ self.GetDistClass.inputMode = QadInputModeEnum.NOT_ZERO
+ self.GetDistClass.startPt = startPt
+ self.GetDistClass.run()
+
+
+ # ============================================================================
+ # waitForRectangleTotalDistanceCols
+ # ============================================================================
+ def waitForRectangleTotalDistanceCols(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_TOT
+
+ if self.GetDistClass is not None:
+ del self.GetDistClass
+ self.GetDistClass = QadGetDistClass(self.plugIn)
+ prompt = QadMsg.translate("Command_ARRAY", "Specifies the total distance between the start and end columns <{0}>: ")
+ default = self.rectangleCols * self.distanceBetweenCols
+ self.GetDistClass.msg = prompt.format(str(default))
+ self.GetDistClass.dist = default
+ self.GetDistClass.inputMode = QadInputModeEnum.NOT_ZERO
+ self.GetDistClass.run()
+
+
+ # ============================================================================
+ # waitForRectangleDistanceBetweenCols
+ # ============================================================================
+ def waitForRectangleDistanceBetweenCols(self, totalOption):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_OR_TOT
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.ASK_FOR_COLUMN_SPACE_FIRST_PT)
+
+ self.defaultValue = self.distanceBetweenCols
+
+ if totalOption:
+ keyWords = QadMsg.translate("Command_ARRAY", "Total")
+ englishKeyWords = "Total"
+ prompt = QadMsg.translate("Command_ARRAY", "Specify distance between columns or [{0}] <{1}>: ").format(keyWords, str(self.defaultValue))
+ keyWords += "_" + englishKeyWords
+ inputType = QadInputTypeEnum.FLOAT | QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS
+ else:
+ prompt = QadMsg.translate("Command_ARRAY", "Specify distance between columns <{0}>: ").format(str(self.defaultValue))
+ keyWords = ""
+ inputType = QadInputTypeEnum.FLOAT | QadInputTypeEnum.POINT2D
+
+ # si appresta ad attendere un punto, un numero reale o enter o una parola chiave
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(prompt, \
+ inputType, \
+ self.defaultValue, \
+ keyWords, \
+ QadInputModeEnum.NOT_ZERO)
+
+
+ # ============================================================================
+ # waitForRectangleFirstCellCorner
+ # ============================================================================
+ def waitForRectangleFirstCellCorner(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_1PT_CELL
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_ARRAY", "Specify first cell corner: "))
+
+
+ # ============================================================================
+ # waitForRectangleSecondCellCorner
+ # ============================================================================
+ def waitForRectangleSecondCellCorner(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_2PT_CELL
+ # imposto il map tool
+ self.getPointMapTool().firstPt = self.firstPt
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.ASK_FOR_2PT_CELL)
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_ARRAY", "Specify second cell corner: "))
+
+
+ # ============================================================================
+ # SERIE RETTANGOLARE - FINE
+ # SERIE TRAIETTORIA - INIZIO
+ # ============================================================================
+
+
+ # ============================================================================
+ # waitForPathObject
+ # ============================================================================
+ def waitForPathObject(self, msgMapTool, msg):
+ if self.entSelClass is not None:
+ del self.entSelClass
+
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_PATH_OBJ
+
+ self.entSelClass = QadEntSelClass(self.plugIn)
+ self.entSelClass.msg = QadMsg.translate("Command_ARRAY", "Select the object to use for the path of the array: ")
+ # scarto la selezione di punti e quote
+ self.entSelClass.checkPointLayer = False
+ self.entSelClass.checkLineLayer = True
+ self.entSelClass.checkPolygonLayer = True
+ self.entSelClass.checkDimLayers = False
+
+ self.entSelClass.run(msgMapTool, msg)
+
+
+ # ============================================================================
+ # waitForPathArrayOptions
+ # ============================================================================
+ def waitForPathArrayOptions(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_MAIN_OPTIONS
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.NONE)
+
+ keyWords = QadMsg.translate("Command_ARRAY", "Method") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Base point") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Tangent direction") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Items") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Rows") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Align items") + "/" + \
+ QadMsg.translate("Command_ARRAY", "eXit")
+ englishKeyWords = "Method" + "/" + "Base point" + "/" + "Tangent direction" + "/" + "Items" + "/" + \
+ "Rows" + "/" + "Align items" + "/" + "eXit"
+
+ self.defaultValue = QadMsg.translate("Command_ARRAY", "eXit")
+ prompt = QadMsg.translate("Command_ARRAY", "Select an option to edit array [{0}] <{1}>: ").format(keyWords, self.defaultValue)
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o enter o una parola chiave
+ # msg, inputType, default, keyWords, nessun controllo
+ self.waitFor(prompt, \
+ QadInputTypeEnum.KEYWORDS, \
+ self.defaultValue, \
+ keyWords, QadInputModeEnum.NONE)
+
+
+ # ============================================================================
+ # waitForPathMethod
+ # ============================================================================
+ def waitForPathMethod(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_PATH_METHOD
+
+ keyWords = QadMsg.translate("Command_ARRAY", "Divide") + "/" + QadMsg.translate("Command_ARRAY", "Measure")
+ if self.pathMethod == QadARRAYCommandClassPathMethodTypeEnum.DIVIDE:
+ self.defaultValue = QadMsg.translate("Command_ARRAY", "Divide")
+ elif self.pathMethod == QadARRAYCommandClassPathMethodTypeEnum.MEASURE:
+ self.defaultValue = QadMsg.translate("Command_ARRAY", "Measure")
+ prompt = QadMsg.translate("Command_ARRAY", "Specify path method [{0}] <{1}>: ").format(keyWords, self.defaultValue)
+
+ englishKeyWords = "Divide" + "/" + "Measure"
+ keyWords += "_" + englishKeyWords
+
+ # si appresta ad attendere enter o una parola chiave
+ # msg, inputType, default, keyWords, nessun controllo
+ self.waitFor(prompt, \
+ QadInputTypeEnum.KEYWORDS, \
+ self.defaultValue, \
+ keyWords, QadInputModeEnum.NONE)
+
+
+ # ============================================================================
+ # waitForPathTangentDirection
+ # ============================================================================
+ def waitForPathTangentDirection(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_TAN_DIRECTION
+
+ if self.GetAngleClass is not None:
+ del self.GetAngleClass
+ # si appresta ad attendere l'angolo di rotazione
+ self.GetAngleClass = QadGetAngleClass(self.plugIn)
+ prompt = QadMsg.translate("Command_ARRAY", "Specify the first point for array tangent direction: ")
+ self.GetAngleClass.msg = prompt.format(str(qad_utils.toDegrees(self.pathTangentDirection)))
+ self.GetAngleClass.angle = self.pathTangentDirection
+ self.GetAngleClass.run()
+ return False
+
+
+ # ============================================================================
+ # waitForPathDistanceBetweenItems
+ # ============================================================================
+ def waitForPathDistanceBetweenItems(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_ITEM_SPACE
+
+ if self.GetDistClass is not None:
+ del self.GetDistClass
+ self.GetDistClass = QadGetDistClass(self.plugIn)
+ prompt = QadMsg.translate("Command_ARRAY", "Specify distance between items along path <{0}>: ")
+ self.GetDistClass.msg = prompt.format(str(self.distanceBetweenCols))
+ self.GetDistClass.dist = self.distanceBetweenCols
+ self.GetDistClass.inputMode = QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE
+ self.GetDistClass.run()
+
+
+ # ============================================================================
+ # SERIE TRAIETTORIA - FINE
+ # SERIE POLARE - INIZIO
+ # ============================================================================
+
+
+ # ============================================================================
+ # waitForPolarCenterPt
+ # ============================================================================
+ def waitForPolarCenterPt(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_CENTER_PT
+
+ keyWords = QadMsg.translate("Command_ARRAY", "Base point")
+ englishKeyWords = "Base point"
+ prompt = QadMsg.translate("Command_ARRAY", "Specify center point of array or [{0}]: ").format(keyWords)
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o enter o una parola chiave
+ # msg, inputType, default, keyWords, nessun controllo
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NONE)
+
+
+ # ============================================================================
+ # waitForPolarArrayOptions
+ # ============================================================================
+ def waitForPolarArrayOptions(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_MAIN_OPTIONS
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_array_maptool_ModeEnum.NONE)
+
+ keyWords = QadMsg.translate("Command_ARRAY", "Base point") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Items") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Angle between") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Fill angle") + "/" + \
+ QadMsg.translate("Command_ARRAY", "ROWs") + "/" + \
+ QadMsg.translate("Command_ARRAY", "Rotate items") + "/" + \
+ QadMsg.translate("Command_ARRAY", "eXit")
+ englishKeyWords = "Base point" + "/" + "Items" + "/" + "Angle between" + "/" + "Angle between" + "/" + \
+ "Fill angle" + "/" + "ROWs" + "/" + "Rotate items" + "/" + "eXit"
+
+ self.defaultValue = QadMsg.translate("Command_ARRAY", "eXit")
+ prompt = QadMsg.translate("Command_ARRAY", "Select an option to edit array [{0}] <{1}>: ").format(keyWords, self.defaultValue)
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o enter o una parola chiave
+ # msg, inputType, default, keyWords, nessun controllo
+ self.waitFor(prompt, \
+ QadInputTypeEnum.KEYWORDS, \
+ self.defaultValue, \
+ keyWords, QadInputModeEnum.NONE)
+
+
+ # ============================================================================
+ # waitForPolarAngleBetween
+ # ============================================================================
+ def waitForPolarAngleBetween(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_ANGLE_BETWEEN_ITEMS
+
+ if self.GetAngleClass is not None:
+ del self.GetAngleClass
+ # si appresta ad attendere l'angolo di rotazione
+ self.GetAngleClass = QadGetAngleClass(self.plugIn)
+ prompt = QadMsg.translate("Command_ARRAY", "Specify the angle between items <{0}>: ")
+ self.GetAngleClass.msg = prompt.format(str(qad_utils.toDegrees(self.polarAngleBetween)))
+ self.GetAngleClass.angle = self.polarAngleBetween
+ self.GetAngleClass.run()
+ return False
+
+
+ # ============================================================================
+ # waitForPolarAngleBetween
+ # ============================================================================
+ def waitForPolarFillAngle(self):
+ self.step = QadARRAYCommandClassStepEnum.ASK_FOR_FULL_ANGLE
+
+ if self.GetAngleClass is not None:
+ del self.GetAngleClass
+ # si appresta ad attendere l'angolo di rotazione
+ self.GetAngleClass = QadGetAngleClass(self.plugIn)
+ default = self.polarItemsNumber * self.polarAngleBetween
+ prompt = QadMsg.translate("Command_ARRAY", "Specify angle to fill (+ = CCW, - = CW) <{0}>: ")
+ self.GetAngleClass.msg = prompt.format(str(qad_utils.toDegrees(default)))
+ self.GetAngleClass.angle = default
+ self.GetAngleClass.run()
+ return False
+
+
+ # ============================================================================
+ # SERIE POLARE - FINE
+ # ============================================================================
+
+
+ # ============================================================================
+ # run
+ # ============================================================================
+ def run(self, msgMapTool = False, msg = None):
+ if self.plugIn.canvas.mapSettings().destinationCrs().isGeographic():
+ self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
+ return True # fine comando
+
+ # =========================================================================
+ # RICHIESTA SELEZIONE OGGETTI
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # inizio del comando
+ if self.cacheEntitySet.isEmpty() == False: # se era già stato impostato da codice tramite "self.setEntitySet"
+ self.waitForArrayType()
+ return False
+
+ if self.SSGetClass.run(msgMapTool, msg) == True:
+ if self.SSGetClass.entitySet.count() == 0:
+ return True # fine comando
+ self.setEntitySet(self.SSGetClass.entitySet)
+
+ del self.SSGetClass
+ self.SSGetClass = None
+
+ self.waitForArrayType()
+ self.step = -1 * self.step # trucchetto per prendere il map tool base
+ self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di selezione entità
+ self.step = -1 * self.step # trucchetto per prendere il map tool base
+
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL TIPO DI SERIE (da step = ASK_FOR_SELSET)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ARRAYTYPE: # dopo aver atteso una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else: # la parola chiave arriva come parametro della funzione
+ value = msg
+
+ if type(value) == unicode:
+ if value == QadMsg.translate("Command_ARRAY", "Rectangular") or value == "Rectangular":
+ self.arrayType = QadARRAYCommandClassSeriesTypeEnum.RECTANGLE
+ self.plugIn.setLastArrayType_array(self.arrayType)
+ self.waitForMainOptions()
+ elif value == QadMsg.translate("Command_ARRAY", "PAth") or value == "PAth":
+ self.arrayType = QadARRAYCommandClassSeriesTypeEnum.PATH
+ self.plugIn.setLastArrayType_array(self.arrayType)
+ self.waitForPathObject(msgMapTool, msg)
+ elif value == QadMsg.translate("Command_ARRAY", "POlar") or value == "POlar":
+ self.arrayType = QadARRAYCommandClassSeriesTypeEnum.POLAR
+ self.plugIn.setLastArrayType_array(self.arrayType)
+ self.waitForPolarCenterPt()
+
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DI UN OPZIONE DAL MENU PRINCIPALE (da step = ASK_FOR_ARRAYTYPE da tutte le opzioni)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_MAIN_OPTIONS: # dopo aver atteso un punto o una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if value is None:
+ value = QadMsg.translate("Command_ARRAY", "eXit")
+
+ if type(value) == unicode:
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.RECTANGLE:
+ if value == QadMsg.translate("Command_ARRAY", "Base point") or value == "Base point":
+ self.waitForBasePt()
+ elif value == QadMsg.translate("Command_ARRAY", "Angle") or value == "Angle":
+ self.waitForRectangleAngle()
+ elif value == QadMsg.translate("Command_ARRAY", "COUnt") or value == "COUnt":
+ self.waitForRectangleColumns(QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_COUNT)
+ elif value == QadMsg.translate("Command_ARRAY", "Spacing") or value == "Spacing":
+ self.waitForRectangleColumnsSpacing()
+ elif value == QadMsg.translate("Command_ARRAY", "Columns") or value == "Columns":
+ self.waitForRectangleColumns(QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_N)
+ elif value == QadMsg.translate("Command_ARRAY", "Rows") or value == "Rows":
+ self.waitForRows(QadARRAYCommandClassStepEnum.ASK_FOR_ROW_N)
+ elif value == QadMsg.translate("Command_ARRAY", "rotate Items") or value == "rotate Items":
+ self.waitForItemsRotation()
+ elif value == QadMsg.translate("Command_ARRAY", "eXit") or value == "eXit":
+ if self.delObj == QadDELOBJEnum.ASK_FOR_DELETE_ALL:
+ self.waitForDelOrigObjs()
+ else:
+ self.doRectangleArray()
+ return True # fine comando
+
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ if value == QadMsg.translate("Command_ARRAY", "Method") or value == "Method":
+ self.waitForPathMethod()
+ elif value == QadMsg.translate("Command_ARRAY", "Base point") or value == "Base point":
+ self.waitForBasePt()
+ elif value == QadMsg.translate("Command_ARRAY", "Tangent direction") or value == "Tangent direction":
+ self.waitForPathTangentDirection()
+ elif value == QadMsg.translate("Command_ARRAY", "Items") or value == "Items":
+ if self.pathMethod == QadARRAYCommandClassPathMethodTypeEnum.MEASURE:
+ self.waitForPathDistanceBetweenItems()
+ elif self.pathMethod == QadARRAYCommandClassPathMethodTypeEnum.DIVIDE:
+ self.waitForItemsNumber()
+ elif value == QadMsg.translate("Command_ARRAY", "Rows") or value == "Rows":
+ self.waitForRows(QadARRAYCommandClassStepEnum.ASK_FOR_ROW_N)
+ elif value == QadMsg.translate("Command_ARRAY", "Align items") or value == "Align items":
+ self.waitForItemsRotation()
+ elif value == QadMsg.translate("Command_ARRAY", "eXit") or value == "eXit":
+ if self.delObj == QadDELOBJEnum.ASK_FOR_DELETE_ALL:
+ self.waitForDelOrigObjs()
+ else:
+ self.doPathArray()
+ return True # fine comando
+
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ if value == QadMsg.translate("Command_ARRAY", "Base point") or value == "Base point":
+ self.waitForBasePt()
+ elif value == QadMsg.translate("Command_ARRAY", "Items") or value == "Items":
+ self.waitForItemsNumber()
+ elif value == QadMsg.translate("Command_ARRAY", "Angle between") or value == "Angle between":
+ self.waitForPolarAngleBetween()
+ elif value == QadMsg.translate("Command_ARRAY", "Fill angle") or value == "Fill angle":
+ self.waitForPolarFillAngle()
+ elif value == QadMsg.translate("Command_ARRAY", "ROWs") or value == "ROWs":
+ self.waitForRows(QadARRAYCommandClassStepEnum.ASK_FOR_ROW_N)
+ elif value == QadMsg.translate("Command_ARRAY", "Rotate items") or value == "Rotate items":
+ self.waitForItemsRotation()
+ elif value == QadMsg.translate("Command_ARRAY", "eXit") or value == "eXit":
+ if self.delObj == QadDELOBJEnum.ASK_FOR_DELETE_ALL:
+ self.waitForDelOrigObjs()
+ else:
+ self.doPolarArray()
+ return True # fine comando
+ elif type(value) == QgsPointXY: # se é stato indicato un punto
+ pass
+
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL PUNTO BASE (da step = ASK_FOR_MAIN_OPTIONS)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_BASE_PT: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ self.basePt.set(value.x(), value.y())
+
+ self.waitForMainOptions()
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DI CANCELLAZIONE DEGLI OGGETTI ORIGINALI (da step = ASK_FOR_MAIN_OPTIONS)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_DEL_ORIG_OBJS: # dopo aver atteso una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ # la parola chiave arriva come parametro della funzione
+ value = msg
+
+ if type(value) == unicode:
+ if value == QadMsg.translate("QAD", "Yes") or value == "Yes":
+ self.delOrigSelSet = True
+ else:
+ self.delOrigSelSet = False
+
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.RECTANGLE:
+ self.doRectangleArray()
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ self.doPathArray()
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ self.doPolarArray()
+
+ return True
+
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DELL'ANGOLO DELLA SERIE (da step = ASK_FOR_MAIN_OPTIONS)
+ # =========================================================================
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ANGLE:
+ if self.GetAngleClass.run(msgMapTool, msg) == True:
+ if self.GetAngleClass.angle is not None:
+ self.rectangleAngle = self.GetAngleClass.angle
+ self.plugIn.setLastRectangleAngle_array(self.rectangleAngle)
+ self.plugIn.setLastRot(self.rectangleAngle)
+ self.waitForMainOptions()
+
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL NUMERO DELLE COLONNE DELLA SERIE RETTANGOLO OPZIONE COUNT (da step = ASK_FOR_MAIN_OPTIONS)
+ # =========================================================================
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_COUNT: # dopo aver atteso un numero intero si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ # il numero di colonne arriva come parametro della funzione
+ value = msg
+
+ maxArray = QadVariables.get(QadMsg.translate("Environment variables", "MAXARRAY"))
+ if value * self.rectangleRows > maxArray:
+ errMsg = QadMsg.translate("Command_ARRAY", "\nThe array size can't be greater than {0} elements. See MAXARRAY system variable.")
+ self.showErr(errMsg.format(str(maxArray)))
+ else:
+ self.rectangleCols = value
+ self.plugIn.setLastRectangleCols_array(self.rectangleCols)
+ self.updatePointMapToolParams()
+ self.waitForRows(QadARRAYCommandClassStepEnum.ASK_FOR_ROW_COUNT)
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL NUMERO DI RIGHE DELLA SERIE RETTANGOLO OPZIONE COUNT (da step = ASK_FOR_COLUMN_N)
+ # =========================================================================
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ROW_COUNT: # dopo aver atteso un numero intero si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ # il numero di righe arriva come parametro della funzione
+ value = msg
+
+ maxArray = QadVariables.get(QadMsg.translate("Environment variables", "MAXARRAY"))
+ if value * self.rectangleCols > maxArray:
+ errMsg = QadMsg.translate("Command_ARRAY", "\nThe array size can't be greater than {0} elements. See MAXARRAY system variable.")
+ self.showErr(errMsg.format(str(maxArray)))
+ else:
+ self.rectangleRows = value
+ self.plugIn.setLastRectangleRows_array(self.rectangleRows)
+ self.waitForMainOptions()
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DELLA DISTANZA TRA COLONNE (da step = ASK_FOR_MAIN_OPTIONS)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_OR_CELL: # dopo aver atteso un punto, un numero o una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == QgsPointXY: # se é stato inserito il primo punto per misurare la distanza tra colonne
+ self.waitForRectangleColumnsSpacing2Pt(value)
+ elif type(value) == float: # se é stato inserita la distanza
+ self.distanceBetweenCols = value
+ self.updatePointMapToolParams()
+ self.waitForDistanceBetweenRows(False, QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE) # senza opzione di "totale"
+ elif type(value) == unicode:
+ if value == QadMsg.translate("Command_ARRAY", "Unit cell") or value == "Unit cell":
+ self.waitForRectangleFirstCellCorner()
+
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL SECONDO PT PER MISURARE LA DISTANZA TRA COLONNE (da step = ASK_FOR_COLUMN_SPACE_OR_CELL)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_2PT: # dopo aver atteso un punto si riavvia il comando
+ if self.GetDistClass.run(msgMapTool, msg) == True:
+ if self.GetDistClass.dist is not None:
+ self.distanceBetweenCols = self.GetDistClass.dist
+
+ del self.GetDistClass
+ self.GetDistClass = None
+
+ self.updatePointMapToolParams()
+ self.waitForDistanceBetweenRows(False, QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE) # senza opzione di "totale"
+ return False # fine comando
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DELLA DISTANZA TRA RIGHE (da step = ASK_FOR_COLUMN_SPACE_OR_CELL)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == QgsPointXY: # se é stato inserito il primo punto per misurare la distanza tra righe
+ self.waitForDistanceBetweenRows2Pt(value)
+ elif type(value) == float: # se é stato inserita la distanza
+ self.distanceBetweenRows = value
+ self.waitForMainOptions()
+ return False # fine comando
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL SECONDO PT PER MISURARE LA DISTANZA TRA RIGHE (da step = ASK_FOR_ROW_SPACE)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE_2PT: # dopo aver atteso un punto si riavvia il comando
+ if self.GetDistClass.run(msgMapTool, msg) == True:
+ if self.GetDistClass.dist is not None:
+ self.distanceBetweenRows = self.GetDistClass.dist
+
+ del self.GetDistClass
+ self.GetDistClass = None
+ self.waitForMainOptions()
+ return False # fine comando
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL PRIMO ANGOLO DELLA CELLA (da step = ASK_FOR_COLUMN_SPACE_OR_CELL)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_1PT_CELL: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == QgsPointXY: # se é stato inserito il primo punto per misurare la distanza tra righe
+ self.firstPt.set(value.x(), value.y())
+ self.waitForRectangleSecondCellCorner()
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL SECONDO ANGOLO DELLA CELLA (da step = ASK_FOR_1PT_CELL)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_2PT_CELL: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == QgsPointXY: # se é stato inserito il primo punto per misurare la distanza tra righe
+ if (value.y() - self.firstPt.y()) == 0 or (value.x() - self.firstPt.x()) == 0:
+ self.showErr(QadMsg.translate("Command_ARRAY", "\nCell size must be greater than 0."))
+ else:
+ self.distanceBetweenRows = value.y() - self.firstPt.y()
+ self.distanceBetweenCols = value.x() - self.firstPt.x()
+ self.waitForMainOptions()
+ else:
+ self.waitForMainOptions()
+
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL NUMERO DELLE COLONNE DELLA SERIE RETTANGOLO OPZIONE COLUMN (da step = ASK_FOR_MAIN_OPTIONS)
+ # =========================================================================
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_N: # dopo aver atteso un numero intero si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ # il numero di righe arriva come parametro della funzione
+ value = msg
+
+ # il numero delle colonnne arriva come parametro della funzione
+ maxArray = QadVariables.get(QadMsg.translate("Environment variables", "MAXARRAY"))
+ if value * self.rectangleRows > maxArray:
+ errMsg = QadMsg.translate("Command_ARRAY", "\nThe array size can't be greater than {0} elements. See MAXARRAY system variable.")
+ self.showErr(errMsg.format(str(maxArray)))
+ else:
+ self.rectangleCols = value
+ self.plugIn.setLastRectangleCols_array(self.rectangleCols)
+ self.updatePointMapToolParams()
+ self.waitForRectangleDistanceBetweenCols(True) # con opzione "TOTAL"
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DELLA DISTANZA TRA COLONNE (da step = ASK_FOR_COLUMN_N)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_OR_TOT: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == QgsPointXY: # se é stato inserito il primo punto per misurare la distanza tra righe
+ self.waitForRectangleColumnsSpacing2Pt(value)
+ elif type(value) == float: # se é stato inserita la distanza
+ self.distanceBetweenCols = value
+ self.waitForMainOptions()
+ elif type(value) == unicode:
+ if value == QadMsg.translate("Command_ARRAY", "Total") or value == "Total":
+ self.waitForRectangleTotalDistanceCols()
+ return False # fine comando
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL SECONDO PT PER MISURARE LA DISTANZA TOTALE TRA COLONNE (da step = ASK_FOR_COLUMN_SPACE_OR_TOT)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_COLUMN_SPACE_TOT: # dopo aver atteso un punto si riavvia il comando
+ if self.GetDistClass.run(msgMapTool, msg) == True:
+ if self.GetDistClass.dist is not None:
+ if self.rectangleCols > 1:
+ self.distanceBetweenCols = self.GetDistClass.dist / (self.rectangleCols - 1)
+
+ del self.GetDistClass
+ self.GetDistClass = None
+ self.waitForMainOptions()
+ return False # fine comando
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL NUMERO DELLE RIGHE OPZIONE ROW (da step = ASK_FOR_MAIN_OPTIONS)
+ # =========================================================================
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ROW_N: # dopo aver atteso un numero intero si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ # il numero di righe arriva come parametro della funzione
+ value = msg
+
+ maxArray = QadVariables.get(QadMsg.translate("Environment variables", "MAXARRAY"))
+ # il numero di righe arriva come parametro della funzione
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.RECTANGLE:
+ if value * self.rectangleCols > maxArray:
+ errMsg = QadMsg.translate("Command_ARRAY", "\nThe array size can't be greater than {0} elements. See MAXARRAY system variable.")
+ self.showErr(errMsg.format(str(maxArray)))
+ return False
+ else:
+ self.rectangleRows = value
+ self.plugIn.setLastRectangleRows_array(self.rectangleRows)
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ if value * self.pathItemsNumber > maxArray:
+ errMsg = QadMsg.translate("Command_ARRAY", "\nThe array size can't be greater than {0} elements. See MAXARRAY system variable.")
+ self.showErr(errMsg.format(str(maxArray)))
+ return False
+ else:
+ self.pathRows = value
+ self.plugIn.setLastPathRows_array(self.pathRows)
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ if value * self.polarItemsNumber > maxArray:
+ errMsg = QadMsg.translate("Command_ARRAY", "\nThe array size can't be greater than {0} elements. See MAXARRAY system variable.")
+ self.showErr(errMsg.format(str(maxArray)))
+ return False
+ else:
+ self.polarRows = value
+ self.plugIn.setLastPolarRows_array(self.polarRows)
+
+ self.updatePointMapToolParams()
+ self.waitForDistanceBetweenRows(True, QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE_OR_TOT) # con opzione "TOTAL"
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DELLA DISTANZA TRA RIGHE (da step = ASK_FOR_ROW_N)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE_OR_TOT: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == QgsPointXY: # se é stato inserito il primo punto per misurare la distanza tra righe
+ self.waitForDistanceBetweenRows2Pt(value)
+ elif type(value) == float: # se é stato inserita la distanza
+ self.distanceBetweenRows = value
+ self.waitForMainOptions()
+ elif type(value) == unicode:
+ if value == QadMsg.translate("Command_ARRAY", "Total") or value == "Total":
+ self.waitForTotalDistanceRows()
+ return False # fine comando
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL SECONDO PT PER MISURARE LA DISTANZA TOTALE TRA RIGHE (da step = ASK_FOR_ROW_SPACE)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ROW_SPACE_TOT: # dopo aver atteso un punto si riavvia il comando
+ if self.GetDistClass.run(msgMapTool, msg) == True:
+ if self.GetDistClass.dist is not None:
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.RECTANGLE:
+ if self.rectangleRows > 1:
+ self.distanceBetweenRows = self.GetDistClass.dist / (self.rectangleRows - 1)
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ if self.pathRows > 1:
+ self.distanceBetweenRows = self.GetDistClass.dist / (self.pathRows - 1)
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ if self.polarRows > 1:
+ self.distanceBetweenRows = self.GetDistClass.dist / (self.polarRows - 1)
+
+ del self.GetDistClass
+ self.GetDistClass = None
+ self.waitForMainOptions()
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL NUMERO DI ELEMENTI DELLA SERIE (da step = ASK_FOR_MAIN_OPTIONS)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ITEM_N:
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ # il numero di elementi arriva come parametro della funzione
+ value = msg
+
+ maxArray = QadVariables.get(QadMsg.translate("Environment variables", "MAXARRAY"))
+
+ if self.arrayType == QadARRAYCommandClassSeriesTypeEnum.PATH:
+ if self.pathMethod == QadARRAYCommandClassPathMethodTypeEnum.DIVIDE:
+ if type(value) == int or type(value) == long: # se é stato inserito il numero di elementi
+ if value * self.pathRows > maxArray:
+ errMsg = QadMsg.translate("Command_ARRAY", "\nThe array size can't be greater than {0} elements. See MAXARRAY system variable.")
+ self.showErr(errMsg.format(str(maxArray)))
+ else:
+ self.pathItemsNumber = value
+ self.setDistancesByPathItemNumberOnDivide()
+ self.waitForMainOptions()
+ elif self.pathMethod == QadARRAYCommandClassPathMethodTypeEnum.MEASURE:
+ if type(value) == int or type(value) == long: # se é stato inserito il numero di elementi
+ if value * self.pathRows > maxArray:
+ errMsg = QadMsg.translate("Command_ARRAY", "\nThe array size can't be greater than {0} elements. See MAXARRAY system variable.")
+ self.showErr(errMsg.format(str(maxArray)))
+ elif (value - 1) * self.distanceBetweenCols > self.pathPolyline.length():
+ errMsg = QadMsg.translate("Command_ARRAY", "\nMaximun number of items = {0}.")
+ self.showErr(errMsg.format(str(int(self.pathPolyline.length() / self.distanceBetweenCols) + 1)))
+ else:
+ self.pathItemsNumber = value
+ self.distanceFromStartPt = 0.0
+ self.waitForMainOptions()
+ elif type(value) == unicode:
+ if value == QadMsg.translate("Command_ARRAY", "Fill entire path") or value == "Fill entire path":
+ self.setItemNumberByDistanceBetweenColsOnMeasure()
+ self.waitForMainOptions()
+ elif self.arrayType == QadARRAYCommandClassSeriesTypeEnum.POLAR:
+ if msg * self.polarRows > maxArray:
+ errMsg = QadMsg.translate("Command_ARRAY", "\nThe array size can't be greater than {0} elements. See MAXARRAY system variable.")
+ self.showErr(errMsg.format(str(maxArray)))
+ else:
+ fillAngle = self.polarItemsNumber * self.polarAngleBetween
+ self.polarItemsNumber = value
+ self.polarAngleBetween = 2 * math.pi / value
+ self.plugIn.setLastPolarItemsNumber_array(self.polarItemsNumber)
+ self.plugIn.setLastPolarAngleBetween_array(self.polarAngleBetween)
+ self.waitForMainOptions()
+
+ return False # fine comando
+
+
+ # ============================================================================
+ # SERIE TRAIETTORIA - INIZIO
+ # ============================================================================
+
+
+ # =========================================================================
+ # RISPOSTA ALLA SELEZIONE DI UN'ENTITA' DA USARE COME PERCORSO DELLA SERIE (da step = ASK_FOR_ARRAYTYPE)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_PATH_OBJ:
+ if self.entSelClass.run(msgMapTool, msg) == True:
+ if self.entSelClass.entity.isInitialized():
+ if self.setPathPolyline(self.entSelClass.entity, self.entSelClass.point) == True:
+ self.setItemNumberByDistanceBetweenColsOnMeasure()
+ self.waitForMainOptions()
+ else:
+ if self.entSelClass.canceledByUsr == True: # fine comando
+ return True
+ self.showMsg(QadMsg.translate("QAD", "No geometries in this position."))
+ self.waitForPathObject(msgMapTool, msg)
+
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL METODO (da step = ASK_FOR_MAIN_OPTIONS)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_PATH_METHOD: # dopo aver atteso una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ # la parola chiave arriva come parametro della funzione
+ value = msg
+
+ if type(value) == unicode:
+ if value == QadMsg.translate("Command_ARRAY", "Divide") or value == "Divide":
+ self.pathMethod = QadARRAYCommandClassPathMethodTypeEnum.DIVIDE
+ self.setDistancesByPathItemNumberOnDivide()
+ elif value == QadMsg.translate("Command_ARRAY", "Measure") or value == "Measure":
+ self.pathMethod = QadARRAYCommandClassPathMethodTypeEnum.MEASURE
+ self.setItemNumberByDistanceBetweenColsOnMeasure()
+ self.waitForMainOptions()
+
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DELLA DIREZIONE DELLA TANGENTE (da step = ASK_FOR_MAIN_OPTIONS)
+ # =========================================================================
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_TAN_DIRECTION:
+ if self.GetAngleClass.run(msgMapTool, msg) == True:
+ if self.GetAngleClass.angle is not None:
+ self.pathTangentDirection = self.GetAngleClass.angle
+ self.plugIn.setLastPathTangentDirection_array(self.pathTangentDirection)
+ self.waitForMainOptions()
+
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL SECONDO PT PER MISURARE LA DISTANZA TRA ELEMENTI (da step = ASK_FOR_MAIN_OPTIONS)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ITEM_SPACE:
+ if self.GetDistClass.run(msgMapTool, msg) == True:
+ if self.GetDistClass.dist is not None:
+ l = self.pathPolyline.length()
+ if self.GetDistClass.dist > l:
+ errMsg = QadMsg.translate("Command_ARRAY", "\nThe distance between items can't be greater than {0}.")
+ self.showErr(errMsg.format(str(l)))
+ else:
+ self.distanceBetweenCols = self.GetDistClass.dist
+
+ del self.GetDistClass
+ self.GetDistClass = None
+ self.updatePointMapToolParams()
+ self.waitForItemsNumber()
+ return False # fine comando
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DELL'ALLINEAMENTO DEGLI ELEMENTI (da step = ASK_FOR_MAIN_OPTIONS)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ITEM_ROTATION: # dopo aver atteso una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ value = self.defaultValue
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+ else:
+ # la parola chiave arriva come parametro della funzione
+ value = msg
+
+ if type(value) == unicode:
+ if value == QadMsg.translate("QAD", "Yes") or value == "Yes":
+ self.itemsRotation = True
+ elif value == QadMsg.translate("QAD", "No") or value == "No":
+ self.itemsRotation = False
+ self.plugIn.setLastItemsRotation_array(self.itemsRotation)
+ self.waitForMainOptions()
+
+ return False
+
+
+ # ============================================================================
+ # SERIE TRAIETTORIA - FINE
+ # SERIE POLARE - INIZIO
+ # ============================================================================
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL CENTRO DELLA SERIE ((da step = ASK_FOR_ARRAYTYPE))
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_CENTER_PT: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == QgsPointXY: # se é stato inserito il punto centrale della serie
+ self.centerPt.set(value.x(), value.y())
+ self.waitForMainOptions()
+ elif type(value) == unicode:
+ if value == QadMsg.translate("Command_ARRAY", "Base point") or value == "Base point":
+ self.updatePointMapToolParams()
+ self.waitForBasePt(QadARRAYCommandClassStepEnum.ASK_FOR_BASE_PT_BEFORE_MAIN_OPTIONS)
+ return False # fine comando
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL PUNTO BASE (da step = ASK_FOR_CENTER_PT)
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_BASE_PT_BEFORE_MAIN_OPTIONS: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ self.basePt.set(value.x(), value.y())
+ self.updatePointMapToolParams()
+ self.waitForPolarCenterPt()
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DELL'ANGOLO TRA GLI ELEMENTI (da step = ASK_FOR_MAIN_OPTIONS)
+ # =========================================================================
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_ANGLE_BETWEEN_ITEMS:
+ if self.GetAngleClass.run(msgMapTool, msg) == True:
+ if self.GetAngleClass.angle is not None:
+ if self.GetAngleClass.angle * self.polarItemsNumber > math.pi * 2:
+ errMsg = QadMsg.translate("Command_ARRAY", "\nThe angle between can't be greater than {0}.")
+ maxAngleBetween = math.pi * 2 / self.polarItemsNumber
+ self.showErr(errMsg.format(str(qad_utils.toDegrees(maxAngleBetween))))
+ else:
+ self.polarAngleBetween = self.GetAngleClass.angle
+ self.plugIn.setLastPolarAngleBetween_array(self.polarAngleBetween)
+
+ self.waitForMainOptions()
+
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DELL'ANGOLO TRA GLI ELEMENTI (da step = ASK_FOR_MAIN_OPTIONS)
+ # =========================================================================
+ elif self.step == QadARRAYCommandClassStepEnum.ASK_FOR_FULL_ANGLE:
+ if self.GetAngleClass.run(msgMapTool, msg) == True:
+ if self.GetAngleClass.angle is not None:
+ self.polarAngleBetween = self.GetAngleClass.angle / self.polarItemsNumber
+ self.plugIn.setLastPolarAngleBetween_array(self.polarAngleBetween)
+ self.waitForMainOptions()
+
+ return False
+
+
+###############################################################################
+# Classe che gestisce il comando ARRAYRECT
+class QadARRAYRECTCommandClass(QadCommandClass):
+
+ def instantiateNewCmd(self):
+ """ istanzia un nuovo comando dello stesso tipo """
+ return QadARRAYRECTCommandClass(self.plugIn)
+
+ def getName(self):
+ return QadMsg.translate("Command_list", "ARRAYRECT")
+
+ def getEnglishName(self):
+ return "ARRAYRECT"
+
+ def connectQAction(self, action):
+ action.triggered.connect(self.plugIn.runARRAYRECTCommand)
+
+ def getIcon(self):
+ return QIcon(":/plugins/qad/icons/arrayRect.svg")
+
+ def getNote(self):
+ # impostare le note esplicative del comando
+ return QadMsg.translate("Command_ARRAY", "Distributes object copies into any combination of rows and columns.")
+
+ def __init__(self, plugIn):
+ QadCommandClass.__init__(self, plugIn)
+ self.SSGetClass = QadSSGetClass(plugIn)
+ self.SSGetClass.onlyEditableLayers = True
+ self.arrayCmd = QadARRAYCommandClass(plugIn)
+
+ def __del__(self):
+ QadCommandClass.__del__(self)
+ if self.SSGetClass is not None:
+ del self.SSGetClass
+ del self.arrayCmd
+
+
+ def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # quando si é in fase di selezione entità
+ return self.SSGetClass.getPointMapTool()
+ else:
+ return self.arrayCmd.getPointMapTool()
+
+
+ def getCurrentContextualMenu(self):
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # quando si é in fase di selezione entità
+ return None # return self.SSGetClass.getCurrentContextualMenu()
+ else:
+ return self.arrayCmd.getCurrentContextualMenu()
+
+
+ # ============================================================================
+ # run
+ # ============================================================================
+ def run(self, msgMapTool = False, msg = None):
+ if self.plugIn.canvas.mapSettings().destinationCrs().isGeographic():
+ self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
+ return True # fine comando
+
+ # =========================================================================
+ # RICHIESTA SELEZIONE OGGETTI
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # inizio del comando
+ if self.SSGetClass.run(msgMapTool, msg) == True:
+ if self.SSGetClass.entitySet.count() == 0:
+ return True # fine comando
+ self.arrayCmd.setEntitySet(self.SSGetClass.entitySet)
+
+ del self.SSGetClass
+ self.SSGetClass = None
+
+ self.step = -1
+ self.arrayCmd.step = QadARRAYCommandClassStepEnum.ASK_FOR_ARRAYTYPE
+
+ return self.arrayCmd.run(False, QadMsg.translate("Command_ARRAY", "Rectangular"))
+
+ return False
+
+ else:
+ return self.arrayCmd.run(msgMapTool, msg)
+
+
+###############################################################################
+# Classe che gestisce il comando ARRAYPATH
+class QadARRAYPATHCommandClass(QadCommandClass):
+
+ def instantiateNewCmd(self):
+ """ istanzia un nuovo comando dello stesso tipo """
+ return QadARRAYPATHCommandClass(self.plugIn)
+
+ def getName(self):
+ return QadMsg.translate("Command_list", "ARRAYPATH")
+
+ def getEnglishName(self):
+ return "ARRAYPATH"
+
+ def connectQAction(self, action):
+ action.triggered.connect(self.plugIn.runARRAYPATHCommand)
+
+ def getIcon(self):
+ return QIcon(":/plugins/qad/icons/arrayPath.svg")
+
+ def getNote(self):
+ # impostare le note esplicative del comando
+ return QadMsg.translate("Command_ARRAY", "Evenly distributes object copies along a path or a portion of a path.")
+
+ def __init__(self, plugIn):
+ QadCommandClass.__init__(self, plugIn)
+ self.SSGetClass = QadSSGetClass(plugIn)
+ self.SSGetClass.onlyEditableLayers = True
+ self.arrayCmd = QadARRAYCommandClass(plugIn)
+
+ def __del__(self):
+ QadCommandClass.__del__(self)
+ if self.SSGetClass is not None:
+ del self.SSGetClass
+ del self.arrayCmd
+
+
+ def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # quando si é in fase di selezione entità
+ return self.SSGetClass.getPointMapTool()
+ else:
+ return self.arrayCmd.getPointMapTool()
+
+
+ def getCurrentContextualMenu(self):
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # quando si é in fase di selezione entità
+ return None # return self.SSGetClass.getCurrentContextualMenu()
+ else:
+ return self.arrayCmd.getCurrentContextualMenu()
+
+
+ # ============================================================================
+ # run
+ # ============================================================================
+ def run(self, msgMapTool = False, msg = None):
+ if self.plugIn.canvas.mapSettings().destinationCrs().isGeographic():
+ self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
+ return True # fine comando
+
+ # =========================================================================
+ # RICHIESTA SELEZIONE OGGETTI
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # inizio del comando
+ if self.SSGetClass.run(msgMapTool, msg) == True:
+ if self.SSGetClass.entitySet.count() == 0:
+ return True # fine comando
+ self.arrayCmd.setEntitySet(self.SSGetClass.entitySet)
+
+ del self.SSGetClass
+ self.SSGetClass = None
+
+ self.step = -1
+ self.arrayCmd.step = QadARRAYCommandClassStepEnum.ASK_FOR_ARRAYTYPE
+
+ return self.arrayCmd.run(False, QadMsg.translate("Command_ARRAY", "PAth"))
+
+ return False
+
+ else:
+ return self.arrayCmd.run(msgMapTool, msg)
+
+
+###############################################################################
+# Classe che gestisce il comando ARRAYPOLAR
+class QadARRAYPOLARCommandClass(QadCommandClass):
+
+ def instantiateNewCmd(self):
+ """ istanzia un nuovo comando dello stesso tipo """
+ return QadARRAYPOLARCommandClass(self.plugIn)
+
+ def getName(self):
+ return QadMsg.translate("Command_list", "ARRAYPOLAR")
+
+ def getEnglishName(self):
+ return "ARRAYPOLAR"
+
+ def connectQAction(self, action):
+ action.triggered.connect(self.plugIn.runARRAYPOLARCommand)
+
+ def getIcon(self):
+ return QIcon(":/plugins/qad/icons/arrayPolar.svg")
+
+ def getNote(self):
+ # impostare le note esplicative del comando
+ return QadMsg.translate("Command_ARRAY", "Evenly distributes object copies in a circular pattern around a center point.")
+
+ def __init__(self, plugIn):
+ QadCommandClass.__init__(self, plugIn)
+ self.SSGetClass = QadSSGetClass(plugIn)
+ self.SSGetClass.onlyEditableLayers = True
+ self.arrayCmd = QadARRAYCommandClass(plugIn)
+
+ def __del__(self):
+ QadCommandClass.__del__(self)
+ if self.SSGetClass is not None:
+ del self.SSGetClass
+ del self.arrayCmd
+
+ def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # quando si é in fase di selezione entità
+ return self.SSGetClass.getPointMapTool()
+ else:
+ return self.arrayCmd.getPointMapTool()
+
+
+ def getCurrentContextualMenu(self):
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # quando si é in fase di selezione entità
+ return None # return self.SSGetClass.getCurrentContextualMenu()
+ else:
+ return self.arrayCmd.getCurrentContextualMenu()
+
+
+ # ============================================================================
+ # run
+ # ============================================================================
+ def run(self, msgMapTool = False, msg = None):
+ if self.plugIn.canvas.mapSettings().destinationCrs().isGeographic():
+ self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
+ return True # fine comando
+
+ # =========================================================================
+ # RICHIESTA SELEZIONE OGGETTI
+ if self.step == QadARRAYCommandClassStepEnum.ASK_FOR_SELSET: # inizio del comando
+ if self.SSGetClass.run(msgMapTool, msg) == True:
+ if self.SSGetClass.entitySet.count() == 0:
+ return True # fine comando
+ self.arrayCmd.setEntitySet(self.SSGetClass.entitySet)
+
+ del self.SSGetClass
+ self.SSGetClass = None
+
+ self.step = -1
+ self.arrayCmd.step = QadARRAYCommandClassStepEnum.ASK_FOR_ARRAYTYPE
+
+ return self.arrayCmd.run(False, QadMsg.translate("Command_ARRAY", "POlar"))
+
+ return False
+
+ else:
+ return self.arrayCmd.run(msgMapTool, msg)
diff --git a/cmd/qad_array_maptool.py b/cmd/qad_array_maptool.py
new file mode 100644
index 00000000..7fc2e920
--- /dev/null
+++ b/cmd/qad_array_maptool.py
@@ -0,0 +1,222 @@
+# -*- coding: utf-8 -*-
+"""
+/***************************************************************************
+ QAD Quantum Aided Design plugin ok
+
+ classe per gestire il map tool in ambito del comando array
+
+ -------------------
+ begin : 2016-05-31
+ copyright : iiiii
+ email : hhhhh
+ developers : bbbbb aaaaa ggggg
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+"""
+
+
+from .. import qad_utils
+from ..qad_getpoint import QadGetPoint, QadGetPointSelectionModeEnum, QadGetPointDrawModeEnum
+from ..qad_highlight import QadHighlight
+from ..qad_dim import QadDimStyles, appendDimEntityIfNotExisting
+from ..qad_entity import QadCacheEntitySetIterator, QadEntityTypeEnum
+from .. import qad_array_fun
+
+
+# ===============================================================================
+# Qad_array_maptool_ModeEnum class.
+# ===============================================================================
+class Qad_array_maptool_ModeEnum():
+ # non si richiede niente
+ NONE = 0
+ # si richiede il punto base
+ ASK_FOR_BASE_PT = 1
+ # si richiede il primo punto per la distanza tra colonne
+ ASK_FOR_COLUMN_SPACE_FIRST_PT = 2
+ # si richiede il primo punto per la dimensione della cella
+ ASK_FOR_1PT_CELL = 3
+ # si richiede il psecondo punto per la dimensione della cella
+ ASK_FOR_2PT_CELL = 4
+ # si richiede il primo punto per la distanza tra righe
+ ASK_FOR_ROW_SPACE_FIRST_PT = 5
+
+
+# ===============================================================================
+# Qad_array_maptool class
+# ===============================================================================
+class Qad_array_maptool(QadGetPoint):
+
+ def __init__(self, plugIn):
+ QadGetPoint.__init__(self, plugIn)
+
+ self.cacheEntitySet = None
+ self.basePt = None
+ self.arrayType = None
+ self.distanceBetweenRows = None
+ self.distanceBetweenCols = None
+ self.itemsRotation = None
+
+ # serie rettangolare
+ self.rectangleAngle = None
+ self.rectangleCols = None
+ self.rectangleRows = None
+ self.firstPt = None
+
+ # serie traiettoria
+ self.pathTangentDirection = None
+ self.pathRows = None
+ self.pathItemsNumber = None
+ self.pathPolyline = None
+
+ # serie polare
+ self.centerPt = None
+ self.polarItemsNumber = None
+ self.polarAngleBetween = None
+ self.polarRows = None
+
+ self.__highlight = QadHighlight(self.canvas)
+
+ def hidePointMapToolMarkers(self):
+ QadGetPoint.hidePointMapToolMarkers(self)
+ self.__highlight.hide()
+
+ def showPointMapToolMarkers(self):
+ QadGetPoint.showPointMapToolMarkers(self)
+ self.__highlight.show()
+
+ def clear(self):
+ QadGetPoint.clear(self)
+ self.__highlight.reset()
+ self.mode = None
+
+
+ # ============================================================================
+ # doRectangleArray
+ # ============================================================================
+ def doRectangleArray(self):
+ self.__highlight.reset()
+
+ dimElaboratedList = [] # lista delle quotature già elaborate
+ entityIterator = QadCacheEntitySetIterator(self.cacheEntitySet)
+ for entity in entityIterator:
+ qadGeom = entity.getQadGeom().copy() # così inizializzo le info qad
+ # verifico se l'entità appartiene ad uno stile di quotatura
+ dimEntity = QadDimStyles.getDimEntity(entity)
+ if dimEntity is not None:
+ if appendDimEntityIfNotExisting(dimElaboratedList, dimEntity) == False: # quota già elaborata
+ continue
+ entity = dimEntity
+
+ if qad_array_fun.arrayRectangleEntity(self.plugIn, entity, self.basePt, self.rectangleRows, self.rectangleCols, \
+ self.distanceBetweenRows, self.distanceBetweenCols, self.rectangleAngle, self.itemsRotation,
+ False, self.__highlight) == False:
+ return
+
+
+ # ============================================================================
+ # doPathArray
+ # ============================================================================
+ def doPathArray(self):
+ self.__highlight.reset()
+
+ dimElaboratedList = [] # lista delle quotature già elaborate
+ entityIterator = QadCacheEntitySetIterator(self.cacheEntitySet)
+ for entity in entityIterator:
+ qadGeom = entity.getQadGeom().copy() # così inizializzo le info qad
+ # verifico se l'entità appartiene ad uno stile di quotatura
+ dimEntity = QadDimStyles.getDimEntity(entity)
+ if dimEntity is not None:
+ if appendDimEntityIfNotExisting(dimElaboratedList, dimEntity) == False: # quota già elaborata
+ continue
+ entity = dimEntity
+
+ if qad_array_fun.arrayPathEntity(self.plugIn, entity, self.basePt, self.pathRows, self.pathItemsNumber, \
+ self.distanceBetweenRows, self.distanceBetweenCols, self.pathTangentDirection, self.itemsRotation, \
+ self.pathPolyline, self.distanceFromStartPt, \
+ False, self.__highlight) == False:
+ return
+
+
+ # ============================================================================
+ # doPolarArray
+ # ============================================================================
+ def doPolarArray(self):
+ self.__highlight.reset()
+
+ dimElaboratedList = [] # lista delle quotature già elaborate
+ entityIterator = QadCacheEntitySetIterator(self.cacheEntitySet)
+ for entity in entityIterator:
+ qadGeom = entity.getQadGeom().copy() # così inizializzo le info qad
+ # verifico se l'entità appartiene ad uno stile di quotatura
+ dimEntity = QadDimStyles.getDimEntity(entity)
+ if dimEntity is not None:
+ if appendDimEntityIfNotExisting(dimElaboratedList, dimEntity) == False: # quota già elaborata
+ continue
+ entity = dimEntity
+
+ if qad_array_fun.arrayPolarEntity(self.plugIn, entity, self.basePt, self.centerPt, self.polarItemsNumber, \
+ self.polarAngleBetween, self.polarRows, self.distanceBetweenRows, self.itemsRotation, \
+ False, self.__highlight) == False:
+ return
+
+
+ def canvasMoveEvent(self, event):
+ QadGetPoint.canvasMoveEvent(self, event)
+
+# # noto il punto base si richiede il secondo punto
+# if self.mode == Qad_array_maptool_ModeEnum.BASE_PT_KNOWN_ASK_FOR_COPY_PT:
+# self.setCopiedGeometries(self.tmpPoint)
+
+
+ def activate(self):
+ QadGetPoint.activate(self)
+ self.__highlight.show()
+
+ def deactivate(self):
+ try: # necessario perché se si chiude QGIS parte questo evento nonostante non ci sia più l'oggetto maptool !
+ QadGetPoint.deactivate(self)
+ self.__highlight.hide()
+ except:
+ pass
+
+ def setMode(self, mode):
+ self.mode = mode
+ # non si richiede niente
+ if self.mode == Qad_array_maptool_ModeEnum.NONE:
+ self.setSelectionMode(QadGetPointSelectionModeEnum.NONE)
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # si richiede il punto base
+ elif self.mode == Qad_array_maptool_ModeEnum.ASK_FOR_BASE_PT:
+ self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION)
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # si richiede il primo punto per la distanza tra colonne
+ elif self.mode == Qad_array_maptool_ModeEnum.ASK_FOR_COLUMN_SPACE_FIRST_PT:
+ self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION)
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # si richiede il primo punto per la dimensione della cella
+ elif self.mode == Qad_array_maptool_ModeEnum.ASK_FOR_1PT_CELL:
+ self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION)
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # si richiede il psecondo punto per la dimensione della cella
+ elif self.mode == Qad_array_maptool_ModeEnum.ASK_FOR_2PT_CELL:
+ self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION)
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_RECTANGLE)
+ self.setStartPoint(self.firstPt)
+ # si richiede il primo punto per la distanza tra righe
+ elif self.mode == Qad_array_maptool_ModeEnum.ASK_FOR_ROW_SPACE_FIRST_PT:
+ self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION)
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+
+
+ # si richiede il secondo punto per la distanza tra colonne
+# elif self.mode == Qad_array_maptool_ModeEnum.ASK_FOR_COLUMN_SPACE_SECOND_PT:
+# self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+# self.setStartPoint(self.firstPt)
diff --git a/cmd/qad_break_cmd.py b/cmd/qad_break_cmd.py
new file mode 100644
index 00000000..ec206959
--- /dev/null
+++ b/cmd/qad_break_cmd.py
@@ -0,0 +1,305 @@
+# -*- coding: utf-8 -*-
+"""
+/***************************************************************************
+ QAD Quantum Aided Design plugin
+
+ comando SPEZZA per tagliare un oggetto
+
+ -------------------
+ begin : 2014-01-09
+ copyright : iiiii
+ email : hhhhh
+ developers : bbbbb aaaaa ggggg
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+"""
+
+
+from qgis.PyQt.QtGui import QIcon
+from qgis.core import QgsWkbTypes, QgsFeature, QgsPointXY
+
+
+from .qad_generic_cmd import QadCommandClass
+from ..qad_getpoint import QadGetPointDrawModeEnum
+from ..qad_textwindow import QadInputTypeEnum, QadInputModeEnum
+from .qad_entsel_cmd import QadEntSelClass
+from ..qad_msg import QadMsg
+from .. import qad_layer
+from .. import qad_utils
+from ..qad_break_fun import breakQadGeometry
+from ..qad_multi_geom import fromQadGeomToQgsGeom, setQadGeomAt
+
+
+# Classe che gestisce il comando BREAK
+class QadBREAKCommandClass(QadCommandClass):
+
+ def instantiateNewCmd(self):
+ """ istanzia un nuovo comando dello stesso tipo """
+ return QadBREAKCommandClass(self.plugIn)
+
+ def getName(self):
+ return QadMsg.translate("Command_list", "BREAK")
+
+ def getEnglishName(self):
+ return "BREAK"
+
+ def connectQAction(self, action):
+ action.triggered.connect(self.plugIn.runBREAKCommand)
+
+ def getIcon(self):
+ return QIcon(":/plugins/qad/icons/break.svg")
+
+ def getNote(self):
+ # impostare le note esplicative del comando
+ return QadMsg.translate("Command_BREAK", "Breaks an object.")
+
+ def __init__(self, plugIn):
+ QadCommandClass.__init__(self, plugIn)
+ self.entSelClass = None
+ self.firstPt = None
+ self.secondPt = None
+
+ def __del__(self):
+ QadCommandClass.__del__(self)
+ if self.entSelClass is not None:
+ self.entSelClass.entity.deselectOnLayer()
+ del self.entSelClass
+
+ def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
+ if self.step == 1: # quando si é in fase di selezione entità
+ return self.entSelClass.getPointMapTool(drawMode)
+ else:
+ return QadCommandClass.getPointMapTool(self, drawMode)
+
+
+ def getCurrentContextualMenu(self):
+ if self.step == 1: # quando si é in fase di selezione entità
+ return self.entSelClass.getCurrentContextualMenu()
+ else:
+ return self.contextualMenu
+
+
+ def waitForEntsel(self, msgMapTool, msg):
+ if self.entSelClass is not None:
+ del self.entSelClass
+ self.step = 1
+ self.entSelClass = QadEntSelClass(self.plugIn)
+ self.entSelClass.msg = QadMsg.translate("Command_BREAK", "Select the object to break: ")
+ # scarto la selezione di punti e poligoni
+ self.entSelClass.checkPointLayer = False
+ self.entSelClass.checkLineLayer = True
+ self.entSelClass.checkPolygonLayer = False
+ self.entSelClass.checkDimLayers = False
+ self.entSelClass.onlyEditableLayers = True
+
+ self.entSelClass.run(msgMapTool, msg)
+
+
+ # ============================================================================
+ # breakFeatures
+ # ============================================================================
+ def breakFeatures(self):
+ f = self.entSelClass.entity.getFeature()
+ if f is None:
+ return
+ qadGeom = self.entSelClass.entity.getQadGeom()
+ result = breakQadGeometry(qadGeom, self.firstPt, self.secondPt)
+ if result is None: return
+
+ layer = self.entSelClass.entity.layer
+ LineTempLayer = None
+ self.plugIn.beginEditCommand("Feature broken", layer)
+
+ line1 = result[0]
+ line2 = result[1]
+ atGeom = result[2]
+ atSubGeom = result[3]
+ if layer.geometryType() == QgsWkbTypes.LineGeometry:
+ if line1 is not None:
+ updGeom = setQadGeomAt(qadGeom, line1, atGeom, atSubGeom)
+ if updGeom is None:
+ self.plugIn.destroyEditCommand()
+ return
+ brokenFeature1 = QgsFeature(f)
+ # trasformo la geometria nel crs del layer
+ brokenFeature1.setGeometry(fromQadGeomToQgsGeom(updGeom, layer))
+ # plugIn, layer, feature, refresh, check_validity
+ if qad_layer.updateFeatureToLayer(self.plugIn, layer, brokenFeature1, False, False) == False:
+ self.plugIn.destroyEditCommand()
+ return
+ if line2 is not None:
+ brokenFeature2 = QgsFeature(f)
+ # trasformo la geometria nel crs del layer
+ brokenFeature2.setGeometry(fromQadGeomToQgsGeom(line2, layer))
+ # plugIn, layer, feature, coordTransform, refresh, check_validity
+ if qad_layer.addFeatureToLayer(self.plugIn, layer, brokenFeature2, None, False, False, False) == False:
+ self.plugIn.destroyEditCommand()
+ return
+ else:
+ # aggiungo le linee nei layer temporanei di QAD
+ if LineTempLayer is None:
+ LineTempLayer = qad_layer.createQADTempLayer(self.plugIn, QgsWkbTypes.LineGeometry)
+ self.plugIn.addLayerToLastEditCommand("Feature broken", LineTempLayer)
+
+ lineGeoms = []
+ if line1 is not None:
+ lineGeoms.append(fromQadGeomToQgsGeom(line1, layer))
+ if line2 is not None:
+ lineGeoms.append(fromQadGeomToQgsGeom(line2, layer))
+
+ # trasformo la geometria in quella dei layer temporanei
+ # plugIn, pointGeoms, lineGeoms, polygonGeoms, coord, refresh
+ if qad_layer.addGeometriesToQADTempLayers(self.plugIn, None, lineGeoms, None, None, False) == False:
+ self.plugIn.destroyEditCommand()
+ return
+
+ updGeom = delQadGeomAt(qadGeom, atGeom, atSubGeom)
+
+ if updGeom == False: # da cancellare
+ # plugIn, layer, feature id, refresh
+ if qad_layer.deleteFeatureToLayer(self.plugIn, layer, f.id(), False) == False:
+ self.plugIn.destroyEditCommand()
+ return
+ else:
+ brokenFeature1 = QgsFeature(f)
+ # trasformo la geometria nel crs del layer
+ brokenFeature1.setGeometry(fromQadGeomToQgsGeom(updGeom, layer))
+ # plugIn, layer, feature, refresh, check_validity
+ if qad_layer.updateFeatureToLayer(self.plugIn, layer, brokenFeature1, False, False) == False:
+ self.plugIn.destroyEditCommand()
+ return
+
+ self.plugIn.endEditCommand()
+
+
+ def run(self, msgMapTool = False, msg = None):
+ if self.plugIn.canvas.mapSettings().destinationCrs().isGeographic():
+ self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
+ return True # fine comando
+
+ if self.step == 0:
+ self.waitForEntsel(msgMapTool, msg)
+ return False # continua
+
+ # =========================================================================
+ # RISPOSTA ALLA SELEZIONE DI UN'ENTITA' (da step = 0)
+ elif self.step == 1:
+ if self.entSelClass.run(msgMapTool, msg) == True:
+ if self.entSelClass.entity.isInitialized():
+ layer = self.entSelClass.entity.layer
+ self.firstPt = self.entSelClass.point
+ self.plugIn.setLastPoint(self.firstPt)
+
+ keyWords = QadMsg.translate("Command_BREAK", "First point")
+ prompt = QadMsg.translate("Command_BREAK", "Specify second break point or [{0}]: ").format(keyWords)
+
+ self.step = 2
+ self.getPointMapTool().refreshSnapType() # aggiorno lo snapType che può essere variato dal maptool di selezione entità
+
+ englishKeyWords = "First point"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o enter o una parola chiave
+ # msg, inputType, default, keyWords, nessun controllo
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NONE)
+ return False
+ else:
+ if self.entSelClass.canceledByUsr == True: # fine comando
+ return True
+ self.showMsg(QadMsg.translate("QAD", "No geometries in this position."))
+ self.waitForEntsel(msgMapTool, msg)
+ return False # continua
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL SECONDO PUNTO DI INTERRUZIONE (da step = 1)
+ elif self.step == 2: # dopo aver atteso un punto o una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ pass # opzione di default "secondo punto"
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if value is None or type(value) == unicode:
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_BREAK", "Specify first break point: "))
+ self.step = 3
+ elif type(value) == QgsPointXY: # se é stato inserito il secondo punto
+ self.secondPt = value
+ self.plugIn.setLastPoint(self.secondPt)
+ self.breakFeatures()
+ return True
+
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL PRIMO PUNTO DI INTERRUZIONE (da step = 2)
+ elif self.step == 3: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ self.firstPt = value
+ self.plugIn.setLastPoint(self.firstPt)
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_BREAK", "Specify second break point: "))
+ self.step = 4
+
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL SECONDO PUNTO DI INTERRUZIONE (da step = 3)
+ elif self.step == 4: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ self.secondPt = value
+ self.plugIn.setLastPoint(self.secondPt)
+ self.breakFeatures()
+
+ return True
diff --git a/qad_circle_cmd.py b/cmd/qad_circle_cmd.py
similarity index 75%
rename from qad_circle_cmd.py
rename to cmd/qad_circle_cmd.py
index dbc07a03..910bf896 100644
--- a/qad_circle_cmd.py
+++ b/cmd/qad_circle_cmd.py
@@ -1,840 +1,849 @@
-# -*- coding: utf-8 -*-
-"""
-/***************************************************************************
- QAD Quantum Aided Design plugin
-
- comando CIRCLE per disegnare un cerchio
-
- -------------------
- begin : 2013-05-22
- copyright : iiiii
- email : hhhhh
- developers : bbbbb aaaaa ggggg
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-"""
-
-
-# Import the PyQt and QGIS libraries
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
-from qgis.core import *
-
-
-from qad_getpoint import *
-from qad_circle_maptool import *
-from qad_generic_cmd import QadCommandClass
-from qad_msg import QadMsg
-from qad_textwindow import *
-from qad_entity import *
-import qad_utils
-import qad_layer
-
-
-# Classe che gestisce il comando CIRCLE
-class QadCIRCLECommandClass(QadCommandClass):
-
- def instantiateNewCmd(self):
- """ istanzia un nuovo comando dello stesso tipo """
- return QadCIRCLECommandClass(self.plugIn)
-
- def getName(self):
- return QadMsg.translate("Command_list", "CIRCLE")
-
- def getEnglishName(self):
- return "CIRCLE"
-
- def connectQAction(self, action):
- QObject.connect(action, SIGNAL("triggered()"), self.plugIn.runCIRCLECommand)
-
- def getIcon(self):
- return QIcon(":/plugins/qad/icons/circle.png")
-
- def getNote(self):
- # impostare le note esplicative del comando
- return QadMsg.translate("Command_CIRCLE", "Draws a circlerc by many methods.")
-
- def __init__(self, plugIn):
- QadCommandClass.__init__(self, plugIn)
- # se questo flag = True il comando serve all'interno di un altro comando per disegnare un cerchio
- # che non verrà salvato su un layer
- self.virtualCmd = False
- self.rubberBandBorderColor = None
- self.rubberBandFillColor = None
- self.centerPt = None
- self.radius = None
- self.area = 100
-
- def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
- if (self.plugIn is not None):
- if self.PointMapTool is None:
- self.PointMapTool = Qad_circle_maptool(self.plugIn)
- self.PointMapTool.setRubberBandColor(self.rubberBandBorderColor, self.rubberBandFillColor)
- return self.PointMapTool
- else:
- return None
-
- def setRubberBandColor(self, rubberBandBorderColor, rubberBandFillColor):
- self.rubberBandBorderColor = rubberBandBorderColor
- self.rubberBandFillColor = rubberBandFillColor
- if self.PointMapTool is not None:
- self.PointMapTool.setRubberBandColor(self.rubberBandBorderColor, self.rubberBandFillColor)
-
- def run(self, msgMapTool = False, msg = None):
- self.isValidPreviousInput = True # per gestire il comando anche in macro
-
- if self.plugIn.canvas.mapRenderer().destinationCrs().geographicFlag():
- self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
- return True # fine comando
-
- currLayer = None
- if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
- # il layer corrente deve essere editabile e di tipo linea o poligono
- currLayer, errMsg = qad_layer.getCurrLayerEditable(self.plugIn.canvas, [QGis.Line, QGis.Polygon])
- if currLayer is None:
- self.showErr(errMsg)
- return True # fine comando
- self.getPointMapTool().geomType = QGis.Line if currLayer.geometryType() == QGis.Line else QGis.Polygon
-
- #=========================================================================
- # RICHIESTA PRIMO PUNTO o CENTRO
- if self.step == 0: # inizio del comando
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_CENTER_PT)
- keyWords = QadMsg.translate("Command_CIRCLE", "3Points") + "/" + \
- QadMsg.translate("Command_CIRCLE", "2POints") + "/" + \
- QadMsg.translate("Command_CIRCLE", "Ttr (tangent tangent radius)")
- prompt = QadMsg.translate("Command_CIRCLE", "Specify the center point of the circle or [{0}]: ").format(keyWords)
-
- englishKeyWords = "3Points" + "/" + "2POints" + "/" + "Ttr (tangent tangent radius)"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o enter o una parola chiave
- # msg, inputType, default, keyWords, nessun controllo
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
- None, \
- keyWords, QadInputModeEnum.NONE)
-
- self.step = 1
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA CENTRO
- elif self.step == 1: # dopo aver atteso un punto o enter o una parola chiave si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi é stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if value is None:
- if self.plugIn.lastPoint is not None:
- value = self.plugIn.lastPoint
- else:
- return True # fine comando
-
- if type(value) == unicode:
- if value == QadMsg.translate("Command_CIRCLE", "3Points") or value == "3Points":
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_PT)
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first point on the circle: "))
- self.step = 4
- elif value == QadMsg.translate("Command_CIRCLE", "2POints") or value == "2POints":
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_DIAM_PT)
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first end of the circle diameter: "))
- self.step = 7
- elif value == QadMsg.translate("Command_CIRCLE", "Ttr (tangent tangent radius)") or \
- value == "Ttr (tangent tangent radius)":
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_TAN)
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first tangent element of the circle: "))
- self.step = 9
- elif type(value) == QgsPoint: # se é stato inserito il centro del cerchio
- self.centerPt = value
- self.plugIn.setLastPoint(value)
-
- # imposto il map tool
- self.getPointMapTool().centerPt = self.centerPt
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_RADIUS)
-
- keyWords = QadMsg.translate("Command_CIRCLE", "Diameter") + "/" + \
- QadMsg.translate("Command_CIRCLE", "Area")
- prompt = QadMsg.translate("Command_CIRCLE", "Specify the circle radius or [{0}]: ").format(keyWords)
-
- englishKeyWords = "Diameter" + "/" + "Area"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o una parola chiave
- # msg, inputType, default, keyWords, valori positivi
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT | QadInputTypeEnum.KEYWORDS, \
- None, \
- keyWords, \
- QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
-
- self.step = 2
-
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA RAGGIO O DIAMETRO O AREA
- elif self.step == 2: # dopo aver atteso un punto o una parola chiave si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == unicode:
- if value == QadMsg.translate("Command_CIRCLE", "Diameter") or value == "Diameter":
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_DIAM)
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, valori positivi
- self.waitFor(QadMsg.translate("Command_CIRCLE", "Specify the circle diameter: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
- None, \
- "", \
- QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
- self.step = 3
- elif value == QadMsg.translate("Command_CIRCLE", "Area") or value == "Area":
- msg = QadMsg.translate("Command_CIRCLE", "Enter circle area in current unit <{0}>: ")
- # si appresta ad attendere un numero reale
- # msg, inputType, default, keyWords, valori positivi
- self.waitFor(msg.format(str(self.area)), QadInputTypeEnum.FLOAT, \
- self.area, "", \
- QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_CENTER_PT)
- self.step = 13
- elif type(value) == QgsPoint or type(value) == float: # se é stato inserito il raggio del cerchio
- if type(value) == QgsPoint: # se é stato inserito il raggio del cerchio con un punto
- self.radius = qad_utils.getDistance(self.centerPt, value)
- else:
- self.radius = value
-
- self.plugIn.setLastRadius(self.radius)
-
- circle = QadCircle()
- circle.set(self.centerPt, self.radius)
- points = circle.asPolyline()
- if points is not None:
- if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
- if currLayer.geometryType() == QGis.Line:
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- else:
- qad_layer.addPolygonToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- keyWords = QadMsg.translate("Command_CIRCLE", "Diameter") + "/" + \
- QadMsg.translate("Command_CIRCLE", "Area")
- prompt = QadMsg.translate("Command_CIRCLE", "Specify the circle radius or [{0}]: ").format(keyWords)
-
- englishKeyWords = "Diameter" + "/" + "Area"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o una parola chiave
- # msg, inputType, default, keyWords, valori positivi
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
- None, \
- keyWords, QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA DIAMETRO DEL CERCHIO (da step = 2)
- elif self.step == 3: # dopo aver atteso un punto o un numero reale si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == QgsPoint: # se é stato inserito un punto
- self.radius = qad_utils.getDistance(self.centerPt, value) / 2
- elif type(value) == float: # se é stato inserito un numero reale
- self.radius = value
-
- self.plugIn.setLastRadius(self.radius)
-
- circle = QadCircle()
- circle.set(self.centerPt, self.radius)
- points = circle.asPolyline()
- if points is not None:
- if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
- if currLayer.geometryType() == QGis.Line:
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- else:
- qad_layer.addPolygonToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, valori positivi
- self.waitFor(QadMsg.translate("Command_CIRCLE", "Specify the circle diameter: "), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
- None, \
- "", \
- QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA DEL PRIMO PUNTO DEL CERCHIO (da step = 1)
- elif self.step == 4: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- snapTypeOnSel = self.getPointMapTool().snapTypeOnSelection
- value = self.getPointMapTool().point
- entity = self.getPointMapTool().entity
- else: # il punto arriva come parametro della funzione
- value = msg
- snapTypeOnSel = QadSnapTypeEnum.NONE
-
- # se é stato selezionato un punto con la modalità TAN_DEF é un punto differito
- if snapTypeOnSel == QadSnapTypeEnum.TAN_DEF and entity.isInitialized():
- self.firstPt = None
- self.firstPtTan = value
- self.firstGeomTan = QgsGeometry(entity.getGeometry()) # duplico la geometria
- coordTransform = QgsCoordinateTransform(entity.layer.crs(), self.plugIn.canvas.mapRenderer().destinationCrs()) # trasformo la geometria
- self.firstGeomTan.transform(coordTransform)
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_PT_KNOWN_ASK_FOR_SECOND_PT)
- else: # altrimenti é un punto esplicito
- self.firstPt = value
- self.plugIn.setLastPoint(value)
- # imposto il map tool
- self.getPointMapTool().firstPt = self.firstPt
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_PT_KNOWN_ASK_FOR_SECOND_PT)
-
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second point on the circle: "))
-
- self.step = 5
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA DEL SECONDO PUNTO DEL CERCHIO (da step = 4)
- elif self.step == 5: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- snapTypeOnSel = self.getPointMapTool().snapTypeOnSelection
- value = self.getPointMapTool().point
- entity = self.getPointMapTool().entity
- else: # il punto arriva come parametro della funzione
- value = msg
- snapTypeOnSel = QadSnapTypeEnum.NONE
-
- # se é stato selezionato un punto con la modalità TAN_DEF é un punto differito
- if snapTypeOnSel == QadSnapTypeEnum.TAN_DEF and entity.isInitialized():
- self.secondPt = None
- self.secondPtTan = value
- self.secondGeomTan = QgsGeometry(entity.getGeometry()) # duplico la geometria
- coordTransform = QgsCoordinateTransform(entity.layer.crs(), self.plugIn.canvas.mapRenderer().destinationCrs()) # trasformo la geometria
- self.secondGeomTan.transform(coordTransform)
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_SECOND_PT_KNOWN_ASK_FOR_THIRD_PT)
- else: # altrimenti é un punto esplicito
- self.secondPt = value
- self.plugIn.setLastPoint(value)
- # imposto il map tool
- self.getPointMapTool().secondPt = self.secondPt
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_SECOND_PT_KNOWN_ASK_FOR_THIRD_PT)
-
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify the third point on the circle: "))
-
- self.step = 6
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA DEL TERZO PUNTO DEL CERCHIO (da step = 5)
- elif self.step == 6: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- snapTypeOnSel = self.getPointMapTool().snapTypeOnSelection
- value = self.getPointMapTool().point
- entity = self.getPointMapTool().entity
- else: # il punto arriva come parametro della funzione
- value = msg
- snapTypeOnSel = QadSnapTypeEnum.NONE
-
- # se é stato selezionato un punto con la modalità TAN_DEF é un punto differito
- if snapTypeOnSel == QadSnapTypeEnum.TAN_DEF and entity.isInitialized():
- self.thirdPt = None
- self.thirdPtTan = value
- self.thirdGeomTan = QgsGeometry(entity.getGeometry()) # duplico la geometria
- coordTransform = QgsCoordinateTransform(entity.layer.crs(), self.plugIn.canvas.mapRenderer().destinationCrs()) # trasformo la geometria
- self.thirdGeomTan.transform(coordTransform)
- else: # altrimenti é un punto esplicito
- self.thirdPt = value
- self.plugIn.setLastPoint(value)
-
- circle = QadCircle()
- points = None
- if self.firstPt is None: # se il primo punto é definito con un punto differito
- if self.secondPt is None: # se il secondo punto é definito con un punto differito
- if self.thirdPt is None: # se il terzo punto é definito con un punto differito
- if circle.from3TanPts(self.firstGeomTan, self.firstPtTan, \
- self.secondGeomTan, self.secondPtTan, \
- self.thirdGeomTan, self.thirdPtTan) == True:
- points = circle.asPolyline()
- else: # se il terzo punto é definito con un punto esplicito
- if circle.from1IntPt2TanPts(self.thirdPt, self.firstGeomTan, self.firstPtTan,
- self.secondGeomTan, self.secondPtTan) == True:
- points = circle.asPolyline()
- else: # se il secondo punto é definito con un punto esplicito
- if self.thirdPt is None: # se il terzo punto é definito con un punto differito
- if circle.from1IntPt2TanPts(self.secondPt, self.firstGeomTan, self.firstPtTan,
- self.thirdGeomTan, self.thirdPtTan) == True:
- points = circle.asPolyline()
- else: # se il terzo punto é definito con un punto esplicito
- if circle.from2IntPts1TanPt(self.secondPt, self.thirdPt, \
- self.firstGeomTan, self.firstPtTan) == True:
- points = circle.asPolyline()
- else: # se il primo punto é definito con un punto esplicito
- if self.secondPt is None: # se il secondo punto é definito con un punto differito
- if self.thirdPt is None: # se il terzo punto é definito con un punto differito
- if circle.from1IntPt2TanPts(self.firstPt, self.secondGeomTan, self.secondPtTan,
- self.thirdGeomTan, self.thirdPtTan) == True:
- points = circle.asPolyline()
- else: # se il terzo punto é definito con un punto esplicito
- if circle.from2IntPts1TanPt(self.firstPt, self.thirdPt, \
- self.secondGeomTan, self.secondPtTan) == True:
- points = circle.asPolyline()
- else: # se il secondo punto é definito con un punto esplicito
- if self.thirdPt is None: # se il terzo punto é definito con un punto differito
- if circle.from2IntPts1TanPt(self.firstPt, self.secondPt, \
- self.thirdGeomTan, self.thirdPtTan) == True:
- points = circle.asPolyline()
- else: # se il terzo punto é definito con un punto esplicito
- if circle.from3Pts(self.firstPt, self.secondPt, value) == True:
- points = circle.asPolyline()
-
- if points is not None:
- self.centerPt = circle.center
- self.radius = circle.radius
- if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
- if currLayer.geometryType() == QGis.Line:
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- else:
- qad_layer.addPolygonToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify the third point on the circle: "))
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA DELLA PRIMA ESTREMITA' DIAM DEL CERCHIO (da step = 1)
- elif self.step == 7: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- snapTypeOnSel = self.getPointMapTool().snapTypeOnSelection
- value = self.getPointMapTool().point
- entity = self.getPointMapTool().entity
- else: # il punto arriva come parametro della funzione
- value = msg
- snapTypeOnSel = QadSnapTypeEnum.NONE
-
- # se é stato selezionato un punto con la modalità TAN_DEF é un punto differito
- if snapTypeOnSel == QadSnapTypeEnum.TAN_DEF and entity.isInitialized():
- self.firstDiamPt = None
- self.firstDiamPtTan = value
- self.firstDiamGeomTan = QgsGeometry(entity.getGeometry()) # duplico la geometria
- coordTransform = QgsCoordinateTransform(entity.layer.crs(), self.plugIn.canvas.mapRenderer().destinationCrs()) # trasformo la geometria
- self.firstDiamGeomTan.transform(coordTransform)
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_DIAM_PT_KNOWN_ASK_FOR_SECOND_DIAM_PT)
- else: # altrimenti é un punto esplicito
- self.firstDiamPt = value
- # imposto il map tool
- self.getPointMapTool().firstDiamPt = self.firstDiamPt
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_DIAM_PT_KNOWN_ASK_FOR_SECOND_DIAM_PT)
-
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second end of the circle diameter: "))
-
- self.step = 8
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA DELLA SECONDA ESTREMITA' DIAM DEL CERCHIO (da step = 7)
- elif self.step == 8: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- snapTypeOnSel = self.getPointMapTool().snapTypeOnSelection
- value = self.getPointMapTool().point
- entity = self.getPointMapTool().entity
- else: # il punto arriva come parametro della funzione
- value = msg
- snapTypeOnSel = QadSnapTypeEnum.NONE
-
- # se é stato selezionato un punto con la modalità TAN_DEF é un punto differito
- if snapTypeOnSel == QadSnapTypeEnum.TAN_DEF and entity.isInitialized():
- self.secondDiamPt = None
- self.secondDiamPtTan = value
- self.secondDiamGeomTan = QgsGeometry(entity.getGeometry()) # duplico la geometria
- coordTransform = QgsCoordinateTransform(entity.layer.crs(), self.plugIn.canvas.mapRenderer().destinationCrs()) # trasformo la geometria
- self.secondDiamGeomTan.transform(coordTransform)
- else: # altrimenti é un punto esplicito
- self.secondDiamPt = value
-
- circle = QadCircle()
- points = None
- if self.firstDiamPt is None: # se il diametro é definito con il primo punto differito
- if self.secondDiamPt is None: # il diametro é definito con il secondo punto differito
- if circle.fromDiamEnds2TanPts(self.firstDiamGeomTan, self.firstDiamPtTan, \
- self.secondDiamGeomTan, self.secondDiamPtTan) == True:
- points = circle.asPolyline()
- else: # se il diametro è definito con il secondo punto esplicito
- if circle.fromDiamEndsPtTanPt(self.secondDiamPt, self.firstDiamGeomTan, self.firstDiamPtTan) == True:
- points = circle.asPolyline()
- else: # se il diametro è definito con il primo punto esplicito
- if self.secondDiamPt is None: # il diametro è definito con il secondo punto differito
- if circle.fromDiamEndsPtTanPt(self.firstDiamPt, self.secondDiamGeomTan, self.secondDiamPtTan) == True:
- points = circle.asPolyline()
- else: # se il diametro è definito con il secondo punto esplicito
- if circle.fromDiamEnds(self.firstDiamPt, self.secondDiamPt) == True:
- points = circle.asPolyline()
-
- if points is not None:
- self.centerPt = circle.center
- self.radius = circle.radius
- if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
- if currLayer.geometryType() == QGis.Line:
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- else:
- qad_layer.addPolygonToLayer(self.plugIn, currLayer, points)
- return True # fine comand
-
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second end of the circle diameter: "))
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA PRIMA TANGENTE (da step = 1)
- elif self.step == 9: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- entity = self.getPointMapTool().entity
- else: # il punto arriva come parametro della funzione
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first tangent element of the circle: "))
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- if not entity.isInitialized(): # se non è stata selezionata una entità
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first tangent element of the circle: "))
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- wkbType = entity.getGeometry().wkbType()
- if wkbType == QGis.WKBPoint or wkbType == QGis.WKBMultiPoint:
- self.showErr(QadMsg.translate("Command_CIRCLE", "\nSelect a circle, an arc or a line."))
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first tangent element of the circle: "))
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- self.tanGeom1 = QgsGeometry(entity.getGeometry())
- coordTransform = QgsCoordinateTransform(entity.layer.crs(), self.plugIn.canvas.mapRenderer().destinationCrs()) # trasformo la geometria
- self.tanGeom1.transform(coordTransform)
- self.tanPt1 = self.getPointMapTool().point
-
- # imposto il map tool
- self.getPointMapTool().tanGeom1 = self.tanGeom1
- self.getPointMapTool().tanPt1 = self.tanPt1
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_TAN_KNOWN_ASK_FOR_SECOND_TAN)
-
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second tangent element of the circle: "))
- self.step = 10
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA SECONDA TANGENTE (da step = 9)
- elif self.step == 10: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- entity = self.getPointMapTool().entity
- else: # il punto arriva come parametro della funzione
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second tangent element of the circle: "))
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- if not entity.isInitialized(): # se non è stata selezionata una entità
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second tangent element of the circle: "))
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- wkbType = entity.getGeometry().wkbType()
- if wkbType == QGis.WKBPoint or wkbType == QGis.WKBMultiPoint:
- self.showErr(QadMsg.translate("Command_CIRCLE", "\nSelect a circle, an arc or a line."))
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second tangent element of the circle: "))
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
-
- self.tanGeom2 = QgsGeometry(entity.getGeometry())
- coordTransform = QgsCoordinateTransform(entity.layer.crs(), self.plugIn.canvas.mapRenderer().destinationCrs()) # trasformo la geometria
- self.tanGeom2.transform(coordTransform)
- self.tanPt2 = self.getPointMapTool().point
-
- # imposto il map tool
- self.getPointMapTool().tanGeom2 = self.tanGeom2
- self.getPointMapTool().tanPt2 = self.tanPt2
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_SECOND_TAN_KNOWN_ASK_FOR_RADIUS)
-
- # si appresta ad attendere un punto o un numero reale
- # msg, inputType, default, keyWords, valori positivi
- msg = QadMsg.translate("Command_CIRCLE", "Specify the circle radius <{0}>: ")
- self.waitFor(msg.format(str(self.plugIn.lastRadius)), \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
- self.plugIn.lastRadius, "", \
- QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
- self.step = 11
- return False
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA RAGGIO (da step = 10)
- elif self.step == 11: # dopo aver atteso un punto o un numero reale si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == QgsPoint:
- self.startPtForRadius = value
-
- # imposto il map tool
- self.getPointMapTool().startPtForRadius = self.startPtForRadius
- self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_SECOND_TAN_FIRSTPTRADIUS_KNOWN_ASK_FOR_SECONDPTRADIUS)
-
- # si appresta ad attendere un punto
- self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second point: "))
- self.step = 12
- return False
- else:
- self.plugIn.setLastRadius(value)
-
- circle = QadCircle()
- if circle.from2TanPtsRadius(self.tanGeom1, self.tanPt1, \
- self.tanGeom2, self.tanPt2, value) == True:
- points = circle.asPolyline()
- if points is not None:
- self.centerPt = circle.center
- self.radius = circle.radius
- if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
- if currLayer.geometryType() == QGis.Line:
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- else:
- qad_layer.addPolygonToLayer(self.plugIn, currLayer, points)
- else:
- self.showMsg(QadMsg.translate("Command_CIRCLE", "\nThe circle doesn't exist."))
- else:
- self.showMsg(QadMsg.translate("Command_CIRCLE", "\nThe circle doesn't exist."))
-
- return True # fine comando
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA SECONDO PUNTO DEL RAGGIO (da step = 11)
- elif self.step == 12: # dopo aver atteso un punto si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
- return True # fine comando
- else:
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- self.radius = qad_utils.getDistance(self.startPtForRadius, value)
- self.plugIn.setLastRadius(self.radius)
-
- circle = QadCircle()
- if circle.from2TanPtsRadius(self.tanGeom1, self.tanPt1, \
- self.tanGeom2, self.tanPt2, self.radius) == True:
- points = circle.asPolyline()
- if points is not None:
- self.centerPt = circle.center
- self.radius = circle.radius
- if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
- if currLayer.geometryType() == QGis.Line:
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- else:
- qad_layer.addPolygonToLayer(self.plugIn, currLayer, points)
- else:
- self.showMsg(QadMsg.translate("Command_CIRCLE", "\nThe circle doesn't exist."))
- else:
- self.showMsg(QadMsg.translate("Command_CIRCLE", "\nThe circle doesn't exist."))
- return True # fine comando
-
- #=========================================================================
- # RISPOSTA ALLA RICHIESTA AREA DEL CERCHIO (da step = 2)
- elif self.step == 13: # dopo aver atteso un numero si riavvia il comando
- if msgMapTool == True: # il punto arriva da una selezione grafica
- # la condizione seguente si verifica se durante la selezione di un punto
- # é stato attivato un altro plugin che ha disattivato Qad
- # quindi stato riattivato il comando che torna qui senza che il maptool
- # abbia selezionato un punto
- if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
- if self.getPointMapTool().rightButton != True: # se NON usato il tasto destro del mouse
- self.setMapTool(self.getPointMapTool()) # riattivo il maptool
- return False
-
- value = self.getPointMapTool().point
- else: # il punto arriva come parametro della funzione
- value = msg
-
- if type(value) == float: # è stata inserita l'area
- self.area = value
-
- circle = QadCircle()
- circle.fromCenterArea(self.centerPt, self.area)
- self.radius = circle.radius
- self.plugIn.setLastRadius(self.radius)
- points = circle.asPolyline()
- if points is not None:
- if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
- if currLayer.geometryType() == QGis.Line:
- qad_layer.addLineToLayer(self.plugIn, currLayer, points)
- else:
- qad_layer.addPolygonToLayer(self.plugIn, currLayer, points)
- return True # fine comando
-
- self.isValidPreviousInput = False # per gestire il comando anche in macro
- return False
+# -*- coding: utf-8 -*-
+"""
+/***************************************************************************
+ QAD Quantum Aided Design plugin
+
+ comando CIRCLE per disegnare un cerchio
+
+ -------------------
+ begin : 2013-05-22
+ copyright : iiiii
+ email : hhhhh
+ developers : bbbbb aaaaa ggggg
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+"""
+
+
+# Import the PyQt and QGIS libraries
+from qgis.core import QgsWkbTypes, QgsPointXY, QgsGeometry
+from qgis.PyQt.QtGui import QIcon
+
+
+from .. import qad_layer
+from .. import qad_utils
+from .qad_circle_maptool import Qad_circle_maptool, Qad_circle_maptool_ModeEnum
+from .qad_generic_cmd import QadCommandClass
+from ..qad_msg import QadMsg
+from ..qad_textwindow import QadInputModeEnum, QadInputTypeEnum
+from ..qad_geom_relations import *
+from ..qad_multi_geom import *
+from ..qad_circle_fun import *
+from ..qad_getpoint import QadGetPointDrawModeEnum
+from ..qad_snapper import QadSnapTypeEnum
+
+
+# Classe che gestisce il comando CIRCLE
+class QadCIRCLECommandClass(QadCommandClass):
+
+ def instantiateNewCmd(self):
+ """ istanzia un nuovo comando dello stesso tipo """
+ return QadCIRCLECommandClass(self.plugIn)
+
+ def getName(self):
+ return QadMsg.translate("Command_list", "CIRCLE")
+
+ def getEnglishName(self):
+ return "CIRCLE"
+
+ def connectQAction(self, action):
+ action.triggered.connect(self.plugIn.runCIRCLECommand)
+
+ def getIcon(self):
+ return QIcon(":/plugins/qad/icons/circle.svg")
+
+ def getNote(self):
+ # impostare le note esplicative del comando
+ return QadMsg.translate("Command_CIRCLE", "Draws a circle by many methods.")
+
+ def __init__(self, plugIn):
+ QadCommandClass.__init__(self, plugIn)
+ # se questo flag = True il comando serve all'interno di un altro comando per disegnare un cerchio
+ # che non verrà salvato su un layer
+ self.virtualCmd = False
+ self.rubberBandBorderColor = None
+ self.rubberBandFillColor = None
+ self.centerPt = None
+ self.radius = None
+ self.area = 100
+
+ def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
+ if (self.plugIn is not None):
+ if self.PointMapTool is None:
+ self.PointMapTool = Qad_circle_maptool(self.plugIn)
+ self.PointMapTool.setRubberBandColor(self.rubberBandBorderColor, self.rubberBandFillColor)
+ return self.PointMapTool
+ else:
+ return None
+
+ def setRubberBandColor(self, rubberBandBorderColor, rubberBandFillColor):
+ self.rubberBandBorderColor = rubberBandBorderColor
+ self.rubberBandFillColor = rubberBandFillColor
+ if self.PointMapTool is not None:
+ self.PointMapTool.setRubberBandColor(self.rubberBandBorderColor, self.rubberBandFillColor)
+
+ def run(self, msgMapTool = False, msg = None):
+ self.isValidPreviousInput = True # per gestire il comando anche in macro
+
+ if self.plugIn.canvas.mapSettings().destinationCrs().isGeographic():
+ self.showMsg(QadMsg.translate("QAD", "\nThe coordinate reference system of the project must be a projected coordinate system.\n"))
+ return True # fine comando
+
+ currLayer = None
+ if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
+ # il layer corrente deve essere editabile e di tipo linea o poligono
+ currLayer, errMsg = qad_layer.getCurrLayerEditable(self.plugIn.canvas, [QgsWkbTypes.LineGeometry, QgsWkbTypes.PolygonGeometry])
+ if currLayer is None:
+ self.showErr(errMsg)
+ return True # fine comando
+ self.getPointMapTool().layer = currLayer
+
+ # =========================================================================
+ # RICHIESTA PRIMO PUNTO o CENTRO
+ if self.step == 0: # inizio del comando
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_CENTER_PT)
+ keyWords = QadMsg.translate("Command_CIRCLE", "3Points") + "/" + \
+ QadMsg.translate("Command_CIRCLE", "2POints") + "/" + \
+ QadMsg.translate("Command_CIRCLE", "Ttr (tangent tangent radius)")
+ prompt = QadMsg.translate("Command_CIRCLE", "Specify the center point of the circle or [{0}]: ").format(keyWords)
+
+ englishKeyWords = "3Points" + "/" + "2POints" + "/" + "Ttr (tangent tangent radius)"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o enter o una parola chiave
+ # msg, inputType, default, keyWords, nessun controllo
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NONE)
+
+ self.step = 1
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA CENTRO
+ elif self.step == 1: # dopo aver atteso un punto o enter o una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi é stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if value is None:
+ if self.plugIn.lastPoint is not None:
+ value = self.plugIn.lastPoint
+ else:
+ return True # fine comando
+
+ if type(value) == unicode:
+ if value == QadMsg.translate("Command_CIRCLE", "3Points") or value == "3Points":
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_PT)
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first point on the circle: "))
+ self.step = 4
+ elif value == QadMsg.translate("Command_CIRCLE", "2POints") or value == "2POints":
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_DIAM_PT)
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first end of the circle diameter: "))
+ self.step = 7
+ elif value == QadMsg.translate("Command_CIRCLE", "Ttr (tangent tangent radius)") or \
+ value == "Ttr (tangent tangent radius)":
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_TAN)
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first tangent element of the circle: "))
+ self.step = 9
+ elif type(value) == QgsPointXY: # se é stato inserito il centro del cerchio
+ self.centerPt = value
+ self.plugIn.setLastPoint(value)
+
+ # imposto il map tool
+ self.getPointMapTool().centerPt = self.centerPt
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_RADIUS)
+
+ keyWords = QadMsg.translate("Command_CIRCLE", "Diameter") + "/" + \
+ QadMsg.translate("Command_CIRCLE", "Area")
+ prompt = QadMsg.translate("Command_CIRCLE", "Specify the circle radius or [{0}]: ").format(keyWords)
+
+ englishKeyWords = "Diameter" + "/" + "Area"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o una parola chiave
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, \
+ QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+
+ self.step = 2
+
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA RAGGIO O DIAMETRO O AREA
+ elif self.step == 2: # dopo aver atteso un punto o una parola chiave si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == unicode:
+ if value == QadMsg.translate("Command_CIRCLE", "Diameter") or value == "Diameter":
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_DIAM)
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(QadMsg.translate("Command_CIRCLE", "Specify the circle diameter: "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
+ None, \
+ "", \
+ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+ self.step = 3
+ elif value == QadMsg.translate("Command_CIRCLE", "Area") or value == "Area":
+ msg = QadMsg.translate("Command_CIRCLE", "Enter circle area in current unit <{0}>: ")
+ # si appresta ad attendere un numero reale
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(msg.format(str(self.area)), QadInputTypeEnum.FLOAT, \
+ self.area, "", \
+ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_CENTER_PT)
+ self.step = 13
+ elif type(value) == QgsPointXY or type(value) == float: # se é stato inserito il raggio del cerchio
+ if type(value) == QgsPointXY: # se é stato inserito il raggio del cerchio con un punto
+ self.radius = qad_utils.getDistance(self.centerPt, value)
+ else:
+ self.radius = value
+
+ self.plugIn.setLastRadius(self.radius)
+
+ circle = QadCircle()
+ if circle.set(self.centerPt, self.radius) is not None:
+ geom = circle.asGeom(currLayer.wkbType())
+ if geom is not None:
+ if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ keyWords = QadMsg.translate("Command_CIRCLE", "Diameter") + "/" + \
+ QadMsg.translate("Command_CIRCLE", "Area")
+ prompt = QadMsg.translate("Command_CIRCLE", "Specify the circle radius or [{0}]: ").format(keyWords)
+
+ englishKeyWords = "Diameter" + "/" + "Area"
+ keyWords += "_" + englishKeyWords
+ # si appresta ad attendere un punto o una parola chiave
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(prompt, \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
+ None, \
+ keyWords, QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DIAMETRO DEL CERCHIO (da step = 2)
+ elif self.step == 3: # dopo aver atteso un punto o un numero reale si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == QgsPointXY: # se é stato inserito un punto
+ self.radius = qad_utils.getDistance(self.centerPt, value) / 2
+ elif type(value) == float: # se é stato inserito un numero reale
+ self.radius = value / 2
+
+ self.plugIn.setLastRadius(self.radius)
+
+ circle = QadCircle()
+ if circle.set(self.centerPt, self.radius) is not None:
+ geom = circle.asGeom(currLayer.wkbType())
+ if geom is not None:
+ if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, valori positivi
+ self.waitFor(QadMsg.translate("Command_CIRCLE", "Specify the circle diameter: "), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
+ None, \
+ "", \
+ QadInputModeEnum.NOT_NULL | QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL PRIMO PUNTO DEL CERCHIO (da step = 1)
+ elif self.step == 4: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ snapTypeOnSel = self.getPointMapTool().snapTypeOnSelection
+ value = self.getPointMapTool().point
+ entity = self.getPointMapTool().entity
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ snapTypeOnSel = QadSnapTypeEnum.NONE
+
+ # se é stato selezionato un punto con la modalità TAN_DEF é un punto differito
+ if snapTypeOnSel == QadSnapTypeEnum.TAN_DEF and entity.isInitialized():
+ self.firstPt = None
+ self.firstPtTan = value
+
+ # la funzione ritorna una lista con
+ # (
+ #
+ #
+ #
+ # se geometria chiusa è tipo polyline la lista contiene anche
+ #
+ # <"a sinistra di" se il punto é alla sinista della parte (< 0 -> sinistra, > 0 -> destra)
+ # )
+ # parte più vicina al punto self.firstPtTan
+ result = getQadGeomClosestPart(entity.getQadGeom(), self.firstPtTan)
+ # duplico la geometria della parte
+ self.firstGeomTan = getQadGeomPartAt(entity.getQadGeom(), result[2], result[3], result[4]).copy()
+
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_PT_KNOWN_ASK_FOR_SECOND_PT)
+ else: # altrimenti é un punto esplicito
+ self.firstPt = value
+ self.plugIn.setLastPoint(value)
+ # imposto il map tool
+ self.getPointMapTool().firstPt = self.firstPt
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_PT_KNOWN_ASK_FOR_SECOND_PT)
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second point on the circle: "))
+
+ self.step = 5
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL SECONDO PUNTO DEL CERCHIO (da step = 4)
+ elif self.step == 5: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ snapTypeOnSel = self.getPointMapTool().snapTypeOnSelection
+ value = self.getPointMapTool().point
+ entity = self.getPointMapTool().entity
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ snapTypeOnSel = QadSnapTypeEnum.NONE
+
+ # se é stato selezionato un punto con la modalità TAN_DEF é un punto differito
+ if snapTypeOnSel == QadSnapTypeEnum.TAN_DEF and entity.isInitialized():
+ self.secondPt = None
+ self.secondPtTan = value
+
+ # la funzione ritorna una lista con
+ # (
+ #
+ #
+ #
+ # se geometria chiusa è tipo polyline la lista contiene anche
+ #
+ # <"a sinistra di" se il punto é alla sinista della parte (< 0 -> sinistra, > 0 -> destra)
+ # )
+ # parte più vicina al punto self.secondPtTan
+ result = getQadGeomClosestPart(entity.getQadGeom(), self.secondPtTan)
+ # duplico la geometria della parte
+ self.secondGeomTan = getQadGeomPartAt(entity.getQadGeom(), result[2], result[3], result[4]).copy()
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_SECOND_PT_KNOWN_ASK_FOR_THIRD_PT)
+ else: # altrimenti é un punto esplicito
+ self.secondPt = value
+ self.plugIn.setLastPoint(value)
+ # imposto il map tool
+ self.getPointMapTool().secondPt = self.secondPt
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_SECOND_PT_KNOWN_ASK_FOR_THIRD_PT)
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify the third point on the circle: "))
+
+ self.step = 6
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DEL TERZO PUNTO DEL CERCHIO (da step = 5)
+ elif self.step == 6: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ snapTypeOnSel = self.getPointMapTool().snapTypeOnSelection
+ value = self.getPointMapTool().point
+ entity = self.getPointMapTool().entity
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ snapTypeOnSel = QadSnapTypeEnum.NONE
+
+ # se é stato selezionato un punto con la modalità TAN_DEF é un punto differito
+ if snapTypeOnSel == QadSnapTypeEnum.TAN_DEF and entity.isInitialized():
+ self.thirdPt = None
+ self.thirdPtTan = value
+
+ # la funzione ritorna una lista con
+ # (
+ #
+ #
+ #
+ # se geometria chiusa è tipo polyline la lista contiene anche
+ #
+ # <"a sinistra di" se il punto é alla sinista della parte (< 0 -> sinistra, > 0 -> destra)
+ # )
+ # parte più vicina al punto self.secondPtTan
+ result = getQadGeomClosestPart(entity.getQadGeom(), self.thirdPtTan)
+ # duplico la geometria della parte
+ self.thirdGeomTan = getQadGeomPartAt(entity.getQadGeom(), result[2], result[3], result[4]).copy()
+ else: # altrimenti é un punto esplicito
+ self.thirdPt = value
+ self.plugIn.setLastPoint(value)
+
+ circle = None
+ if self.firstPt is None: # se il primo punto é definito con un punto differito
+ if self.secondPt is None: # se il secondo punto é definito con un punto differito
+ if self.thirdPt is None: # se il terzo punto é definito con un punto differito
+ circle = circleFrom3TanPts(self.firstGeomTan, self.firstPtTan, \
+ self.secondGeomTan, self.secondPtTan, \
+ self.thirdGeomTan, self.thirdPtTan)
+ else: # se il terzo punto é definito con un punto esplicito
+ circle = circleFrom1IntPt2TanPts(self.thirdPt, self.firstGeomTan, self.firstPtTan,
+ self.secondGeomTan, self.secondPtTan)
+ else: # se il secondo punto é definito con un punto esplicito
+ if self.thirdPt is None: # se il terzo punto é definito con un punto differito
+ circle = circleFrom1IntPt2TanPts(self.secondPt, self.firstGeomTan, self.firstPtTan,
+ self.thirdGeomTan, self.thirdPtTan)
+ else: # se il terzo punto é definito con un punto esplicito
+ circle = circleFrom2IntPts1TanPt(self.secondPt, self.thirdPt, \
+ self.firstGeomTan, self.firstPtTan)
+ else: # se il primo punto é definito con un punto esplicito
+ if self.secondPt is None: # se il secondo punto é definito con un punto differito
+ if self.thirdPt is None: # se il terzo punto é definito con un punto differito
+ circe = circleFrom1IntPt2TanPts(self.firstPt, self.secondGeomTan, self.secondPtTan,
+ self.thirdGeomTan, self.thirdPtTan)
+ else: # se il terzo punto é definito con un punto esplicito
+ circe = circleFrom2IntPts1TanPt(self.firstPt, self.thirdPt, \
+ self.secondGeomTan, self.secondPtTan)
+ else: # se il secondo punto é definito con un punto esplicito
+ if self.thirdPt is None: # se il terzo punto é definito con un punto differito
+ circle = circleFrom2IntPts1TanPt(self.firstPt, self.secondPt, \
+ self.thirdGeomTan, self.thirdPtTan)
+ else: # se il terzo punto é definito con un punto esplicito
+ circle = circleFrom3Pts(self.firstPt, self.secondPt, value)
+
+ if circle is not None:
+ self.centerPt = circle.center
+ self.radius = circle.radius
+
+ geom = circle.asGeom(currLayer.wkbType())
+ if geom is not None:
+ if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify the third point on the circle: "))
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DELLA PRIMA ESTREMITA' DIAM DEL CERCHIO (da step = 1)
+ elif self.step == 7: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ snapTypeOnSel = self.getPointMapTool().snapTypeOnSelection
+ value = self.getPointMapTool().point
+ entity = self.getPointMapTool().entity
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ snapTypeOnSel = QadSnapTypeEnum.NONE
+
+ # se é stato selezionato un punto con la modalità TAN_DEF é un punto differito
+ if snapTypeOnSel == QadSnapTypeEnum.TAN_DEF and entity.isInitialized():
+ self.firstDiamPt = None
+ self.firstDiamPtTan = value
+ result = getQadGeomClosestPart(entity.getQadGeom(), self.firstDiamPtTan)
+ # duplico la geometria della parte
+ self.firstDiamGeomTan = getQadGeomPartAt(entity.getQadGeom(), result[2], result[3], result[4]).copy()
+ # imposto il map tool
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_DIAM_PT_KNOWN_ASK_FOR_SECOND_DIAM_PT)
+ else: # altrimenti é un punto esplicito
+ self.firstDiamPt = value
+ # imposto il map tool
+ self.getPointMapTool().firstDiamPt = self.firstDiamPt
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_DIAM_PT_KNOWN_ASK_FOR_SECOND_DIAM_PT)
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second end of the circle diameter: "))
+
+ self.step = 8
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA DELLA SECONDA ESTREMITA' DIAM DEL CERCHIO (da step = 7)
+ elif self.step == 8: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ snapTypeOnSel = self.getPointMapTool().snapTypeOnSelection
+ value = self.getPointMapTool().point
+ entity = self.getPointMapTool().entity
+ else: # il punto arriva come parametro della funzione
+ value = msg
+ snapTypeOnSel = QadSnapTypeEnum.NONE
+
+ # se é stato selezionato un punto con la modalità TAN_DEF é un punto differito
+ if snapTypeOnSel == QadSnapTypeEnum.TAN_DEF and entity.isInitialized():
+ self.secondDiamPt = None
+ self.secondDiamPtTan = value
+ result = getQadGeomClosestPart(entity.getQadGeom(), self.secondDiamPtTan)
+ # duplico la geometria della parte
+ self.secondDiamGeomTan = getQadGeomPartAt(entity.getQadGeom(), result[2], result[3], result[4]).copy()
+ else: # altrimenti é un punto esplicito
+ self.secondDiamPt = value
+
+ circle = None
+ if self.firstDiamPt is None: # se il diametro é definito con il primo punto differito
+ if self.secondDiamPt is None: # il diametro é definito con il secondo punto differito
+ circle = circleFromDiamEnds2TanPts(self.firstDiamGeomTan, self.firstDiamPtTan, \
+ self.secondDiamGeomTan, self.secondDiamPtTan)
+ else: # se il diametro è definito con il secondo punto esplicito
+ circle = circleFromDiamEndsPtTanPt(self.secondDiamPt, self.firstDiamGeomTan, self.firstDiamPtTan)
+ else: # se il diametro è definito con il primo punto esplicito
+ if self.secondDiamPt is None: # il diametro è definito con il secondo punto differito
+ circle = circleFromDiamEndsPtTanPt(self.firstDiamPt, self.secondDiamGeomTan, self.secondDiamPtTan)
+ else: # se il diametro è definito con il secondo punto esplicito
+ circle = QadCircle().fromDiamEnds(self.firstDiamPt, self.secondDiamPt)
+
+ if circle is not None:
+ self.centerPt = circle.center
+ self.radius = circle.radius
+
+ geom = circle.asGeom(currLayer.wkbType())
+ if geom is not None:
+ if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second end of the circle diameter: "))
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA PRIMA TANGENTE (da step = 1)
+ elif self.step == 9: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ entity = self.getPointMapTool().entity
+ else: # il punto arriva come parametro della funzione
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first tangent element of the circle: "))
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ if not entity.isInitialized(): # se non è stata selezionata una entità
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first tangent element of the circle: "))
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ result = getQadGeomClosestPart(entity.getQadGeom(), self.getPointMapTool().point)
+ g = getQadGeomPartAt(entity.getQadGeom(), result[2], result[3], result[4])
+ gType = g.whatIs()
+ if gType != "LINE" and gType != "ARC" and gType != "CIRCLE":
+ self.showErr(QadMsg.translate("Command_CIRCLE", "\nSelect a circle, an arc or a line."))
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify first tangent element of the circle: "))
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ self.tanPt1 = self.getPointMapTool().point
+ # duplico la geometria della parte
+ self.tanGeom1 = g.copy()
+
+ # imposto il map tool
+ self.getPointMapTool().tanGeom1 = self.tanGeom1
+ self.getPointMapTool().tanPt1 = self.tanPt1
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_TAN_KNOWN_ASK_FOR_SECOND_TAN)
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second tangent element of the circle: "))
+ self.step = 10
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA SECONDA TANGENTE (da step = 9)
+ elif self.step == 10: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ entity = self.getPointMapTool().entity
+ else: # il punto arriva come parametro della funzione
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second tangent element of the circle: "))
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ if not entity.isInitialized(): # se non è stata selezionata una entità
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second tangent element of the circle: "))
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ result = getQadGeomClosestPart(entity.getQadGeom(), self.getPointMapTool().point)
+ g = getQadGeomPartAt(entity.getQadGeom(), result[2], result[3], result[4])
+ gType = g.whatIs()
+ if gType != "LINE" and gType != "ARC" and gType != "CIRCLE":
+ self.showErr(QadMsg.translate("Command_CIRCLE", "\nSelect a circle, an arc or a line."))
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second tangent element of the circle: "))
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
+
+ self.tanPt2 = self.getPointMapTool().point
+ # duplico la geometria della parte
+ self.tanGeom2 = g.copy()
+
+ # imposto il map tool
+ self.getPointMapTool().tanGeom2 = self.tanGeom2
+ self.getPointMapTool().tanPt2 = self.tanPt2
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_SECOND_TAN_KNOWN_ASK_FOR_RADIUS)
+
+ # si appresta ad attendere un punto o un numero reale
+ # msg, inputType, default, keyWords, valori positivi
+ msg = QadMsg.translate("Command_CIRCLE", "Specify the circle radius <{0}>: ")
+ self.waitFor(msg.format(str(self.plugIn.lastRadius)), \
+ QadInputTypeEnum.POINT2D | QadInputTypeEnum.FLOAT, \
+ self.plugIn.lastRadius, "", \
+ QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
+ self.step = 11
+ return False
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA RAGGIO (da step = 10)
+ elif self.step == 11: # dopo aver atteso un punto o un numero reale si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == QgsPointXY:
+ self.startPtForRadius = value
+
+ # imposto il map tool
+ self.getPointMapTool().startPtForRadius = self.startPtForRadius
+ self.getPointMapTool().setMode(Qad_circle_maptool_ModeEnum.FIRST_SECOND_TAN_FIRSTPTRADIUS_KNOWN_ASK_FOR_SECONDPTRADIUS)
+
+ # si appresta ad attendere un punto
+ self.waitForPoint(QadMsg.translate("Command_CIRCLE", "Specify second point: "))
+ self.step = 12
+ return False
+ else:
+ self.plugIn.setLastRadius(value)
+
+ circle = circleFrom2TanPtsRadius(self.tanGeom1, self.tanPt1, \
+ self.tanGeom2, self.tanPt2, value)
+ if circle is not None:
+ geom = circle.asGeom(currLayer.wkbType())
+ if geom is not None:
+ self.centerPt = circle.center
+ self.radius = circle.radius
+ if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ else:
+ self.showMsg(QadMsg.translate("Command_CIRCLE", "\nThe circle doesn't exist."))
+ else:
+ self.showMsg(QadMsg.translate("Command_CIRCLE", "\nThe circle doesn't exist."))
+
+ return True # fine comando
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA SECONDO PUNTO DEL RAGGIO (da step = 11)
+ elif self.step == 12: # dopo aver atteso un punto si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton == True: # se usato il tasto destro del mouse
+ return True # fine comando
+ else:
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ self.radius = qad_utils.getDistance(self.startPtForRadius, value)
+ self.plugIn.setLastRadius(self.radius)
+
+ circle = circleFrom2TanPtsRadius(self.tanGeom1, self.tanPt1, \
+ self.tanGeom2, self.tanPt2, self.radius)
+ if circle is not None:
+ geom = circle.asGeom(currLayer.wkbType())
+ if geom is not None:
+ self.centerPt = circle.center
+ self.radius = circle.radius
+ if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ else:
+ self.showMsg(QadMsg.translate("Command_CIRCLE", "\nThe circle doesn't exist."))
+ else:
+ self.showMsg(QadMsg.translate("Command_CIRCLE", "\nThe circle doesn't exist."))
+ return True # fine comando
+
+ # =========================================================================
+ # RISPOSTA ALLA RICHIESTA AREA DEL CERCHIO (da step = 2)
+ elif self.step == 13: # dopo aver atteso un numero si riavvia il comando
+ if msgMapTool == True: # il punto arriva da una selezione grafica
+ # la condizione seguente si verifica se durante la selezione di un punto
+ # é stato attivato un altro plugin che ha disattivato Qad
+ # quindi stato riattivato il comando che torna qui senza che il maptool
+ # abbia selezionato un punto
+ if self.getPointMapTool().point is None: # il maptool é stato attivato senza un punto
+ if self.getPointMapTool().rightButton != True: # se NON usato il tasto destro del mouse
+ self.setMapTool(self.getPointMapTool()) # riattivo il maptool
+ return False
+
+ value = self.getPointMapTool().point
+ else: # il punto arriva come parametro della funzione
+ value = msg
+
+ if type(value) == float: # è stata inserita l'area
+ self.area = value
+
+ circle = QadCircle().fromCenterArea(self.centerPt, self.area)
+ if circle is not None:
+ self.radius = circle.radius
+ self.plugIn.setLastRadius(self.radius)
+ geom = circle.asGeom(currLayer.wkbType())
+ if geom is not None:
+ if self.virtualCmd == False: # se si vuole veramente salvare il cerchio in un layer
+ qad_layer.addGeomToLayer(self.plugIn, currLayer, self.mapToLayerCoordinates(currLayer, geom))
+ return True # fine comando
+
+ self.isValidPreviousInput = False # per gestire il comando anche in macro
+ return False
diff --git a/qad_circle_maptool.py b/cmd/qad_circle_maptool.py
similarity index 84%
rename from qad_circle_maptool.py
rename to cmd/qad_circle_maptool.py
index 25b0cbe4..42d48f38 100644
--- a/qad_circle_maptool.py
+++ b/cmd/qad_circle_maptool.py
@@ -1,214 +1,208 @@
-# -*- coding: utf-8 -*-
-"""
-/***************************************************************************
- QAD Quantum Aided Design plugin
-
- classe per gestire il map tool di richiesta di un punto in ambito del comando cerchio
-
- -------------------
- begin : 2013-05-22
- copyright : iiiii
- email : hhhhh
- developers : bbbbb aaaaa ggggg
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-"""
-
-
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
-from qgis.core import *
-from qgis.gui import *
-import math
-
-
-import qad_utils
-from qad_snapper import *
-from qad_snappointsdisplaymanager import *
-from qad_variables import *
-from qad_getpoint import *
-from qad_circle import *
-from qad_rubberband import QadRubberBand
-
-
-#===============================================================================
-# Qad_circle_maptool_ModeEnum class.
-#===============================================================================
-class Qad_circle_maptool_ModeEnum():
- # noto niente si richiede il centro
- NONE_KNOWN_ASK_FOR_CENTER_PT = 1
- # noto il centro del cerchio si richiede il raggio
- CENTER_PT_KNOWN_ASK_FOR_RADIUS = 2
- # noto il centro del cerchio si richiede il diametro
- CENTER_PT_KNOWN_ASK_FOR_DIAM = 3
- # noto niente si richiede il primo punto
- NONE_KNOWN_ASK_FOR_FIRST_PT = 4
- # noto il primo punto si richiede il secondo punto
- FIRST_PT_KNOWN_ASK_FOR_SECOND_PT = 5
- # noto il primo e il secondo punto si richiede il terzo punto
- FIRST_SECOND_PT_KNOWN_ASK_FOR_THIRD_PT = 6
- # noto niente si richiede il primo punto di estremità diam
- NONE_KNOWN_ASK_FOR_FIRST_DIAM_PT = 7
- # noto il primo punto di estremità diam si richiede il secondo punto di estremità diam
- FIRST_DIAM_PT_KNOWN_ASK_FOR_SECOND_DIAM_PT = 8
- # noto niente si richiede l'entita del primo punto di tangenza
- NONE_KNOWN_ASK_FOR_FIRST_TAN = 9
- # nota l'entita del primo punto di tangenza si richiede quella del secondo punto di tangenza
- FIRST_TAN_KNOWN_ASK_FOR_SECOND_TAN = 10
- # note la prima e la seconda entita dei punti di tangenza si richiede il raggio
- FIRST_SECOND_TAN_KNOWN_ASK_FOR_RADIUS = 11
- # noto note la prima, la seconda entita dei punti di tangenza e il primo punto per misurare il raggio
- # si richiede il secondo punto per misurare il raggio
- FIRST_SECOND_TAN_FIRSTPTRADIUS_KNOWN_ASK_FOR_SECONDPTRADIUS = 12
-
-#===============================================================================
-# Qad_circle_maptool class
-#===============================================================================
-class Qad_circle_maptool(QadGetPoint):
-
- def __init__(self, plugIn):
- QadGetPoint.__init__(self, plugIn)
-
- self.centerPt = None
- self.radius = None
- self.firstPt = None
- self.secondPt = None
- self.firstDiamPt = None
- self.tan1 = None
- self.tan2 = None
- self.startPtForRadius = None
-
- self.__rubberBand = QadRubberBand(self.canvas, False)
- self.geomType = QGis.Polygon
-
- def setRubberBandColor(self, rubberBandBorderColor, rubberBandFillColor):
- if rubberBandBorderColor is not None:
- self.__rubberBand.setBorderColor(rubberBandBorderColor)
- if rubberBandFillColor is not None:
- self.__rubberBand.setFillColor(rubberBandFillColor)
-
- def hidePointMapToolMarkers(self):
- QadGetPoint.hidePointMapToolMarkers(self)
- self.__rubberBand.hide()
-
- def showPointMapToolMarkers(self):
- QadGetPoint.showPointMapToolMarkers(self)
- self.__rubberBand.show()
-
- def clear(self):
- QadGetPoint.clear(self)
- self.__rubberBand.reset()
- self.mode = None
-
-
- def canvasMoveEvent(self, event):
- QadGetPoint.canvasMoveEvent(self, event)
-
- self.__rubberBand.reset()
-
- result = False
- circle = QadCircle()
-
- # noto il centro del cerchio si richiede il raggio
- if self.mode == Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_RADIUS:
- radius = qad_utils.getDistance(self.centerPt, self.tmpPoint)
- circle.set(self.centerPt, radius)
- result = True
- # noto il centro del cerchio si richiede il diametro
- elif self.mode == Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_DIAM:
- diam = qad_utils.getDistance(self.centerPt, self.tmpPoint)
- result = circle.set(self.centerPt, diam / 2)
- result = True
- # noto il primo e il secondo punto si richiede il terzo punto
- elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_SECOND_PT_KNOWN_ASK_FOR_THIRD_PT:
- if (self.firstPt is not None) and (self.secondPt is not None):
- result = circle.from3Pts(self.firstPt, self.secondPt, self.tmpPoint)
- # noto il primo punto di estremità diam si richiede il secondo punto di estremità diam
- elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_DIAM_PT_KNOWN_ASK_FOR_SECOND_DIAM_PT:
- if self.firstDiamPt is not None:
- result = circle.fromDiamEnds(self.firstDiamPt, self.tmpPoint)
- # noto note la prima, la seconda entita dei punti di tangenza e il primo punto per misurare il raggio
- # si richiede il secondo punto per misurare il raggio
- elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_SECOND_TAN_FIRSTPTRADIUS_KNOWN_ASK_FOR_SECONDPTRADIUS:
- radius = qad_utils.getDistance(self.startPtForRadius, self.tmpPoint)
- result = circle.from2TanPtsRadius(self.tanGeom1, self.tanPt1, \
- self.tanGeom2, self.tanPt2, radius)
-
- if result == True:
- points = circle.asPolyline()
-
- if points is not None:
- if self.geomType == QGis.Polygon:
- self.__rubberBand.setPolygon(points)
- else:
- self.__rubberBand.setLine(points)
-
-
- def activate(self):
- QadGetPoint.activate(self)
- self.__rubberBand.show()
-
-
- def deactivate(self):
- try: # necessario perché se si chiude QGIS parte questo evento nonostante non ci sia più l'oggetto maptool !
- QadGetPoint.deactivate(self)
- self.__rubberBand.hide()
- except:
- pass
-
- def setMode(self, mode):
- self.mode = mode
- # noto niente si richiede il centro
- if self.mode == Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_CENTER_PT:
- self.setDrawMode(QadGetPointDrawModeEnum.NONE)
- # noto il centro del cerchio si richiede il raggio
- elif self.mode == Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_RADIUS:
- self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
- self.setStartPoint(self.centerPt)
- # noto il centro del cerchio si richiede il diametro
- elif self.mode == Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_DIAM:
- self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
- self.setStartPoint(self.centerPt)
- # noto niente si richiede il primo punto
- elif self.mode == Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_PT:
- self.setDrawMode(QadGetPointDrawModeEnum.NONE)
- # noto il primo punto si richiede il secondo punto
- elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_PT_KNOWN_ASK_FOR_SECOND_PT:
- self.setDrawMode(QadGetPointDrawModeEnum.NONE)
- # noto il primo e il secondo punto si richiede il terzo punto
- elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_SECOND_PT_KNOWN_ASK_FOR_THIRD_PT:
- self.setDrawMode(QadGetPointDrawModeEnum.NONE)
- # noto niente si richiede il primo punto di estremità diam
- elif self.mode == Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_DIAM_PT:
- self.setDrawMode(QadGetPointDrawModeEnum.NONE)
- # noto il primo punto di estremità diam si richiede il secondo punto di estremità diam
- elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_DIAM_PT_KNOWN_ASK_FOR_SECOND_DIAM_PT:
- self.setDrawMode(QadGetPointDrawModeEnum.NONE)
- # noto niente si richiede l'entita del primo punto di tangenza
- elif self.mode == Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_TAN:
- self.setDrawMode(QadGetPointDrawModeEnum.NONE)
- self.setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION)
- self.forceSnapTypeOnce(QadSnapTypeEnum.TAN_DEF)
- # nota l'entita del primo punto di tangenza si richiede quella del secondo punto di tangenza
- elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_TAN_KNOWN_ASK_FOR_SECOND_TAN:
- self.setDrawMode(QadGetPointDrawModeEnum.NONE)
- self.setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION)
- self.forceSnapTypeOnce(QadSnapTypeEnum.TAN_DEF)
- # note la prima e la seconda entita dei punti di tangenza si richiede il raggio
- elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_SECOND_TAN_KNOWN_ASK_FOR_RADIUS:
- self.setDrawMode(QadGetPointDrawModeEnum.NONE)
- # siccome il puntatore era stato variato in ENTITY_SELECTION dalla selez precedente
- self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION)
- # noto note la prima, la seconda entita dei punti di tangenza e il primo punto per misurare il raggio
- # si richiede il secondo punto per misurare il raggio
- elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_SECOND_TAN_FIRSTPTRADIUS_KNOWN_ASK_FOR_SECONDPTRADIUS:
- self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
- self.setStartPoint(self.startPtForRadius)
+# -*- coding: utf-8 -*-
+"""
+/***************************************************************************
+ QAD Quantum Aided Design plugin
+
+ classe per gestire il map tool di richiesta di un punto in ambito del comando cerchio
+
+ -------------------
+ begin : 2013-05-22
+ copyright : iiiii
+ email : hhhhh
+ developers : bbbbb aaaaa ggggg
+ ***************************************************************************/
+
+/***************************************************************************
+ * *
+ * 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. *
+ * *
+ ***************************************************************************/
+"""
+
+
+from qgis.core import QgsWkbTypes
+
+
+from .. import qad_utils
+from ..qad_getpoint import QadGetPoint, QadGetPointDrawModeEnum, QadGetPointSelectionModeEnum
+from ..qad_circle import QadCircle
+from ..qad_circle_fun import *
+from ..qad_rubberband import QadRubberBand
+from ..qad_snapper import QadSnapTypeEnum
+
+
+# ===============================================================================
+# Qad_circle_maptool_ModeEnum class.
+# ===============================================================================
+class Qad_circle_maptool_ModeEnum():
+ # noto niente si richiede il centro
+ NONE_KNOWN_ASK_FOR_CENTER_PT = 1
+ # noto il centro del cerchio si richiede il raggio
+ CENTER_PT_KNOWN_ASK_FOR_RADIUS = 2
+ # noto il centro del cerchio si richiede il diametro
+ CENTER_PT_KNOWN_ASK_FOR_DIAM = 3
+ # noto niente si richiede il primo punto
+ NONE_KNOWN_ASK_FOR_FIRST_PT = 4
+ # noto il primo punto si richiede il secondo punto
+ FIRST_PT_KNOWN_ASK_FOR_SECOND_PT = 5
+ # noto il primo e il secondo punto si richiede il terzo punto
+ FIRST_SECOND_PT_KNOWN_ASK_FOR_THIRD_PT = 6
+ # noto niente si richiede il primo punto di estremità diam
+ NONE_KNOWN_ASK_FOR_FIRST_DIAM_PT = 7
+ # noto il primo punto di estremità diam si richiede il secondo punto di estremità diam
+ FIRST_DIAM_PT_KNOWN_ASK_FOR_SECOND_DIAM_PT = 8
+ # noto niente si richiede l'entita del primo punto di tangenza
+ NONE_KNOWN_ASK_FOR_FIRST_TAN = 9
+ # nota l'entita del primo punto di tangenza si richiede quella del secondo punto di tangenza
+ FIRST_TAN_KNOWN_ASK_FOR_SECOND_TAN = 10
+ # note la prima e la seconda entita dei punti di tangenza si richiede il raggio
+ FIRST_SECOND_TAN_KNOWN_ASK_FOR_RADIUS = 11
+ # noto note la prima, la seconda entita dei punti di tangenza e il primo punto per misurare il raggio
+ # si richiede il secondo punto per misurare il raggio
+ FIRST_SECOND_TAN_FIRSTPTRADIUS_KNOWN_ASK_FOR_SECONDPTRADIUS = 12
+
+# ===============================================================================
+# Qad_circle_maptool class
+# ===============================================================================
+class Qad_circle_maptool(QadGetPoint):
+
+ def __init__(self, plugIn):
+ QadGetPoint.__init__(self, plugIn)
+
+ self.centerPt = None
+ self.radius = None
+ self.firstPt = None
+ self.secondPt = None
+ self.firstDiamPt = None
+ self.tan1 = None
+ self.tan2 = None
+ self.startPtForRadius = None
+
+ self.__rubberBand = QadRubberBand(self.canvas, False)
+ self.layer = None
+ self.mode = None
+
+
+ def setRubberBandColor(self, rubberBandBorderColor, rubberBandFillColor):
+ if rubberBandBorderColor is not None:
+ self.__rubberBand.setBorderColor(rubberBandBorderColor)
+ if rubberBandFillColor is not None:
+ self.__rubberBand.setFillColor(rubberBandFillColor)
+
+ def hidePointMapToolMarkers(self):
+ QadGetPoint.hidePointMapToolMarkers(self)
+ self.__rubberBand.hide()
+
+ def showPointMapToolMarkers(self):
+ QadGetPoint.showPointMapToolMarkers(self)
+ self.__rubberBand.show()
+
+ def clear(self):
+ QadGetPoint.clear(self)
+ self.__rubberBand.reset()
+ self.mode = None
+
+
+ def canvasMoveEvent(self, event):
+ QadGetPoint.canvasMoveEvent(self, event)
+
+ self.__rubberBand.reset()
+
+ circle = None
+
+ # noto il centro del cerchio si richiede il raggio
+ if self.mode == Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_RADIUS:
+ radius = qad_utils.getDistance(self.centerPt, self.tmpPoint)
+ circle = QadCircle().set(self.centerPt, radius)
+ # noto il centro del cerchio si richiede il diametro
+ elif self.mode == Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_DIAM:
+ diam = qad_utils.getDistance(self.centerPt, self.tmpPoint)
+ circle = QadCircle().set(self.centerPt, diam / 2)
+ # noto il primo e il secondo punto si richiede il terzo punto
+ elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_SECOND_PT_KNOWN_ASK_FOR_THIRD_PT:
+ if (self.firstPt is not None) and (self.secondPt is not None):
+ circle = circleFrom3Pts(self.firstPt, self.secondPt, self.tmpPoint)
+ # noto il primo punto di estremità diam si richiede il secondo punto di estremità diam
+ elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_DIAM_PT_KNOWN_ASK_FOR_SECOND_DIAM_PT:
+ if self.firstDiamPt is not None:
+ circle = QadCircle().fromDiamEnds(self.firstDiamPt, self.tmpPoint)
+ # noto note la prima, la seconda entita dei punti di tangenza e il primo punto per misurare il raggio
+ # si richiede il secondo punto per misurare il raggio
+ elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_SECOND_TAN_FIRSTPTRADIUS_KNOWN_ASK_FOR_SECONDPTRADIUS:
+ radius = qad_utils.getDistance(self.startPtForRadius, self.tmpPoint)
+ circle = circleFrom2TanPtsRadius(self.tanGeom1, self.tanPt1, \
+ self.tanGeom2, self.tanPt2, radius)
+
+ if circle is not None:
+ if self.layer is not None:
+ g = circle.asGeom(self.layer.wkbType())
+ else:
+ g = circle.asGeom(QgsWkbTypes.CompoundCurve) # è un cerchio virtuale che non verrà salvato da questo comando
+
+ if g is not None:
+ self.__rubberBand.setGeometry(g)
+
+
+ def activate(self):
+ QadGetPoint.activate(self)
+ self.__rubberBand.show()
+
+
+ def deactivate(self):
+ try: # necessario perché se si chiude QGIS parte questo evento nonostante non ci sia più l'oggetto maptool !
+ QadGetPoint.deactivate(self)
+ self.__rubberBand.hide()
+ except:
+ pass
+
+ def setMode(self, mode):
+ self.mode = mode
+ # noto niente si richiede il centro
+ if self.mode == Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_CENTER_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # noto il centro del cerchio si richiede il raggio
+ elif self.mode == Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_RADIUS:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.centerPt)
+ # noto il centro del cerchio si richiede il diametro
+ elif self.mode == Qad_circle_maptool_ModeEnum.CENTER_PT_KNOWN_ASK_FOR_DIAM:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.centerPt)
+ # noto niente si richiede il primo punto
+ elif self.mode == Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # noto il primo punto si richiede il secondo punto
+ elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_PT_KNOWN_ASK_FOR_SECOND_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # noto il primo e il secondo punto si richiede il terzo punto
+ elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_SECOND_PT_KNOWN_ASK_FOR_THIRD_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # noto niente si richiede il primo punto di estremità diam
+ elif self.mode == Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_DIAM_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # noto il primo punto di estremità diam si richiede il secondo punto di estremità diam
+ elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_DIAM_PT_KNOWN_ASK_FOR_SECOND_DIAM_PT:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # noto niente si richiede l'entita del primo punto di tangenza
+ elif self.mode == Qad_circle_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_FIRST_TAN:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ self.setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION)
+ self.forceSnapTypeOnce(QadSnapTypeEnum.TAN_DEF)
+ # nota l'entita del primo punto di tangenza si richiede quella del secondo punto di tangenza
+ elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_TAN_KNOWN_ASK_FOR_SECOND_TAN:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ self.setSelectionMode(QadGetPointSelectionModeEnum.ENTITY_SELECTION)
+ self.forceSnapTypeOnce(QadSnapTypeEnum.TAN_DEF)
+ # note la prima e la seconda entita dei punti di tangenza si richiede il raggio
+ elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_SECOND_TAN_KNOWN_ASK_FOR_RADIUS:
+ self.setDrawMode(QadGetPointDrawModeEnum.NONE)
+ # siccome il puntatore era stato variato in ENTITY_SELECTION dalla selez precedente
+ self.setSelectionMode(QadGetPointSelectionModeEnum.POINT_SELECTION)
+ # noto note la prima, la seconda entita dei punti di tangenza e il primo punto per misurare il raggio
+ # si richiede il secondo punto per misurare il raggio
+ elif self.mode == Qad_circle_maptool_ModeEnum.FIRST_SECOND_TAN_FIRSTPTRADIUS_KNOWN_ASK_FOR_SECONDPTRADIUS:
+ self.setDrawMode(QadGetPointDrawModeEnum.ELASTIC_LINE)
+ self.setStartPoint(self.startPtForRadius)
diff --git a/qad_copy_cmd.py b/cmd/qad_copy_cmd.py
similarity index 76%
rename from qad_copy_cmd.py
rename to cmd/qad_copy_cmd.py
index 73d9d67e..f3d9becb 100644
--- a/qad_copy_cmd.py
+++ b/cmd/qad_copy_cmd.py
@@ -1,552 +1,555 @@
-# -*- coding: utf-8 -*-
-"""
-/***************************************************************************
- QAD Quantum Aided Design plugin
-
- comando COPY per copiare oggetti
-
- -------------------
- begin : 2013-10-02
- copyright : iiiii
- email : hhhhh
- developers : bbbbb aaaaa ggggg
- ***************************************************************************/
-
-/***************************************************************************
- * *
- * 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. *
- * *
- ***************************************************************************/
-"""
-
-
-# Import the PyQt and QGIS libraries
-from PyQt4.QtCore import *
-from PyQt4.QtGui import *
-from qgis.core import *
-
-
-from qad_copy_maptool import *
-from qad_generic_cmd import QadCommandClass
-from qad_msg import QadMsg
-from qad_getpoint import *
-from qad_textwindow import *
-from qad_ssget_cmd import QadSSGetClass
-from qad_entity import *
-from qad_variables import *
-import qad_utils
-import qad_layer
-from qad_dim import *
-
-
-# Classe che gestisce il comando COPY
-class QadCOPYCommandClass(QadCommandClass):
-
- def instantiateNewCmd(self):
- """ istanzia un nuovo comando dello stesso tipo """
- return QadCOPYCommandClass(self.plugIn)
-
- def getName(self):
- return QadMsg.translate("Command_list", "COPY")
-
- def getEnglishName(self):
- return "COPY"
-
- def connectQAction(self, action):
- QObject.connect(action, SIGNAL("triggered()"), self.plugIn.runCOPYCommand)
-
- def getIcon(self):
- return QIcon(":/plugins/qad/icons/copyEnt.png")
-
- def getNote(self):
- # impostare le note esplicative del comando
- return QadMsg.translate("Command_COPY", "Copies selected objects a specified distance in a specified direction.")
-
- def __init__(self, plugIn):
- QadCommandClass.__init__(self, plugIn)
- self.SSGetClass = QadSSGetClass(plugIn)
- self.SSGetClass.onlyEditableLayers = True
- self.entitySet = QadEntitySet()
- self.basePt = QgsPoint()
- self.series = False
- self.seriesLen = 2
- self.adjust = False
- self.copyMode = QadVariables.get(QadMsg.translate("Environment variables", "COPYMODE"))
-
- self.featureCache = [] # lista di (layer, feature)
- self.nOperationsToUndo = 0
-
- def __del__(self):
- QadCommandClass.__del__(self)
- del self.SSGetClass
-
- def getPointMapTool(self, drawMode = QadGetPointDrawModeEnum.NONE):
- if self.step == 0: # quando si é in fase di selezione entità
- return self.SSGetClass.getPointMapTool()
- else:
- if (self.plugIn is not None):
- if self.PointMapTool is None:
- self.PointMapTool = Qad_copy_maptool(self.plugIn)
- return self.PointMapTool
- else:
- return None
-
-
- #============================================================================
- # move
- #============================================================================
- def move(self, f, offSetX, offSetY, layerEntitySet, entitySet, dimEntity):
- if dimEntity is None:
- # sposto la feature e la rimuovo da entitySet (é la prima)
- f.setGeometry(qad_utils.moveQgsGeometry(f.geometry(), offSetX, offSetY))
- # plugIn, layer, feature, coordTransform, refresh, check_validity
- if qad_layer.addFeatureToLayer(self.plugIn, layerEntitySet.layer, f, None, False, False) == False:
- return False
- else:
- # sposto la quota
- dimEntity.move(offSetX, offSetY)
- if dimEntity.addToLayers(self.plugIn) == False:
- return False
-
- return True
-
-
- #============================================================================
- # copyGeoms
- #============================================================================
- def copyGeoms(self, newPt):
- # copio entitySet
- entitySet = QadEntitySet(self.entitySet)
-
- self.plugIn.beginEditCommand("Feature copied", entitySet.getLayerList())
-
- for layerEntitySet in entitySet.layerEntitySetList:
- layer = layerEntitySet.layer
-
- transformedBasePt = self.mapToLayerCoordinates(layer, self.basePt)
- transformedNewPt = self.mapToLayerCoordinates(layer, newPt)
- offSetX = transformedNewPt.x() - transformedBasePt.x()
- offSetY = transformedNewPt.y() - transformedBasePt.y()
-
- while len(layerEntitySet.featureIds) > 0:
- featureId = layerEntitySet.featureIds[0]
- f = layerEntitySet.getFeature(featureId)
- if f is None:
- del layerEntitySet.featureIds[0]
- continue
-
- # verifico se l'entità appartiene ad uno stile di quotatura
- dimEntity = QadDimStyles.getDimEntity(layerEntitySet.layer, f.id())
-
- if self.series and self.seriesLen > 0: # devo fare una serie
- if self.adjust == True:
- offSetX = offSetX / (self.seriesLen - 1)
- offSetY = offSetY / (self.seriesLen - 1)
-
- deltaX = offSetX
- deltaY = offSetY
-
- for i in xrange(1, self.seriesLen, 1):
- if self.move(f, deltaX, deltaY, layerEntitySet, entitySet, dimEntity) == False:
- self.plugIn.destroyEditCommand()
- return
- deltaX = deltaX + offSetX
- deltaY = deltaY + offSetY
- else:
- if self.move(f, offSetX, offSetY, layerEntitySet, entitySet, dimEntity) == False:
- self.plugIn.destroyEditCommand()
- return
-
- # la rimuovo da entitySet
- if dimEntity is None:
- del layerEntitySet.featureIds[0]
- else:
- dimEntitySet = dimEntity.getEntitySet()
- entitySet.subtract(dimEntitySet)
-
- self.plugIn.endEditCommand()
- self.nOperationsToUndo = self.nOperationsToUndo + 1
-
-
- #============================================================================
- # waitForBasePt
- #============================================================================
- def waitForBasePt(self):
- # imposto il map tool
- self.getPointMapTool().setMode(Qad_copy_maptool_ModeEnum.NONE_KNOWN_ASK_FOR_BASE_PT)
-
- if self.copyMode == 0: # Imposta il comando COPIA in modo che venga ripetuto automaticamente
- keyWords = QadMsg.translate("Command_COPY", "Displacement") + "/" + \
- QadMsg.translate("Command_COPY", "mOde")
- englishKeyWords = "Displacement" + "/" + "mOde"
-
- else:
- # l'opzione Multiple viene tradotta in italiano in "MUltiplo" nel contesto "waitForBasePt"
- # l'opzione Multiple viene tradotta in italiano in "Multipla" nel contesto "waitForMode"
- # e "Multipla" nel caso di modalità di copia
- keyWords = QadMsg.translate("Command_COPY", "Displacement") + "/" + \
- QadMsg.translate("Command_COPY", "mOde") + "/" + \
- QadMsg.translate("Command_COPY", "Multiple", "waitForBasePt")
- englishKeyWords = "Displacement" + "/" + "mOde" + "/" + "Multiple"
-
- default = QadMsg.translate("Command_COPY", "Displacement")
- prompt = QadMsg.translate("Command_COPY", "Specify base point or [{0}] <{1}>: ").format(keyWords, default)
-
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o enter o una parola chiave
- # msg, inputType, default, keyWords, nessun controllo
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
- default, \
- keyWords, QadInputModeEnum.NONE)
- self.step = 2
-
- #============================================================================
- # waitForSeries
- #============================================================================
- def waitForSeries(self):
- # si appresta ad attendere un numero intero
- msg = QadMsg.translate("Command_COPY", "Number of Items to Array <{0}>: ")
- # msg, inputType, default, keyWords, valori positivi
- self.waitFor(msg.format(str(self.seriesLen)), \
- QadInputTypeEnum.INT, \
- self.seriesLen, \
- "", \
- QadInputModeEnum.NOT_ZERO | QadInputModeEnum.NOT_NEGATIVE)
- self.step = 6
-
- #============================================================================
- # waitForSecondPt
- #============================================================================
- def waitForSecondPt(self):
- self.series = False
- self.adjust = False
- self.getPointMapTool().seriesLen = 0
- self.getPointMapTool().setMode(Qad_copy_maptool_ModeEnum.BASE_PT_KNOWN_ASK_FOR_COPY_PT)
-
- if len(self.featureCache) > 0:
- keyWords = QadMsg.translate("Command_COPY", "Array") + "/" + \
- QadMsg.translate("Command_COPY", "Exit") + "/" + \
- QadMsg.translate("Command_COPY", "Undo")
- default = QadMsg.translate("Command_COPY", "Exit")
- prompt = QadMsg.translate("Command_COPY", "Specify second point or [{0}] <{1}>: ").format(keyWords, default)
-
- englishKeyWords = "Array" + "/" + "Exit" + "/" + "Undo" + "/" + "Exit"
- keyWords += "_" + englishKeyWords
- # si appresta ad attendere un punto o enter o una parola chiave
- # msg, inputType, default, keyWords, nessun controllo
- self.waitFor(prompt, \
- QadInputTypeEnum.POINT2D | QadInputTypeEnum.KEYWORDS, \
- default, \
- keyWords, QadInputModeEnum.NONE)
- else:
- keyWords = QadMsg.translate("Command_COPY", "Array")
- prompt = QadMsg.translate("Command_COPY", "Specify second point or [{0}]