diff --git a/Build.PL b/Build.PL
index d5f7344cfe..b7df2b1925 100644
--- a/Build.PL
+++ b/Build.PL
@@ -10,6 +10,7 @@ my %prereqs = qw(
Devel::CheckLib 0
Encode 0
Encode::Locale 1.05
+ ExtUtils::CppGuess 0
ExtUtils::MakeMaker 6.80
ExtUtils::ParseXS 3.22
File::Basename 0
@@ -128,7 +129,7 @@ EOF
# temporary workaround for upstream bug in test
push @cmd, '--notest'
- if $module =~ /^(?:OpenGL|Math::PlanePath|Test::Harness)$/;
+ if $module =~ /^(?:OpenGL|Math::PlanePath|Test::Harness|IO::Scalar)$/;
push @cmd, "$module~$version";
my $res = system @cmd;
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000000..dba13ed2dd
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,661 @@
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 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 Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+our General Public Licenses are 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.
+
+ 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.
+
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+ 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 Affero 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. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+ 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 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 work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero 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 Affero 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 Affero 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 Affero 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 Affero 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 Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see .
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+ 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 AGPL, see
+.
diff --git a/README.md b/README.md
index 5d7d70eb09..af047f7623 100644
--- a/README.md
+++ b/README.md
@@ -5,7 +5,7 @@ A: Yes.
Slic3r [](https://travis-ci.org/alexrj/Slic3r) [](https://ci.appveyor.com/project/lordofhyphens/slic3r) [](http://osx-build.slic3r.org:8080/job/Slic3r)
======
Prebuilt Windows (64-bit) and OSX (>10.7) builds:
-* https://bintray.com/lordofhyphens/Slic3r/slic3r_dev/view (from build server)
+* http://dl.slic3r.org/dev/
diff --git a/lib/Slic3r.pm b/lib/Slic3r.pm
index 294b623ecc..ca09d71f90 100644
--- a/lib/Slic3r.pm
+++ b/lib/Slic3r.pm
@@ -56,7 +56,6 @@ use Slic3r::GCode::ArcFitting;
use Slic3r::GCode::MotionPlanner;
use Slic3r::GCode::PressureRegulator;
use Slic3r::GCode::Reader;
-use Slic3r::GCode::SpiralVase;
use Slic3r::GCode::VibrationLimit;
use Slic3r::Geometry qw(PI);
use Slic3r::Geometry::Clipper;
diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm
index 72f28c8bbf..7ccca6a974 100644
--- a/lib/Slic3r/Config.pm
+++ b/lib/Slic3r/Config.pm
@@ -8,12 +8,6 @@ use utf8;
use List::Util qw(first max);
-# cemetery of old config settings
-our @Ignore = qw(duplicate_x duplicate_y multiply_x multiply_y support_material_tool acceleration
- adjust_overhang_flow standby_temperature scale rotate duplicate duplicate_grid
- rotate scale duplicate_grid start_perimeters_at_concave_points start_perimeters_at_non_overhang
- randomize_start seal_position bed_size print_center g0);
-
# C++ Slic3r::PrintConfigDef exported as a Perl hash of hashes.
# The C++ counterpart is a constant singleton.
our $Options = print_config_def();
@@ -119,11 +113,7 @@ sub load_ini_hash {
my ($ini_hash) = @_;
my $config = $class->new;
- foreach my $opt_key (keys %$ini_hash) {
- ($opt_key, my $value) = _handle_legacy($opt_key, $ini_hash->{$opt_key});
- next if !defined $opt_key;
- $config->set_deserialize($opt_key, $value);
- }
+ $config->set_deserialize($_, $ini_hash->{$_}) for keys %$ini_hash;
return $config;
}
@@ -144,60 +134,6 @@ sub get_value {
: $self->get($opt_key);
}
-sub _handle_legacy {
- my ($opt_key, $value) = @_;
-
- # handle legacy options
- if ($opt_key =~ /^(extrusion_width|bottom_layer_speed|first_layer_height)_ratio$/) {
- $opt_key = $1;
- $opt_key =~ s/^bottom_layer_speed$/first_layer_speed/;
- $value = $value =~ /^\d+(?:\.\d+)?$/ && $value != 0 ? ($value*100) . "%" : 0;
- }
- if ($opt_key eq 'threads' && !$Slic3r::have_threads) {
- $value = 1;
- }
- if ($opt_key eq 'gcode_flavor' && $value eq 'makerbot') {
- $value = 'makerware';
- }
- if ($opt_key eq 'fill_density' && defined($value) && $value !~ /%/ && $value <= 1) {
- # fill_density was turned into a percent value
- $value *= 100;
- $value = "$value"; # force update of the PV value, workaround for bug https://rt.cpan.org/Ticket/Display.html?id=94110
- }
- if ($opt_key eq 'randomize_start' && $value) {
- $opt_key = 'seam_position';
- $value = 'random';
- }
- if ($opt_key eq 'bed_size' && $value) {
- $opt_key = 'bed_shape';
- my ($x, $y) = split /,/, $value;
- $value = "0x0,${x}x0,${x}x${y},0x${y}";
- }
- return () if first { $_ eq $opt_key } @Ignore;
-
- # For historical reasons, the world's full of configs having these very low values;
- # to avoid unexpected behavior we need to ignore them. Banning these two hard-coded
- # values is a dirty hack and will need to be removed sometime in the future, but it
- # will avoid lots of complaints for now.
- if ($opt_key eq 'perimeter_acceleration' && $value == '25') {
- $value = 0;
- }
- if ($opt_key eq 'infill_acceleration' && $value == '50') {
- $value = 0;
- }
-
- if (!exists $Options->{$opt_key}) {
- my @keys = grep { $Options->{$_}{aliases} && grep $_ eq $opt_key, @{$Options->{$_}{aliases}} } keys %$Options;
- if (!@keys) {
- warn "Unknown option $opt_key\n";
- return ();
- }
- $opt_key = $keys[0];
- }
-
- return ($opt_key, $value);
-}
-
# Create a hash of hashes from the underlying C++ Slic3r::DynamicPrintConfig.
# The first hash key is '_' meaning no category.
sub as_ini {
diff --git a/lib/Slic3r/GCode/SpiralVase.pm b/lib/Slic3r/GCode/SpiralVase.pm
deleted file mode 100644
index 837e33d16f..0000000000
--- a/lib/Slic3r/GCode/SpiralVase.pm
+++ /dev/null
@@ -1,86 +0,0 @@
-package Slic3r::GCode::SpiralVase;
-use Moo;
-
-has 'config' => (is => 'ro', required => 1);
-has 'enable' => (is => 'rw', default => sub { 0 });
-has 'reader' => (is => 'ro', default => sub { Slic3r::GCode::Reader->new });
-
-use Slic3r::Geometry qw(unscale);
-
-sub BUILD {
- my ($self) = @_;
- $self->reader->apply_print_config($self->config);
-}
-
-sub process_layer {
- my $self = shift;
- my ($gcode) = @_;
-
- # This post-processor relies on several assumptions:
- # - all layers are processed through it, including those that are not supposed
- # to be transformed, in order to update the reader with the XY positions
- # - each call to this method includes a full layer, with a single Z move
- # at the beginning
- # - each layer is composed by suitable geometry (i.e. a single complete loop)
- # - loops were not clipped before calling this method
-
- # if we're not going to modify G-code, just feed it to the reader
- # in order to update positions
- if (!$self->enable) {
- $self->reader->parse($gcode, sub {});
- return $gcode;
- }
-
- # get total XY length for this layer by summing all extrusion moves
- my $total_layer_length = 0;
- my $layer_height = 0;
- my $z = undef;
- $self->reader->clone->parse($gcode, sub {
- my ($reader, $cmd, $args, $info) = @_;
-
- if ($cmd eq 'G1') {
- if ($info->{extruding}) {
- $total_layer_length += $info->{dist_XY};
- } elsif (exists $args->{Z}) {
- $layer_height += $info->{dist_Z};
- $z //= $args->{Z};
- }
- }
- });
-
- #use XXX; XXX [ $gcode, $layer_height, $z, $total_layer_length ];
- # remove layer height from initial Z
- $z -= $layer_height;
-
- my $new_gcode = "";
- $self->reader->parse($gcode, sub {
- my ($reader, $cmd, $args, $info) = @_;
-
- if ($cmd eq 'G1' && exists $args->{Z}) {
- # if this is the initial Z move of the layer, replace it with a
- # (redundant) move to the last Z of previous layer
- my $line = $info->{raw};
- $line =~ s/ Z[.0-9]+/ Z$z/;
- $new_gcode .= "$line\n";
- } elsif ($cmd eq 'G1' && !exists($args->{Z}) && $info->{dist_XY}) {
- # horizontal move
- my $line = $info->{raw};
- if ($info->{extruding}) {
- $z += $info->{dist_XY} * $layer_height / $total_layer_length;
- $line =~ s/^G1 /sprintf 'G1 Z%.3f ', $z/e;
- $new_gcode .= "$line\n";
- }
- # skip travel moves: the move to first perimeter point will
- # cause a visible seam when loops are not aligned in XY; by skipping
- # it we blend the first loop move in the XY plane (although the smoothness
- # of such blend depend on how long the first segment is; maybe we should
- # enforce some minimum length?)
- } else {
- $new_gcode .= "$info->{raw}\n";
- }
- });
-
- return $new_gcode;
-}
-
-1;
diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm
index 0624e8883d..7fe1e4133a 100644
--- a/lib/Slic3r/GUI.pm
+++ b/lib/Slic3r/GUI.pm
@@ -54,11 +54,14 @@ use constant FILE_WILDCARDS => {
svg => 'SVG files *.svg|*.svg;*.SVG',
};
use constant MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(known stl obj amf)};
+use constant STL_MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(stl)};
+use constant AMF_MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(amf)};
our $datadir;
# If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
our $no_controller;
our $autosave;
+our $threads;
our @cb;
our $Settings = {
@@ -69,6 +72,8 @@ our $Settings = {
background_processing => 0,
# If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
no_controller => 0,
+ threads => $Slic3r::Config::Options->{threads}{default},
+ color_toolpaths_by => 'role',
},
};
@@ -119,16 +124,16 @@ sub OnInit {
my $last_version;
if (-f "$enc_datadir/slic3r.ini") {
my $ini = eval { Slic3r::Config->read_ini("$datadir/slic3r.ini") };
- $Settings = $ini if $ini;
- $last_version = $Settings->{_}{version};
+ if ($ini) {
+ $last_version = $ini->{_}{version};
+ $ini->{_}{$_} = $Settings->{_}{$_}
+ for grep !exists $ini->{_}{$_}, keys %{$Settings->{_}};
+ $Settings = $ini;
+ }
delete $Settings->{_}{mode}; # handle legacy
- $Settings->{_}{autocenter} //= 1;
- $Settings->{_}{invert_zoom} //= 0;
- $Settings->{_}{background_processing} //= 1;
- # If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
- $Settings->{_}{no_controller} //= 1;
}
$Settings->{_}{version} = $Slic3r::VERSION;
+ $Settings->{_}{threads} = $threads if $threads;
$self->save_settings;
if (-f "$enc_datadir/simple.ini") {
@@ -325,7 +330,7 @@ sub have_version_check {
my ($self) = @_;
# return an explicit 0
- return ($Slic3r::have_threads && $Slic3r::build && $have_LWP) || 0;
+ return ($Slic3r::have_threads && $Slic3r::VERSION !~ /-dev$/ && $have_LWP) || 0;
}
sub check_version {
diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm
index 0e6ba3c8f8..7c9ae2deeb 100644
--- a/lib/Slic3r/GUI/3DScene.pm
+++ b/lib/Slic3r/GUI/3DScene.pm
@@ -50,7 +50,7 @@ use constant PI => 3.1415927;
# Constant to determine if Vertex Buffer objects are used to draw
# bed grid and the cut plane for object separation.
-use constant HAS_VBO => 1;
+use constant HAS_VBO => eval { glGenBuffersARB_p(0); 1 };
# phi / theta angles to orient the camera.
@@ -748,10 +748,10 @@ sub InitGL {
# Enables Smooth Color Shading; try GL_FLAT for (lack of) fun.
glShadeModel(GL_SMOOTH);
- glMaterialfv_p(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, 0.5, 0.3, 0.3, 1);
+ glMaterialfv_p(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, 0.3, 0.3, 0.3, 1);
glMaterialfv_p(GL_FRONT_AND_BACK, GL_SPECULAR, 1, 1, 1, 1);
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50);
- glMaterialfv_p(GL_FRONT_AND_BACK, GL_EMISSION, 0.1, 0, 0, 0.9);
+ glMaterialfv_p(GL_FRONT_AND_BACK, GL_EMISSION, 0.1, 0.1, 0.1, 0.9);
# A handy trick -- have surface material mirror the color.
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
@@ -1152,21 +1152,25 @@ use List::Util qw(first min max);
use Slic3r::Geometry qw(scale unscale epsilon);
use Slic3r::Print::State ':steps';
-use constant COLORS => [ [1,1,0,1], [1,0.5,0.5,1], [0.5,1,0.5,1], [0.5,0.5,1,1] ];
-
__PACKAGE__->mk_accessors(qw(
+ colors
color_by
+ color_toolpaths_by
select_by
drag_by
volumes_by_object
_objects_by_volumes
));
+sub default_colors { [1,0.95,0.2,1], [1,0.45,0.45,1], [0.5,1,0.5,1], [0.5,0.5,1,1] }
+
sub new {
my $class = shift;
my $self = $class->SUPER::new(@_);
+ $self->colors([ $self->default_colors ]);
$self->color_by('volume'); # object | volume
+ $self->color_toolpaths_by('role'); # role | extruder
$self->select_by('object'); # object | volume | instance
$self->drag_by('instance'); # object | instance
$self->volumes_by_object({}); # obj_idx => [ volume_idx, volume_idx ... ]
@@ -1204,7 +1208,7 @@ sub load_object {
$color_idx = $obj_idx;
}
- my $color = [ @{COLORS->[ $color_idx % scalar(@{&COLORS}) ]} ];
+ my $color = [ @{$self->colors->[ $color_idx % scalar(@{$self->colors}) ]} ];
$color->[3] = $volume->modifier ? 0.5 : 1;
push @{$self->volumes}, my $v = Slic3r::GUI::3DScene::Volume->new(
bounding_box => $mesh->bounding_box,
@@ -1281,7 +1285,7 @@ sub load_print_object_slices {
push @{$self->volumes}, my $v = Slic3r::GUI::3DScene::Volume->new(
bounding_box => $bb,
- color => COLORS->[0],
+ color => $self->colors->[0],
verts => OpenGL::Array->new_list(GL_FLOAT, @verts),
norms => OpenGL::Array->new_list(GL_FLOAT, @norms),
quad_verts => OpenGL::Array->new_list(GL_FLOAT, @quad_verts),
@@ -1299,66 +1303,75 @@ sub load_print_toolpaths {
&& $print->config->interior_brim_width == 0
&& $print->config->brim_connections_width == 0;
- my $qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- my $tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- my %offsets = (); # print_z => [ qverts, tverts ]
-
- my $skirt_height = 0; # number of layers
- if ($print->has_infinite_skirt) {
- $skirt_height = $print->total_layer_count;
- } else {
- $skirt_height = min($print->config->skirt_height, $print->total_layer_count);
- }
- $skirt_height ||= 1 if $print->config->brim_width > 0 || $print->config->interior_brim_width;
-
- # get first $skirt_height layers (maybe this should be moved to a PrintObject method?)
- my $object0 = $print->get_object(0);
- my @layers = ();
- push @layers, map $object0->get_layer($_-1), 1..min($skirt_height, $object0->layer_count);
- push @layers, map $object0->get_support_layer($_-1), 1..min($skirt_height, $object0->support_layer_count);
- @layers = sort { $a->print_z <=> $b->print_z } @layers;
- @layers = @layers[0..($skirt_height-1)];
-
- foreach my $i (0..($skirt_height-1)) {
- my $top_z = $layers[$i]->print_z;
- $offsets{$top_z} = [$qverts->size, $tverts->size];
-
- if ($i == 0) {
- $self->_extrusionentity_to_verts($print->brim, $top_z, Slic3r::Point->new(0,0), $qverts, $tverts);
- }
-
- $self->_extrusionentity_to_verts($print->skirt, $top_z, Slic3r::Point->new(0,0), $qverts, $tverts);
- }
-
my $bb = Slic3r::Geometry::BoundingBoxf3->new;
{
my $pbb = $print->bounding_box;
$bb->merge_point(Slic3r::Pointf3->new_unscale(@{$pbb->min_point}));
$bb->merge_point(Slic3r::Pointf3->new_unscale(@{$pbb->max_point}));
}
- push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
- bounding_box => $bb,
- color => COLORS->[2],
- qverts => $qverts,
- tverts => $tverts,
- offsets => { %offsets },
- );
+
+ my $color_by_extruder = $self->color_toolpaths_by eq 'extruder';
+
+ if (!$print->brim->empty) {
+ my $color = $color_by_extruder
+ ? $self->colors->[ ($print->brim_extruder-1) % @{$self->colors} ]
+ : $self->colors->[2];
+
+ push @{$self->volumes}, my $volume = Slic3r::GUI::3DScene::Volume->new(
+ bounding_box => $bb,
+ color => $color,
+ qverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
+ tverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
+ offsets => {}, # print_z => [ qverts, tverts ]
+ );
+
+ my $top_z = $print->get_object(0)->get_layer(0)->print_z;
+ $volume->offsets->{$top_z} = [0, 0];
+ $self->_extrusionentity_to_verts($print->brim, $top_z, Slic3r::Point->new(0,0),
+ $volume->qverts, $volume->tverts);
+ }
+
+ if (!$print->skirt->empty) {
+ # TODO: it's a bit difficult to predict skirt extruders with the current skirt logic.
+ # We need to rewrite it anyway.
+ my $color = +($self->default_colors)[0];
+ push @{$self->volumes}, my $volume = Slic3r::GUI::3DScene::Volume->new(
+ bounding_box => $bb,
+ color => $color,
+ qverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
+ tverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
+ offsets => {}, # print_z => [ qverts, tverts ]
+ );
+
+ my $skirt_height = 0; # number of layers
+ if ($print->has_infinite_skirt) {
+ $skirt_height = $print->total_layer_count;
+ } else {
+ $skirt_height = min($print->config->skirt_height, $print->total_layer_count);
+ }
+ $skirt_height ||= 1 if $print->config->brim_width > 0 || $print->config->interior_brim_width;
+
+ # get first $skirt_height layers (maybe this should be moved to a PrintObject method?)
+ my $object0 = $print->get_object(0);
+ my @layers = ();
+ push @layers, map $object0->get_layer($_-1), 1..min($skirt_height, $object0->layer_count);
+ push @layers, map $object0->get_support_layer($_-1), 1..min($skirt_height, $object0->support_layer_count);
+ @layers = sort { $a->print_z <=> $b->print_z } @layers;
+ @layers = @layers[0..($skirt_height-1)];
+
+ foreach my $i (0..($skirt_height-1)) {
+ my $top_z = $layers[$i]->print_z;
+ $volume->offsets->{$top_z} = [$volume->qverts->size, $volume->tverts->size];
+
+ $self->_extrusionentity_to_verts($print->skirt, $top_z, Slic3r::Point->new(0,0),
+ $volume->qverts, $volume->tverts);
+ }
+ }
}
sub load_print_object_toolpaths {
my ($self, $object) = @_;
- my $perim_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- my $perim_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- my $infill_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- my $infill_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- my $support_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- my $support_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
-
- my %perim_offsets = (); # print_z => [ qverts, tverts ]
- my %infill_offsets = ();
- my %support_offsets = ();
-
# order layers by print_z
my @layers = sort { $a->print_z <=> $b->print_z }
@{$object->layers}, @{$object->support_layers};
@@ -1374,122 +1387,91 @@ sub load_print_object_toolpaths {
$bb->merge_point(Slic3r::Pointf3->new_unscale(@{$cbb->max_point}, $object->size->z));
}
}
-
+
+ my %volumes = (); # color => Volume
+
# Maximum size of an allocation block: 32MB / sizeof(float)
my $alloc_size_max = 32 * 1048576 / 4;
+ my $add = sub {
+ my ($coll, $top_z, $copy, $color) = @_;
+
+ my $volume = $volumes{$color};
+ if (!$volume) {
+ push @{$self->volumes}, $volumes{$color} = $volume = Slic3r::GUI::3DScene::Volume->new(
+ bounding_box => $bb,
+ color => $color,
+ qverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
+ tverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
+ offsets => {}, # print_z => [ qverts, tverts ]
+ );
+ }
+
+ $volume->offsets->{$top_z} //= [ $volume->qverts->size, $volume->tverts->size ];
+ $self->_extrusionentity_to_verts($coll, $top_z, $copy, $volume->qverts, $volume->tverts);
+ };
+
+ my $color_by_extruder = $self->color_toolpaths_by eq 'extruder';
+
foreach my $layer (@layers) {
my $top_z = $layer->print_z;
-
- if (!exists $perim_offsets{$top_z}) {
- $perim_offsets{$top_z} = [
- $perim_qverts->size, $perim_tverts->size,
- ];
- }
- if (!exists $infill_offsets{$top_z}) {
- $infill_offsets{$top_z} = [
- $infill_qverts->size, $infill_tverts->size,
- ];
- }
- if (!exists $support_offsets{$top_z}) {
- $support_offsets{$top_z} = [
- $support_qverts->size, $support_tverts->size,
- ];
- }
-
foreach my $copy (@{ $object->_shifted_copies }) {
foreach my $layerm (@{$layer->regions}) {
if ($object->step_done(STEP_PERIMETERS)) {
- $self->_extrusionentity_to_verts($layerm->perimeters, $top_z, $copy,
- $perim_qverts, $perim_tverts);
+ my $color = $color_by_extruder
+ ? $self->colors->[ ($layerm->region->config->perimeter_extruder-1) % @{$self->colors} ]
+ : $self->colors->[0];
+ $add->($layerm->perimeters, $top_z, $copy, $color);
}
if ($object->step_done(STEP_INFILL)) {
- $self->_extrusionentity_to_verts($layerm->fills, $top_z, $copy,
- $infill_qverts, $infill_tverts);
+ my $color = $color_by_extruder
+ ? $self->colors->[ ($layerm->region->config->infill_extruder-1) % @{$self->colors} ]
+ : $self->colors->[1];
+
+ if ($color_by_extruder && $layerm->region->config->infill_extruder != $layerm->region->config->solid_infill_extruder) {
+ # divide solid and non-solid infill
+ my $solid = Slic3r::ExtrusionPath::Collection->new;
+ my $non_solid = Slic3r::ExtrusionPath::Collection->new;
+ foreach my $fill (@{$layerm->fills}) {
+ if ($fill->[0]->is_solid_infill) {
+ $solid->append($fill);
+ } else {
+ $non_solid->append($fill);
+ }
+ }
+ $add->($non_solid, $top_z, $copy, $color);
+ $color = $self->colors->[ ($layerm->region->config->solid_infill_extruder-1) % @{&COLORS} ];
+ $add->($solid, $top_z, $copy, $color);
+ } else {
+ $add->($layerm->fills, $top_z, $copy, $color);
+ }
}
}
if ($layer->isa('Slic3r::Layer::Support') && $object->step_done(STEP_SUPPORTMATERIAL)) {
- $self->_extrusionentity_to_verts($layer->support_fills, $top_z, $copy,
- $support_qverts, $support_tverts);
-
- $self->_extrusionentity_to_verts($layer->support_interface_fills, $top_z, $copy,
- $support_qverts, $support_tverts);
+ {
+ my $color = $color_by_extruder
+ ? $self->colors->[ ($layer->object->config->support_material_extruder-1) % @{$self->colors} ]
+ : $self->colors->[2];
+ $add->($layer->support_fills, $top_z, $copy, $color);
+ }
+ {
+ my $color = ($color_by_extruder)
+ ? $self->colors->[ ($layer->object->config->support_material_interface_extruder-1) % @{$self->colors} ]
+ : $self->colors->[2];
+ $add->($layer->support_interface_fills, $top_z, $copy, $color);
+ }
}
}
-
- if ($perim_qverts->size() > $alloc_size_max || $perim_tverts->size() > $alloc_size_max) {
- # Store the vertex arrays and restart their containers.
- push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
- bounding_box => $bb,
- color => COLORS->[0],
- qverts => $perim_qverts,
- tverts => $perim_tverts,
- offsets => { %perim_offsets },
- );
- $perim_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- $perim_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- %perim_offsets = ();
+
+ foreach my $color (keys %volumes) {
+ my $volume = $volumes{$color};
+ if ($volume->qverts->size() > $alloc_size_max || $volume->tverts->size() > $alloc_size_max) {
+ # stop appending to this volume; create a new one next time
+ delete $volumes{$color};
+ }
}
-
- if ($infill_qverts->size() > $alloc_size_max || $infill_tverts->size() > $alloc_size_max) {
- # Store the vertex arrays and restart their containers.
- push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
- bounding_box => $bb,
- color => COLORS->[1],
- qverts => $infill_qverts,
- tverts => $infill_tverts,
- offsets => { %infill_offsets },
- );
- $infill_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- $infill_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- %infill_offsets = ();
- }
-
- if ($support_qverts->size() > $alloc_size_max || $support_tverts->size() > $alloc_size_max) {
- # Store the vertex arrays and restart their containers.
- push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
- bounding_box => $bb,
- color => COLORS->[2],
- qverts => $support_qverts,
- tverts => $support_tverts,
- offsets => { %support_offsets },
- );
- $support_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- $support_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
- %support_offsets = ();
- }
- }
-
- if ($perim_qverts->size() > 0 || $perim_tverts->size() > 0) {
- push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
- bounding_box => $bb,
- color => COLORS->[0],
- qverts => $perim_qverts,
- tverts => $perim_tverts,
- offsets => { %perim_offsets },
- );
- }
-
- if ($infill_qverts->size() > 0 || $infill_tverts->size() > 0) {
- push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
- bounding_box => $bb,
- color => COLORS->[1],
- qverts => $infill_qverts,
- tverts => $infill_tverts,
- offsets => { %infill_offsets },
- );
- }
-
- if ($support_qverts->size() > 0 || $support_tverts->size() > 0) {
- push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
- bounding_box => $bb,
- color => COLORS->[2],
- qverts => $support_qverts,
- tverts => $support_tverts,
- offsets => { %support_offsets },
- );
}
}
diff --git a/lib/Slic3r/GUI/Controller/ManualControlDialog.pm b/lib/Slic3r/GUI/Controller/ManualControlDialog.pm
index 224c5e0690..37dec1634c 100644
--- a/lib/Slic3r/GUI/Controller/ManualControlDialog.pm
+++ b/lib/Slic3r/GUI/Controller/ManualControlDialog.pm
@@ -193,18 +193,18 @@ sub new {
my $sbsizer = Wx::StaticBoxSizer->new($box, wxVERTICAL);
$right_sizer->Add($sbsizer, 1, wxEXPAND, 0);
- my $log = $self->{log_textctrl} = Wx::TextCtrl->new($box, -1, "", wxDefaultPosition, wxDefaultSize,
+ my $log = $self->{log_textctrl} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxBORDER_NONE);
- $log->SetBackgroundColour($box->GetBackgroundColour);
+ $log->SetBackgroundColour($self->GetBackgroundColour);
$log->SetFont($Slic3r::GUI::small_font);
$log->SetEditable(0);
$sbsizer->Add($self->{log_textctrl}, 1, wxEXPAND, 0);
my $cmd_sizer = Wx::BoxSizer->new(wxHORIZONTAL);
- my $cmd_textctrl = Wx::TextCtrl->new($box, -1, '');
+ my $cmd_textctrl = Wx::TextCtrl->new($self, -1, '');
$cmd_sizer->Add($cmd_textctrl, 1, wxEXPAND, 0);
- my $btn = Wx::Button->new($box, -1,
+ my $btn = Wx::Button->new($self, -1,
"Send", wxDefaultPosition, wxDefaultSize, wxBU_LEFT | wxBU_EXACTFIT);
$btn->SetFont($Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
@@ -212,7 +212,7 @@ sub new {
}
$cmd_sizer->Add($btn, 0, wxEXPAND | wxLEFT, 5);
- EVT_BUTTON($box, $btn, sub {
+ EVT_BUTTON($self, $btn, sub {
return if $cmd_textctrl->GetValue eq '';
$self->sender->send($cmd_textctrl->GetValue, 1);
$cmd_textctrl->SetValue('');
diff --git a/lib/Slic3r/GUI/Controller/PrinterPanel.pm b/lib/Slic3r/GUI/Controller/PrinterPanel.pm
index 3f5fbf9c12..53850a69ec 100644
--- a/lib/Slic3r/GUI/Controller/PrinterPanel.pm
+++ b/lib/Slic3r/GUI/Controller/PrinterPanel.pm
@@ -85,7 +85,7 @@ sub new {
# printer name
{
- my $text = Wx::StaticText->new($box, -1, $self->printer_name, wxDefaultPosition, [220,-1]);
+ my $text = Wx::StaticText->new($self, -1, $self->printer_name, wxDefaultPosition, [220,-1]);
my $font = $text->GetFont;
$font->SetPointSize(20);
$text->SetFont($font);
@@ -99,19 +99,19 @@ sub new {
$conn_sizer->AddGrowableCol(1, 1);
$left_sizer->Add($conn_sizer, 0, wxEXPAND | wxTOP, 5);
{
- my $text = Wx::StaticText->new($box, -1, "Port:", wxDefaultPosition, wxDefaultSize);
+ my $text = Wx::StaticText->new($self, -1, "Port:", wxDefaultPosition, wxDefaultSize);
$text->SetFont($Slic3r::GUI::small_font);
$conn_sizer->Add($text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
}
my $serial_port_sizer = Wx::BoxSizer->new(wxHORIZONTAL);
{
- $self->{serial_port_combobox} = Wx::ComboBox->new($box, -1, $config->serial_port, wxDefaultPosition, wxDefaultSize, []);
+ $self->{serial_port_combobox} = Wx::ComboBox->new($self, -1, $config->serial_port, wxDefaultPosition, wxDefaultSize, []);
$self->{serial_port_combobox}->SetFont($Slic3r::GUI::small_font);
$self->update_serial_ports;
$serial_port_sizer->Add($self->{serial_port_combobox}, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 1);
}
{
- $self->{btn_rescan_serial} = my $btn = Wx::BitmapButton->new($box, -1, Wx::Bitmap->new($Slic3r::var->("arrow_rotate_clockwise.png"), wxBITMAP_TYPE_PNG),
+ $self->{btn_rescan_serial} = my $btn = Wx::BitmapButton->new($self, -1, Wx::Bitmap->new($Slic3r::var->("arrow_rotate_clockwise.png"), wxBITMAP_TYPE_PNG),
wxDefaultPosition, wxDefaultSize, &Wx::wxBORDER_NONE);
$btn->SetToolTipString("Rescan serial ports")
if $btn->can('SetToolTipString');
@@ -121,19 +121,19 @@ sub new {
$conn_sizer->Add($serial_port_sizer, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
{
- my $text = Wx::StaticText->new($box, -1, "Speed:", wxDefaultPosition, wxDefaultSize);
+ my $text = Wx::StaticText->new($self, -1, "Speed:", wxDefaultPosition, wxDefaultSize);
$text->SetFont($Slic3r::GUI::small_font);
$conn_sizer->Add($text, 0, wxRIGHT | wxALIGN_CENTER_VERTICAL, 5);
}
my $serial_speed_sizer = Wx::BoxSizer->new(wxHORIZONTAL);
{
- $self->{serial_speed_combobox} = Wx::ComboBox->new($box, -1, $config->serial_speed, wxDefaultPosition, wxDefaultSize,
+ $self->{serial_speed_combobox} = Wx::ComboBox->new($self, -1, $config->serial_speed, wxDefaultPosition, wxDefaultSize,
["115200", "250000"]);
$self->{serial_speed_combobox}->SetFont($Slic3r::GUI::small_font);
$serial_speed_sizer->Add($self->{serial_speed_combobox}, 0, wxALIGN_CENTER_VERTICAL, 0);
}
{
- $self->{btn_disconnect} = my $btn = Wx::Button->new($box, -1, "Disconnect", wxDefaultPosition, wxDefaultSize);
+ $self->{btn_disconnect} = my $btn = Wx::Button->new($self, -1, "Disconnect", wxDefaultPosition, wxDefaultSize);
$btn->SetFont($Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("delete.png"), wxBITMAP_TYPE_PNG));
@@ -146,7 +146,7 @@ sub new {
# buttons
{
- $self->{btn_connect} = my $btn = Wx::Button->new($box, -1, "Connect to printer", wxDefaultPosition, [-1, 40]);
+ $self->{btn_connect} = my $btn = Wx::Button->new($self, -1, "Connect to printer", wxDefaultPosition, [-1, 40]);
my $font = $btn->GetFont;
$font->SetPointSize($font->GetPointSize + 2);
$btn->SetFont($font);
@@ -165,12 +165,12 @@ sub new {
}
# status
- $self->{status_text} = Wx::StaticText->new($box, -1, "", wxDefaultPosition, [200,-1]);
+ $self->{status_text} = Wx::StaticText->new($self, -1, "", wxDefaultPosition, [200,-1]);
$left_sizer->Add($self->{status_text}, 1, wxEXPAND | wxTOP, 15);
# manual control
{
- $self->{btn_manual_control} = my $btn = Wx::Button->new($box, -1, "Manual control", wxDefaultPosition, wxDefaultSize);
+ $self->{btn_manual_control} = my $btn = Wx::Button->new($self, -1, "Manual control", wxDefaultPosition, wxDefaultSize);
$btn->SetFont($Slic3r::GUI::small_font);
if ($Slic3r::GUI::have_button_icons) {
$btn->SetBitmap(Wx::Bitmap->new($Slic3r::var->("cog.png"), wxBITMAP_TYPE_PNG));
@@ -187,7 +187,7 @@ sub new {
# temperature
{
- my $temp_panel = $self->{temp_panel} = Wx::Panel->new($box, -1);
+ my $temp_panel = $self->{temp_panel} = Wx::Panel->new($self, -1);
my $temp_sizer = Wx::BoxSizer->new(wxHORIZONTAL);
my $temp_font = Wx::Font->new($Slic3r::GUI::small_font);
@@ -220,11 +220,11 @@ sub new {
# print jobs panel
$self->{print_jobs_sizer} = my $print_jobs_sizer = Wx::BoxSizer->new(wxVERTICAL);
{
- my $text = Wx::StaticText->new($box, -1, "Queue:", wxDefaultPosition, wxDefaultSize);
+ my $text = Wx::StaticText->new($self, -1, "Queue:", wxDefaultPosition, wxDefaultSize);
$text->SetFont($Slic3r::GUI::small_font);
$print_jobs_sizer->Add($text, 0, wxEXPAND, 0);
- $self->{jobs_panel} = Wx::ScrolledWindow->new($box, -1, wxDefaultPosition, wxDefaultSize,
+ $self->{jobs_panel} = Wx::ScrolledWindow->new($self, -1, wxDefaultPosition, wxDefaultSize,
wxVSCROLL | wxBORDER_NONE);
$self->{jobs_panel}->SetScrollbars(0, 1, 0, 1);
$self->{jobs_panel_sizer} = Wx::BoxSizer->new(wxVERTICAL);
@@ -248,13 +248,13 @@ sub new {
my $log_sizer = Wx::BoxSizer->new(wxVERTICAL);
{
- my $text = Wx::StaticText->new($box, -1, "Log:", wxDefaultPosition, wxDefaultSize);
+ my $text = Wx::StaticText->new($self, -1, "Log:", wxDefaultPosition, wxDefaultSize);
$text->SetFont($Slic3r::GUI::small_font);
$log_sizer->Add($text, 0, wxEXPAND, 0);
- my $log = $self->{log_textctrl} = Wx::TextCtrl->new($box, -1, "", wxDefaultPosition, wxDefaultSize,
+ my $log = $self->{log_textctrl} = Wx::TextCtrl->new($self, -1, "", wxDefaultPosition, wxDefaultSize,
wxTE_MULTILINE | wxBORDER_NONE);
- $log->SetBackgroundColour($box->GetBackgroundColour);
+ $log->SetBackgroundColour($self->GetBackgroundColour);
$log->SetFont($Slic3r::GUI::small_font);
$log->SetEditable(0);
$log_sizer->Add($self->{log_textctrl}, 1, wxEXPAND, 0);
diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm
index 93ca6bfaed..3ce77a14d0 100644
--- a/lib/Slic3r/GUI/MainFrame.pm
+++ b/lib/Slic3r/GUI/MainFrame.pm
@@ -193,7 +193,7 @@ sub _init_menubar {
$self->_append_menu_item($self->{plater_menu}, "Export plate as STL...", 'Export current plate as STL', sub {
$plater->export_stl;
}, undef, 'brick_go.png');
- $self->_append_menu_item($self->{plater_menu}, "Export plate as AMF...", 'Export current plate as AMF', sub {
+ $self->_append_menu_item($self->{plater_menu}, "Export plate with modifiers as AMF...", 'Export current plate as AMF, including all modifier meshes', sub {
$plater->export_amf;
}, undef, 'brick_go.png');
@@ -225,6 +225,32 @@ sub _init_menubar {
$self->_append_menu_item($self->{viewMenu}, "Rear" , 'Rear View' , sub { $self->select_view('rear' ); });
$self->_append_menu_item($self->{viewMenu}, "Left" , 'Left View' , sub { $self->select_view('left' ); });
$self->_append_menu_item($self->{viewMenu}, "Right" , 'Right View' , sub { $self->select_view('right' ); });
+ $self->{viewMenu}->AppendSeparator();
+ $self->{color_toolpaths_by_role} = $self->_append_menu_item($self->{viewMenu},
+ "Color Toolpaths by Role",
+ 'Color toolpaths according to perimeter/infill/support material',
+ sub {
+ $Slic3r::GUI::Settings->{_}{color_toolpaths_by} = 'role';
+ wxTheApp->save_settings;
+ $self->{plater}{preview3D}->reload_print;
+ },
+ undef, undef, wxITEM_RADIO
+ );
+ $self->{color_toolpaths_by_extruder} = $self->_append_menu_item($self->{viewMenu},
+ "Color Toolpaths by Filament",
+ 'Color toolpaths using the configured extruder/filament color',
+ sub {
+ $Slic3r::GUI::Settings->{_}{color_toolpaths_by} = 'extruder';
+ wxTheApp->save_settings;
+ $self->{plater}{preview3D}->reload_print;
+ },
+ undef, undef, wxITEM_RADIO
+ );
+ if ($Slic3r::GUI::Settings->{_}{color_toolpaths_by} eq 'role') {
+ $self->{color_toolpaths_by_role}->Check(1);
+ } else {
+ $self->{color_toolpaths_by_extruder}->Check(1);
+ }
}
# Window menu
@@ -354,11 +380,7 @@ sub quick_slice {
$sprint->apply_config($config);
$sprint->set_model($model);
-
- {
- my $extra = $self->extra_variables;
- $sprint->placeholder_parser->set($_, $extra->{$_}) for keys %$extra;
- }
+ # FIXME: populate placeholders (preset names etc.)
# select output file
my $output_file;
@@ -612,10 +634,10 @@ sub select_view {
}
sub _append_menu_item {
- my ($self, $menu, $string, $description, $cb, $id, $icon) = @_;
+ my ($self, $menu, $string, $description, $cb, $id, $icon, $kind) = @_;
$id //= &Wx::NewId();
- my $item = $menu->Append($id, $string, $description);
+ my $item = $menu->Append($id, $string, $description, $kind);
$self->_set_menu_item_icon($item, $icon);
EVT_MENU($self, $id, $cb);
diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm
index 5fb3b29f4b..f15c8911d1 100644
--- a/lib/Slic3r/GUI/Plater.pm
+++ b/lib/Slic3r/GUI/Plater.pm
@@ -13,7 +13,7 @@ use threads::shared qw(shared_clone);
use Wx qw(:button :cursor :dialog :filedialog :keycode :icon :font :id :misc
:panel :sizer :toolbar :window wxTheApp :notebook :combobox);
use Wx::Event qw(EVT_BUTTON EVT_COMMAND EVT_KEY_DOWN EVT_MOUSE_EVENTS EVT_PAINT EVT_TOOL
- EVT_CHOICE EVT_COMBOBOX EVT_TIMER EVT_NOTEBOOK_PAGE_CHANGED);
+ EVT_CHOICE EVT_COMBOBOX EVT_TIMER EVT_NOTEBOOK_PAGE_CHANGED EVT_LEFT_UP);
use base qw(Wx::Panel Class::Accessor);
__PACKAGE__->mk_accessors(qw(presets));
@@ -49,7 +49,7 @@ sub new {
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
$self->{config} = Slic3r::Config->new_from_defaults(qw(
bed_shape complete_objects extruder_clearance_radius skirts skirt_distance brim_width
- serial_port serial_speed octoprint_host octoprint_apikey overridable
+ serial_port serial_speed octoprint_host octoprint_apikey overridable filament_colour
));
$self->{model} = Slic3r::Model->new;
$self->{print} = Slic3r::Print->new;
@@ -89,7 +89,7 @@ sub new {
$menu->Destroy;
};
my $on_instances_moved = sub {
- $self->update;
+ $self->on_model_change;
};
# Initialize 3D plater
@@ -235,34 +235,46 @@ sub new {
EVT_BUTTON($self, $self->{btn_print}, sub {
$self->{print_file} = $self->export_gcode(Wx::StandardPaths::Get->GetTempDir());
});
- EVT_BUTTON($self, $self->{btn_send_gcode}, sub {
+ EVT_LEFT_UP($self->{btn_send_gcode}, sub {
+ my (undef, $e) = @_;
+
my $filename = basename($self->{print}->output_filepath($main::opt{output} // ''));
- $filename = Wx::GetTextFromUser("Save to printer with the following name:",
- "OctoPrint", $filename, $self);
- my $process_dialog = Wx::ProgressDialog->new('Querying OctoPrint…', "Checking whether file already exists…", 100, $self, 0);
- $process_dialog->Pulse;
+ if (!$e->AltDown) {
+ # When the alt key is pressed, bypass the dialog.
+ my $dlg = Slic3r::GUI::Plater::OctoPrintSpoolDialog->new($self, $filename);
+ return unless $dlg->ShowModal == wxID_OK;
+ $filename = $dlg->{filename};
+ }
- my $ua = LWP::UserAgent->new;
- $ua->timeout(5);
- my $res = $ua->get("http://" . $self->{config}->octoprint_host . "/api/files/local");
- $process_dialog->Destroy;
- if ($res->is_success) {
- if ($res->decoded_content =~ /"name":\s*"\Q$filename\E"/) {
- my $dialog = Wx::MessageDialog->new($self,
- "It looks like a file with the same name already exists in the server. "
- . "Shall I overwrite it?",
- 'OctoPrint', wxICON_WARNING | wxYES | wxNO);
- return if $dialog->ShowModal() == wxID_NO;
+ if (!$Slic3r::GUI::Settings->{octoprint}{overwrite}) {
+ my $progress = Wx::ProgressDialog->new('Querying OctoPrint…',
+ "Checking whether file already exists…", 100, $self, 0);
+ $progress->Pulse;
+
+ my $ua = LWP::UserAgent->new;
+ $ua->timeout(5);
+ my $res = $ua->get("http://" . $self->{config}->octoprint_host . "/api/files/local");
+ $progress->Destroy;
+ if ($res->is_success) {
+ if ($res->decoded_content =~ /"name":\s*"\Q$filename\E"/) {
+ my $dialog = Wx::MessageDialog->new($self,
+ "It looks like a file with the same name already exists in the server. "
+ . "Shall I overwrite it?",
+ 'OctoPrint', wxICON_WARNING | wxYES | wxNO);
+ if ($dialog->ShowModal() == wxID_NO) {
+ return;
+ }
+ }
+ } else {
+ my $message = "Error while connecting to the OctoPrint server: " . $res->status_line;
+ Slic3r::GUI::show_error($self, $message);
+ return;
}
}
- my $dialog = Wx::MessageDialog->new($self,
- "Shall I start the print after uploading the file?",
- 'OctoPrint', wxICON_QUESTION | wxYES | wxNO);
- $self->{send_gcode_file_print} = ($dialog->ShowModal() == wxID_YES);
-
- $self->{send_gcode_file} = $self->export_gcode(Wx::StandardPaths::Get->GetTempDir() . "/$filename");
+ $self->{send_gcode_file_print} = $Slic3r::GUI::Settings->{octoprint}{start};
+ $self->{send_gcode_file} = $self->export_gcode(Wx::StandardPaths::Get->GetTempDir() . "/" . $filename);
});
EVT_BUTTON($self, $self->{btn_export_stl}, \&export_stl);
@@ -344,7 +356,7 @@ sub new {
if ($self->{preview3D}) {
$self->{preview3D}->set_bed_shape($self->{config}->bed_shape);
}
- $self->update;
+ $self->on_model_change;
{
my $presets = $self->{presets_sizer} = Wx::FlexGridSizer->new(3, 3, 1, 2);
@@ -439,7 +451,7 @@ sub new {
my $print_info_sizer;
{
- my $box = Wx::StaticBox->new($self, -1, "Sliced Info");
+ my $box = Wx::StaticBox->new($self, -1, "Print Summary");
$print_info_sizer = Wx::StaticBoxSizer->new($box, wxVERTICAL);
$print_info_sizer->SetMinSize([350,-1]);
my $grid_sizer = Wx::FlexGridSizer->new(2, 2, 5, 5);
@@ -448,9 +460,7 @@ sub new {
$grid_sizer->AddGrowableCol(3, 1);
$print_info_sizer->Add($grid_sizer, 0, wxEXPAND);
my @info = (
- fil_cm => "Used Filament (cm)",
- fil_cm3 => "Used Filament (cm^3)",
- fil_g => "Used Filament (g)",
+ fil => "Used Filament",
cost => "Cost",
);
while (my $field = shift @info) {
@@ -463,7 +473,7 @@ sub new {
$self->{"print_info_$field"}->SetFont($Slic3r::GUI::small_font);
$grid_sizer->Add($self->{"print_info_$field"}, 0);
}
- $self->{"sliced_info_box"} = $print_info_sizer;
+ $self->{sliced_info_box} = $print_info_sizer;
}
@@ -474,14 +484,13 @@ sub new {
$buttons_sizer->Add($self->{btn_send_gcode}, 0, wxALIGN_RIGHT, 0);
$buttons_sizer->Add($self->{btn_export_gcode}, 0, wxALIGN_RIGHT, 0);
- my $right_sizer = Wx::BoxSizer->new(wxVERTICAL);
+ $self->{right_sizer} = my $right_sizer = Wx::BoxSizer->new(wxVERTICAL);
$right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets;
$right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5);
$right_sizer->Add($self->{settings_override_panel}, 1, wxEXPAND, 5);
$right_sizer->Add($object_info_sizer, 0, wxEXPAND, 0);
$right_sizer->Add($print_info_sizer, 0, wxEXPAND, 0);
$right_sizer->Hide($print_info_sizer);
- $self->{"right_sizer"} = $right_sizer;
my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
$hsizer->Add($self->{preview_notebook}, 1, wxEXPAND | wxTOP, 1);
@@ -517,34 +526,6 @@ sub _on_select_preset {
my $config = $self->config;
$self->on_extruders_change(scalar @{$config->get('nozzle_diameter')});
-
- foreach my $opt_key (@{$self->{config}->diff($config)}) {
- # Ignore overrides. No need to set them in our config; we'll use them directly below.
- next if $opt_key eq 'overrides';
-
- $self->{config}->set($opt_key, $config->get($opt_key));
-
- if ($opt_key eq 'bed_shape') {
- $self->{canvas}->update_bed_size;
- $self->{canvas3D}->update_bed_size if $self->{canvas3D};
- $self->{preview3D}->set_bed_shape($self->{config}->bed_shape)
- if $self->{preview3D};
- $self->update;
- } elsif ($opt_key eq 'serial_port') {
- if ($config->get('serial_port')) {
- $self->{btn_print}->Show;
- } else {
- $self->{btn_print}->Hide;
- }
- $self->Layout;
- } elsif ($opt_key eq 'octoprint_host') {
- if ($config->get('octoprint_host')) {
- $self->{btn_send_gcode}->Show;
- } else {
- $self->{btn_send_gcode}->Hide;
- }
- }
- }
if ($group eq 'print') {
$self->{settings_override_config}->clear;
@@ -559,8 +540,6 @@ sub _on_select_preset {
$self->load_presets;
}
- return if !$self->GetFrame->is_loaded;
-
$self->config_changed;
}
@@ -894,7 +873,7 @@ sub load_model_objects {
$self->make_thumbnail($_) for @obj_idx;
$self->arrange if $need_arrange;
- $self->update;
+ $self->on_model_change;
# zoom to objects
$self->{canvas3D}->zoom_to_volumes
@@ -902,8 +881,6 @@ sub load_model_objects {
$self->object_list_changed;
- $self->schedule_background_process;
-
return @obj_idx;
}
@@ -936,8 +913,7 @@ sub remove {
$self->object_list_changed;
$self->select_object(undef);
- $self->update;
- $self->schedule_background_process;
+ $self->on_model_change;
}
sub reset {
@@ -955,7 +931,7 @@ sub reset {
$self->object_list_changed;
$self->select_object(undef);
- $self->update;
+ $self->on_model_change;
}
sub increase {
@@ -979,9 +955,8 @@ sub increase {
if ($Slic3r::GUI::Settings->{_}{autocenter}) {
$self->arrange;
} else {
- $self->update;
+ $self->on_model_change;
}
- $self->schedule_background_process;
}
sub decrease {
@@ -1001,8 +976,7 @@ sub decrease {
$self->remove;
}
- $self->update;
- $self->schedule_background_process;
+ $self->on_model_change;
}
sub set_number_of_copies {
@@ -1074,8 +1048,7 @@ sub rotate {
$self->{print}->add_model_object($model_object, $obj_idx);
$self->selection_changed; # refresh info (size etc.)
- $self->update;
- $self->schedule_background_process;
+ $self->on_model_change;
}
sub mirror {
@@ -1102,8 +1075,7 @@ sub mirror {
$self->{print}->add_model_object($model_object, $obj_idx);
$self->selection_changed; # refresh info (size etc.)
- $self->update;
- $self->schedule_background_process;
+ $self->on_model_change;
}
sub changescale {
@@ -1157,7 +1129,7 @@ sub changescale {
my $newsize = Wx::GetTextFromUser("Enter the new max size for the selected object:",
"Scale", $cursize, $self);
return if !$newsize || $newsize !~ /^\d*(?:\.\d*)?$/ || $newsize < 0;
- $scale = $newsize / $cursize * 100;
+ $scale = $model_instance->scaling_factor * $newsize / $cursize * 100;
} else {
# max scale factor should be above 2540 to allow importing files exported in inches
# Wx::GetNumberFromUser() does not support decimal numbers
@@ -1184,8 +1156,7 @@ sub changescale {
$self->{print}->add_model_object($model_object, $obj_idx);
$self->selection_changed(1); # refresh info (size, volume etc.)
- $self->update;
- $self->schedule_background_process;
+ $self->on_model_change;
}
sub arrange {
@@ -1198,7 +1169,7 @@ sub arrange {
# ignore arrange failures on purpose: user has visual feedback and we don't need to warn him
# when parts don't fit in print bed
- $self->update(1);
+ $self->on_model_change(1);
}
sub split_object {
@@ -1245,28 +1216,77 @@ sub split_object {
$self->load_model_objects(@model_objects);
}
+sub toggle_print_stats {
+ my ($self, $show) = @_;
+
+ return if !$self->GetFrame->is_loaded;
+
+ if ($show) {
+ $self->{right_sizer}->Show($self->{sliced_info_box});
+ } else {
+ $self->{right_sizer}->Hide($self->{sliced_info_box});
+ }
+ $self->{right_sizer}->Layout;
+}
+
sub config_changed {
- my ($self) = @_;
+ my $self = shift;
+
+ my $config = $self->config;
if ($Slic3r::GUI::autosave) {
- $self->config->save($Slic3r::GUI::autosave);
+ $config->save($Slic3r::GUI::autosave);
}
- # (re) start timer
- $self->schedule_background_process;
+ # Apply changes to the plater-specific config options.
+ foreach my $opt_key (@{$self->{config}->diff($config)}) {
+ # Ignore overrides. No need to set them in our config; we'll use them directly below.
+ next if $opt_key eq 'overrides';
+
+ $self->{config}->set($opt_key, $config->get($opt_key));
+
+ if ($opt_key eq 'bed_shape') {
+ $self->{canvas}->update_bed_size;
+ $self->{canvas3D}->update_bed_size if $self->{canvas3D};
+ $self->{preview3D}->set_bed_shape($self->{config}->bed_shape)
+ if $self->{preview3D};
+ $self->on_model_change;
+ } elsif ($opt_key eq 'serial_port') {
+ if ($config->get('serial_port')) {
+ $self->{btn_print}->Show;
+ } else {
+ $self->{btn_print}->Hide;
+ }
+ $self->Layout;
+ } elsif ($opt_key eq 'octoprint_host') {
+ if ($config->get('octoprint_host')) {
+ $self->{btn_send_gcode}->Show;
+ } else {
+ $self->{btn_send_gcode}->Hide;
+ }
+ $self->Layout;
+ }
+ }
+
+ return if !$self->GetFrame->is_loaded;
+
+ $self->toggle_print_stats(0);
+
+ if ($Slic3r::GUI::Settings->{_}{background_processing}) {
+ # (re)start timer
+ $self->schedule_background_process;
+ } else {
+ $self->async_apply_config;
+ }
}
sub schedule_background_process {
my ($self) = @_;
- $self->{processed} = 0;
+ warn 'schedule_background_process() is not supposed to be called when background processing is disabled'
+ if !$Slic3r::GUI::Settings->{_}{background_processing};
- if (!$Slic3r::GUI::Settings->{_}{background_processing}) {
- my $sel = $self->{preview_notebook}->GetSelection;
- if ($sel == $self->{preview3D_page_idx} || $sel == $self->{toolpaths2D_page_idx}) {
- $self->{preview_notebook}->SetSelection(0);
- }
- }
+ $self->{processed} = 0;
if (defined $self->{apply_config_timer}) {
$self->{apply_config_timer}->Start(PROCESS_DELAY, 1); # 1 = one shot
@@ -1278,10 +1298,6 @@ sub schedule_background_process {
sub async_apply_config {
my ($self) = @_;
- # reset preview canvases
- $self->{toolpaths2D}->reload_print if $self->{toolpaths2D};
- $self->{preview3D}->reload_print if $self->{preview3D};
-
# pause process thread before applying new config
# since we don't want to touch data that is being used by the threads
$self->pause_background_process;
@@ -1289,16 +1305,20 @@ sub async_apply_config {
# apply new config
my $invalidated = $self->{print}->apply_config($self->config);
- return if !$Slic3r::GUI::Settings->{_}{background_processing};
+ # reset preview canvases (invalidated contents will be hidden)
+ $self->{toolpaths2D}->reload_print if $self->{toolpaths2D};
+ $self->{preview3D}->reload_print if $self->{preview3D};
if ($invalidated) {
+ if (!$Slic3r::GUI::Settings->{_}{background_processing}) {
+ $self->hide_preview;
+ return;
+ }
+
# kill current thread if any
$self->stop_background_process;
# remove the sliced statistics box because something changed.
- if ($self->{"right_sizer"}) {
- $self->{"right_sizer"}->Hide($self->{"sliced_info_box"});
- $self->{"right_sizer"}->Layout;
- }
+ $self->toggle_print_stats(0);
} else {
$self->resume_background_process;
}
@@ -1329,6 +1349,10 @@ sub start_background_process {
return;
}
+ if ($Slic3r::GUI::Settings->{_}{threads}) {
+ $self->{print}->config->set('threads', $Slic3r::GUI::Settings->{_}{threads});
+ }
+
# start thread
@_ = ();
$self->{process_thread} = Slic3r::spawn_thread(sub {
@@ -1472,8 +1496,7 @@ sub export_gcode {
# this updates buttons status
$self->object_list_changed;
- $self->{"right_sizer"}->Show($self->{"sliced_info_box"});
- $self->{"right_sizer"}->Layout;
+ $self->toggle_print_stats(1);
return $self->{export_gcode_output_file};
}
@@ -1568,10 +1591,22 @@ sub on_export_completed {
$self->send_gcode if $send_gcode;
$self->{print_file} = undef;
$self->{send_gcode_file} = undef;
- $self->{"print_info_cost"}->SetLabel(sprintf("%.2f" , $self->{print}->total_cost));
- $self->{"print_info_fil_g"}->SetLabel(sprintf("%.2f" , $self->{print}->total_weight));
- $self->{"print_info_fil_cm3"}->SetLabel(sprintf("%.2f" , $self->{print}->total_extruded_volume) / 1000);
- $self->{"print_info_fil_cm"}->SetLabel(sprintf("%.2f" , $self->{print}->total_used_filament) / 10);
+
+ {
+ my $fil = sprintf(
+ '%.2fcm (%.2fcm³%s)',
+ $self->{print}->total_used_filament / 10,
+ $self->{print}->total_extruded_volume / 1000,
+ $self->{print}->total_weight
+ ? sprintf(', %.2fg', $self->{print}->total_weight)
+ : '',
+ );
+ my $cost = $self->{print}->total_cost
+ ? sprintf("%.2f" , $self->{print}->total_cost)
+ : 'n.a.';
+ $self->{print_info_fil}->SetLabel($fil);
+ $self->{print_info_cost}->SetLabel($cost);
+ }
# this updates buttons status
$self->object_list_changed;
@@ -1683,6 +1718,23 @@ sub export_object_stl {
$self->statusbar->SetStatusText("STL file exported to $output_file");
}
+# Export function for a single AMF output
+sub export_object_amf {
+ my $self = shift;
+
+ my ($obj_idx, $object) = $self->selected_object;
+ return if !defined $obj_idx;
+
+ my $local_model = Slic3r::Model->new;
+ my $model_object = $self->{model}->objects->[$obj_idx];
+ # copy model_object -> local_model
+ $local_model->add_object($model_object);
+
+ my $output_file = $self->_get_export_file('AMF') or return;
+ $local_model->write_amf($output_file);
+ $self->statusbar->SetStatusText("AMF file exported to $output_file");
+}
+
sub export_amf {
my $self = shift;
@@ -1697,14 +1749,21 @@ sub _get_export_file {
my $self = shift;
my ($format) = @_;
- my $suffix = $format eq 'STL' ? '.stl' : '.amf.xml';
+ my $suffix = $format eq 'STL' ? '.stl' : '.amf';
my $output_file = $main::opt{output};
{
$output_file = $self->{print}->output_filepath($output_file // '');
$output_file =~ s/\.gcode$/$suffix/i;
- my $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
- basename($output_file), &Slic3r::GUI::MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
+ my $dlg;
+ $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
+ basename($output_file), &Slic3r::GUI::STL_MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT)
+ if $format eq 'STL';
+
+ $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
+ basename($output_file), &Slic3r::GUI::AMF_MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT)
+ if $format eq 'AMF';
+
if ($dlg->ShowModal != wxID_OK) {
$dlg->Destroy;
return undef;
@@ -1749,30 +1808,42 @@ sub on_thumbnail_made {
# this method gets called whenever print center is changed or the objects' bounding box changes
# (i.e. when an object is added/removed/moved/rotated/scaled)
-sub update {
+sub on_model_change {
my ($self, $force_autocenter) = @_;
+ my $running = $self->pause_background_process;
+
if ($Slic3r::GUI::Settings->{_}{autocenter} || $force_autocenter) {
$self->{model}->center_instances_around_point($self->bed_centerf);
}
+ $self->refresh_canvases;
- my $running = $self->pause_background_process;
my $invalidated = $self->{print}->reload_model_instances();
- # The mere fact that no steps were invalidated when reloading model instances
- # doesn't mean that all steps were done: for example, validation might have
- # failed upon previous instance move, so we have no running thread and no steps
- # are invalidated on this move, thus we need to schedule a new run.
- if ($invalidated || !$running) {
- $self->schedule_background_process;
+ if ($Slic3r::GUI::Settings->{_}{background_processing}) {
+ if ($invalidated || !$running) {
+ # The mere fact that no steps were invalidated when reloading model instances
+ # doesn't mean that all steps were done: for example, validation might have
+ # failed upon previous instance move, so we have no running thread and no steps
+ # are invalidated on this move, thus we need to schedule a new run.
+ $self->schedule_background_process;
+ $self->toggle_print_stats(0);
+ } else {
+ $self->resume_background_process;
+ }
} else {
- $self->resume_background_process;
+ $self->hide_preview;
}
- if ($self->{"right_sizer"}) {
- $self->{"right_sizer"}->Hide($self->{"sliced_info_box"});
- $self->{"right_sizer"}->Layout;
+}
+
+sub hide_preview {
+ my ($self) = @_;
+
+ my $sel = $self->{preview_notebook}->GetSelection;
+ if ($sel == $self->{preview3D_page_idx} || $sel == $self->{toolpaths2D_page_idx}) {
+ $self->{preview_notebook}->SetSelection(0);
}
- $self->refresh_canvases;
+ $self->{processed} = 0;
}
sub on_extruders_change {
@@ -1896,7 +1967,7 @@ sub object_settings_dialog {
if ($dlg->PartsChanged || $dlg->PartSettingsChanged) {
$self->stop_background_process;
$self->{print}->reload_object($obj_idx);
- $self->schedule_background_process;
+ $self->on_model_change;
} else {
$self->resume_background_process;
}
@@ -2126,6 +2197,9 @@ sub object_menu {
$frame->_append_menu_item($menu, "Export object as STL…", 'Export this single object as STL file', sub {
$self->export_object_stl;
}, undef, 'brick_go.png');
+ $frame->_append_menu_item($menu, "Export object and modifiers as AMF…", 'Export this single object and all associated modifiers as AMF file', sub {
+ $self->export_object_amf;
+ }, undef, 'brick_go.png');
return $menu;
}
@@ -2223,4 +2297,73 @@ sub transform_thumbnail {
$self->transformed_thumbnail($t);
}
+package Slic3r::GUI::Plater::OctoPrintSpoolDialog;
+use Wx qw(:dialog :id :misc :sizer :icon wxTheApp);
+use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER);
+use base 'Wx::Dialog';
+
+sub new {
+ my $class = shift;
+ my ($parent, $filename) = @_;
+ my $self = $class->SUPER::new($parent, -1, "Send to OctoPrint", wxDefaultPosition,
+ [400, -1]);
+
+ $self->{filename} = $filename;
+ $Slic3r::GUI::Settings->{octoprint} //= {};
+
+ my $optgroup;
+ $optgroup = Slic3r::GUI::OptionsGroup->new(
+ parent => $self,
+ title => 'Send to OctoPrint',
+ on_change => sub {
+ my ($opt_id) = @_;
+
+ if ($opt_id eq 'filename') {
+ $self->{filename} = $optgroup->get_value($opt_id);
+ } else {
+ $Slic3r::GUI::Settings->{octoprint}{$opt_id} = $optgroup->get_value($opt_id);
+ }
+ },
+ label_width => 200,
+ );
+ $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
+ opt_id => 'filename',
+ type => 's',
+ label => 'File name',
+ width => 200,
+ tooltip => 'The name used for labelling the print job.',
+ default => $filename,
+ ));
+ $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
+ opt_id => 'overwrite',
+ type => 'bool',
+ label => 'Overwrite existing file',
+ tooltip => 'If selected, any existing file with the same name will be overwritten without confirmation.',
+ default => $Slic3r::GUI::Settings->{octoprint}{overwrite} // 0,
+ ));
+ $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
+ opt_id => 'start',
+ type => 'bool',
+ label => 'Start print',
+ tooltip => 'If selected, print will start after the upload.',
+ default => $Slic3r::GUI::Settings->{octoprint}{start} // 0,
+ ));
+
+ my $sizer = Wx::BoxSizer->new(wxVERTICAL);
+ $sizer->Add($optgroup->sizer, 0, wxEXPAND | wxTOP | wxBOTTOM | wxLEFT | wxRIGHT, 10);
+
+ my $buttons = $self->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
+ $sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
+ EVT_BUTTON($self, wxID_OK, sub {
+ wxTheApp->save_settings;
+ $self->EndModal(wxID_OK);
+ $self->Close; # needed on Linux
+ });
+
+ $self->SetSizer($sizer);
+ $sizer->SetSizeHints($self);
+
+ return $self;
+}
+
1;
diff --git a/lib/Slic3r/GUI/Plater/3DPreview.pm b/lib/Slic3r/GUI/Plater/3DPreview.pm
index c1d1cf57e9..dddefee013 100644
--- a/lib/Slic3r/GUI/Plater/3DPreview.pm
+++ b/lib/Slic3r/GUI/Plater/3DPreview.pm
@@ -117,6 +117,16 @@ sub load_print {
}
if ($self->IsShown) {
+ # set colors
+ $self->canvas->color_toolpaths_by($Slic3r::GUI::Settings->{_}{color_toolpaths_by});
+ if ($self->canvas->color_toolpaths_by eq 'extruder') {
+ my @filament_colors = map { s/^#//; [ map $_/255, (unpack 'C*', pack 'H*', $_), 255 ] }
+ @{$self->print->config->filament_colour};
+ $self->canvas->colors->[$_] = $filament_colors[$_] for 0..$#filament_colors;
+ } else {
+ $self->canvas->colors([ $self->canvas->default_colors ]);
+ }
+
# load skirt and brim
$self->canvas->load_print_toolpaths($self->print);
diff --git a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm
index d7909816b1..c0979cd136 100644
--- a/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm
+++ b/lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm
@@ -77,7 +77,7 @@ sub new {
{
my $label = Wx::StaticText->new($self, -1, "You can use this section to override the default layer height for parts of this object. Set layer height to zero to skip portions of the input file.",
- wxDefaultPosition, [-1, 40]);
+ wxDefaultPosition, wxDefaultSize);
$label->SetFont(Wx::SystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT));
$sizer->Add($label, 0, wxEXPAND | wxALL, 10);
}
@@ -90,7 +90,7 @@ sub new {
$grid->SetColLabelValue(0, "Min Z (mm)");
$grid->SetColLabelValue(1, "Max Z (mm)");
$grid->SetColLabelValue(2, "Layer height (mm)");
- $grid->SetColSize($_, 135) for 0..2;
+ $grid->SetColSize($_, -1) for 0..2;
$grid->SetDefaultCellAlignment(wxALIGN_CENTRE, wxALIGN_CENTRE);
# load data
diff --git a/lib/Slic3r/GUI/Preferences.pm b/lib/Slic3r/GUI/Preferences.pm
index c6f2f1d13a..9c96efa3a4 100644
--- a/lib/Slic3r/GUI/Preferences.pm
+++ b/lib/Slic3r/GUI/Preferences.pm
@@ -57,6 +57,13 @@ sub new {
default => $Slic3r::GUI::Settings->{_}{background_processing},
readonly => !$Slic3r::have_threads,
));
+ $optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
+ opt_id => 'threads',
+ type => 'i',
+ label => 'Threads',
+ tooltip => $Slic3r::Config::Options->{threads}{tooltip},
+ default => $Slic3r::GUI::Settings->{_}{threads},
+ ));
$optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
opt_id => 'no_controller',
type => 'bool',
diff --git a/lib/Slic3r/GUI/PresetEditor.pm b/lib/Slic3r/GUI/PresetEditor.pm
index da70a1840b..d5fae9311d 100644
--- a/lib/Slic3r/GUI/PresetEditor.pm
+++ b/lib/Slic3r/GUI/PresetEditor.pm
@@ -521,7 +521,7 @@ sub options {
external_perimeter_extrusion_width infill_extrusion_width solid_infill_extrusion_width
top_infill_extrusion_width support_material_extrusion_width
infill_overlap bridge_flow_ratio
- xy_size_compensation threads resolution overridable compatible_printers
+ xy_size_compensation resolution overridable compatible_printers
print_settings_id
)
}
@@ -755,7 +755,6 @@ sub build {
{
my $optgroup = $page->new_optgroup('Other');
$optgroup->append_single_option_line('xy_size_compensation');
- $optgroup->append_single_option_line('threads') if $Slic3r::have_threads;
$optgroup->append_single_option_line('resolution');
}
}
@@ -832,14 +831,13 @@ sub _update {
my $config = $self->{config};
- if ($config->spiral_vase && !($config->perimeters == 1 && $config->top_solid_layers == 0 && $config->fill_density == 0 && $config->infill_only_where_needed == 0 && $config->support_material == 0)) {
+ if ($config->spiral_vase && !($config->perimeters == 1 && $config->top_solid_layers == 0 && $config->fill_density == 0 && $config->support_material == 0)) {
my $dialog = Wx::MessageDialog->new($self,
"The Spiral Vase mode requires:\n"
. "- one perimeter\n"
. "- no top solid layers\n"
. "- 0% fill density\n"
. "- no support material\n"
- . "- no infill where necessary\n"
. "\nShall I adjust those settings in order to enable Spiral Vase?",
'Spiral Vase', wxICON_WARNING | wxYES | wxNO);
if ($dialog->ShowModal() == wxID_YES) {
@@ -848,7 +846,6 @@ sub _update {
$new_conf->set("top_solid_layers", 0);
$new_conf->set("fill_density", 0);
$new_conf->set("support_material", 0);
- $new_conf->set("infill_only_where_needed", 0);
$self->load_config($new_conf);
} else {
my $new_conf = Slic3r::Config->new;
@@ -1012,12 +1009,7 @@ sub build {
$optgroup->append_single_option_line('filament_colour', 0);
$optgroup->append_single_option_line('filament_diameter', 0);
$optgroup->append_single_option_line('extrusion_multiplier', 0);
- $optgroup->append_single_option_line('filament_density', 0);
- $optgroup->append_single_option_line('filament_cost', 0);
}
-
-
-
{
my $optgroup = $page->new_optgroup('Temperature (°C)');
@@ -1039,6 +1031,11 @@ sub build {
$optgroup->append_line($line);
}
}
+ {
+ my $optgroup = $page->new_optgroup('Optional information');
+ $optgroup->append_single_option_line('filament_density', 0);
+ $optgroup->append_single_option_line('filament_cost', 0);
+ }
}
{
@@ -1082,9 +1079,8 @@ sub build {
$optgroup->append_single_option_line('min_print_speed');
}
}
-
{
- my $page = $self->add_options_page('Custom G-code', 'cog.png');
+ my $page = $self->add_options_page('Custom G-code', 'script.png');
{
my $optgroup = $page->new_optgroup('Start G-code',
label_width => 0,
@@ -1104,6 +1100,19 @@ sub build {
$optgroup->append_single_option_line($option);
}
}
+
+ {
+ my $page = $self->add_options_page('Notes', 'note.png');
+ {
+ my $optgroup = $page->new_optgroup('Notes',
+ label_width => 0,
+ );
+ my $option = $optgroup->get_option('filament_notes', 0);
+ $option->full_width(1);
+ $option->height(250);
+ $optgroup->append_single_option_line($option);
+ }
+ }
{
my $page = $self->add_options_page('Overrides', 'wrench.png');
@@ -1398,7 +1407,7 @@ sub build {
}
}
{
- my $page = $self->add_options_page('Custom G-code', 'cog.png');
+ my $page = $self->add_options_page('Custom G-code', 'script.png');
{
my $optgroup = $page->new_optgroup('Start G-code',
label_width => 0,
diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm
index bd0701437a..3faad83172 100644
--- a/lib/Slic3r/Print/GCode.pm
+++ b/lib/Slic3r/Print/GCode.pm
@@ -48,7 +48,7 @@ sub BUILD {
$self->_cooling_buffer(Slic3r::GCode::CoolingBuffer->new($self->_gcodegen));
- $self->_spiral_vase(Slic3r::GCode::SpiralVase->new(config => $self->config))
+ $self->_spiral_vase(Slic3r::GCode::SpiralVase->new($self->config))
if $self->config->spiral_vase;
$self->_vibration_limit(Slic3r::GCode::VibrationLimit->new(config => $self->config))
@@ -323,10 +323,10 @@ sub process_layer {
# check whether we're going to apply spiralvase logic
if (defined $self->_spiral_vase) {
- $self->_spiral_vase->enable(
- ($layer->id > 0 || $self->print->config->brim_width == 0
- || $self->print->config->interior_brim_width == 0 || $self->print->config->brim_connections_width == 0)
- && ($layer->id >= $self->print->config->skirt_height && !$self->print->has_infinite_skirt)
+ $self->_spiral_vase->set_enable(
+ $layer->id > 0
+ && ($self->print->config->skirts == 0
+ || ($layer->id >= $self->print->config->skirt_height && !$self->print->has_infinite_skirt))
&& !defined(first { $_->region->config->bottom_solid_layers > $layer->id } @{$layer->regions})
&& !defined(first { $_->perimeters->items_count > 1 } @{$layer->regions})
&& !defined(first { $_->fills->items_count > 0 } @{$layer->regions})
@@ -462,11 +462,7 @@ sub process_layer {
# extrude brim
if (!$self->_brim_done) {
- my $extr = $self->print->regions->[0]->config->perimeter_extruder-1;
- if (my $o = first { $_->config->raft_layers > 0 } @{$self->objects}) {
- $extr = $o->config->support_material_extruder-1;
- }
- $gcode .= $self->_gcodegen->set_extruder($extr);
+ $gcode .= $self->_gcodegen->set_extruder($self->print->brim_extruder-1);
$self->_gcodegen->set_origin(Slic3r::Pointf->new(0,0));
$self->_gcodegen->avoid_crossing_perimeters->set_use_external_mp(1);
$gcode .= $self->_gcodegen->extrude($_, 'brim', $object->config->support_material_speed)
diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm
index ba6bb62b77..d8e41d77ee 100644
--- a/lib/Slic3r/Print/Object.pm
+++ b/lib/Slic3r/Print/Object.pm
@@ -3,7 +3,7 @@ package Slic3r::Print::Object;
use strict;
use warnings;
-use List::Util qw(min max sum first);
+use List::Util qw(min max sum first any);
use Slic3r::Flow ':roles';
use Slic3r::Geometry qw(X Y Z PI scale unscale chained_path epsilon);
use Slic3r::Geometry::Clipper qw(diff diff_ex intersection intersection_ex union union_ex
@@ -459,7 +459,7 @@ sub generate_support_material {
$self->_support_material->generate($self);
$self->set_step_done(STEP_SUPPORTMATERIAL);
- my $stats = "Weight: %.1fg, Cost: %.1f" , $self->print->total_weight, $self->print->total_cost;
+ my $stats = sprintf "Weight: %.1fg, Cost: %.1f" , $self->print->total_weight, $self->print->total_cost;
$self->print->status_cb->(85, $stats);
}
@@ -488,9 +488,9 @@ sub _support_material {
# fill_surfaces but we only turn them into VOID surfaces, thus preserving the boundaries.
sub clip_fill_surfaces {
my $self = shift;
- # sanity check for incompatible options:
- # spiral_vase and infill_only_where_needed
- return unless $self->config->infill_only_where_needed and not $self->config->spiral_vase;
+
+ return unless $self->config->infill_only_where_needed
+ && any { $_->config->fill_density > 0 } @{$self->print->regions};
# We only want infill under ceilings; this is almost like an
# internal support material.
@@ -548,6 +548,8 @@ sub clip_fill_surfaces {
# apply new internal infill to regions
foreach my $layerm (@{$lower_layer->regions}) {
+ next if $layerm->region->config->fill_density == 0;
+
my (@internal, @other) = ();
foreach my $surface (map $_->clone, @{$layerm->fill_surfaces}) {
if ($surface->surface_type == S_TYPE_INTERNAL || $surface->surface_type == S_TYPE_INTERNALVOID) {
diff --git a/lib/Slic3r/Print/Simple.pm b/lib/Slic3r/Print/Simple.pm
index 9087ae0bc1..26f1d43839 100644
--- a/lib/Slic3r/Print/Simple.pm
+++ b/lib/Slic3r/Print/Simple.pm
@@ -14,7 +14,7 @@ use Slic3r::Geometry::Clipper qw(diff);
has '_print' => (
is => 'ro',
default => sub { Slic3r::Print->new },
- handles => [qw(apply_config extruders output_filepath
+ handles => [qw(apply_config config extruders output_filepath
total_used_filament total_extruded_volume
placeholder_parser process)],
);
diff --git a/package/win/slic3r.exe.manifest b/package/win/slic3r.exe.manifest
new file mode 100644
index 0000000000..40c7d9e6b3
--- /dev/null
+++ b/package/win/slic3r.exe.manifest
@@ -0,0 +1,32 @@
+
+
+
+ Slic3r
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/package/win/slic3r.rc b/package/win/slic3r.rc
index 3c1bfa4dd5..20cfa265e0 100644
--- a/package/win/slic3r.rc
+++ b/package/win/slic3r.rc
@@ -22,4 +22,4 @@ BEGIN
VALUE "Translation", 0x409, 1252
END
END
-
+1 Manifest slic3r.exe.manifest
diff --git a/slic3r.pl b/slic3r.pl
index 3aa3292ba5..70f42aac04 100755
--- a/slic3r.pl
+++ b/slic3r.pl
@@ -29,6 +29,7 @@ my %cli_options = ();
'debug' => \$Slic3r::debug,
'gui' => \$opt{gui},
'o|output=s' => \$opt{output},
+ 'j|threads=i' => \$opt{threads},
'save=s' => \$opt{save},
'load=s@' => \$opt{load},
@@ -103,6 +104,7 @@ if ((!@ARGV || $opt{gui}) && !$opt{save} && eval "require Slic3r::GUI; 1") {
$Slic3r::GUI::datadir = Slic3r::decode_path($opt{datadir} // '');
$Slic3r::GUI::no_controller = $opt{no_controller};
$Slic3r::GUI::autosave = Slic3r::decode_path($opt{autosave} // '');
+ $Slic3r::GUI::threads = $opt{threads};
}
$gui = Slic3r::GUI->new;
setlocale(LC_NUMERIC, 'C');
@@ -260,6 +262,7 @@ if (@ARGV) { # slicing from command line
);
$sprint->apply_config($config);
+ $sprint->config->set('threads', $opt{threads}) if $opt{threads};
$sprint->set_model($model);
if ($opt{export_svg}) {
@@ -290,7 +293,7 @@ sub usage {
my $j = '';
if ($Slic3r::have_threads) {
$j = <<"EOF";
- -j, --threads Number of threads to use (1+, default: $config->{threads})
+ -j, --threads Number of threads to use
EOF
}
@@ -459,7 +462,7 @@ $j
--extra-perimeters Add more perimeters when needed (default: yes)
--avoid-crossing-perimeters Optimize travel moves so that no perimeters are crossed (default: no)
--thin-walls Detect single-width walls (default: yes)
- --overhangs Experimental option to use bridge flow, speed and fan for overhangs
+ --detect-bridging-perimeters Detect bridging perimeters and apply bridge flow, speed and fan
(default: yes)
Support material options:
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 934f42724e..85e98471ec 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.8)
project (slic3r)
# only on newer GCCs: -ftemplate-backtrace-limit=0
-set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -DM_PI=3.14159265358979323846 -D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DBOOST_ASIO_DISABLE_KQUEUE")
+set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -DM_PI=3.14159265358979323846 -D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DBOOST_ASIO_DISABLE_KQUEUE")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -DSLIC3R_DEBUG")
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.7.0)
@@ -14,7 +14,8 @@ endif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.7.0)
set(CMAKE_INCLUDE_CURRENT_DIR ON)
IF(CMAKE_HOST_APPLE)
- set(CMAKE_EXE_LINKER_FLAGS "-framework IOKit -framework CoreFoundation")
+ set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE")
+ set(CMAKE_EXE_LINKER_FLAGS "-framework IOKit -framework CoreFoundation -lc++")
ELSE(CMAKE_HOST_APPLE)
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
ENDIF(CMAKE_HOST_APPLE)
@@ -54,6 +55,8 @@ add_library(libslic3r STATIC
${LIBDIR}/libslic3r/Flow.cpp
${LIBDIR}/libslic3r/GCode.cpp
${LIBDIR}/libslic3r/GCode/CoolingBuffer.cpp
+ ${LIBDIR}/libslic3r/GCode/SpiralVase.cpp
+ ${LIBDIR}/libslic3r/GCodeReader.cpp
${LIBDIR}/libslic3r/GCodeSender.cpp
${LIBDIR}/libslic3r/GCodeWriter.cpp
${LIBDIR}/libslic3r/Geometry.cpp
@@ -82,6 +85,7 @@ add_library(libslic3r STATIC
${LIBDIR}/libslic3r/SVG.cpp
${LIBDIR}/libslic3r/TriangleMesh.cpp
)
+
add_library(admesh STATIC
${LIBDIR}/admesh/connect.c
${LIBDIR}/admesh/normals.c
@@ -90,6 +94,8 @@ add_library(admesh STATIC
${LIBDIR}/admesh/stlinit.c
${LIBDIR}/admesh/util.c
)
+set_property(TARGET admesh PROPERTY C_STANDARD 99)
+
add_library(clipper STATIC ${LIBDIR}/clipper.cpp)
add_library(expat STATIC
${LIBDIR}/expat/xmlparse.c
diff --git a/t/shells.t b/t/shells.t
index 63eb1905d5..2347ff3662 100644
--- a/t/shells.t
+++ b/t/shells.t
@@ -186,7 +186,7 @@ use Slic3r::Test;
my $first_layer_temperature_set = 0;
my $temperature_set = 0;
my @z_steps = ();
- Slic3r::GCode::Reader->new->parse(Slic3r::Test::gcode($print), sub {
+ Slic3r::GCode::Reader->new(Z => $config->z_offset)->parse(Slic3r::Test::gcode($print), sub {
my ($self, $cmd, $args, $info) = @_;
if ($cmd eq 'G1') {
diff --git a/var/script.png b/var/script.png
new file mode 100755
index 0000000000..0f9ed4d483
Binary files /dev/null and b/var/script.png differ
diff --git a/xs/Build.PL b/xs/Build.PL
index 12837630ed..87ba0c1ef6 100644
--- a/xs/Build.PL
+++ b/xs/Build.PL
@@ -15,13 +15,18 @@ my $mswin = $^O eq 'MSWin32';
# HAS_BOOL : stops Perl/lib/CORE/handy.h from doing "# define bool char" for MSVC
# NOGDI : prevents inclusion of wingdi.h which defines functions Polygon() and Polyline() in global namespace
# BOOST_ASIO_DISABLE_KQUEUE : prevents a Boost ASIO bug on OS X: https://svn.boost.org/trac/boost/ticket/5339
-# std=c++11 Enforce usage of C++11 (required now). Minimum compiler supported: gcc 4.9, clang 3.3, MSVC 14.0
-my @cflags = qw(-D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DSLIC3RXS -DBOOST_ASIO_DISABLE_KQUEUE
- -std=c++11);
+my @cflags = qw(-D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DSLIC3RXS -DBOOST_ASIO_DISABLE_KQUEUE);
if ($cpp_guess->is_gcc) {
# GCC is pedantic with c++11 std, so undefine strict ansi to get M_PI back
push @cflags, qw(-U__STRICT_ANSI__);
}
+if (`$Config{cc} -v` =~ /gcc version 4\.6\./) {
+ # Compatibility with GCC 4.6 is not a requirement, but as long as code compiles on it we try to support it.
+ push @cflags, qw(-std=c++0x);
+} else {
+ # std=c++11 Enforce usage of C++11 (required now). Minimum compiler supported: gcc 4.9, clang 3.3, MSVC 14.0
+ push @cflags, qw(-std=c++11);
+}
my @ldflags = ();
if ($^O eq 'darwin') {
push @cflags, qw(-stdlib=libc++);
@@ -75,8 +80,8 @@ if (defined $ENV{BOOST_INCLUDEDIR}) {
}
my @boost_libs = ();
-if (defined $ENV{BOOST_LIBRARYDIR}) {
- push @boost_libs, $ENV{BOOST_LIBRARYDIR}
+if (defined $ENV{BOOST_LIBRARYPATH}) {
+ push @boost_libs, $ENV{BOOST_LIBRARYPATH}
} elsif (defined $ENV{BOOST_DIR}) {
my $subdir = $ENV{BOOST_DIR} . ($mswin ? '\stage\lib' : '/stage/lib');
if (-d $subdir) {
@@ -154,12 +159,12 @@ Slic3r requires the Boost libraries. Please make sure they are installed.
If they are installed, this script should be able to locate them in several
standard locations. If this is not the case, you might want to supply their
-path through the BOOST_DIR environment variable:
+path through the BOOST_INCLUDEPATH and BOOST_LIBRARYPATH environment variables:
- BOOST_DIR=/path/to/boost perl Build.PL
+ BOOST_INCLUDEPATH=/usr/local/include BOOST_LIBRARYPATH=/usr/lib perl Build.PL
-Or you may specify BOOST_INCLUDEPATH and BOOST_LIBRARYPATH separatly, which
-is handy, if you have built Boost libraries with mutliple settings.
+If you just compiled Boost in its source directory without installing it in the
+system you can just provide the BOOST_DIR variable pointing to that directory.
EOF
diff --git a/xs/MANIFEST b/xs/MANIFEST
index 3b89458d3b..a2ffbba5a7 100644
--- a/xs/MANIFEST
+++ b/xs/MANIFEST
@@ -66,6 +66,8 @@ src/libslic3r/GCode.cpp
src/libslic3r/GCode.hpp
src/libslic3r/GCode/CoolingBuffer.cpp
src/libslic3r/GCode/CoolingBuffer.hpp
+src/libslic3r/GCode/SpiralVase.cpp
+src/libslic3r/GCode/SpiralVase.hpp
src/libslic3r/GCodeSender.cpp
src/libslic3r/GCodeSender.hpp
src/libslic3r/GCodeWriter.cpp
diff --git a/xs/src/admesh/util.c b/xs/src/admesh/util.c
index a786240ad3..a2e32c2f51 100644
--- a/xs/src/admesh/util.c
+++ b/xs/src/admesh/util.c
@@ -192,11 +192,11 @@ void stl_transform(stl_file *stl, float *trafo3x4) {
for (i_face = 0; i_face < stl->stats.number_of_facets; ++ i_face) {
stl_vertex *vertices = stl->facet_start[i_face].vertex;
for (i_vertex = 0; i_vertex < 3; ++ i_vertex) {
- stl_vertex &v_dst = vertices[i_vertex];
- stl_vertex v_src = v_dst;
- v_dst.x = trafo3x4[0] * v_src.x + trafo3x4[1] * v_src.y + trafo3x4[2] * v_src.z + trafo3x4[3];
- v_dst.y = trafo3x4[4] * v_src.x + trafo3x4[5] * v_src.y + trafo3x4[6] * v_src.z + trafo3x4[7];
- v_dst.z = trafo3x4[8] * v_src.x + trafo3x4[9] * v_src.y + trafo3x4[10] * v_src.z + trafo3x4[11];
+ stl_vertex* v_dst = &vertices[i_vertex];
+ stl_vertex v_src = *v_dst;
+ v_dst->x = trafo3x4[0] * v_src.x + trafo3x4[1] * v_src.y + trafo3x4[2] * v_src.z + trafo3x4[3];
+ v_dst->y = trafo3x4[4] * v_src.x + trafo3x4[5] * v_src.y + trafo3x4[6] * v_src.z + trafo3x4[7];
+ v_dst->z = trafo3x4[8] * v_src.x + trafo3x4[9] * v_src.y + trafo3x4[10] * v_src.z + trafo3x4[11];
}
}
stl_get_size(stl);
diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp
index d5a67702a5..b5565ea76f 100644
--- a/xs/src/libslic3r/Config.cpp
+++ b/xs/src/libslic3r/Config.cpp
@@ -9,6 +9,8 @@
#include
#include
#include
+#include
+#include
#include
#include
#include
@@ -106,7 +108,6 @@ bool unescape_string_cstyle(const std::string &str, std::string &str_out)
bool unescape_strings_cstyle(const std::string &str, std::vector &out)
{
- out.clear();
if (str.empty())
return true;
@@ -221,6 +222,12 @@ ConfigDef::add(const t_config_option_key &opt_key, const ConfigOptionDef &def)
return &this->options[opt_key];
}
+bool
+ConfigDef::has(const t_config_option_key &opt_key) const
+{
+ return this->options.count(opt_key) > 0;
+}
+
const ConfigOptionDef*
ConfigDef::get(const t_config_option_key &opt_key) const
{
@@ -292,12 +299,27 @@ ConfigBase::serialize(const t_config_option_key &opt_key) const {
}
bool
-ConfigBase::set_deserialize(const t_config_option_key &opt_key, std::string str, bool append) {
+ConfigBase::set_deserialize(t_config_option_key opt_key, std::string str, bool append) {
const ConfigOptionDef* optdef = this->def->get(opt_key);
- if (optdef == NULL) throw UnknownOptionException();
+ if (optdef == NULL) {
+ // If we didn't find an option, look for any other option having this as an alias.
+ for (const auto &opt : this->def->options) {
+ for (const t_config_option_key &opt_key2 : opt.second.aliases) {
+ if (opt_key2 == opt_key) {
+ opt_key = opt_key2;
+ optdef = &opt.second;
+ break;
+ }
+ }
+ if (optdef != NULL) break;
+ }
+ if (optdef == NULL)
+ throw UnknownOptionException();
+ }
+
if (!optdef->shortcut.empty()) {
- for (std::vector::const_iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it) {
- if (!this->set_deserialize(*it, str)) return false;
+ for (const t_config_option_key &shortcut : optdef->shortcut) {
+ if (!this->set_deserialize(shortcut, str)) return false;
}
return true;
}
@@ -377,7 +399,9 @@ ConfigBase::load(const std::string &file)
pt::read_ini(file, tree);
BOOST_FOREACH(const pt::ptree::value_type &v, tree) {
try {
- this->set_deserialize(v.first.c_str(), v.second.get_value().c_str());
+ t_config_option_key opt_key = v.first;
+ std::string value = v.second.get_value();
+ this->set_deserialize(opt_key, value);
} catch (UnknownOptionException &e) {
// ignore
}
@@ -508,56 +532,109 @@ DynamicConfig::clear() {
this->options.clear();
}
+void
+DynamicConfig::read_cli(const std::vector &tokens, t_config_option_keys* extra)
+{
+ std::vector _argv;
+
+ // push a bogus executable name (argv[0])
+ _argv.push_back("");
+
+ for (size_t i = 0; i < tokens.size(); ++i)
+ _argv.push_back(const_cast(tokens[i].c_str()));
+
+ this->read_cli(_argv.size(), &_argv[0], extra);
+}
+
void
DynamicConfig::read_cli(const int argc, const char** argv, t_config_option_keys* extra)
{
+ // cache the CLI option => opt_key mapping
+ std::map opts;
+ for (const auto &oit : this->def->options) {
+ std::string cli = oit.second.cli;
+ cli = cli.substr(0, cli.find("="));
+ boost::trim_right_if(cli, boost::is_any_of("!"));
+ std::vector tokens;
+ boost::split(tokens, cli, boost::is_any_of("|"));
+ for (const std::string &t : tokens)
+ opts[t] = oit.first;
+ }
+
bool parse_options = true;
for (int i = 1; i < argc; ++i) {
std::string token = argv[i];
+ // Store non-option arguments in the provided vector.
+ if (!parse_options || !boost::starts_with(token, "-")) {
+ extra->push_back(token);
+ continue;
+ }
+
+
+ // Stop parsing tokens as options when -- is supplied.
if (token == "--") {
- // stop parsing tokens as options
parse_options = false;
- } else if (parse_options && boost::starts_with(token, "-")) {
- boost::algorithm::trim_left_if(token, boost::algorithm::is_any_of("-"));
- // TODO: handle --key=value
-
- // look for the option def
- t_config_option_key opt_key;
- const ConfigOptionDef* optdef;
- for (t_optiondef_map::const_iterator oit = this->def->options.begin();
- oit != this->def->options.end(); ++oit) {
- optdef = &oit->second;
-
- if (optdef->cli == token
- || optdef->cli == token + '!'
- || boost::starts_with(optdef->cli, token + "=")
- || boost::starts_with(optdef->cli, token + "|")
- || (token.length() == 1 && boost::contains(optdef->cli, "|" + token))) {
- opt_key = oit->first;
- break;
- }
+ continue;
+ }
+
+ // Remove leading dashes
+ boost::trim_left_if(token, boost::is_any_of("-"));
+
+ // Remove the "no-" prefix used to negate boolean options.
+ bool no = false;
+ if (boost::starts_with(token, "no-")) {
+ no = true;
+ boost::replace_first(token, "no-", "");
+ }
+
+ // Read value when supplied in the --key=value form.
+ std::string value;
+ {
+ size_t equals_pos = token.find("=");
+ if (equals_pos != std::string::npos) {
+ value = token.substr(equals_pos+1);
+ token.erase(equals_pos);
}
-
- if (opt_key.empty()) {
- printf("Warning: unknown option --%s\n", token.c_str());
+ }
+
+ // Look for the cli -> option mapping.
+ const auto it = opts.find(token);
+ if (it == opts.end()) {
+ printf("Warning: unknown option --%s\n", token.c_str());
+ continue;
+ }
+ const t_config_option_key opt_key = it->second;
+ const ConfigOptionDef &optdef = this->def->options.at(opt_key);
+
+ // If the option type expects a value and it was not already provided,
+ // look for it in the next token.
+ if (optdef.type != coBool && optdef.type != coBools && value.empty()) {
+ if (i == (argc-1)) {
+ printf("No value supplied for --%s\n", token.c_str());
continue;
}
-
- if (ConfigOptionBool* opt = this->opt(opt_key, true)) {
- opt->value = !boost::starts_with(token, "no-");
- } else if (ConfigOptionBools* opt = this->opt(opt_key, true)) {
- opt->values.push_back(!boost::starts_with(token, "no-"));
- } else {
- // we expect one more token carrying the value
- if (i == (argc-1)) {
- printf("No value supplied for --%s\n", token.c_str());
- exit(1);
- }
- this->set_deserialize(opt_key, argv[++i], true);
- }
+ value = argv[++i];
+ }
+
+ // Store the option value.
+ const bool existing = this->has(opt_key);
+ if (ConfigOptionBool* opt = this->opt(opt_key, true)) {
+ opt->value = !no;
+ } else if (ConfigOptionBools* opt = this->opt(opt_key, true)) {
+ if (!existing) opt->values.clear(); // remove the default values
+ opt->values.push_back(!no);
+ } else if (ConfigOptionStrings* opt = this->opt(opt_key, true)) {
+ if (!existing) opt->values.clear(); // remove the default values
+ opt->deserialize(value, true);
+ } else if (ConfigOptionFloats* opt = this->opt(opt_key, true)) {
+ if (!existing) opt->values.clear(); // remove the default values
+ opt->deserialize(value, true);
+ } else if (ConfigOptionPoints* opt = this->opt(opt_key, true)) {
+ if (!existing) opt->values.clear(); // remove the default values
+ opt->deserialize(value, true);
} else {
- extra->push_back(token);
+ this->set_deserialize(opt_key, value, true);
}
}
}
@@ -614,4 +691,27 @@ ConfigOptionPoint3::deserialize(std::string str, bool append) {
return true;
};
+bool
+ConfigOptionPoints::deserialize(std::string str, bool append) {
+ if (!append) this->values.clear();
+
+ std::vector tokens;
+ boost::split(tokens, str, boost::is_any_of("x,"));
+ if (tokens.size() % 2) return false;
+
+ try {
+ for (size_t i = 0; i < tokens.size(); ++i) {
+ Pointf point;
+ point.x = boost::lexical_cast(tokens[i]);
+ point.y = boost::lexical_cast(tokens[++i]);
+ this->values.push_back(point);
+ }
+ } catch (boost::bad_lexical_cast &e) {
+ printf("%s\n", e.what());
+ return false;
+ }
+
+ return true;
+}
+
}
diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp
index 908d761a8e..45ba8a3baf 100644
--- a/xs/src/libslic3r/Config.hpp
+++ b/xs/src/libslic3r/Config.hpp
@@ -248,6 +248,7 @@ class ConfigOptionStrings : public ConfigOptionVector
};
bool deserialize(std::string str, bool append = false) {
+ if (!append) this->values.clear();
return unescape_strings_cstyle(str, this->values);
};
};
@@ -390,24 +391,7 @@ class ConfigOptionPoints : public ConfigOptionVector
return vv;
};
- bool deserialize(std::string str, bool append = false) {
- if (!append) this->values.clear();
- std::istringstream is(str);
- std::string point_str;
- while (std::getline(is, point_str, ',')) {
- Pointf point;
- std::istringstream iss(point_str);
- std::string coord_str;
- if (std::getline(iss, coord_str, 'x')) {
- std::istringstream(coord_str) >> point.x;
- if (std::getline(iss, coord_str, 'x')) {
- std::istringstream(coord_str) >> point.y;
- }
- }
- this->values.push_back(point);
- }
- return true;
- };
+ bool deserialize(std::string str, bool append = false);
};
class ConfigOptionBool : public ConfigOptionSingle
@@ -642,6 +626,7 @@ class ConfigDef
t_optiondef_map options;
ConfigOptionDef* add(const t_config_option_key &opt_key, ConfigOptionType type);
ConfigOptionDef* add(const t_config_option_key &opt_key, const ConfigOptionDef &def);
+ bool has(const t_config_option_key &opt_key) const;
const ConfigOptionDef* get(const t_config_option_key &opt_key) const;
void merge(const ConfigDef &other);
};
@@ -669,7 +654,7 @@ class ConfigBase
bool equals(ConfigBase &other);
t_config_option_keys diff(ConfigBase &other);
std::string serialize(const t_config_option_key &opt_key) const;
- bool set_deserialize(const t_config_option_key &opt_key, std::string str, bool append = false);
+ virtual bool set_deserialize(t_config_option_key opt_key, std::string str, bool append = false);
double get_abs_value(const t_config_option_key &opt_key) const;
double get_abs_value(const t_config_option_key &opt_key, double ratio_over) const;
void setenv_();
@@ -693,6 +678,7 @@ class DynamicConfig : public virtual ConfigBase
t_config_option_keys keys() const;
void erase(const t_config_option_key &opt_key);
void clear();
+ void read_cli(const std::vector &tokens, t_config_option_keys* extra);
void read_cli(const int argc, const char **argv, t_config_option_keys* extra);
private:
diff --git a/xs/src/libslic3r/ExPolygon.cpp b/xs/src/libslic3r/ExPolygon.cpp
index 19c3184f34..ec02acc356 100644
--- a/xs/src/libslic3r/ExPolygon.cpp
+++ b/xs/src/libslic3r/ExPolygon.cpp
@@ -129,6 +129,14 @@ ExPolygon::has_boundary_point(const Point &point) const
return false;
}
+void
+ExPolygon::remove_vertical_collinear_points(coord_t tolerance)
+{
+ this->contour.remove_vertical_collinear_points(tolerance);
+ for (Polygon &p : this->holes)
+ p.remove_vertical_collinear_points(tolerance);
+}
+
void
ExPolygon::simplify_p(double tolerance, Polygons* polygons) const
{
diff --git a/xs/src/libslic3r/ExPolygon.hpp b/xs/src/libslic3r/ExPolygon.hpp
index 4289eb3904..63cc560cd9 100644
--- a/xs/src/libslic3r/ExPolygon.hpp
+++ b/xs/src/libslic3r/ExPolygon.hpp
@@ -29,6 +29,7 @@ class ExPolygon
bool contains(const Point &point) const;
bool contains_b(const Point &point) const;
bool has_boundary_point(const Point &point) const;
+ void remove_vertical_collinear_points(coord_t tolerance);
void simplify_p(double tolerance, Polygons* polygons) const;
Polygons simplify_p(double tolerance) const;
ExPolygons simplify(double tolerance) const;
diff --git a/xs/src/libslic3r/Fill/FillRectilinear.cpp b/xs/src/libslic3r/Fill/FillRectilinear.cpp
index cc7b0ca133..c74da28775 100644
--- a/xs/src/libslic3r/Fill/FillRectilinear.cpp
+++ b/xs/src/libslic3r/Fill/FillRectilinear.cpp
@@ -1,3 +1,9 @@
+//#define DEBUG_RECTILINEAR
+#ifdef DEBUG_RECTILINEAR
+ #undef NDEBUG
+ #include "../SVG.hpp"
+#endif
+
#include "../ClipperUtils.hpp"
#include "../ExPolygon.hpp"
#include "../PolylineCollection.hpp"
@@ -7,17 +13,16 @@
#include "FillRectilinear.hpp"
-//#define DEBUG_RECTILINEAR
-#ifdef DEBUG_RECTILINEAR
- #include "../SVG.hpp"
-#endif
-
namespace Slic3r {
void
FillRectilinear::_fill_single_direction(ExPolygon expolygon,
const direction_t &direction, coord_t x_shift, Polylines* out)
{
+ // Remove almost collinear points (vertical ones might break this algorithm
+ // because of rounding).
+ expolygon.remove_vertical_collinear_points(1);
+
// rotate polygons so that we can work with vertical lines here
expolygon.rotate(-direction.first);
@@ -58,6 +63,27 @@ FillRectilinear::_fill_single_direction(ExPolygon expolygon,
// Whenever between two intersection points we find vertices of the original polygon,
// store them in the 'skipped' member of the latter point.
+ struct IntersectionPoint : Point {
+ enum ipType { ipTypeLower, ipTypeUpper, ipTypeMiddle };
+ ipType type;
+
+ // skipped contains the polygon points accumulated between the previous intersection
+ // point and the current one, in the original polygon winding order (does not contain
+ // either points)
+ Points skipped;
+
+ // next contains a polygon portion connecting this point to the first intersection
+ // point found following the polygon in any direction but having:
+ // x > this->x || (x == this->x && y > this->y)
+ // (it doesn't contain *this but it contains the target intersection point)
+ Points next;
+
+ IntersectionPoint() : Point() {};
+ IntersectionPoint(coord_t x, coord_t y, ipType _type) : Point(x,y), type(_type) {};
+ };
+ typedef std::map vertical_t; //
+ typedef std::map grid_t; // >
+
grid_t grid;
{
const Polygons polygons = expolygon;
diff --git a/xs/src/libslic3r/Fill/FillRectilinear.hpp b/xs/src/libslic3r/Fill/FillRectilinear.hpp
index d5d5b8ecfb..11e3ec4a6a 100644
--- a/xs/src/libslic3r/Fill/FillRectilinear.hpp
+++ b/xs/src/libslic3r/Fill/FillRectilinear.hpp
@@ -23,27 +23,6 @@ protected:
void _fill_single_direction(ExPolygon expolygon, const direction_t &direction,
coord_t x_shift, Polylines* out);
-
- struct IntersectionPoint : Point {
- enum ipType { ipTypeLower, ipTypeUpper, ipTypeMiddle };
- ipType type;
-
- // skipped contains the polygon points accumulated between the previous intersection
- // point and the current one, in the original polygon winding order (does not contain
- // either points)
- Points skipped;
-
- // next contains a polygon portion connecting this point to the first intersection
- // point found following the polygon in any direction but having:
- // x > this->x || (x == this->x && y > this->y)
- // (it doesn't contain *this but it contains the target intersection point)
- Points next;
-
- IntersectionPoint() : Point() {};
- IntersectionPoint(coord_t x, coord_t y, ipType _type) : Point(x,y), type(_type) {};
- };
- typedef std::map vertical_t; //
- typedef std::map grid_t; // >
};
class FillAlignedRectilinear : public FillRectilinear
diff --git a/xs/src/libslic3r/GCode/SpiralVase.cpp b/xs/src/libslic3r/GCode/SpiralVase.cpp
new file mode 100644
index 0000000000..b56c9e58b8
--- /dev/null
+++ b/xs/src/libslic3r/GCode/SpiralVase.cpp
@@ -0,0 +1,95 @@
+#include "SpiralVase.hpp"
+#include
+
+namespace Slic3r {
+
+std::string
+_format_z(float z)
+{
+ std::ostringstream ss;
+ ss << std::fixed << std::setprecision(3)
+ << z;
+ return ss.str();
+}
+
+std::string
+SpiralVase::process_layer(const std::string &gcode)
+{
+ /* This post-processor relies on several assumptions:
+ - all layers are processed through it, including those that are not supposed
+ to be transformed, in order to update the reader with the XY positions
+ - each call to this method includes a full layer, with a single Z move
+ at the beginning
+ - each layer is composed by suitable geometry (i.e. a single complete loop)
+ - loops were not clipped before calling this method */
+
+ // If we're not going to modify G-code, just feed it to the reader
+ // in order to update positions.
+ if (!this->enable) {
+ this->_reader.parse(gcode, {});
+ return gcode;
+ }
+
+ // Get total XY length for this layer by summing all extrusion moves.
+ float total_layer_length = 0;
+ float layer_height = 0;
+ float z;
+ bool set_z = false;
+
+ {
+ GCodeReader r = this->_reader; // clone
+ r.parse(gcode, [&total_layer_length, &layer_height, &z, &set_z]
+ (GCodeReader &, GCodeReader::GCodeLine &line) {
+ if (line.cmd == "G1") {
+ if (line.extruding()) {
+ total_layer_length += line.dist_XY();
+ } else if (line.has('Z')) {
+ layer_height += line.dist_Z();
+ if (!set_z) {
+ z = line.new_Z();
+ set_z = true;
+ }
+ }
+ }
+ });
+ }
+
+ // Remove layer height from initial Z.
+ z -= layer_height;
+
+ std::string new_gcode;
+ this->_reader.parse(gcode, [&new_gcode, &z, &layer_height, &total_layer_length]
+ (GCodeReader &, GCodeReader::GCodeLine line) {
+ if (line.cmd == "G1") {
+ if (line.has('Z')) {
+ // If this is the initial Z move of the layer, replace it with a
+ // (redundant) move to the last Z of previous layer.
+ line.set('Z', _format_z(z));
+ new_gcode += line.raw + '\n';
+ return;
+ } else {
+ float dist_XY = line.dist_XY();
+ if (dist_XY > 0) {
+ // horizontal move
+ if (line.extruding()) {
+ z += dist_XY * layer_height / total_layer_length;
+ line.set('Z', _format_z(z));
+ new_gcode += line.raw + '\n';
+ }
+ return;
+
+ /* Skip travel moves: the move to first perimeter point will
+ cause a visible seam when loops are not aligned in XY; by skipping
+ it we blend the first loop move in the XY plane (although the smoothness
+ of such blend depend on how long the first segment is; maybe we should
+ enforce some minimum length?). */
+ }
+ }
+ }
+ new_gcode += line.raw + '\n';
+ });
+
+ return new_gcode;
+}
+
+}
diff --git a/xs/src/libslic3r/GCode/SpiralVase.hpp b/xs/src/libslic3r/GCode/SpiralVase.hpp
new file mode 100644
index 0000000000..f14d15879d
--- /dev/null
+++ b/xs/src/libslic3r/GCode/SpiralVase.hpp
@@ -0,0 +1,29 @@
+#ifndef slic3r_SpiralVase_hpp_
+#define slic3r_SpiralVase_hpp_
+
+#include "libslic3r.h"
+#include "GCode.hpp"
+#include "GCodeReader.hpp"
+
+namespace Slic3r {
+
+class SpiralVase {
+ public:
+ bool enable;
+
+ SpiralVase(const PrintConfig &config)
+ : enable(false), _config(&config)
+ {
+ this->_reader.Z = this->_config->z_offset;
+ this->_reader.apply_config(*this->_config);
+ };
+ std::string process_layer(const std::string &gcode);
+
+ private:
+ const PrintConfig* _config;
+ GCodeReader _reader;
+};
+
+}
+
+#endif
diff --git a/xs/src/libslic3r/GCodeReader.cpp b/xs/src/libslic3r/GCodeReader.cpp
new file mode 100644
index 0000000000..fcaaea9be8
--- /dev/null
+++ b/xs/src/libslic3r/GCodeReader.cpp
@@ -0,0 +1,91 @@
+#include "GCodeReader.hpp"
+#include
+#include
+#include
+
+namespace Slic3r {
+
+void
+GCodeReader::apply_config(const PrintConfigBase &config)
+{
+ this->_config.apply(config, true);
+ this->_extrusion_axis = this->_config.get_extrusion_axis()[0];
+}
+
+void
+GCodeReader::parse(const std::string &gcode, callback_t callback)
+{
+ std::istringstream ss(gcode);
+ std::string line;
+ while (std::getline(ss, line)) {
+ GCodeLine gline(this);
+ gline.raw = line;
+ if (this->verbose)
+ std::cout << line << std::endl;
+
+ // strip comment
+ {
+ size_t pos = line.find(';');
+ if (pos != std::string::npos) {
+ gline.comment = line.substr(pos+1);
+ line.erase(pos);
+ }
+ }
+
+ // command and args
+ {
+ std::vector args;
+ boost::split(args, line, boost::is_any_of(" "));
+
+ // first one is cmd
+ gline.cmd = args.front();
+ args.erase(args.begin());
+
+ for (std::string &arg : args) {
+ if (arg.size() < 2) continue;
+ gline.args.insert(std::make_pair(arg[0], arg.substr(1)));
+ }
+ }
+
+ // convert extrusion axis
+ if (this->_extrusion_axis != 'E') {
+ const auto it = gline.args.find(this->_extrusion_axis);
+ if (it != gline.args.end()) {
+ std::swap(gline.args['E'], it->second);
+ gline.args.erase(it);
+ }
+ }
+
+ if (callback) callback(*this, gline);
+
+ // update coordinates
+ if (gline.cmd == "G0" || gline.cmd == "G1" || gline.cmd == "G92") {
+ this->X = gline.new_X();
+ this->Y = gline.new_Y();
+ this->Z = gline.new_Z();
+ this->E = gline.new_E();
+ this->F = gline.new_F();
+ }
+ }
+}
+
+void
+GCodeReader::GCodeLine::set(char arg, std::string value)
+{
+ const std::string space(" ");
+ if (this->has(arg)) {
+ size_t pos = this->raw.find(space + arg)+2;
+ size_t end = this->raw.find(' ', pos+1);
+ this->raw = this->raw.replace(pos, end-pos, value);
+ } else {
+ size_t pos = this->raw.find(' ');
+ if (pos == std::string::npos) {
+ this->raw += space + arg + value;
+ } else {
+ this->raw = this->raw.replace(pos, 0, space + arg + value);
+ }
+ }
+ this->args[arg] = value;
+}
+
+}
diff --git a/xs/src/libslic3r/GCodeReader.hpp b/xs/src/libslic3r/GCodeReader.hpp
new file mode 100644
index 0000000000..267ac0e186
--- /dev/null
+++ b/xs/src/libslic3r/GCodeReader.hpp
@@ -0,0 +1,64 @@
+#ifndef slic3r_GCodeReader_hpp_
+#define slic3r_GCodeReader_hpp_
+
+#include "libslic3r.h"
+#include
+#include
+#include
+#include
+#include "PrintConfig.hpp"
+
+namespace Slic3r {
+
+class GCodeReader;
+class GCodeReader {
+ public:
+
+ class GCodeLine {
+ public:
+ GCodeReader* reader;
+ std::string raw;
+ std::string cmd;
+ std::string comment;
+ std::map args;
+
+ GCodeLine(GCodeReader* _reader) : reader(_reader) {};
+
+ bool has(char arg) const { return this->args.count(arg) > 0; };
+ float new_X() const { return this->has('X') ? atof(this->args.at('X').c_str()) : this->reader->X; };
+ float new_Y() const { return this->has('Y') ? atof(this->args.at('Y').c_str()) : this->reader->Y; };
+ float new_Z() const { return this->has('Z') ? atof(this->args.at('Z').c_str()) : this->reader->Z; };
+ float new_E() const { return this->has('E') ? atof(this->args.at('E').c_str()) : this->reader->E; };
+ float new_F() const { return this->has('F') ? atof(this->args.at('F').c_str()) : this->reader->F; };
+ float dist_X() const { return this->new_X() - this->reader->X; };
+ float dist_Y() const { return this->new_Y() - this->reader->Y; };
+ float dist_Z() const { return this->new_Z() - this->reader->Z; };
+ float dist_E() const { return this->new_E() - this->reader->E; };
+ float dist_XY() const {
+ float x = this->dist_X();
+ float y = this->dist_Y();
+ return sqrt(x*x + y*y);
+ };
+ bool extruding() const { return this->cmd == "G1" && this->dist_E() > 0; };
+ bool retracting() const { return this->cmd == "G1" && this->dist_E() < 0; };
+ bool travel() const { return this->cmd == "G1" && !this->has('E'); };
+ void set(char arg, std::string value);
+ };
+ typedef std::function callback_t;
+
+ float X, Y, Z, E, F;
+ bool verbose;
+ callback_t callback;
+
+ GCodeReader() : X(0), Y(0), Z(0), E(0), F(0), verbose(false), _extrusion_axis('E') {};
+ void apply_config(const PrintConfigBase &config);
+ void parse(const std::string &gcode, callback_t callback);
+
+ private:
+ GCodeConfig _config;
+ char _extrusion_axis;
+};
+
+} /* namespace Slic3r */
+
+#endif /* slic3r_GCodeReader_hpp_ */
diff --git a/xs/src/libslic3r/IO/AMF.cpp b/xs/src/libslic3r/IO/AMF.cpp
index 32471e1055..f0bb7a60a8 100644
--- a/xs/src/libslic3r/IO/AMF.cpp
+++ b/xs/src/libslic3r/IO/AMF.cpp
@@ -1,4 +1,6 @@
#include "../IO.hpp"
+#include
+#include
#include
#include