From d73e8558a26899b4eb13367eb40346dd6827f802 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 9 Jan 2017 10:44:11 +0100 Subject: [PATCH 01/37] Added AGPLv3 license text --- LICENSE | 661 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 661 insertions(+) create mode 100644 LICENSE 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 +. From cdf48ade2588e01c217e23391e356a580657ed47 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Thu, 16 Mar 2017 11:10:23 +0100 Subject: [PATCH 02/37] Fix a typo in the BOOST_* environment variables and clarify the error message. Also, support GCC 4.6.x. --- xs/Build.PL | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) 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 From f724090d293ff9c3519be68f66ba42eed7839237 Mon Sep 17 00:00:00 2001 From: Paul Novak Date: Thu, 16 Mar 2017 19:38:10 -0700 Subject: [PATCH 03/37] Use default size for label and size column label to fit content. --- lib/Slic3r/GUI/Plater/ObjectSettingsDialog.pm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 From b50417cb2072027cea9b6a44a9ac15f3bc08a4ad Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 16:03:58 +0100 Subject: [PATCH 04/37] Cosmetic improvements --- lib/Slic3r/GUI/Plater.pm | 26 ++++++++++++++++++-------- lib/Slic3r/GUI/Tab.pm | 14 +++++++------- var/script.png | Bin 0 -> 748 bytes xs/src/libslic3r/PrintConfig.cpp | 4 ++-- 4 files changed, 27 insertions(+), 17 deletions(-) create mode 100755 var/script.png diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 3ce193a7c2..d8d11f3e28 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -435,7 +435,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); @@ -444,9 +444,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) { @@ -1398,10 +1396,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; diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 1b61e3f384..6f772d2b78 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -916,12 +916,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)'); @@ -943,6 +938,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); + } } { @@ -1008,7 +1008,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, @@ -1237,7 +1237,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/var/script.png b/var/script.png new file mode 100755 index 0000000000000000000000000000000000000000..0f9ed4d48301ffdce04cdb17dbf8acbad8372d11 GIT binary patch literal 748 zcmVrG{ z$cl-P=->hx6#}NAmbP5myY~I>{qOhtLMa7Y{qE64eE#g}(xpY)TeQ8l?;Upi4EuP3 zj9qNwYy4OP^j-JLi)W5q`snr30AQZ_=_2*h-J^Uqwd^<9gC_@m_YruehOwSPa9@O%#PST ztn>RnbQXoQ3&2p_*N2(YI zkrMO}==(rnxsJAW59QQs0L07JZk*~;x_q%%{cN7dr3j%I4jC^oS!R20 zp-X8Kpw211iFbazd*AM1?Vu^zTr_Qvx?Y!ieJR$aQy;v2#^ddUoYEFRo!j>1ci(tn z{K@;T0)Sj-bCEg}zP!0%dBFa`LT=k_fI7GB{l`yczPWYR>anra$&%HTk?G3F@#Ue> zFdEg-dzaUZYPNRv<+lA7pzgcw+uL{UoxOeM-g%tFNu0n5OqYg(!P3&eWMyo1vh4Ri e9{q`*0R9JiiaRV3rbYDt0000add("filament_density", coFloats); def->label = "Density"; def->tooltip = "Enter your filament density here. This is only for statistical information. A decent way is to weigh a known length of filament and compute the ratio of the length to volume. Better is to calculate the volume directly through displacement."; - def->sidetext = "g/cm^3"; + def->sidetext = "g/cm³"; def->cli = "filament-density=f@"; def->min = 0; { @@ -909,7 +909,7 @@ PrintConfigDef::PrintConfigDef() def->default_value = new ConfigOptionFloat(4); def = this->add("resolution", coFloat); - def->label = "Resolution"; + def->label = "Resolution (deprecated)"; def->tooltip = "Minimum detail resolution, used to simplify the input file for speeding up the slicing job and reducing memory usage. High-resolution models often carry more detail than printers can render. Set to zero to disable any simplification and use full resolution from input."; def->sidetext = "mm"; def->cli = "resolution=f"; From a1c7b65741be6b0a889567db0f434fe2f6969e42 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 16:41:34 +0100 Subject: [PATCH 05/37] Moved threads option from print settings to application preferences --- lib/Slic3r/GUI.pm | 20 ++++++++++---------- lib/Slic3r/GUI/Plater.pm | 4 ++++ lib/Slic3r/GUI/Preferences.pm | 7 +++++++ lib/Slic3r/GUI/Tab.pm | 3 +-- lib/Slic3r/Print/Simple.pm | 2 +- slic3r.pl | 5 ++++- xs/src/libslic3r/PrintConfig.cpp | 1 - xs/src/libslic3r/PrintConfig.hpp | 2 ++ 8 files changed, 29 insertions(+), 15 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index c4fe92a04c..aea900028d 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -60,6 +60,7 @@ our $no_controller; our $no_plater; our $mode; our $autosave; +our $threads; our @cb; our $Settings = { @@ -70,8 +71,8 @@ our $Settings = { invert_zoom => 0, background_processing => 0, # If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden. - # By default, Prusa has the controller hidden. - no_controller => 1, + no_controller => 0, + threads => $Slic3r::Config::Options->{threads}{default}, }, }; @@ -121,16 +122,15 @@ 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}; - $Settings->{_}{mode} ||= 'expert'; - $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; + if ($ini) { + $last_version = $ini->{_}{version}; + $ini->{_}{$_} = $Settings->{_}{$_} + for grep !exists $ini->{_}{$_}, keys %{$Settings->{_}}; + $Settings = $ini; + } } $Settings->{_}{version} = $Slic3r::VERSION; + $Settings->{_}{threads} = $threads if $threads; $self->save_settings; # application frame diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index d8d11f3e28..c620673712 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1157,6 +1157,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 { diff --git a/lib/Slic3r/GUI/Preferences.pm b/lib/Slic3r/GUI/Preferences.pm index 91465fa646..231eb5cc91 100644 --- a/lib/Slic3r/GUI/Preferences.pm +++ b/lib/Slic3r/GUI/Preferences.pm @@ -67,6 +67,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/Tab.pm b/lib/Slic3r/GUI/Tab.pm index 6f772d2b78..a19bb1e76d 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -497,7 +497,7 @@ sub build { 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 + xy_size_compensation resolution )); $self->{config}->set('print_settings_id', ''); @@ -686,7 +686,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'); } } 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/slic3r.pl b/slic3r.pl index d4ebd5c488..69bb58593b 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}, @@ -109,6 +110,7 @@ if ((!@ARGV || $opt{gui}) && !$opt{save} && eval "require Slic3r::GUI; 1") { $Slic3r::GUI::no_plater = $opt{no_plater}; $Slic3r::GUI::mode = $opt{gui_mode}; $Slic3r::GUI::autosave = $opt{autosave}; + $Slic3r::GUI::threads = $opt{threads}; } $gui = Slic3r::GUI->new; setlocale(LC_NUMERIC, 'C'); @@ -263,6 +265,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}) { @@ -293,7 +296,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 } diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 5866615105..1766f63cdf 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1383,7 +1383,6 @@ PrintConfigDef::PrintConfigDef() def = this->add("threads", coInt); def->label = "Threads"; def->tooltip = "Threads are used to parallelize long-running tasks. Optimal threads number is slightly above the number of available cores/processors."; - def->cli = "threads|j=i"; def->readonly = true; def->min = 1; { diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index bd63bb9190..2ea423d8cc 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -624,6 +624,7 @@ class CLIConfig ConfigOptionString save; ConfigOptionFloat scale; ConfigOptionPoint3 scale_to_fit; + ConfigOptionBool threads; CLIConfig() : ConfigBase(), StaticConfig() { this->def = &cli_config_def; @@ -647,6 +648,7 @@ class CLIConfig OPT_PTR(save); OPT_PTR(scale); OPT_PTR(scale_to_fit); + OPT_PTR(threads); return NULL; }; From 33059e18d7945625a5cecd646dd5b642291ed61e Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 16:44:09 +0100 Subject: [PATCH 06/37] Change the logic used for enabling version checks so that it's compatible with the new packaging method --- lib/Slic3r/GUI.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index aea900028d..7d2f7f26b3 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -297,7 +297,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 { From 8067295684181dd5b6ddc94d306aaf027f6f70ca Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 16:45:35 +0100 Subject: [PATCH 07/37] Check number of skirt loops before disabling spiral vase --- lib/Slic3r/Print/GCode.pm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index bd0701437a..635a4b65fe 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -326,7 +326,8 @@ sub process_layer { $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->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}) From 5cc509f3fee77307cf4c128f39fca39b3de3c96b Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 16:55:29 +0100 Subject: [PATCH 08/37] Try to autodetect HAS_VBO. #3772 --- lib/Slic3r/GUI/3DScene.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 0e6ba3c8f8..67046853f1 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. From 94ed08c14d62b2fc7e1427ef272d1be42a486fc7 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 17:13:53 +0100 Subject: [PATCH 09/37] Make width and speed options readable again in the override panel --- xs/src/libslic3r/PrintConfig.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 1766f63cdf..10efc1b6c5 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -210,6 +210,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("external_perimeter_extrusion_width", coFloatOrPercent); def->label = "↳ external"; + def->full_label = "External perimeters extrusion width"; def->gui_type = "f_enum_open"; def->category = "Extrusion Width"; def->tooltip = "Set this to a non-zero value to set a manual extrusion width for external perimeters. If auto is chosen, a value will be used that maximizes accuracy of the external visible surfaces. If expressed as percentage (for example 200%) it will be computed over layer height."; @@ -222,6 +223,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("external_perimeter_speed", coFloatOrPercent); def->label = "↳ external"; + def->full_label = "External perimeters speed"; def->gui_type = "f_enum_open"; def->category = "Speed"; def->tooltip = "This separate setting will affect the speed of external perimeters (the visible ones). If expressed as percentage (for example: 80%) it will be calculated on the perimeters speed setting above."; @@ -458,6 +460,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("fill_gaps", coBool); def->label = "Fill gaps"; + def->category = "Infill"; def->tooltip = "If this is enabled, gaps will be filled with single passes. Enable this for better quality, disable it for shorter printing times."; def->cli = "fill-gaps!"; def->default_value = new ConfigOptionBool(true); @@ -554,6 +557,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("gap_fill_speed", coFloat); def->label = "↳ gaps"; + def->full_label = "Gap fill speed"; def->gui_type = "f_enum_open"; def->category = "Speed"; def->tooltip = "Speed for filling gaps. Since these are usually single lines you might want to use a low speed for better sticking. If expressed as percentage (for example: 80%) it will be calculated on the infill speed setting above."; @@ -1102,6 +1106,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("small_perimeter_speed", coFloatOrPercent); def->label = "↳ small"; + def->full_label = "Small perimeters speed"; def->gui_type = "f_enum_open"; def->category = "Speed"; def->tooltip = "This separate setting will affect the speed of perimeters having radius <= 6.5mm (usually holes). If expressed as percentage (for example: 80%) it will be calculated on the perimeters speed setting above."; @@ -1141,6 +1146,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("solid_infill_extrusion_width", coFloatOrPercent); def->label = "↳ solid"; + def->full_label = "Solid infill extrusion width"; def->gui_type = "f_enum_open"; def->category = "Extrusion Width"; def->tooltip = "Set this to a non-zero value to set a manual extrusion width for infill for solid surfaces. If expressed as percentage (for example 90%) it will be computed over layer height."; @@ -1153,6 +1159,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("solid_infill_speed", coFloatOrPercent); def->label = "↳ solid"; + def->full_label = "Solid infill speed"; def->gui_type = "f_enum_open"; def->category = "Speed"; def->tooltip = "Speed for printing solid regions (top/bottom/internal horizontal shells). This can be expressed as a percentage (for example: 80%) over the default infill speed above."; @@ -1299,6 +1306,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("support_material_interface_speed", coFloatOrPercent); def->label = "↳ interface"; + def->category = "Support material interface speed"; def->gui_type = "f_enum_open"; def->category = "Support material"; def->tooltip = "Speed for printing support material interface layers. If expressed as percentage (for example 50%) it will be calculated over support material speed."; @@ -1401,6 +1409,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("top_infill_extrusion_width", coFloatOrPercent); def->label = "↳ top solid"; + def->full_label = "Top solid infill extrusion width"; def->gui_type = "f_enum_open"; def->category = "Extrusion Width"; def->tooltip = "Set this to a non-zero value to set a manual extrusion width for infill for top surfaces. You may want to use thinner extrudates to fill all narrow regions and get a smoother finish. If expressed as percentage (for example 90%) it will be computed over layer height."; @@ -1421,6 +1430,7 @@ PrintConfigDef::PrintConfigDef() def = this->add("top_solid_infill_speed", coFloatOrPercent); def->label = "↳ top solid"; + def->full_label = "Top solid infill speed"; def->gui_type = "f_enum_open"; def->category = "Speed"; def->tooltip = "Speed for printing top solid layers (it only applies to the uppermost external layers and not to their internal solid layers). You may want to slow down this to get a nicer surface finish. This can be expressed as a percentage (for example: 80%) over the solid infill speed above."; From 4c577043f4eefe6a74f6ca2e57d40facd7c1d82e Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 18:53:13 +0100 Subject: [PATCH 10/37] Fixed tests broken by the spiral vase change --- lib/Slic3r/GCode/SpiralVase.pm | 2 ++ lib/Slic3r/Print/GCode.pm | 3 +-- t/shells.t | 2 +- 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GCode/SpiralVase.pm b/lib/Slic3r/GCode/SpiralVase.pm index 837e33d16f..d35e29e713 100644 --- a/lib/Slic3r/GCode/SpiralVase.pm +++ b/lib/Slic3r/GCode/SpiralVase.pm @@ -9,6 +9,8 @@ use Slic3r::Geometry qw(unscale); sub BUILD { my ($self) = @_; + + $self->reader->Z($self->config->z_offset); $self->reader->apply_print_config($self->config); } diff --git a/lib/Slic3r/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index 635a4b65fe..2617697162 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -324,8 +324,7 @@ 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 > 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}) 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') { From 69d169165e024cd76ff38abc4739351d4bc195a3 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 19:17:24 +0100 Subject: [PATCH 11/37] Make sure infill_only_where_needed has no effect when fill_density = 0%. No need to require it to be explicitely turned off for spiral_vase, since it's disabled anyway. #3386 #3126 --- lib/Slic3r/GUI/Tab.pm | 4 +--- lib/Slic3r/Print/Object.pm | 10 ++++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/Slic3r/GUI/Tab.pm b/lib/Slic3r/GUI/Tab.pm index a19bb1e76d..770060edf4 100644 --- a/lib/Slic3r/GUI/Tab.pm +++ b/lib/Slic3r/GUI/Tab.pm @@ -745,14 +745,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) { @@ -761,7 +760,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; diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index ba6bb62b77..d96c99ed22 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 @@ -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->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) { From c4188accc9193b0674486cbc520c0f1e3db22741 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 19:19:34 +0100 Subject: [PATCH 12/37] List ExtUtils::CppGuess as a dependency explicitely. #3329 --- Build.PL | 1 + 1 file changed, 1 insertion(+) diff --git a/Build.PL b/Build.PL index d5f7344cfe..ad5147adbf 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 From a5b10287d645c171c0577728e5da753949299232 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 20:05:04 +0100 Subject: [PATCH 13/37] Typo --- lib/Slic3r/Print/Object.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index d96c99ed22..11f7b6f299 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -548,7 +548,7 @@ sub clip_fill_surfaces { # apply new internal infill to regions foreach my $layerm (@{$lower_layer->regions}) { - next if $layerm->config->fill_density == 0; + next if $layerm->region->config->fill_density == 0; my (@internal, @other) = (); foreach my $surface (map $_->clone, @{$layerm->fill_surfaces}) { From 4c78e54a4697c96333c71fa00fe39d7696373dcd Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 20:17:59 +0100 Subject: [PATCH 14/37] Compensate for origin_translation when exporting AMF files in order to preserve alignment of further added parts. #3348 --- xs/src/libslic3r/IO/AMF.cpp | 48 +++++++++++++++++++------------------ 1 file changed, 25 insertions(+), 23 deletions(-) diff --git a/xs/src/libslic3r/IO/AMF.cpp b/xs/src/libslic3r/IO/AMF.cpp index 32471e1055..ce49640d0d 100644 --- a/xs/src/libslic3r/IO/AMF.cpp +++ b/xs/src/libslic3r/IO/AMF.cpp @@ -528,18 +528,23 @@ AMF::write(Model& model, std::string output_file) std::vector vertices_offsets; int num_vertices = 0; for (ModelVolume *volume : object->volumes) { + volume->mesh.check_topology(); vertices_offsets.push_back(num_vertices); - if (! volume->mesh.repaired) - CONFESS("store_amf() requires repair()"); auto &stl = volume->mesh.stl; if (stl.v_shared == NULL) stl_generate_shared_vertices(&stl); for (size_t i = 0; i < stl.stats.shared_vertices; ++ i) { + // Subtract origin_translation in order to restore the coordinates of the parts + // before they were imported. Otherwise, when this AMF file is reimported parts + // will be placed in the plater correctly, but we will have lost origin_translation + // thus any additional part added will not align with the others. + // In order to do this we compensate for this translation in the instance placement + // below. fprintf(file, " \n"); fprintf(file, " \n"); - fprintf(file, " %f\n", stl.v_shared[i].x); - fprintf(file, " %f\n", stl.v_shared[i].y); - fprintf(file, " %f\n", stl.v_shared[i].z); + fprintf(file, " %f\n", stl.v_shared[i].x - object->origin_translation.x); + fprintf(file, " %f\n", stl.v_shared[i].y - object->origin_translation.y); + fprintf(file, " %f\n", stl.v_shared[i].z - object->origin_translation.z); fprintf(file, " \n"); fprintf(file, " \n"); } @@ -569,24 +574,21 @@ AMF::write(Model& model, std::string output_file) } fprintf(file, " \n"); fprintf(file, " \n"); - if (! object->instances.empty()) { - for (ModelInstance *instance : object->instances) { - char buf[512]; - sprintf(buf, - " \n" - " %lf\n" - " %lf\n" - " %lf\n" - " %lf\n" - " \n", - object_id, - instance->offset.x, - instance->offset.y, - instance->rotation, - instance->scaling_factor); - //FIXME missing instance->scaling_factor - instances.append(buf); - } + for (const ModelInstance* instance : object->instances) { + char buf[512]; + sprintf(buf, + " \n" + " %lf\n" + " %lf\n" + " %lf\n" + " %lf\n" + " \n", + object_id, + instance->offset.x + object->origin_translation.x, + instance->offset.y + object->origin_translation.y, + instance->rotation, + instance->scaling_factor); + instances.append(buf); } } if (! instances.empty()) { From a6609682fc93755ffbee7a7ce7961f1374dfe357 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 20:51:36 +0100 Subject: [PATCH 15/37] Clean IO::AMF::write() --- xs/src/libslic3r/IO/AMF.cpp | 160 ++++++++++++++++-------------- xs/src/libslic3r/TriangleMesh.hpp | 2 +- 2 files changed, 88 insertions(+), 74 deletions(-) diff --git a/xs/src/libslic3r/IO/AMF.cpp b/xs/src/libslic3r/IO/AMF.cpp index ce49640d0d..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 #include @@ -495,109 +497,121 @@ AMF::read(std::string input_file, Model* model) bool AMF::write(Model& model, std::string output_file) { - FILE *file = ::fopen(output_file.c_str(), "wb"); - if (file == NULL) - return false; - - fprintf(file, "\n"); - fprintf(file, "\n"); - fprintf(file, "Slic3r %s\n", SLIC3R_VERSION); + using namespace std; + + ofstream file; + file.open(output_file, ios::out | ios::trunc); + + file << "" << endl + << "" << endl + << "Slic3r " << SLIC3R_VERSION << "" << endl; + for (const auto &material : model.materials) { if (material.first.empty()) continue; // note that material-id must never be 0 since it's reserved by the AMF spec - fprintf(file, " \n", material.first.c_str()); + file << " " << endl; for (const auto &attr : material.second->attributes) - fprintf(file, " %s\n", attr.first.c_str(), attr.second.c_str()); + file << " " << attr.second << "" << endl; for (const std::string &key : material.second->config.keys()) - fprintf(file, " %s\n", key.c_str(), material.second->config.serialize(key).c_str()); - fprintf(file, " \n"); + file << " " + << material.second->config.serialize(key) << "" << endl; + file << " " << endl; } - std::string instances; - for (size_t object_id = 0; object_id < model.objects.size(); ++ object_id) { + + ostringstream instances; + for (size_t object_id = 0; object_id < model.objects.size(); ++object_id) { ModelObject *object = model.objects[object_id]; - fprintf(file, " \n", object_id); + file << " " << endl; + for (const std::string &key : object->config.keys()) - fprintf(file, " %s\n", key.c_str(), object->config.serialize(key).c_str()); - if (! object->name.empty()) - fprintf(file, " %s\n", object->name.c_str()); + file << " " + << object->config.serialize(key) << "" << endl; + + if (!object->name.empty()) + file << " " << object->name << "" << endl; - //FIXME Store the layer height ranges (ModelObject::layer_height_ranges) - fprintf(file, " \n"); - fprintf(file, " \n"); - std::vector vertices_offsets; - int num_vertices = 0; + //FIXME: Store the layer height ranges (ModelObject::layer_height_ranges) + file << " " << endl; + file << " " << endl; + + std::vector vertices_offsets; + size_t num_vertices = 0; + for (ModelVolume *volume : object->volumes) { - volume->mesh.check_topology(); + volume->mesh.require_shared_vertices(); vertices_offsets.push_back(num_vertices); - auto &stl = volume->mesh.stl; - if (stl.v_shared == NULL) - stl_generate_shared_vertices(&stl); - for (size_t i = 0; i < stl.stats.shared_vertices; ++ i) { + const auto &stl = volume->mesh.stl; + for (size_t i = 0; i < stl.stats.shared_vertices; ++i) // Subtract origin_translation in order to restore the coordinates of the parts // before they were imported. Otherwise, when this AMF file is reimported parts // will be placed in the plater correctly, but we will have lost origin_translation // thus any additional part added will not align with the others. // In order to do this we compensate for this translation in the instance placement // below. - fprintf(file, " \n"); - fprintf(file, " \n"); - fprintf(file, " %f\n", stl.v_shared[i].x - object->origin_translation.x); - fprintf(file, " %f\n", stl.v_shared[i].y - object->origin_translation.y); - fprintf(file, " %f\n", stl.v_shared[i].z - object->origin_translation.z); - fprintf(file, " \n"); - fprintf(file, " \n"); - } + file << " " << endl + << " " << endl + << " " << (stl.v_shared[i].x - object->origin_translation.x) << "" << endl + << " " << (stl.v_shared[i].y - object->origin_translation.y) << "" << endl + << " " << (stl.v_shared[i].z - object->origin_translation.z) << "" << endl + << " " << endl + << " " << endl; + num_vertices += stl.stats.shared_vertices; } - fprintf(file, " \n"); - for (size_t i_volume = 0; i_volume < object->volumes.size(); ++ i_volume) { + file << " " << endl; + + for (size_t i_volume = 0; i_volume < object->volumes.size(); ++i_volume) { ModelVolume *volume = object->volumes[i_volume]; int vertices_offset = vertices_offsets[i_volume]; + if (volume->material_id().empty()) - fprintf(file, " \n"); + file << " " << endl; else - fprintf(file, " \n", volume->material_id().c_str()); + file << " material_id() << "\">" << endl; + for (const std::string &key : volume->config.keys()) - fprintf(file, " %s\n", key.c_str(), volume->config.serialize(key).c_str()); - if (! volume->name.empty()) - fprintf(file, " %s\n", volume->name.c_str()); + file << " " + << volume->config.serialize(key) << "" << endl; + + if (!volume->name.empty()) + file << " " << volume->name << "" << endl; + if (volume->modifier) - fprintf(file, " 1\n"); - for (int i = 0; i < volume->mesh.stl.stats.number_of_facets; ++ i) { - fprintf(file, " \n"); + file << " 1" << endl; + + for (int i = 0; i < volume->mesh.stl.stats.number_of_facets; ++i) { + file << " " << endl; for (int j = 0; j < 3; ++ j) - fprintf(file, " %d\n", j+1, volume->mesh.stl.v_indices[i].vertex[j] + vertices_offset, j+1); - fprintf(file, " \n"); + file << " " + << (volume->mesh.stl.v_indices[i].vertex[j] + vertices_offset) + << "" << endl; + file << " " << endl; } - fprintf(file, " \n"); - } - fprintf(file, " \n"); - fprintf(file, " \n"); - for (const ModelInstance* instance : object->instances) { - char buf[512]; - sprintf(buf, - " \n" - " %lf\n" - " %lf\n" - " %lf\n" - " %lf\n" - " \n", - object_id, - instance->offset.x + object->origin_translation.x, - instance->offset.y + object->origin_translation.y, - instance->rotation, - instance->scaling_factor); - instances.append(buf); + file << " " << endl; } + file << " " << endl; + file << " " << endl; + + for (const ModelInstance* instance : object->instances) + instances + << " " << endl + << " " << instance->offset.x + object->origin_translation.x << "" << endl + << " " << instance->offset.y + object->origin_translation.y << "" << endl + << " %" << instance->rotation << "" << endl + << " " << instance->scaling_factor << "" << endl + << " " << endl; } - if (! instances.empty()) { - fprintf(file, " \n"); - fwrite(instances.data(), instances.size(), 1, file); - fprintf(file, " \n"); - } - fprintf(file, "\n"); - fclose(file); + + std::string instances_str = instances.str(); + if (!instances_str.empty()) + file << " " << endl + << instances_str + << " " << endl; + + file << "" << endl; + + file.close(); return true; } diff --git a/xs/src/libslic3r/TriangleMesh.hpp b/xs/src/libslic3r/TriangleMesh.hpp index cba8ba43ed..51a4e9df43 100644 --- a/xs/src/libslic3r/TriangleMesh.hpp +++ b/xs/src/libslic3r/TriangleMesh.hpp @@ -58,6 +58,7 @@ class TriangleMesh bool needed_repair() const; size_t facets_count() const; void extrude_tin(float offset); + void require_shared_vertices(); static TriangleMesh make_cube(double x, double y, double z); static TriangleMesh make_cylinder(double r, double h, double fa=(2*PI/360)); @@ -67,7 +68,6 @@ class TriangleMesh bool repaired; private: - void require_shared_vertices(); friend class TriangleMeshSlicer; friend class TriangleMeshSlicer; friend class TriangleMeshSlicer; From 6b334e29dcf5a6fafab82b5228eba95b5db38dd8 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Fri, 17 Mar 2017 14:57:19 -0500 Subject: [PATCH 16/37] change public link for auto builds --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index dd3c2e29aa..57010dd4c8 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ A: Yes. Slic3r [![Build Status](https://travis-ci.org/alexrj/Slic3r.svg?branch=master)](https://travis-ci.org/alexrj/Slic3r) [![Build status](https://ci.appveyor.com/api/projects/status/8iqmeat6cj158vo6?svg=true)](https://ci.appveyor.com/project/lordofhyphens/slic3r) [![Build Status](http://osx-build.slic3r.org:8080/buildStatus/icon?job=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/ From d8a8e0d1c1e3867f388f187dcbada51d28d242dc Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 21:15:45 +0100 Subject: [PATCH 17/37] Rename/alias --overhangs to --detect-bridging-perimeters to match better the name used in GUI. #3532 --- slic3r.pl | 2 +- xs/src/libslic3r/PrintConfig.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/slic3r.pl b/slic3r.pl index 69bb58593b..c881f95600 100755 --- a/slic3r.pl +++ b/slic3r.pl @@ -466,7 +466,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/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 10efc1b6c5..63d600e4e3 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -818,7 +818,7 @@ PrintConfigDef::PrintConfigDef() def->label = "Detect bridging perimeters"; def->category = "Layers and Perimeters"; def->tooltip = "Experimental option to adjust flow for overhangs (bridge flow will be used), to apply bridge speed to them and enable fan."; - def->cli = "overhangs!"; + def->cli = "overhangs|detect-bridging-perimeters!"; def->default_value = new ConfigOptionBool(true); def = this->add("perimeter_acceleration", coFloat); From abbc458f106c655c487eec0937e01add02373be5 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 21:47:22 +0100 Subject: [PATCH 18/37] Fix stats output --- lib/Slic3r/Print/Object.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/Print/Object.pm b/lib/Slic3r/Print/Object.pm index 11f7b6f299..d8e41d77ee 100644 --- a/lib/Slic3r/Print/Object.pm +++ b/lib/Slic3r/Print/Object.pm @@ -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); } From 4f17a7b236e82554a173f9f93f4539b00ef71426 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 22:38:19 +0100 Subject: [PATCH 19/37] Fixes to CMake compilation --- src/CMakeLists.txt | 8 ++++++-- xs/src/admesh/util.c | 10 +++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 934f42724e..f3d4f46291 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) @@ -82,6 +83,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 +92,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/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); From c9f0a4c934f5cb3406f752b2a521817150d979e8 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Fri, 17 Mar 2017 22:51:07 +0100 Subject: [PATCH 20/37] Quick fix for Quick Slice. #3773 --- lib/Slic3r/GUI/MainFrame.pm | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index a3c04cd25f..ddf67a28fb 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -415,11 +415,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; From 90395f93940410093244e9cfcaf3dce407ddc811 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 18 Mar 2017 00:48:24 +0100 Subject: [PATCH 21/37] Complete implementation of read_cli() --- xs/src/libslic3r/Config.cpp | 128 +++++++++++++++++++++++++----------- xs/src/libslic3r/Config.hpp | 32 +++++---- xs/t/15_config.t | 43 +++++++++++- xs/xsp/Config.xsp | 2 + 4 files changed, 154 insertions(+), 51 deletions(-) diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp index ccb357cf29..66b3d0445b 100644 --- a/xs/src/libslic3r/Config.cpp +++ b/xs/src/libslic3r/Config.cpp @@ -106,7 +106,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; @@ -500,56 +499,109 @@ DynamicConfig::erase(const t_config_option_key &opt_key) { this->options.erase(opt_key); } +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); } } } diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index 8e375701e2..32a80adeea 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -12,6 +12,9 @@ #include #include "libslic3r.h" #include "Point.hpp" +#include +#include +#include namespace Slic3r { @@ -248,6 +251,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); }; }; @@ -392,20 +396,23 @@ class ConfigOptionPoints : public ConfigOptionVector 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; - } + + 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); } - this->values.push_back(point); + } catch (boost::bad_lexical_cast &e) { + printf("%s\n", e.what()); + return false; } + return true; }; }; @@ -691,6 +698,7 @@ class DynamicConfig : public virtual ConfigBase virtual ConfigOption* optptr(const t_config_option_key &opt_key, bool create = false); t_config_option_keys keys() const; void erase(const t_config_option_key &opt_key); + 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/t/15_config.t b/xs/t/15_config.t index 256fa539ff..214baad9f2 100644 --- a/xs/t/15_config.t +++ b/xs/t/15_config.t @@ -4,7 +4,7 @@ use strict; use warnings; use Slic3r::XS; -use Test::More tests => 147; +use Test::More tests => 159; use Data::Dumper; foreach my $config (Slic3r::Config->new, Slic3r::Config::Static::new_FullPrintConfig) { @@ -251,4 +251,45 @@ foreach my $config (Slic3r::Config->new, Slic3r::Config::Static::new_FullPrintCo ok 1, 'did not crash on reading invalid items in config'; } +{ + my $parse = sub { + my @argv = @_; + my $config = Slic3r::Config->new; + $config->read_cli(\@argv); + return $config; + }; + { + my $config = $parse->(qw(--extra-perimeters --perimeters 1 --layer-height 0.45 + --fill-density 70% --detect-bridging-perimeters --notes=foobar)); + is $config->get('extra_perimeters'), 1, 'read_cli(): bool'; + is $config->get('perimeters'), 1, 'read_cli(): int'; + is $config->get('layer_height'), 0.45, 'read_cli(): float'; + is $config->serialize('fill_density'), '70%', 'read_cli(): percent'; + is $config->get('overhangs'), 1, 'read_cli(): alternative'; + is $config->get('notes'), 'foobar', 'read_cli(): key=val'; + } + { + my $config = $parse->(qw(--extra-perimeters --no-extra-perimeters)); + ok $config->has('extra_perimeters'), 'read_cli(): negated bool'; + is_deeply $config->get('extra_perimeters'), 0, 'read_cli(): negated bool'; + } + { + my $config = $parse->(qw(--wipe --no-wipe --wipe)); + is_deeply $config->get('wipe'), [1,0,1], 'read_cli(): bools array'; + } + { + my $config = $parse->(qw(--post-process foo --post-process bar)); + is_deeply $config->get('post_process'), ['foo', 'bar'], 'read_cli(): strings array'; + } + { + my $config = $parse->(qw(--retract-speed 0.4 --retract-speed 0.5)); + is_deeply $config->get('retract_speed'), [0.4, 0.5], 'read_cli(): floats array'; + } + { + my $config = $parse->(qw(--extruder-offset 0,0 --extruder-offset 10x5)); + is_deeply [ map $_->pp, @{$config->get('extruder_offset')} ], + [[0,0], [10,5]], 'read_cli(): points array'; + } +} + __END__ diff --git a/xs/xsp/Config.xsp b/xs/xsp/Config.xsp index 96c4830e06..6b4fb19509 100644 --- a/xs/xsp/Config.xsp +++ b/xs/xsp/Config.xsp @@ -40,6 +40,8 @@ double min_object_distance(); %name{_load} void load(std::string file); %name{_save} void save(std::string file); + std::vector read_cli(std::vector _argv) + %code{% THIS->read_cli(_argv, &RETVAL); %}; }; %name{Slic3r::Config::Static} class StaticPrintConfig { From e7c854c91917c3ed9ecc923a5bc442fcd7f00ce9 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 18 Mar 2017 11:29:48 +0100 Subject: [PATCH 22/37] Ported Config::_handle_legacy() to XS --- lib/Slic3r/Config.pm | 66 +--------------------------- xs/src/libslic3r/Config.cpp | 34 ++++++++++++--- xs/src/libslic3r/Config.hpp | 3 +- xs/src/libslic3r/PrintConfig.cpp | 74 ++++++++++++++++++++++++++++++++ xs/src/libslic3r/PrintConfig.hpp | 5 ++- 5 files changed, 110 insertions(+), 72 deletions(-) diff --git a/lib/Slic3r/Config.pm b/lib/Slic3r/Config.pm index 5168ddf947..2763a8fd0f 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(); @@ -120,11 +114,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; } @@ -145,60 +135,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/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp index 66b3d0445b..9901282ff5 100644 --- a/xs/src/libslic3r/Config.cpp +++ b/xs/src/libslic3r/Config.cpp @@ -9,6 +9,7 @@ #include #include #include +#include #include #include #include @@ -220,6 +221,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 { @@ -288,12 +295,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; } @@ -373,7 +395,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 } diff --git a/xs/src/libslic3r/Config.hpp b/xs/src/libslic3r/Config.hpp index 32a80adeea..412c65fd31 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -649,6 +649,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); }; @@ -675,7 +676,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_(); diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 63d600e4e3..5a932bde7d 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1,4 +1,5 @@ #include "PrintConfig.hpp" +#include #include namespace Slic3r { @@ -1577,6 +1578,79 @@ PrintConfigBase::min_object_distance() const : duplicate_distance; } +bool +PrintConfigBase::set_deserialize(t_config_option_key opt_key, std::string str, bool append) +{ + this->_handle_legacy(opt_key, str); + if (opt_key.empty()) return true; // ignore option + return ConfigBase::set_deserialize(opt_key, str, append); +} + +void +PrintConfigBase::_handle_legacy(t_config_option_key &opt_key, std::string &value) const +{ + // handle legacy options + if (opt_key == "extrusion_width_ratio" || opt_key == "bottom_layer_speed_ratio" + || opt_key == "first_layer_height_ratio") { + boost::replace_first(opt_key, "_ratio", ""); + if (opt_key == "bottom_layer_speed") opt_key = "first_layer_speed"; + try { + float v = boost::lexical_cast(value); + if (v != 0) + value = boost::lexical_cast(v*100) + "%"; + } catch (boost::bad_lexical_cast &) { + value = "0"; + } + } else if (opt_key == "gcode_flavor" && value == "makerbot") { + value = "makerware"; + } else if (opt_key == "fill_density" && value.find("%") == std::string::npos) { + try { + // fill_density was turned into a percent value + float v = boost::lexical_cast(value); + value = boost::lexical_cast(v*100) + "%"; + } catch (boost::bad_lexical_cast &) {} + } else if (opt_key == "randomize_start" && value == "1") { + opt_key = "seam_position"; + value = "random"; + } else if (opt_key == "bed_size" && !value.empty()) { + opt_key = "bed_shape"; + ConfigOptionPoint p; + p.deserialize(value); + std::ostringstream oss; + oss << "0x0," << p.value.x << "x0," << p.value.x << "x" << p.value.y << ",0x" << p.value.y; + value = oss.str(); + } else if ((opt_key == "perimeter_acceleration" && value == "25") + || (opt_key == "infill_acceleration" && value == "50")) { + /* 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. */ + value = "0"; + } + + // cemetery of old config settings + if (opt_key == "duplicate_x" || opt_key == "duplicate_y" || opt_key == "multiply_x" + || opt_key == "multiply_y" || opt_key == "support_material_tool" + || opt_key == "acceleration" || opt_key == "adjust_overhang_flow" + || opt_key == "standby_temperature" || opt_key == "scale" || opt_key == "rotate" + || opt_key == "duplicate" || opt_key == "duplicate_grid" || opt_key == "rotate" + || opt_key == "scale" || opt_key == "duplicate_grid" + || opt_key == "start_perimeters_at_concave_points" + || opt_key == "start_perimeters_at_non_overhang" || opt_key == "randomize_start" + || opt_key == "seal_position" || opt_key == "bed_size" + || opt_key == "print_center" || opt_key == "g0" || opt_key == "threads") + { + opt_key = ""; + return; + } + + if (!this->def->has(opt_key)) { + printf("Unknown option %s\n", opt_key.c_str()); + opt_key = ""; + return; + } +} + CLIConfigDef::CLIConfigDef() { ConfigOptionDef* def; diff --git a/xs/src/libslic3r/PrintConfig.hpp b/xs/src/libslic3r/PrintConfig.hpp index 2ea423d8cc..5cf7054bf6 100644 --- a/xs/src/libslic3r/PrintConfig.hpp +++ b/xs/src/libslic3r/PrintConfig.hpp @@ -112,8 +112,11 @@ class PrintConfigBase : public virtual ConfigBase PrintConfigBase() { this->def = &print_config_def; }; - + bool set_deserialize(t_config_option_key opt_key, std::string str, bool append = false); double min_object_distance() const; + + protected: + void _handle_legacy(t_config_option_key &opt_key, std::string &value) const; }; // Slic3r dynamic configuration, used to override the configuration From 7467eb8fbb869404f27c0295c131ee393658c628 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 18 Mar 2017 12:28:53 +0100 Subject: [PATCH 23/37] Merge all OctoPrint print options in a single dialog (bypassable by pressing the Alt key). #3765 #3655 --- lib/Slic3r/GUI/Plater.pm | 127 ++++++++++++++++++++++++++++++++------- 1 file changed, 104 insertions(+), 23 deletions(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index c620673712..03477b811d 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -14,7 +14,7 @@ use Wx qw(:button :cursor :dialog :filedialog :keycode :icon :font :id :listctrl :panel :sizer :toolbar :window wxTheApp :notebook :combobox); use Wx::Event qw(EVT_BUTTON EVT_COMMAND EVT_KEY_DOWN EVT_LIST_ITEM_ACTIVATED EVT_LIST_ITEM_DESELECTED EVT_LIST_ITEM_SELECTED 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 'Wx::Panel'; use constant TB_ADD => &Wx::NewId; @@ -253,34 +253,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); @@ -2117,4 +2129,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; From 702cf43a0a9a86c2db9dfb27d50aa631cffe6b19 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 18 Mar 2017 14:56:23 +0100 Subject: [PATCH 24/37] Bugfix: prevent crashes from rounding issues caused by almost-collinear points in the new FillRectilinear. #3684 --- xs/src/libslic3r/ExPolygon.cpp | 8 +++++++ xs/src/libslic3r/ExPolygon.hpp | 1 + xs/src/libslic3r/Fill/FillRectilinear.cpp | 15 ++++++++----- xs/src/libslic3r/Polygon.cpp | 26 +++++++++++++++++++++++ xs/src/libslic3r/Polygon.hpp | 2 ++ 5 files changed, 47 insertions(+), 5 deletions(-) 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..2d3c84eb0a 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); diff --git a/xs/src/libslic3r/Polygon.cpp b/xs/src/libslic3r/Polygon.cpp index e365129700..3d87a986b7 100644 --- a/xs/src/libslic3r/Polygon.cpp +++ b/xs/src/libslic3r/Polygon.cpp @@ -148,6 +148,32 @@ Polygon::contains(const Point &point) const return result; } +void +Polygon::douglas_peucker(double tolerance) +{ + this->points.push_back(this->points.front()); + this->points = MultiPoint::_douglas_peucker(this->points, tolerance); + this->points.pop_back(); +} + +void +Polygon::remove_vertical_collinear_points(coord_t tolerance) +{ + Points &pp = this->points; + pp.push_back(pp.front()); + for (size_t i = 0; i < pp.size()-1; ++i) { + while (i < pp.size()-1) { + Point &next = pp[i+1]; + if (std::abs(next.x - pp[i].x) <= tolerance) { + pp.erase(pp.begin() + i+1); + } else { + break; + } + } + } + pp.pop_back(); +} + // this only works on CCW polygons as CW will be ripped out by Clipper's simplify_polygons() Polygons Polygon::simplify(double tolerance) const diff --git a/xs/src/libslic3r/Polygon.hpp b/xs/src/libslic3r/Polygon.hpp index 1b98872188..b1576ad27e 100644 --- a/xs/src/libslic3r/Polygon.hpp +++ b/xs/src/libslic3r/Polygon.hpp @@ -39,6 +39,8 @@ class Polygon : public MultiPoint { // Does an unoriented polygon contain a point? // Tested by counting intersections along a horizontal line. bool contains(const Point &point) const; + void douglas_peucker(double tolerance); + void remove_vertical_collinear_points(coord_t tolerance); Polygons simplify(double tolerance) const; void simplify(double tolerance, Polygons &polygons) const; void triangulate_convex(Polygons* polygons) const; From 7eed7f2dba5851b2c8cd7f5650151e107acde6ff Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 18 Mar 2017 15:37:16 +0100 Subject: [PATCH 25/37] Fixed previous commit --- xs/src/libslic3r/Polygon.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xs/src/libslic3r/Polygon.cpp b/xs/src/libslic3r/Polygon.cpp index 3d87a986b7..5d12b30628 100644 --- a/xs/src/libslic3r/Polygon.cpp +++ b/xs/src/libslic3r/Polygon.cpp @@ -163,9 +163,10 @@ Polygon::remove_vertical_collinear_points(coord_t tolerance) pp.push_back(pp.front()); for (size_t i = 0; i < pp.size()-1; ++i) { while (i < pp.size()-1) { - Point &next = pp[i+1]; - if (std::abs(next.x - pp[i].x) <= tolerance) { - pp.erase(pp.begin() + i+1); + const Point &p = pp[i]; + const Point &next = pp[i+1]; + if (next.x == p.x && std::abs(next.y - p.y) <= tolerance) { + pp.erase(pp.begin() + i); } else { break; } From b571f4af8475ecbb599bc9323f23164f8482bf20 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 18 Mar 2017 15:59:21 +0100 Subject: [PATCH 26/37] Bugfix: scale to size didn't work multiple times. #3768 --- lib/Slic3r/GUI/Plater.pm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 03477b811d..74078f76d0 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1008,7 +1008,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 From c773d407fdb420109dc0e4e04ef90d9e5eb82675 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 18 Mar 2017 16:11:31 +0100 Subject: [PATCH 27/37] Allow spiral_vase with multiple copies/objects when Sequential Printing is enabled --- xs/src/libslic3r/Print.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index f7c722265f..a3007801d2 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -660,7 +660,7 @@ Print::validate() const if (this->config.spiral_vase) { size_t total_copies_count = 0; FOREACH_OBJECT(this, i_object) total_copies_count += (*i_object)->copies().size(); - if (total_copies_count > 1) + if (total_copies_count > 1 && !this->config.complete_objects) return "The Spiral Vase option can only be used when printing a single object."; if (this->regions.size() > 1) return "The Spiral Vase option can only be used when printing single material objects."; From 35be0eefef1a73cc2a909afa4fe9d30256c7b9e2 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 18 Mar 2017 11:44:06 -0500 Subject: [PATCH 28/37] Remove boost references from Config.hpp (this does not work on Windows!) --- xs/src/libslic3r/Config.cpp | 24 ++++++++++++++++++++++++ xs/src/libslic3r/Config.hpp | 25 +------------------------ xs/src/libslic3r/PrintConfig.cpp | 1 + 3 files changed, 26 insertions(+), 24 deletions(-) diff --git a/xs/src/libslic3r/Config.cpp b/xs/src/libslic3r/Config.cpp index 9901282ff5..2937f7d641 100644 --- a/xs/src/libslic3r/Config.cpp +++ b/xs/src/libslic3r/Config.cpp @@ -10,6 +10,7 @@ #include #include #include +#include #include #include #include @@ -682,4 +683,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 412c65fd31..127efa06db 100644 --- a/xs/src/libslic3r/Config.hpp +++ b/xs/src/libslic3r/Config.hpp @@ -12,9 +12,6 @@ #include #include "libslic3r.h" #include "Point.hpp" -#include -#include -#include namespace Slic3r { @@ -394,27 +391,7 @@ class ConfigOptionPoints : public ConfigOptionVector return vv; }; - bool deserialize(std::string str, bool append = false) { - 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; - }; + bool deserialize(std::string str, bool append = false); }; class ConfigOptionBool : public ConfigOptionSingle diff --git a/xs/src/libslic3r/PrintConfig.cpp b/xs/src/libslic3r/PrintConfig.cpp index 5a932bde7d..c1b5870f9d 100644 --- a/xs/src/libslic3r/PrintConfig.cpp +++ b/xs/src/libslic3r/PrintConfig.cpp @@ -1,5 +1,6 @@ #include "PrintConfig.hpp" #include +#include #include namespace Slic3r { From d4136b38dffe55e7195a0e5b0bdab9801019c9ed Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sat, 18 Mar 2017 12:22:08 -0500 Subject: [PATCH 29/37] Add manifest to Windows RC file (adapted from Strawberry Perl manifest). Fixes #3740 --- package/win/slic3r.exe.manifest | 32 ++++++++++++++++++++++++++++++++ package/win/slic3r.rc | 2 +- 2 files changed, 33 insertions(+), 1 deletion(-) create mode 100644 package/win/slic3r.exe.manifest 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 From 72681aca01a108898666f8c71d655c93230c8a9a Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 18 Mar 2017 19:08:38 +0100 Subject: [PATCH 30/37] Don't perform CPAN tests for IO::Scalar. #3573 --- Build.PL | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Build.PL b/Build.PL index ad5147adbf..b7df2b1925 100644 --- a/Build.PL +++ b/Build.PL @@ -129,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; From 76f60471afb5a5fc378065d8266b59cc71937ddc Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sat, 18 Mar 2017 19:51:07 +0100 Subject: [PATCH 31/37] Moved typedefs to FillRectilinear.cpp --- xs/src/libslic3r/Fill/FillRectilinear.cpp | 21 +++++++++++++++++++++ xs/src/libslic3r/Fill/FillRectilinear.hpp | 21 --------------------- 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/xs/src/libslic3r/Fill/FillRectilinear.cpp b/xs/src/libslic3r/Fill/FillRectilinear.cpp index 2d3c84eb0a..c74da28775 100644 --- a/xs/src/libslic3r/Fill/FillRectilinear.cpp +++ b/xs/src/libslic3r/Fill/FillRectilinear.cpp @@ -63,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 From ad666beac0e0c5301312aaec320d614d942ca318 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Sun, 19 Mar 2017 01:40:18 +0100 Subject: [PATCH 32/37] Ported GCodeReader and SpiralVase to C++ --- lib/Slic3r.pm | 1 - lib/Slic3r/GCode/SpiralVase.pm | 88 ------------------------- lib/Slic3r/Print/GCode.pm | 4 +- src/CMakeLists.txt | 2 + xs/MANIFEST | 2 + xs/src/libslic3r/GCode/SpiralVase.cpp | 95 +++++++++++++++++++++++++++ xs/src/libslic3r/GCode/SpiralVase.hpp | 29 ++++++++ xs/src/libslic3r/GCodeReader.cpp | 91 +++++++++++++++++++++++++ xs/src/libslic3r/GCodeReader.hpp | 64 ++++++++++++++++++ xs/src/perlglue.cpp | 1 + xs/xsp/GCode.xsp | 13 ++++ xs/xsp/my.map | 4 ++ 12 files changed, 303 insertions(+), 91 deletions(-) delete mode 100644 lib/Slic3r/GCode/SpiralVase.pm create mode 100644 xs/src/libslic3r/GCode/SpiralVase.cpp create mode 100644 xs/src/libslic3r/GCode/SpiralVase.hpp create mode 100644 xs/src/libslic3r/GCodeReader.cpp create mode 100644 xs/src/libslic3r/GCodeReader.hpp 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/GCode/SpiralVase.pm b/lib/Slic3r/GCode/SpiralVase.pm deleted file mode 100644 index d35e29e713..0000000000 --- a/lib/Slic3r/GCode/SpiralVase.pm +++ /dev/null @@ -1,88 +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->Z($self->config->z_offset); - $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/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index 2617697162..9a653e89d9 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,7 +323,7 @@ sub process_layer { # check whether we're going to apply spiralvase logic if (defined $self->_spiral_vase) { - $self->_spiral_vase->enable( + $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)) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index f3d4f46291..85e98471ec 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -55,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 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/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/perlglue.cpp b/xs/src/perlglue.cpp index 3c08d61443..9ce012a36f 100644 --- a/xs/src/perlglue.cpp +++ b/xs/src/perlglue.cpp @@ -15,6 +15,7 @@ REGISTER_CLASS(Filler, "Filler"); REGISTER_CLASS(AvoidCrossingPerimeters, "GCode::AvoidCrossingPerimeters"); REGISTER_CLASS(CoolingBuffer, "GCode::CoolingBuffer"); REGISTER_CLASS(OozePrevention, "GCode::OozePrevention"); +REGISTER_CLASS(SpiralVase, "GCode::SpiralVase"); REGISTER_CLASS(Wipe, "GCode::Wipe"); REGISTER_CLASS(GCode, "GCode"); REGISTER_CLASS(GCodeSender, "GCode::Sender"); diff --git a/xs/xsp/GCode.xsp b/xs/xsp/GCode.xsp index 579951c731..f73ca44426 100644 --- a/xs/xsp/GCode.xsp +++ b/xs/xsp/GCode.xsp @@ -4,6 +4,7 @@ #include #include "libslic3r/GCode.hpp" #include "libslic3r/GCode/CoolingBuffer.hpp" +#include "libslic3r/GCode/SpiralVase.hpp" %} %name{Slic3r::GCode::AvoidCrossingPerimeters} class AvoidCrossingPerimeters { @@ -81,6 +82,18 @@ std::string flush(); }; +%name{Slic3r::GCode::SpiralVase} class SpiralVase { + SpiralVase(StaticPrintConfig* config) + %code{% RETVAL = new SpiralVase(*dynamic_cast(config)); %}; + ~SpiralVase(); + + bool enable() + %code{% RETVAL = THIS->enable; %}; + void set_enable(bool enable) + %code{% THIS->enable = enable; %}; + std::string process_layer(std::string gcode); +}; + %name{Slic3r::GCode} class GCode { GCode(); ~GCode(); diff --git a/xs/xsp/my.map b/xs/xsp/my.map index 1ce5d719fd..c47d79e005 100644 --- a/xs/xsp/my.map +++ b/xs/xsp/my.map @@ -198,6 +198,10 @@ CoolingBuffer* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T Clone O_OBJECT_SLIC3R_T +SpiralVase* O_OBJECT_SLIC3R +Ref O_OBJECT_SLIC3R_T +Clone O_OBJECT_SLIC3R_T + GCode* O_OBJECT_SLIC3R Ref O_OBJECT_SLIC3R_T Clone O_OBJECT_SLIC3R_T From af8ae8d2680b575b00c9bbb4853ab68eaecd4b89 Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 19 Mar 2017 00:22:17 -0500 Subject: [PATCH 33/37] Added single-object AMF export (with modifier meshes). Extended text on plate AMF export to indicate that it exports modifier meshes. --- lib/Slic3r/GUI/MainFrame.pm | 2 +- lib/Slic3r/GUI/Plater.pm | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/lib/Slic3r/GUI/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index ddf67a28fb..390ab2edb9 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -249,7 +249,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'); $self->_append_menu_item($self->{plater_menu}, "Open DLP Projector…\tCtrl+L", 'Open projector window for DLP printing', sub { diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 74078f76d0..7f6c215983 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1539,6 +1539,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; @@ -2032,6 +2049,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; } From dddbe64b866e10a7c88645faadb77a2508341d1e Mon Sep 17 00:00:00 2001 From: Joseph Lenox Date: Sun, 19 Mar 2017 00:31:14 -0500 Subject: [PATCH 34/37] Restrict file types for model exports to what we are permitting (UX fix). Changed extension from .amf.xml -> .amf (common usage) Fixes #3774 --- lib/Slic3r/GUI.pm | 2 ++ lib/Slic3r/GUI/Plater.pm | 13 ++++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 7d2f7f26b3..2459ef9c5c 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -53,6 +53,8 @@ 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. diff --git a/lib/Slic3r/GUI/Plater.pm b/lib/Slic3r/GUI/Plater.pm index 7f6c215983..c72350def0 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -1570,14 +1570,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; From 52a94e8f404fe330bbd0a5cdbc5c40c2e1578ae9 Mon Sep 17 00:00:00 2001 From: Ranvir Singh Date: Mon, 20 Mar 2017 00:32:59 +0530 Subject: [PATCH 35/37] remove deprecated code and add new one (#3775) change auto_ptr to unique_ptr --- xs/src/libslic3r/Print.cpp | 2 +- xs/src/libslic3r/SLAPrint.cpp | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index a3007801d2..be6f24f381 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -882,7 +882,7 @@ Print::_make_brim() } } - std::auto_ptr filler(Fill::new_from_type(ipRectilinear)); + std::unique_ptr filler(Fill::new_from_type(ipRectilinear)); filler->min_spacing = flow.spacing(); filler->dont_adjust = true; filler->density = 1; diff --git a/xs/src/libslic3r/SLAPrint.cpp b/xs/src/libslic3r/SLAPrint.cpp index 826e6184ec..02043e1910 100644 --- a/xs/src/libslic3r/SLAPrint.cpp +++ b/xs/src/libslic3r/SLAPrint.cpp @@ -57,7 +57,7 @@ SLAPrint::slice() // generate infill if (this->config.fill_density < 100) { - std::auto_ptr fill(Fill::new_from_type(this->config.fill_pattern.value)); + std::unique_ptr fill(Fill::new_from_type(this->config.fill_pattern.value)); fill->bounding_box.merge(Point::new_scale(bb.min.x, bb.min.y)); fill->bounding_box.merge(Point::new_scale(bb.max.x, bb.max.y)); fill->min_spacing = this->config.get_abs_value("infill_extrusion_width", this->config.layer_height.value); @@ -184,7 +184,7 @@ SLAPrint::_infill_layer(size_t i, const Fill* _fill) // Generate internal infill { - std::auto_ptr fill(_fill->clone()); + std::unique_ptr fill(_fill->clone()); fill->layer_id = i; fill->z = layer.print_z; From a19cc10b8e7f126a3f0f102716bb4d8536f3590f Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 20 Mar 2017 13:59:09 +0100 Subject: [PATCH 36/37] Bugfix: Controller was crashing on wxWidgets 2.8.x. #3159 --- .../GUI/Controller/ManualControlDialog.pm | 10 +++--- lib/Slic3r/GUI/Controller/PrinterPanel.pm | 32 +++++++++---------- 2 files changed, 21 insertions(+), 21 deletions(-) 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); From 9dbe2eea37eb2b6a219bff7c12852df25d07bee8 Mon Sep 17 00:00:00 2001 From: Alessandro Ranellucci Date: Mon, 20 Mar 2017 15:46:22 +0100 Subject: [PATCH 37/37] Menu option for coloring toolpaths by extruder using the configured filament colors --- lib/Slic3r/GUI.pm | 1 + lib/Slic3r/GUI/3DScene.pm | 288 ++++++++++++++--------------- lib/Slic3r/GUI/MainFrame.pm | 30 ++- lib/Slic3r/GUI/Plater.pm | 120 ++++++------ lib/Slic3r/GUI/Plater/3DPreview.pm | 10 + lib/Slic3r/Print/GCode.pm | 6 +- xs/src/libslic3r/Print.cpp | 12 ++ xs/src/libslic3r/Print.hpp | 1 + xs/xsp/Print.xsp | 1 + 9 files changed, 256 insertions(+), 213 deletions(-) diff --git a/lib/Slic3r/GUI.pm b/lib/Slic3r/GUI.pm index 2459ef9c5c..0ab4112778 100644 --- a/lib/Slic3r/GUI.pm +++ b/lib/Slic3r/GUI.pm @@ -75,6 +75,7 @@ our $Settings = { # 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', }, }; diff --git a/lib/Slic3r/GUI/3DScene.pm b/lib/Slic3r/GUI/3DScene.pm index 67046853f1..7c9ae2deeb 100644 --- a/lib/Slic3r/GUI/3DScene.pm +++ b/lib/Slic3r/GUI/3DScene.pm @@ -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/MainFrame.pm b/lib/Slic3r/GUI/MainFrame.pm index 390ab2edb9..92ee27954d 100644 --- a/lib/Slic3r/GUI/MainFrame.pm +++ b/lib/Slic3r/GUI/MainFrame.pm @@ -303,6 +303,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); + } } # Help menu @@ -800,10 +826,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 c72350def0..efda7aedf1 100644 --- a/lib/Slic3r/GUI/Plater.pm +++ b/lib/Slic3r/GUI/Plater.pm @@ -50,7 +50,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 + serial_port serial_speed octoprint_host octoprint_apikey filament_colour )); $self->{model} = Slic3r::Model->new; $self->{print} = Slic3r::Print->new; @@ -90,7 +90,7 @@ sub new { $menu->Destroy; }; my $on_instances_moved = sub { - $self->update; + $self->on_model_change; }; # Initialize 3D plater @@ -374,7 +374,7 @@ sub new { if ($self->{preview3D}) { $self->{preview3D}->set_bed_shape($self->{config}->bed_shape); } - $self->update; + $self->on_model_change; { my $presets; @@ -522,13 +522,12 @@ sub _on_select_preset { $Slic3r::GUI::Settings->{presets}{"filament_${_}"} = $choice->GetString($filament_presets[$_]) for 1 .. $#filament_presets; wxTheApp->save_settings; - return; + } else { + # call GetSelection() in scalar context as it's context-aware + $self->{on_select_preset}->($group, scalar $choice->GetSelection) + if $self->{on_select_preset}; } - # call GetSelection() in scalar context as it's context-aware - $self->{on_select_preset}->($group, scalar $choice->GetSelection) - if $self->{on_select_preset}; - # get new config and generate on_config_change() event for updating plater and other things $self->on_config_change($self->GetFrame->config); } @@ -735,7 +734,7 @@ sub load_model_objects { $self->make_thumbnail($obj_idx); } $self->arrange if $need_arrange; - $self->update; + $self->on_model_change; # zoom to objects $self->{canvas3D}->zoom_to_volumes @@ -745,8 +744,6 @@ sub load_model_objects { $self->{list}->Select($obj_idx[-1], 1); $self->object_list_changed; - $self->schedule_background_process; - return @obj_idx; } @@ -780,8 +777,7 @@ sub remove { $self->object_list_changed; $self->select_object(undef); - $self->update; - $self->schedule_background_process; + $self->on_model_change; } sub reset { @@ -800,7 +796,7 @@ sub reset { $self->object_list_changed; $self->select_object(undef); - $self->update; + $self->on_model_change; } sub increase { @@ -825,9 +821,8 @@ sub increase { if ($Slic3r::GUI::Settings->{_}{autocenter}) { $self->arrange; } else { - $self->update; + $self->on_model_change; } - $self->schedule_background_process; } sub decrease { @@ -852,8 +847,7 @@ sub decrease { $self->{list}->Select($obj_idx, 0); $self->{list}->Select($obj_idx, 1); } - $self->update; - $self->schedule_background_process; + $self->on_model_change; } sub set_number_of_copies { @@ -925,8 +919,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 { @@ -953,8 +946,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 { @@ -1035,8 +1027,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 { @@ -1049,7 +1040,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 { @@ -1099,14 +1090,10 @@ sub split_object { 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 @@ -1118,10 +1105,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; @@ -1129,9 +1112,16 @@ sub async_apply_config { # apply new config my $invalidated = $self->{print}->apply_config($self->GetFrame->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. @@ -1629,30 +1619,45 @@ 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; + if ($self->{"right_sizer"}) { + $self->{"right_sizer"}->Hide($self->{"sliced_info_box"}); + $self->{"right_sizer"}->Layout; + } + } 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 { @@ -1701,6 +1706,7 @@ sub on_config_change { my $self = shift; my ($config) = @_; + # Apply changes to the plater-specific config options. foreach my $opt_key (@{$self->{config}->diff($config)}) { $self->{config}->set($opt_key, $config->get($opt_key)); if ($opt_key eq 'bed_shape') { @@ -1708,7 +1714,7 @@ sub on_config_change { $self->{canvas3D}->update_bed_size if $self->{canvas3D}; $self->{preview3D}->set_bed_shape($self->{config}->bed_shape) if $self->{preview3D}; - $self->update; + $self->on_model_change; } elsif ($opt_key eq 'serial_port') { if ($config->get('serial_port')) { $self->{btn_print}->Show; @@ -1723,8 +1729,12 @@ sub on_config_change { $self->{btn_send_gcode}->Hide; } $self->Layout; + } elsif (0 && $opt_key eq 'filament_colour') { + $self->{print}->config->set('filament_colour', $config->filament_colour); + $self->{preview3D}->reload_print if $self->{preview3D}; } } + if ($self->{"right_sizer"}) { $self->{"right_sizer"}->Hide($self->{"sliced_info_box"}); $self->{"right_sizer"}->Layout; @@ -1732,8 +1742,12 @@ sub on_config_change { return if !$self->GetFrame->is_loaded; - # (re)start timer - $self->schedule_background_process; + if ($Slic3r::GUI::Settings->{_}{background_processing}) { + # (re)start timer + $self->schedule_background_process; + } else { + $self->async_apply_config; + } } sub list_item_deselected { 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/Print/GCode.pm b/lib/Slic3r/Print/GCode.pm index 9a653e89d9..3faad83172 100644 --- a/lib/Slic3r/Print/GCode.pm +++ b/lib/Slic3r/Print/GCode.pm @@ -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/xs/src/libslic3r/Print.cpp b/xs/src/libslic3r/Print.cpp index be6f24f381..807d58b45e 100644 --- a/xs/src/libslic3r/Print.cpp +++ b/xs/src/libslic3r/Print.cpp @@ -187,6 +187,7 @@ Print::invalidate_state_by_config_options(const std::vector || *opt_key == "extrusion_multiplier" || *opt_key == "fan_always_on" || *opt_key == "fan_below_layer_time" + || *opt_key == "filament_colour" || *opt_key == "filament_diameter" || *opt_key == "first_layer_acceleration" || *opt_key == "first_layer_bed_temperature" @@ -348,6 +349,17 @@ Print::extruders() const return extruders; } +size_t +Print::brim_extruder() const +{ + size_t e = this->get_region(0)->config.perimeter_extruder; + for (const PrintObject* object : this->objects) { + if (object->config.raft_layers > 0) + e = object->config.support_material_extruder; + } + return e; +} + void Print::_simplify_slices(double distance) { diff --git a/xs/src/libslic3r/Print.hpp b/xs/src/libslic3r/Print.hpp index a5bc63defa..b68ea6e35d 100644 --- a/xs/src/libslic3r/Print.hpp +++ b/xs/src/libslic3r/Print.hpp @@ -214,6 +214,7 @@ class Print std::set object_extruders() const; std::set support_material_extruders() const; std::set extruders() const; + size_t brim_extruder() const; void _simplify_slices(double distance); double max_allowed_layer_height() const; bool has_support_material() const; diff --git a/xs/xsp/Print.xsp b/xs/xsp/Print.xsp index 1bd25edb42..c4590a69e3 100644 --- a/xs/xsp/Print.xsp +++ b/xs/xsp/Print.xsp @@ -224,6 +224,7 @@ _constant() RETVAL.push_back(*e); } %}; + int brim_extruder(); void clear_filament_stats() %code%{ THIS->filament_stats.clear();