mirror of
https://git.mirrors.martin98.com/https://github.com/slic3r/Slic3r.git
synced 2025-08-04 03:40:38 +08:00
Merge remote-tracking branch 'origin/master' into gui3
Conflicts: lib/Slic3r/GUI.pm lib/Slic3r/GUI/Plater.pm lib/Slic3r/GUI/PresetEditor.pm slic3r.pl xs/src/libslic3r/Config.cpp xs/src/libslic3r/Config.hpp
This commit is contained in:
commit
1fadfd6fb8
3
Build.PL
3
Build.PL
@ -10,6 +10,7 @@ my %prereqs = qw(
|
||||
Devel::CheckLib 0
|
||||
Encode 0
|
||||
Encode::Locale 1.05
|
||||
ExtUtils::CppGuess 0
|
||||
ExtUtils::MakeMaker 6.80
|
||||
ExtUtils::ParseXS 3.22
|
||||
File::Basename 0
|
||||
@ -128,7 +129,7 @@ EOF
|
||||
|
||||
# temporary workaround for upstream bug in test
|
||||
push @cmd, '--notest'
|
||||
if $module =~ /^(?:OpenGL|Math::PlanePath|Test::Harness)$/;
|
||||
if $module =~ /^(?:OpenGL|Math::PlanePath|Test::Harness|IO::Scalar)$/;
|
||||
|
||||
push @cmd, "$module~$version";
|
||||
my $res = system @cmd;
|
||||
|
661
LICENSE
Normal file
661
LICENSE
Normal file
@ -0,0 +1,661 @@
|
||||
GNU AFFERO GENERAL PUBLIC LICENSE
|
||||
Version 3, 19 November 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
|
||||
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.
|
||||
|
||||
<one line to give the program's name and a brief idea of what it does.>
|
||||
Copyright (C) <year> <name of author>
|
||||
|
||||
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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
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
|
||||
<http://www.gnu.org/licenses/>.
|
@ -5,7 +5,7 @@ A: Yes.
|
||||
Slic3r [](https://travis-ci.org/alexrj/Slic3r) [](https://ci.appveyor.com/project/lordofhyphens/slic3r) [](http://osx-build.slic3r.org:8080/job/Slic3r)
|
||||
======
|
||||
Prebuilt Windows (64-bit) and OSX (>10.7) builds:
|
||||
* https://bintray.com/lordofhyphens/Slic3r/slic3r_dev/view (from build server)
|
||||
* http://dl.slic3r.org/dev/
|
||||
|
||||
<img width=256 src=https://cloud.githubusercontent.com/assets/31754/22719818/09998c92-ed6d-11e6-9fa0-09de638f3a36.png />
|
||||
|
||||
|
@ -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;
|
||||
|
@ -8,12 +8,6 @@ use utf8;
|
||||
|
||||
use List::Util qw(first max);
|
||||
|
||||
# cemetery of old config settings
|
||||
our @Ignore = qw(duplicate_x duplicate_y multiply_x multiply_y support_material_tool acceleration
|
||||
adjust_overhang_flow standby_temperature scale rotate duplicate duplicate_grid
|
||||
rotate scale duplicate_grid start_perimeters_at_concave_points start_perimeters_at_non_overhang
|
||||
randomize_start seal_position bed_size print_center g0);
|
||||
|
||||
# C++ Slic3r::PrintConfigDef exported as a Perl hash of hashes.
|
||||
# The C++ counterpart is a constant singleton.
|
||||
our $Options = print_config_def();
|
||||
@ -119,11 +113,7 @@ sub load_ini_hash {
|
||||
my ($ini_hash) = @_;
|
||||
|
||||
my $config = $class->new;
|
||||
foreach my $opt_key (keys %$ini_hash) {
|
||||
($opt_key, my $value) = _handle_legacy($opt_key, $ini_hash->{$opt_key});
|
||||
next if !defined $opt_key;
|
||||
$config->set_deserialize($opt_key, $value);
|
||||
}
|
||||
$config->set_deserialize($_, $ini_hash->{$_}) for keys %$ini_hash;
|
||||
return $config;
|
||||
}
|
||||
|
||||
@ -144,60 +134,6 @@ sub get_value {
|
||||
: $self->get($opt_key);
|
||||
}
|
||||
|
||||
sub _handle_legacy {
|
||||
my ($opt_key, $value) = @_;
|
||||
|
||||
# handle legacy options
|
||||
if ($opt_key =~ /^(extrusion_width|bottom_layer_speed|first_layer_height)_ratio$/) {
|
||||
$opt_key = $1;
|
||||
$opt_key =~ s/^bottom_layer_speed$/first_layer_speed/;
|
||||
$value = $value =~ /^\d+(?:\.\d+)?$/ && $value != 0 ? ($value*100) . "%" : 0;
|
||||
}
|
||||
if ($opt_key eq 'threads' && !$Slic3r::have_threads) {
|
||||
$value = 1;
|
||||
}
|
||||
if ($opt_key eq 'gcode_flavor' && $value eq 'makerbot') {
|
||||
$value = 'makerware';
|
||||
}
|
||||
if ($opt_key eq 'fill_density' && defined($value) && $value !~ /%/ && $value <= 1) {
|
||||
# fill_density was turned into a percent value
|
||||
$value *= 100;
|
||||
$value = "$value"; # force update of the PV value, workaround for bug https://rt.cpan.org/Ticket/Display.html?id=94110
|
||||
}
|
||||
if ($opt_key eq 'randomize_start' && $value) {
|
||||
$opt_key = 'seam_position';
|
||||
$value = 'random';
|
||||
}
|
||||
if ($opt_key eq 'bed_size' && $value) {
|
||||
$opt_key = 'bed_shape';
|
||||
my ($x, $y) = split /,/, $value;
|
||||
$value = "0x0,${x}x0,${x}x${y},0x${y}";
|
||||
}
|
||||
return () if first { $_ eq $opt_key } @Ignore;
|
||||
|
||||
# For historical reasons, the world's full of configs having these very low values;
|
||||
# to avoid unexpected behavior we need to ignore them. Banning these two hard-coded
|
||||
# values is a dirty hack and will need to be removed sometime in the future, but it
|
||||
# will avoid lots of complaints for now.
|
||||
if ($opt_key eq 'perimeter_acceleration' && $value == '25') {
|
||||
$value = 0;
|
||||
}
|
||||
if ($opt_key eq 'infill_acceleration' && $value == '50') {
|
||||
$value = 0;
|
||||
}
|
||||
|
||||
if (!exists $Options->{$opt_key}) {
|
||||
my @keys = grep { $Options->{$_}{aliases} && grep $_ eq $opt_key, @{$Options->{$_}{aliases}} } keys %$Options;
|
||||
if (!@keys) {
|
||||
warn "Unknown option $opt_key\n";
|
||||
return ();
|
||||
}
|
||||
$opt_key = $keys[0];
|
||||
}
|
||||
|
||||
return ($opt_key, $value);
|
||||
}
|
||||
|
||||
# Create a hash of hashes from the underlying C++ Slic3r::DynamicPrintConfig.
|
||||
# The first hash key is '_' meaning no category.
|
||||
sub as_ini {
|
||||
|
@ -1,86 +0,0 @@
|
||||
package Slic3r::GCode::SpiralVase;
|
||||
use Moo;
|
||||
|
||||
has 'config' => (is => 'ro', required => 1);
|
||||
has 'enable' => (is => 'rw', default => sub { 0 });
|
||||
has 'reader' => (is => 'ro', default => sub { Slic3r::GCode::Reader->new });
|
||||
|
||||
use Slic3r::Geometry qw(unscale);
|
||||
|
||||
sub BUILD {
|
||||
my ($self) = @_;
|
||||
$self->reader->apply_print_config($self->config);
|
||||
}
|
||||
|
||||
sub process_layer {
|
||||
my $self = shift;
|
||||
my ($gcode) = @_;
|
||||
|
||||
# This post-processor relies on several assumptions:
|
||||
# - all layers are processed through it, including those that are not supposed
|
||||
# to be transformed, in order to update the reader with the XY positions
|
||||
# - each call to this method includes a full layer, with a single Z move
|
||||
# at the beginning
|
||||
# - each layer is composed by suitable geometry (i.e. a single complete loop)
|
||||
# - loops were not clipped before calling this method
|
||||
|
||||
# if we're not going to modify G-code, just feed it to the reader
|
||||
# in order to update positions
|
||||
if (!$self->enable) {
|
||||
$self->reader->parse($gcode, sub {});
|
||||
return $gcode;
|
||||
}
|
||||
|
||||
# get total XY length for this layer by summing all extrusion moves
|
||||
my $total_layer_length = 0;
|
||||
my $layer_height = 0;
|
||||
my $z = undef;
|
||||
$self->reader->clone->parse($gcode, sub {
|
||||
my ($reader, $cmd, $args, $info) = @_;
|
||||
|
||||
if ($cmd eq 'G1') {
|
||||
if ($info->{extruding}) {
|
||||
$total_layer_length += $info->{dist_XY};
|
||||
} elsif (exists $args->{Z}) {
|
||||
$layer_height += $info->{dist_Z};
|
||||
$z //= $args->{Z};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
#use XXX; XXX [ $gcode, $layer_height, $z, $total_layer_length ];
|
||||
# remove layer height from initial Z
|
||||
$z -= $layer_height;
|
||||
|
||||
my $new_gcode = "";
|
||||
$self->reader->parse($gcode, sub {
|
||||
my ($reader, $cmd, $args, $info) = @_;
|
||||
|
||||
if ($cmd eq 'G1' && exists $args->{Z}) {
|
||||
# if this is the initial Z move of the layer, replace it with a
|
||||
# (redundant) move to the last Z of previous layer
|
||||
my $line = $info->{raw};
|
||||
$line =~ s/ Z[.0-9]+/ Z$z/;
|
||||
$new_gcode .= "$line\n";
|
||||
} elsif ($cmd eq 'G1' && !exists($args->{Z}) && $info->{dist_XY}) {
|
||||
# horizontal move
|
||||
my $line = $info->{raw};
|
||||
if ($info->{extruding}) {
|
||||
$z += $info->{dist_XY} * $layer_height / $total_layer_length;
|
||||
$line =~ s/^G1 /sprintf 'G1 Z%.3f ', $z/e;
|
||||
$new_gcode .= "$line\n";
|
||||
}
|
||||
# skip travel moves: the move to first perimeter point will
|
||||
# cause a visible seam when loops are not aligned in XY; by skipping
|
||||
# it we blend the first loop move in the XY plane (although the smoothness
|
||||
# of such blend depend on how long the first segment is; maybe we should
|
||||
# enforce some minimum length?)
|
||||
} else {
|
||||
$new_gcode .= "$info->{raw}\n";
|
||||
}
|
||||
});
|
||||
|
||||
return $new_gcode;
|
||||
}
|
||||
|
||||
1;
|
@ -54,11 +54,14 @@ use constant FILE_WILDCARDS => {
|
||||
svg => 'SVG files *.svg|*.svg;*.SVG',
|
||||
};
|
||||
use constant MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(known stl obj amf)};
|
||||
use constant STL_MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(stl)};
|
||||
use constant AMF_MODEL_WILDCARD => join '|', @{&FILE_WILDCARDS}{qw(amf)};
|
||||
|
||||
our $datadir;
|
||||
# If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
|
||||
our $no_controller;
|
||||
our $autosave;
|
||||
our $threads;
|
||||
our @cb;
|
||||
|
||||
our $Settings = {
|
||||
@ -69,6 +72,8 @@ our $Settings = {
|
||||
background_processing => 0,
|
||||
# If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
|
||||
no_controller => 0,
|
||||
threads => $Slic3r::Config::Options->{threads}{default},
|
||||
color_toolpaths_by => 'role',
|
||||
},
|
||||
};
|
||||
|
||||
@ -119,16 +124,16 @@ sub OnInit {
|
||||
my $last_version;
|
||||
if (-f "$enc_datadir/slic3r.ini") {
|
||||
my $ini = eval { Slic3r::Config->read_ini("$datadir/slic3r.ini") };
|
||||
$Settings = $ini if $ini;
|
||||
$last_version = $Settings->{_}{version};
|
||||
if ($ini) {
|
||||
$last_version = $ini->{_}{version};
|
||||
$ini->{_}{$_} = $Settings->{_}{$_}
|
||||
for grep !exists $ini->{_}{$_}, keys %{$Settings->{_}};
|
||||
$Settings = $ini;
|
||||
}
|
||||
delete $Settings->{_}{mode}; # handle legacy
|
||||
$Settings->{_}{autocenter} //= 1;
|
||||
$Settings->{_}{invert_zoom} //= 0;
|
||||
$Settings->{_}{background_processing} //= 1;
|
||||
# If set, the "Controller" tab for the control of the printer over serial line and the serial port settings are hidden.
|
||||
$Settings->{_}{no_controller} //= 1;
|
||||
}
|
||||
$Settings->{_}{version} = $Slic3r::VERSION;
|
||||
$Settings->{_}{threads} = $threads if $threads;
|
||||
$self->save_settings;
|
||||
|
||||
if (-f "$enc_datadir/simple.ini") {
|
||||
@ -325,7 +330,7 @@ sub have_version_check {
|
||||
my ($self) = @_;
|
||||
|
||||
# return an explicit 0
|
||||
return ($Slic3r::have_threads && $Slic3r::build && $have_LWP) || 0;
|
||||
return ($Slic3r::have_threads && $Slic3r::VERSION !~ /-dev$/ && $have_LWP) || 0;
|
||||
}
|
||||
|
||||
sub check_version {
|
||||
|
@ -50,7 +50,7 @@ use constant PI => 3.1415927;
|
||||
|
||||
# Constant to determine if Vertex Buffer objects are used to draw
|
||||
# bed grid and the cut plane for object separation.
|
||||
use constant HAS_VBO => 1;
|
||||
use constant HAS_VBO => eval { glGenBuffersARB_p(0); 1 };
|
||||
|
||||
|
||||
# phi / theta angles to orient the camera.
|
||||
@ -748,10 +748,10 @@ sub InitGL {
|
||||
# Enables Smooth Color Shading; try GL_FLAT for (lack of) fun.
|
||||
glShadeModel(GL_SMOOTH);
|
||||
|
||||
glMaterialfv_p(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, 0.5, 0.3, 0.3, 1);
|
||||
glMaterialfv_p(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE, 0.3, 0.3, 0.3, 1);
|
||||
glMaterialfv_p(GL_FRONT_AND_BACK, GL_SPECULAR, 1, 1, 1, 1);
|
||||
glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, 50);
|
||||
glMaterialfv_p(GL_FRONT_AND_BACK, GL_EMISSION, 0.1, 0, 0, 0.9);
|
||||
glMaterialfv_p(GL_FRONT_AND_BACK, GL_EMISSION, 0.1, 0.1, 0.1, 0.9);
|
||||
|
||||
# A handy trick -- have surface material mirror the color.
|
||||
glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
|
||||
@ -1152,21 +1152,25 @@ use List::Util qw(first min max);
|
||||
use Slic3r::Geometry qw(scale unscale epsilon);
|
||||
use Slic3r::Print::State ':steps';
|
||||
|
||||
use constant COLORS => [ [1,1,0,1], [1,0.5,0.5,1], [0.5,1,0.5,1], [0.5,0.5,1,1] ];
|
||||
|
||||
__PACKAGE__->mk_accessors(qw(
|
||||
colors
|
||||
color_by
|
||||
color_toolpaths_by
|
||||
select_by
|
||||
drag_by
|
||||
volumes_by_object
|
||||
_objects_by_volumes
|
||||
));
|
||||
|
||||
sub default_colors { [1,0.95,0.2,1], [1,0.45,0.45,1], [0.5,1,0.5,1], [0.5,0.5,1,1] }
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
|
||||
my $self = $class->SUPER::new(@_);
|
||||
$self->colors([ $self->default_colors ]);
|
||||
$self->color_by('volume'); # object | volume
|
||||
$self->color_toolpaths_by('role'); # role | extruder
|
||||
$self->select_by('object'); # object | volume | instance
|
||||
$self->drag_by('instance'); # object | instance
|
||||
$self->volumes_by_object({}); # obj_idx => [ volume_idx, volume_idx ... ]
|
||||
@ -1204,7 +1208,7 @@ sub load_object {
|
||||
$color_idx = $obj_idx;
|
||||
}
|
||||
|
||||
my $color = [ @{COLORS->[ $color_idx % scalar(@{&COLORS}) ]} ];
|
||||
my $color = [ @{$self->colors->[ $color_idx % scalar(@{$self->colors}) ]} ];
|
||||
$color->[3] = $volume->modifier ? 0.5 : 1;
|
||||
push @{$self->volumes}, my $v = Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $mesh->bounding_box,
|
||||
@ -1281,7 +1285,7 @@ sub load_print_object_slices {
|
||||
|
||||
push @{$self->volumes}, my $v = Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $bb,
|
||||
color => COLORS->[0],
|
||||
color => $self->colors->[0],
|
||||
verts => OpenGL::Array->new_list(GL_FLOAT, @verts),
|
||||
norms => OpenGL::Array->new_list(GL_FLOAT, @norms),
|
||||
quad_verts => OpenGL::Array->new_list(GL_FLOAT, @quad_verts),
|
||||
@ -1299,66 +1303,75 @@ sub load_print_toolpaths {
|
||||
&& $print->config->interior_brim_width == 0
|
||||
&& $print->config->brim_connections_width == 0;
|
||||
|
||||
my $qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
my $tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
my %offsets = (); # print_z => [ qverts, tverts ]
|
||||
|
||||
my $skirt_height = 0; # number of layers
|
||||
if ($print->has_infinite_skirt) {
|
||||
$skirt_height = $print->total_layer_count;
|
||||
} else {
|
||||
$skirt_height = min($print->config->skirt_height, $print->total_layer_count);
|
||||
}
|
||||
$skirt_height ||= 1 if $print->config->brim_width > 0 || $print->config->interior_brim_width;
|
||||
|
||||
# get first $skirt_height layers (maybe this should be moved to a PrintObject method?)
|
||||
my $object0 = $print->get_object(0);
|
||||
my @layers = ();
|
||||
push @layers, map $object0->get_layer($_-1), 1..min($skirt_height, $object0->layer_count);
|
||||
push @layers, map $object0->get_support_layer($_-1), 1..min($skirt_height, $object0->support_layer_count);
|
||||
@layers = sort { $a->print_z <=> $b->print_z } @layers;
|
||||
@layers = @layers[0..($skirt_height-1)];
|
||||
|
||||
foreach my $i (0..($skirt_height-1)) {
|
||||
my $top_z = $layers[$i]->print_z;
|
||||
$offsets{$top_z} = [$qverts->size, $tverts->size];
|
||||
|
||||
if ($i == 0) {
|
||||
$self->_extrusionentity_to_verts($print->brim, $top_z, Slic3r::Point->new(0,0), $qverts, $tverts);
|
||||
}
|
||||
|
||||
$self->_extrusionentity_to_verts($print->skirt, $top_z, Slic3r::Point->new(0,0), $qverts, $tverts);
|
||||
}
|
||||
|
||||
my $bb = Slic3r::Geometry::BoundingBoxf3->new;
|
||||
{
|
||||
my $pbb = $print->bounding_box;
|
||||
$bb->merge_point(Slic3r::Pointf3->new_unscale(@{$pbb->min_point}));
|
||||
$bb->merge_point(Slic3r::Pointf3->new_unscale(@{$pbb->max_point}));
|
||||
}
|
||||
push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $bb,
|
||||
color => COLORS->[2],
|
||||
qverts => $qverts,
|
||||
tverts => $tverts,
|
||||
offsets => { %offsets },
|
||||
);
|
||||
|
||||
my $color_by_extruder = $self->color_toolpaths_by eq 'extruder';
|
||||
|
||||
if (!$print->brim->empty) {
|
||||
my $color = $color_by_extruder
|
||||
? $self->colors->[ ($print->brim_extruder-1) % @{$self->colors} ]
|
||||
: $self->colors->[2];
|
||||
|
||||
push @{$self->volumes}, my $volume = Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $bb,
|
||||
color => $color,
|
||||
qverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
|
||||
tverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
|
||||
offsets => {}, # print_z => [ qverts, tverts ]
|
||||
);
|
||||
|
||||
my $top_z = $print->get_object(0)->get_layer(0)->print_z;
|
||||
$volume->offsets->{$top_z} = [0, 0];
|
||||
$self->_extrusionentity_to_verts($print->brim, $top_z, Slic3r::Point->new(0,0),
|
||||
$volume->qverts, $volume->tverts);
|
||||
}
|
||||
|
||||
if (!$print->skirt->empty) {
|
||||
# TODO: it's a bit difficult to predict skirt extruders with the current skirt logic.
|
||||
# We need to rewrite it anyway.
|
||||
my $color = +($self->default_colors)[0];
|
||||
push @{$self->volumes}, my $volume = Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $bb,
|
||||
color => $color,
|
||||
qverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
|
||||
tverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
|
||||
offsets => {}, # print_z => [ qverts, tverts ]
|
||||
);
|
||||
|
||||
my $skirt_height = 0; # number of layers
|
||||
if ($print->has_infinite_skirt) {
|
||||
$skirt_height = $print->total_layer_count;
|
||||
} else {
|
||||
$skirt_height = min($print->config->skirt_height, $print->total_layer_count);
|
||||
}
|
||||
$skirt_height ||= 1 if $print->config->brim_width > 0 || $print->config->interior_brim_width;
|
||||
|
||||
# get first $skirt_height layers (maybe this should be moved to a PrintObject method?)
|
||||
my $object0 = $print->get_object(0);
|
||||
my @layers = ();
|
||||
push @layers, map $object0->get_layer($_-1), 1..min($skirt_height, $object0->layer_count);
|
||||
push @layers, map $object0->get_support_layer($_-1), 1..min($skirt_height, $object0->support_layer_count);
|
||||
@layers = sort { $a->print_z <=> $b->print_z } @layers;
|
||||
@layers = @layers[0..($skirt_height-1)];
|
||||
|
||||
foreach my $i (0..($skirt_height-1)) {
|
||||
my $top_z = $layers[$i]->print_z;
|
||||
$volume->offsets->{$top_z} = [$volume->qverts->size, $volume->tverts->size];
|
||||
|
||||
$self->_extrusionentity_to_verts($print->skirt, $top_z, Slic3r::Point->new(0,0),
|
||||
$volume->qverts, $volume->tverts);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sub load_print_object_toolpaths {
|
||||
my ($self, $object) = @_;
|
||||
|
||||
my $perim_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
my $perim_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
my $infill_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
my $infill_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
my $support_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
my $support_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
|
||||
my %perim_offsets = (); # print_z => [ qverts, tverts ]
|
||||
my %infill_offsets = ();
|
||||
my %support_offsets = ();
|
||||
|
||||
# order layers by print_z
|
||||
my @layers = sort { $a->print_z <=> $b->print_z }
|
||||
@{$object->layers}, @{$object->support_layers};
|
||||
@ -1374,122 +1387,91 @@ sub load_print_object_toolpaths {
|
||||
$bb->merge_point(Slic3r::Pointf3->new_unscale(@{$cbb->max_point}, $object->size->z));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
my %volumes = (); # color => Volume
|
||||
|
||||
# Maximum size of an allocation block: 32MB / sizeof(float)
|
||||
my $alloc_size_max = 32 * 1048576 / 4;
|
||||
|
||||
my $add = sub {
|
||||
my ($coll, $top_z, $copy, $color) = @_;
|
||||
|
||||
my $volume = $volumes{$color};
|
||||
if (!$volume) {
|
||||
push @{$self->volumes}, $volumes{$color} = $volume = Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $bb,
|
||||
color => $color,
|
||||
qverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
|
||||
tverts => Slic3r::GUI::_3DScene::GLVertexArray->new,
|
||||
offsets => {}, # print_z => [ qverts, tverts ]
|
||||
);
|
||||
}
|
||||
|
||||
$volume->offsets->{$top_z} //= [ $volume->qverts->size, $volume->tverts->size ];
|
||||
$self->_extrusionentity_to_verts($coll, $top_z, $copy, $volume->qverts, $volume->tverts);
|
||||
};
|
||||
|
||||
my $color_by_extruder = $self->color_toolpaths_by eq 'extruder';
|
||||
|
||||
foreach my $layer (@layers) {
|
||||
my $top_z = $layer->print_z;
|
||||
|
||||
if (!exists $perim_offsets{$top_z}) {
|
||||
$perim_offsets{$top_z} = [
|
||||
$perim_qverts->size, $perim_tverts->size,
|
||||
];
|
||||
}
|
||||
if (!exists $infill_offsets{$top_z}) {
|
||||
$infill_offsets{$top_z} = [
|
||||
$infill_qverts->size, $infill_tverts->size,
|
||||
];
|
||||
}
|
||||
if (!exists $support_offsets{$top_z}) {
|
||||
$support_offsets{$top_z} = [
|
||||
$support_qverts->size, $support_tverts->size,
|
||||
];
|
||||
}
|
||||
|
||||
foreach my $copy (@{ $object->_shifted_copies }) {
|
||||
foreach my $layerm (@{$layer->regions}) {
|
||||
if ($object->step_done(STEP_PERIMETERS)) {
|
||||
$self->_extrusionentity_to_verts($layerm->perimeters, $top_z, $copy,
|
||||
$perim_qverts, $perim_tverts);
|
||||
my $color = $color_by_extruder
|
||||
? $self->colors->[ ($layerm->region->config->perimeter_extruder-1) % @{$self->colors} ]
|
||||
: $self->colors->[0];
|
||||
$add->($layerm->perimeters, $top_z, $copy, $color);
|
||||
}
|
||||
|
||||
if ($object->step_done(STEP_INFILL)) {
|
||||
$self->_extrusionentity_to_verts($layerm->fills, $top_z, $copy,
|
||||
$infill_qverts, $infill_tverts);
|
||||
my $color = $color_by_extruder
|
||||
? $self->colors->[ ($layerm->region->config->infill_extruder-1) % @{$self->colors} ]
|
||||
: $self->colors->[1];
|
||||
|
||||
if ($color_by_extruder && $layerm->region->config->infill_extruder != $layerm->region->config->solid_infill_extruder) {
|
||||
# divide solid and non-solid infill
|
||||
my $solid = Slic3r::ExtrusionPath::Collection->new;
|
||||
my $non_solid = Slic3r::ExtrusionPath::Collection->new;
|
||||
foreach my $fill (@{$layerm->fills}) {
|
||||
if ($fill->[0]->is_solid_infill) {
|
||||
$solid->append($fill);
|
||||
} else {
|
||||
$non_solid->append($fill);
|
||||
}
|
||||
}
|
||||
$add->($non_solid, $top_z, $copy, $color);
|
||||
$color = $self->colors->[ ($layerm->region->config->solid_infill_extruder-1) % @{&COLORS} ];
|
||||
$add->($solid, $top_z, $copy, $color);
|
||||
} else {
|
||||
$add->($layerm->fills, $top_z, $copy, $color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($layer->isa('Slic3r::Layer::Support') && $object->step_done(STEP_SUPPORTMATERIAL)) {
|
||||
$self->_extrusionentity_to_verts($layer->support_fills, $top_z, $copy,
|
||||
$support_qverts, $support_tverts);
|
||||
|
||||
$self->_extrusionentity_to_verts($layer->support_interface_fills, $top_z, $copy,
|
||||
$support_qverts, $support_tverts);
|
||||
{
|
||||
my $color = $color_by_extruder
|
||||
? $self->colors->[ ($layer->object->config->support_material_extruder-1) % @{$self->colors} ]
|
||||
: $self->colors->[2];
|
||||
$add->($layer->support_fills, $top_z, $copy, $color);
|
||||
}
|
||||
{
|
||||
my $color = ($color_by_extruder)
|
||||
? $self->colors->[ ($layer->object->config->support_material_interface_extruder-1) % @{$self->colors} ]
|
||||
: $self->colors->[2];
|
||||
$add->($layer->support_interface_fills, $top_z, $copy, $color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($perim_qverts->size() > $alloc_size_max || $perim_tverts->size() > $alloc_size_max) {
|
||||
# Store the vertex arrays and restart their containers.
|
||||
push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $bb,
|
||||
color => COLORS->[0],
|
||||
qverts => $perim_qverts,
|
||||
tverts => $perim_tverts,
|
||||
offsets => { %perim_offsets },
|
||||
);
|
||||
$perim_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
$perim_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
%perim_offsets = ();
|
||||
|
||||
foreach my $color (keys %volumes) {
|
||||
my $volume = $volumes{$color};
|
||||
if ($volume->qverts->size() > $alloc_size_max || $volume->tverts->size() > $alloc_size_max) {
|
||||
# stop appending to this volume; create a new one next time
|
||||
delete $volumes{$color};
|
||||
}
|
||||
}
|
||||
|
||||
if ($infill_qverts->size() > $alloc_size_max || $infill_tverts->size() > $alloc_size_max) {
|
||||
# Store the vertex arrays and restart their containers.
|
||||
push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $bb,
|
||||
color => COLORS->[1],
|
||||
qverts => $infill_qverts,
|
||||
tverts => $infill_tverts,
|
||||
offsets => { %infill_offsets },
|
||||
);
|
||||
$infill_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
$infill_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
%infill_offsets = ();
|
||||
}
|
||||
|
||||
if ($support_qverts->size() > $alloc_size_max || $support_tverts->size() > $alloc_size_max) {
|
||||
# Store the vertex arrays and restart their containers.
|
||||
push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $bb,
|
||||
color => COLORS->[2],
|
||||
qverts => $support_qverts,
|
||||
tverts => $support_tverts,
|
||||
offsets => { %support_offsets },
|
||||
);
|
||||
$support_qverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
$support_tverts = Slic3r::GUI::_3DScene::GLVertexArray->new;
|
||||
%support_offsets = ();
|
||||
}
|
||||
}
|
||||
|
||||
if ($perim_qverts->size() > 0 || $perim_tverts->size() > 0) {
|
||||
push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $bb,
|
||||
color => COLORS->[0],
|
||||
qverts => $perim_qverts,
|
||||
tverts => $perim_tverts,
|
||||
offsets => { %perim_offsets },
|
||||
);
|
||||
}
|
||||
|
||||
if ($infill_qverts->size() > 0 || $infill_tverts->size() > 0) {
|
||||
push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $bb,
|
||||
color => COLORS->[1],
|
||||
qverts => $infill_qverts,
|
||||
tverts => $infill_tverts,
|
||||
offsets => { %infill_offsets },
|
||||
);
|
||||
}
|
||||
|
||||
if ($support_qverts->size() > 0 || $support_tverts->size() > 0) {
|
||||
push @{$self->volumes}, Slic3r::GUI::3DScene::Volume->new(
|
||||
bounding_box => $bb,
|
||||
color => COLORS->[2],
|
||||
qverts => $support_qverts,
|
||||
tverts => $support_tverts,
|
||||
offsets => { %support_offsets },
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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('');
|
||||
|
@ -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);
|
||||
|
@ -193,7 +193,7 @@ sub _init_menubar {
|
||||
$self->_append_menu_item($self->{plater_menu}, "Export plate as STL...", 'Export current plate as STL', sub {
|
||||
$plater->export_stl;
|
||||
}, undef, 'brick_go.png');
|
||||
$self->_append_menu_item($self->{plater_menu}, "Export plate as AMF...", 'Export current plate as AMF', sub {
|
||||
$self->_append_menu_item($self->{plater_menu}, "Export plate with modifiers as AMF...", 'Export current plate as AMF, including all modifier meshes', sub {
|
||||
$plater->export_amf;
|
||||
}, undef, 'brick_go.png');
|
||||
|
||||
@ -225,6 +225,32 @@ sub _init_menubar {
|
||||
$self->_append_menu_item($self->{viewMenu}, "Rear" , 'Rear View' , sub { $self->select_view('rear' ); });
|
||||
$self->_append_menu_item($self->{viewMenu}, "Left" , 'Left View' , sub { $self->select_view('left' ); });
|
||||
$self->_append_menu_item($self->{viewMenu}, "Right" , 'Right View' , sub { $self->select_view('right' ); });
|
||||
$self->{viewMenu}->AppendSeparator();
|
||||
$self->{color_toolpaths_by_role} = $self->_append_menu_item($self->{viewMenu},
|
||||
"Color Toolpaths by Role",
|
||||
'Color toolpaths according to perimeter/infill/support material',
|
||||
sub {
|
||||
$Slic3r::GUI::Settings->{_}{color_toolpaths_by} = 'role';
|
||||
wxTheApp->save_settings;
|
||||
$self->{plater}{preview3D}->reload_print;
|
||||
},
|
||||
undef, undef, wxITEM_RADIO
|
||||
);
|
||||
$self->{color_toolpaths_by_extruder} = $self->_append_menu_item($self->{viewMenu},
|
||||
"Color Toolpaths by Filament",
|
||||
'Color toolpaths using the configured extruder/filament color',
|
||||
sub {
|
||||
$Slic3r::GUI::Settings->{_}{color_toolpaths_by} = 'extruder';
|
||||
wxTheApp->save_settings;
|
||||
$self->{plater}{preview3D}->reload_print;
|
||||
},
|
||||
undef, undef, wxITEM_RADIO
|
||||
);
|
||||
if ($Slic3r::GUI::Settings->{_}{color_toolpaths_by} eq 'role') {
|
||||
$self->{color_toolpaths_by_role}->Check(1);
|
||||
} else {
|
||||
$self->{color_toolpaths_by_extruder}->Check(1);
|
||||
}
|
||||
}
|
||||
|
||||
# Window menu
|
||||
@ -354,11 +380,7 @@ sub quick_slice {
|
||||
|
||||
$sprint->apply_config($config);
|
||||
$sprint->set_model($model);
|
||||
|
||||
{
|
||||
my $extra = $self->extra_variables;
|
||||
$sprint->placeholder_parser->set($_, $extra->{$_}) for keys %$extra;
|
||||
}
|
||||
# FIXME: populate placeholders (preset names etc.)
|
||||
|
||||
# select output file
|
||||
my $output_file;
|
||||
@ -612,10 +634,10 @@ sub select_view {
|
||||
}
|
||||
|
||||
sub _append_menu_item {
|
||||
my ($self, $menu, $string, $description, $cb, $id, $icon) = @_;
|
||||
my ($self, $menu, $string, $description, $cb, $id, $icon, $kind) = @_;
|
||||
|
||||
$id //= &Wx::NewId();
|
||||
my $item = $menu->Append($id, $string, $description);
|
||||
my $item = $menu->Append($id, $string, $description, $kind);
|
||||
$self->_set_menu_item_icon($item, $icon);
|
||||
|
||||
EVT_MENU($self, $id, $cb);
|
||||
|
@ -13,7 +13,7 @@ use threads::shared qw(shared_clone);
|
||||
use Wx qw(:button :cursor :dialog :filedialog :keycode :icon :font :id :misc
|
||||
:panel :sizer :toolbar :window wxTheApp :notebook :combobox);
|
||||
use Wx::Event qw(EVT_BUTTON EVT_COMMAND EVT_KEY_DOWN EVT_MOUSE_EVENTS EVT_PAINT EVT_TOOL
|
||||
EVT_CHOICE EVT_COMBOBOX EVT_TIMER EVT_NOTEBOOK_PAGE_CHANGED);
|
||||
EVT_CHOICE EVT_COMBOBOX EVT_TIMER EVT_NOTEBOOK_PAGE_CHANGED EVT_LEFT_UP);
|
||||
use base qw(Wx::Panel Class::Accessor);
|
||||
|
||||
__PACKAGE__->mk_accessors(qw(presets));
|
||||
@ -49,7 +49,7 @@ sub new {
|
||||
my $self = $class->SUPER::new($parent, -1, wxDefaultPosition, wxDefaultSize, wxTAB_TRAVERSAL);
|
||||
$self->{config} = Slic3r::Config->new_from_defaults(qw(
|
||||
bed_shape complete_objects extruder_clearance_radius skirts skirt_distance brim_width
|
||||
serial_port serial_speed octoprint_host octoprint_apikey overridable
|
||||
serial_port serial_speed octoprint_host octoprint_apikey overridable filament_colour
|
||||
));
|
||||
$self->{model} = Slic3r::Model->new;
|
||||
$self->{print} = Slic3r::Print->new;
|
||||
@ -89,7 +89,7 @@ sub new {
|
||||
$menu->Destroy;
|
||||
};
|
||||
my $on_instances_moved = sub {
|
||||
$self->update;
|
||||
$self->on_model_change;
|
||||
};
|
||||
|
||||
# Initialize 3D plater
|
||||
@ -235,34 +235,46 @@ sub new {
|
||||
EVT_BUTTON($self, $self->{btn_print}, sub {
|
||||
$self->{print_file} = $self->export_gcode(Wx::StandardPaths::Get->GetTempDir());
|
||||
});
|
||||
EVT_BUTTON($self, $self->{btn_send_gcode}, sub {
|
||||
EVT_LEFT_UP($self->{btn_send_gcode}, sub {
|
||||
my (undef, $e) = @_;
|
||||
|
||||
my $filename = basename($self->{print}->output_filepath($main::opt{output} // ''));
|
||||
$filename = Wx::GetTextFromUser("Save to printer with the following name:",
|
||||
"OctoPrint", $filename, $self);
|
||||
|
||||
my $process_dialog = Wx::ProgressDialog->new('Querying OctoPrint…', "Checking whether file already exists…", 100, $self, 0);
|
||||
$process_dialog->Pulse;
|
||||
if (!$e->AltDown) {
|
||||
# When the alt key is pressed, bypass the dialog.
|
||||
my $dlg = Slic3r::GUI::Plater::OctoPrintSpoolDialog->new($self, $filename);
|
||||
return unless $dlg->ShowModal == wxID_OK;
|
||||
$filename = $dlg->{filename};
|
||||
}
|
||||
|
||||
my $ua = LWP::UserAgent->new;
|
||||
$ua->timeout(5);
|
||||
my $res = $ua->get("http://" . $self->{config}->octoprint_host . "/api/files/local");
|
||||
$process_dialog->Destroy;
|
||||
if ($res->is_success) {
|
||||
if ($res->decoded_content =~ /"name":\s*"\Q$filename\E"/) {
|
||||
my $dialog = Wx::MessageDialog->new($self,
|
||||
"It looks like a file with the same name already exists in the server. "
|
||||
. "Shall I overwrite it?",
|
||||
'OctoPrint', wxICON_WARNING | wxYES | wxNO);
|
||||
return if $dialog->ShowModal() == wxID_NO;
|
||||
if (!$Slic3r::GUI::Settings->{octoprint}{overwrite}) {
|
||||
my $progress = Wx::ProgressDialog->new('Querying OctoPrint…',
|
||||
"Checking whether file already exists…", 100, $self, 0);
|
||||
$progress->Pulse;
|
||||
|
||||
my $ua = LWP::UserAgent->new;
|
||||
$ua->timeout(5);
|
||||
my $res = $ua->get("http://" . $self->{config}->octoprint_host . "/api/files/local");
|
||||
$progress->Destroy;
|
||||
if ($res->is_success) {
|
||||
if ($res->decoded_content =~ /"name":\s*"\Q$filename\E"/) {
|
||||
my $dialog = Wx::MessageDialog->new($self,
|
||||
"It looks like a file with the same name already exists in the server. "
|
||||
. "Shall I overwrite it?",
|
||||
'OctoPrint', wxICON_WARNING | wxYES | wxNO);
|
||||
if ($dialog->ShowModal() == wxID_NO) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
my $message = "Error while connecting to the OctoPrint server: " . $res->status_line;
|
||||
Slic3r::GUI::show_error($self, $message);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
my $dialog = Wx::MessageDialog->new($self,
|
||||
"Shall I start the print after uploading the file?",
|
||||
'OctoPrint', wxICON_QUESTION | wxYES | wxNO);
|
||||
$self->{send_gcode_file_print} = ($dialog->ShowModal() == wxID_YES);
|
||||
|
||||
$self->{send_gcode_file} = $self->export_gcode(Wx::StandardPaths::Get->GetTempDir() . "/$filename");
|
||||
$self->{send_gcode_file_print} = $Slic3r::GUI::Settings->{octoprint}{start};
|
||||
$self->{send_gcode_file} = $self->export_gcode(Wx::StandardPaths::Get->GetTempDir() . "/" . $filename);
|
||||
});
|
||||
EVT_BUTTON($self, $self->{btn_export_stl}, \&export_stl);
|
||||
|
||||
@ -344,7 +356,7 @@ sub new {
|
||||
if ($self->{preview3D}) {
|
||||
$self->{preview3D}->set_bed_shape($self->{config}->bed_shape);
|
||||
}
|
||||
$self->update;
|
||||
$self->on_model_change;
|
||||
|
||||
{
|
||||
my $presets = $self->{presets_sizer} = Wx::FlexGridSizer->new(3, 3, 1, 2);
|
||||
@ -439,7 +451,7 @@ sub new {
|
||||
|
||||
my $print_info_sizer;
|
||||
{
|
||||
my $box = Wx::StaticBox->new($self, -1, "Sliced Info");
|
||||
my $box = Wx::StaticBox->new($self, -1, "Print Summary");
|
||||
$print_info_sizer = Wx::StaticBoxSizer->new($box, wxVERTICAL);
|
||||
$print_info_sizer->SetMinSize([350,-1]);
|
||||
my $grid_sizer = Wx::FlexGridSizer->new(2, 2, 5, 5);
|
||||
@ -448,9 +460,7 @@ sub new {
|
||||
$grid_sizer->AddGrowableCol(3, 1);
|
||||
$print_info_sizer->Add($grid_sizer, 0, wxEXPAND);
|
||||
my @info = (
|
||||
fil_cm => "Used Filament (cm)",
|
||||
fil_cm3 => "Used Filament (cm^3)",
|
||||
fil_g => "Used Filament (g)",
|
||||
fil => "Used Filament",
|
||||
cost => "Cost",
|
||||
);
|
||||
while (my $field = shift @info) {
|
||||
@ -463,7 +473,7 @@ sub new {
|
||||
$self->{"print_info_$field"}->SetFont($Slic3r::GUI::small_font);
|
||||
$grid_sizer->Add($self->{"print_info_$field"}, 0);
|
||||
}
|
||||
$self->{"sliced_info_box"} = $print_info_sizer;
|
||||
$self->{sliced_info_box} = $print_info_sizer;
|
||||
|
||||
}
|
||||
|
||||
@ -474,14 +484,13 @@ sub new {
|
||||
$buttons_sizer->Add($self->{btn_send_gcode}, 0, wxALIGN_RIGHT, 0);
|
||||
$buttons_sizer->Add($self->{btn_export_gcode}, 0, wxALIGN_RIGHT, 0);
|
||||
|
||||
my $right_sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$self->{right_sizer} = my $right_sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$right_sizer->Add($presets, 0, wxEXPAND | wxTOP, 10) if defined $presets;
|
||||
$right_sizer->Add($buttons_sizer, 0, wxEXPAND | wxBOTTOM, 5);
|
||||
$right_sizer->Add($self->{settings_override_panel}, 1, wxEXPAND, 5);
|
||||
$right_sizer->Add($object_info_sizer, 0, wxEXPAND, 0);
|
||||
$right_sizer->Add($print_info_sizer, 0, wxEXPAND, 0);
|
||||
$right_sizer->Hide($print_info_sizer);
|
||||
$self->{"right_sizer"} = $right_sizer;
|
||||
|
||||
my $hsizer = Wx::BoxSizer->new(wxHORIZONTAL);
|
||||
$hsizer->Add($self->{preview_notebook}, 1, wxEXPAND | wxTOP, 1);
|
||||
@ -517,34 +526,6 @@ sub _on_select_preset {
|
||||
my $config = $self->config;
|
||||
|
||||
$self->on_extruders_change(scalar @{$config->get('nozzle_diameter')});
|
||||
|
||||
foreach my $opt_key (@{$self->{config}->diff($config)}) {
|
||||
# Ignore overrides. No need to set them in our config; we'll use them directly below.
|
||||
next if $opt_key eq 'overrides';
|
||||
|
||||
$self->{config}->set($opt_key, $config->get($opt_key));
|
||||
|
||||
if ($opt_key eq 'bed_shape') {
|
||||
$self->{canvas}->update_bed_size;
|
||||
$self->{canvas3D}->update_bed_size if $self->{canvas3D};
|
||||
$self->{preview3D}->set_bed_shape($self->{config}->bed_shape)
|
||||
if $self->{preview3D};
|
||||
$self->update;
|
||||
} elsif ($opt_key eq 'serial_port') {
|
||||
if ($config->get('serial_port')) {
|
||||
$self->{btn_print}->Show;
|
||||
} else {
|
||||
$self->{btn_print}->Hide;
|
||||
}
|
||||
$self->Layout;
|
||||
} elsif ($opt_key eq 'octoprint_host') {
|
||||
if ($config->get('octoprint_host')) {
|
||||
$self->{btn_send_gcode}->Show;
|
||||
} else {
|
||||
$self->{btn_send_gcode}->Hide;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ($group eq 'print') {
|
||||
$self->{settings_override_config}->clear;
|
||||
@ -559,8 +540,6 @@ sub _on_select_preset {
|
||||
$self->load_presets;
|
||||
}
|
||||
|
||||
return if !$self->GetFrame->is_loaded;
|
||||
|
||||
$self->config_changed;
|
||||
}
|
||||
|
||||
@ -894,7 +873,7 @@ sub load_model_objects {
|
||||
|
||||
$self->make_thumbnail($_) for @obj_idx;
|
||||
$self->arrange if $need_arrange;
|
||||
$self->update;
|
||||
$self->on_model_change;
|
||||
|
||||
# zoom to objects
|
||||
$self->{canvas3D}->zoom_to_volumes
|
||||
@ -902,8 +881,6 @@ sub load_model_objects {
|
||||
|
||||
$self->object_list_changed;
|
||||
|
||||
$self->schedule_background_process;
|
||||
|
||||
return @obj_idx;
|
||||
}
|
||||
|
||||
@ -936,8 +913,7 @@ sub remove {
|
||||
$self->object_list_changed;
|
||||
|
||||
$self->select_object(undef);
|
||||
$self->update;
|
||||
$self->schedule_background_process;
|
||||
$self->on_model_change;
|
||||
}
|
||||
|
||||
sub reset {
|
||||
@ -955,7 +931,7 @@ sub reset {
|
||||
$self->object_list_changed;
|
||||
|
||||
$self->select_object(undef);
|
||||
$self->update;
|
||||
$self->on_model_change;
|
||||
}
|
||||
|
||||
sub increase {
|
||||
@ -979,9 +955,8 @@ sub increase {
|
||||
if ($Slic3r::GUI::Settings->{_}{autocenter}) {
|
||||
$self->arrange;
|
||||
} else {
|
||||
$self->update;
|
||||
$self->on_model_change;
|
||||
}
|
||||
$self->schedule_background_process;
|
||||
}
|
||||
|
||||
sub decrease {
|
||||
@ -1001,8 +976,7 @@ sub decrease {
|
||||
$self->remove;
|
||||
}
|
||||
|
||||
$self->update;
|
||||
$self->schedule_background_process;
|
||||
$self->on_model_change;
|
||||
}
|
||||
|
||||
sub set_number_of_copies {
|
||||
@ -1074,8 +1048,7 @@ sub rotate {
|
||||
$self->{print}->add_model_object($model_object, $obj_idx);
|
||||
|
||||
$self->selection_changed; # refresh info (size etc.)
|
||||
$self->update;
|
||||
$self->schedule_background_process;
|
||||
$self->on_model_change;
|
||||
}
|
||||
|
||||
sub mirror {
|
||||
@ -1102,8 +1075,7 @@ sub mirror {
|
||||
$self->{print}->add_model_object($model_object, $obj_idx);
|
||||
|
||||
$self->selection_changed; # refresh info (size etc.)
|
||||
$self->update;
|
||||
$self->schedule_background_process;
|
||||
$self->on_model_change;
|
||||
}
|
||||
|
||||
sub changescale {
|
||||
@ -1157,7 +1129,7 @@ sub changescale {
|
||||
my $newsize = Wx::GetTextFromUser("Enter the new max size for the selected object:",
|
||||
"Scale", $cursize, $self);
|
||||
return if !$newsize || $newsize !~ /^\d*(?:\.\d*)?$/ || $newsize < 0;
|
||||
$scale = $newsize / $cursize * 100;
|
||||
$scale = $model_instance->scaling_factor * $newsize / $cursize * 100;
|
||||
} else {
|
||||
# max scale factor should be above 2540 to allow importing files exported in inches
|
||||
# Wx::GetNumberFromUser() does not support decimal numbers
|
||||
@ -1184,8 +1156,7 @@ sub changescale {
|
||||
$self->{print}->add_model_object($model_object, $obj_idx);
|
||||
|
||||
$self->selection_changed(1); # refresh info (size, volume etc.)
|
||||
$self->update;
|
||||
$self->schedule_background_process;
|
||||
$self->on_model_change;
|
||||
}
|
||||
|
||||
sub arrange {
|
||||
@ -1198,7 +1169,7 @@ sub arrange {
|
||||
# ignore arrange failures on purpose: user has visual feedback and we don't need to warn him
|
||||
# when parts don't fit in print bed
|
||||
|
||||
$self->update(1);
|
||||
$self->on_model_change(1);
|
||||
}
|
||||
|
||||
sub split_object {
|
||||
@ -1245,28 +1216,77 @@ sub split_object {
|
||||
$self->load_model_objects(@model_objects);
|
||||
}
|
||||
|
||||
sub toggle_print_stats {
|
||||
my ($self, $show) = @_;
|
||||
|
||||
return if !$self->GetFrame->is_loaded;
|
||||
|
||||
if ($show) {
|
||||
$self->{right_sizer}->Show($self->{sliced_info_box});
|
||||
} else {
|
||||
$self->{right_sizer}->Hide($self->{sliced_info_box});
|
||||
}
|
||||
$self->{right_sizer}->Layout;
|
||||
}
|
||||
|
||||
sub config_changed {
|
||||
my ($self) = @_;
|
||||
my $self = shift;
|
||||
|
||||
my $config = $self->config;
|
||||
|
||||
if ($Slic3r::GUI::autosave) {
|
||||
$self->config->save($Slic3r::GUI::autosave);
|
||||
$config->save($Slic3r::GUI::autosave);
|
||||
}
|
||||
|
||||
# (re) start timer
|
||||
$self->schedule_background_process;
|
||||
# Apply changes to the plater-specific config options.
|
||||
foreach my $opt_key (@{$self->{config}->diff($config)}) {
|
||||
# Ignore overrides. No need to set them in our config; we'll use them directly below.
|
||||
next if $opt_key eq 'overrides';
|
||||
|
||||
$self->{config}->set($opt_key, $config->get($opt_key));
|
||||
|
||||
if ($opt_key eq 'bed_shape') {
|
||||
$self->{canvas}->update_bed_size;
|
||||
$self->{canvas3D}->update_bed_size if $self->{canvas3D};
|
||||
$self->{preview3D}->set_bed_shape($self->{config}->bed_shape)
|
||||
if $self->{preview3D};
|
||||
$self->on_model_change;
|
||||
} elsif ($opt_key eq 'serial_port') {
|
||||
if ($config->get('serial_port')) {
|
||||
$self->{btn_print}->Show;
|
||||
} else {
|
||||
$self->{btn_print}->Hide;
|
||||
}
|
||||
$self->Layout;
|
||||
} elsif ($opt_key eq 'octoprint_host') {
|
||||
if ($config->get('octoprint_host')) {
|
||||
$self->{btn_send_gcode}->Show;
|
||||
} else {
|
||||
$self->{btn_send_gcode}->Hide;
|
||||
}
|
||||
$self->Layout;
|
||||
}
|
||||
}
|
||||
|
||||
return if !$self->GetFrame->is_loaded;
|
||||
|
||||
$self->toggle_print_stats(0);
|
||||
|
||||
if ($Slic3r::GUI::Settings->{_}{background_processing}) {
|
||||
# (re)start timer
|
||||
$self->schedule_background_process;
|
||||
} else {
|
||||
$self->async_apply_config;
|
||||
}
|
||||
}
|
||||
|
||||
sub schedule_background_process {
|
||||
my ($self) = @_;
|
||||
|
||||
$self->{processed} = 0;
|
||||
warn 'schedule_background_process() is not supposed to be called when background processing is disabled'
|
||||
if !$Slic3r::GUI::Settings->{_}{background_processing};
|
||||
|
||||
if (!$Slic3r::GUI::Settings->{_}{background_processing}) {
|
||||
my $sel = $self->{preview_notebook}->GetSelection;
|
||||
if ($sel == $self->{preview3D_page_idx} || $sel == $self->{toolpaths2D_page_idx}) {
|
||||
$self->{preview_notebook}->SetSelection(0);
|
||||
}
|
||||
}
|
||||
$self->{processed} = 0;
|
||||
|
||||
if (defined $self->{apply_config_timer}) {
|
||||
$self->{apply_config_timer}->Start(PROCESS_DELAY, 1); # 1 = one shot
|
||||
@ -1278,10 +1298,6 @@ sub schedule_background_process {
|
||||
sub async_apply_config {
|
||||
my ($self) = @_;
|
||||
|
||||
# reset preview canvases
|
||||
$self->{toolpaths2D}->reload_print if $self->{toolpaths2D};
|
||||
$self->{preview3D}->reload_print if $self->{preview3D};
|
||||
|
||||
# pause process thread before applying new config
|
||||
# since we don't want to touch data that is being used by the threads
|
||||
$self->pause_background_process;
|
||||
@ -1289,16 +1305,20 @@ sub async_apply_config {
|
||||
# apply new config
|
||||
my $invalidated = $self->{print}->apply_config($self->config);
|
||||
|
||||
return if !$Slic3r::GUI::Settings->{_}{background_processing};
|
||||
# reset preview canvases (invalidated contents will be hidden)
|
||||
$self->{toolpaths2D}->reload_print if $self->{toolpaths2D};
|
||||
$self->{preview3D}->reload_print if $self->{preview3D};
|
||||
|
||||
if ($invalidated) {
|
||||
if (!$Slic3r::GUI::Settings->{_}{background_processing}) {
|
||||
$self->hide_preview;
|
||||
return;
|
||||
}
|
||||
|
||||
# kill current thread if any
|
||||
$self->stop_background_process;
|
||||
# remove the sliced statistics box because something changed.
|
||||
if ($self->{"right_sizer"}) {
|
||||
$self->{"right_sizer"}->Hide($self->{"sliced_info_box"});
|
||||
$self->{"right_sizer"}->Layout;
|
||||
}
|
||||
$self->toggle_print_stats(0);
|
||||
} else {
|
||||
$self->resume_background_process;
|
||||
}
|
||||
@ -1329,6 +1349,10 @@ sub start_background_process {
|
||||
return;
|
||||
}
|
||||
|
||||
if ($Slic3r::GUI::Settings->{_}{threads}) {
|
||||
$self->{print}->config->set('threads', $Slic3r::GUI::Settings->{_}{threads});
|
||||
}
|
||||
|
||||
# start thread
|
||||
@_ = ();
|
||||
$self->{process_thread} = Slic3r::spawn_thread(sub {
|
||||
@ -1472,8 +1496,7 @@ sub export_gcode {
|
||||
|
||||
# this updates buttons status
|
||||
$self->object_list_changed;
|
||||
$self->{"right_sizer"}->Show($self->{"sliced_info_box"});
|
||||
$self->{"right_sizer"}->Layout;
|
||||
$self->toggle_print_stats(1);
|
||||
|
||||
return $self->{export_gcode_output_file};
|
||||
}
|
||||
@ -1568,10 +1591,22 @@ sub on_export_completed {
|
||||
$self->send_gcode if $send_gcode;
|
||||
$self->{print_file} = undef;
|
||||
$self->{send_gcode_file} = undef;
|
||||
$self->{"print_info_cost"}->SetLabel(sprintf("%.2f" , $self->{print}->total_cost));
|
||||
$self->{"print_info_fil_g"}->SetLabel(sprintf("%.2f" , $self->{print}->total_weight));
|
||||
$self->{"print_info_fil_cm3"}->SetLabel(sprintf("%.2f" , $self->{print}->total_extruded_volume) / 1000);
|
||||
$self->{"print_info_fil_cm"}->SetLabel(sprintf("%.2f" , $self->{print}->total_used_filament) / 10);
|
||||
|
||||
{
|
||||
my $fil = sprintf(
|
||||
'%.2fcm (%.2fcm³%s)',
|
||||
$self->{print}->total_used_filament / 10,
|
||||
$self->{print}->total_extruded_volume / 1000,
|
||||
$self->{print}->total_weight
|
||||
? sprintf(', %.2fg', $self->{print}->total_weight)
|
||||
: '',
|
||||
);
|
||||
my $cost = $self->{print}->total_cost
|
||||
? sprintf("%.2f" , $self->{print}->total_cost)
|
||||
: 'n.a.';
|
||||
$self->{print_info_fil}->SetLabel($fil);
|
||||
$self->{print_info_cost}->SetLabel($cost);
|
||||
}
|
||||
|
||||
# this updates buttons status
|
||||
$self->object_list_changed;
|
||||
@ -1683,6 +1718,23 @@ sub export_object_stl {
|
||||
$self->statusbar->SetStatusText("STL file exported to $output_file");
|
||||
}
|
||||
|
||||
# Export function for a single AMF output
|
||||
sub export_object_amf {
|
||||
my $self = shift;
|
||||
|
||||
my ($obj_idx, $object) = $self->selected_object;
|
||||
return if !defined $obj_idx;
|
||||
|
||||
my $local_model = Slic3r::Model->new;
|
||||
my $model_object = $self->{model}->objects->[$obj_idx];
|
||||
# copy model_object -> local_model
|
||||
$local_model->add_object($model_object);
|
||||
|
||||
my $output_file = $self->_get_export_file('AMF') or return;
|
||||
$local_model->write_amf($output_file);
|
||||
$self->statusbar->SetStatusText("AMF file exported to $output_file");
|
||||
}
|
||||
|
||||
sub export_amf {
|
||||
my $self = shift;
|
||||
|
||||
@ -1697,14 +1749,21 @@ sub _get_export_file {
|
||||
my $self = shift;
|
||||
my ($format) = @_;
|
||||
|
||||
my $suffix = $format eq 'STL' ? '.stl' : '.amf.xml';
|
||||
my $suffix = $format eq 'STL' ? '.stl' : '.amf';
|
||||
|
||||
my $output_file = $main::opt{output};
|
||||
{
|
||||
$output_file = $self->{print}->output_filepath($output_file // '');
|
||||
$output_file =~ s/\.gcode$/$suffix/i;
|
||||
my $dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
|
||||
basename($output_file), &Slic3r::GUI::MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT);
|
||||
my $dlg;
|
||||
$dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
|
||||
basename($output_file), &Slic3r::GUI::STL_MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT)
|
||||
if $format eq 'STL';
|
||||
|
||||
$dlg = Wx::FileDialog->new($self, "Save $format file as:", dirname($output_file),
|
||||
basename($output_file), &Slic3r::GUI::AMF_MODEL_WILDCARD, wxFD_SAVE | wxFD_OVERWRITE_PROMPT)
|
||||
if $format eq 'AMF';
|
||||
|
||||
if ($dlg->ShowModal != wxID_OK) {
|
||||
$dlg->Destroy;
|
||||
return undef;
|
||||
@ -1749,30 +1808,42 @@ sub on_thumbnail_made {
|
||||
|
||||
# this method gets called whenever print center is changed or the objects' bounding box changes
|
||||
# (i.e. when an object is added/removed/moved/rotated/scaled)
|
||||
sub update {
|
||||
sub on_model_change {
|
||||
my ($self, $force_autocenter) = @_;
|
||||
|
||||
my $running = $self->pause_background_process;
|
||||
|
||||
if ($Slic3r::GUI::Settings->{_}{autocenter} || $force_autocenter) {
|
||||
$self->{model}->center_instances_around_point($self->bed_centerf);
|
||||
}
|
||||
$self->refresh_canvases;
|
||||
|
||||
my $running = $self->pause_background_process;
|
||||
my $invalidated = $self->{print}->reload_model_instances();
|
||||
|
||||
# The mere fact that no steps were invalidated when reloading model instances
|
||||
# doesn't mean that all steps were done: for example, validation might have
|
||||
# failed upon previous instance move, so we have no running thread and no steps
|
||||
# are invalidated on this move, thus we need to schedule a new run.
|
||||
if ($invalidated || !$running) {
|
||||
$self->schedule_background_process;
|
||||
if ($Slic3r::GUI::Settings->{_}{background_processing}) {
|
||||
if ($invalidated || !$running) {
|
||||
# The mere fact that no steps were invalidated when reloading model instances
|
||||
# doesn't mean that all steps were done: for example, validation might have
|
||||
# failed upon previous instance move, so we have no running thread and no steps
|
||||
# are invalidated on this move, thus we need to schedule a new run.
|
||||
$self->schedule_background_process;
|
||||
$self->toggle_print_stats(0);
|
||||
} else {
|
||||
$self->resume_background_process;
|
||||
}
|
||||
} else {
|
||||
$self->resume_background_process;
|
||||
$self->hide_preview;
|
||||
}
|
||||
if ($self->{"right_sizer"}) {
|
||||
$self->{"right_sizer"}->Hide($self->{"sliced_info_box"});
|
||||
$self->{"right_sizer"}->Layout;
|
||||
}
|
||||
|
||||
sub hide_preview {
|
||||
my ($self) = @_;
|
||||
|
||||
my $sel = $self->{preview_notebook}->GetSelection;
|
||||
if ($sel == $self->{preview3D_page_idx} || $sel == $self->{toolpaths2D_page_idx}) {
|
||||
$self->{preview_notebook}->SetSelection(0);
|
||||
}
|
||||
$self->refresh_canvases;
|
||||
$self->{processed} = 0;
|
||||
}
|
||||
|
||||
sub on_extruders_change {
|
||||
@ -1896,7 +1967,7 @@ sub object_settings_dialog {
|
||||
if ($dlg->PartsChanged || $dlg->PartSettingsChanged) {
|
||||
$self->stop_background_process;
|
||||
$self->{print}->reload_object($obj_idx);
|
||||
$self->schedule_background_process;
|
||||
$self->on_model_change;
|
||||
} else {
|
||||
$self->resume_background_process;
|
||||
}
|
||||
@ -2126,6 +2197,9 @@ sub object_menu {
|
||||
$frame->_append_menu_item($menu, "Export object as STL…", 'Export this single object as STL file', sub {
|
||||
$self->export_object_stl;
|
||||
}, undef, 'brick_go.png');
|
||||
$frame->_append_menu_item($menu, "Export object and modifiers as AMF…", 'Export this single object and all associated modifiers as AMF file', sub {
|
||||
$self->export_object_amf;
|
||||
}, undef, 'brick_go.png');
|
||||
|
||||
return $menu;
|
||||
}
|
||||
@ -2223,4 +2297,73 @@ sub transform_thumbnail {
|
||||
$self->transformed_thumbnail($t);
|
||||
}
|
||||
|
||||
package Slic3r::GUI::Plater::OctoPrintSpoolDialog;
|
||||
use Wx qw(:dialog :id :misc :sizer :icon wxTheApp);
|
||||
use Wx::Event qw(EVT_BUTTON EVT_TEXT_ENTER);
|
||||
use base 'Wx::Dialog';
|
||||
|
||||
sub new {
|
||||
my $class = shift;
|
||||
my ($parent, $filename) = @_;
|
||||
my $self = $class->SUPER::new($parent, -1, "Send to OctoPrint", wxDefaultPosition,
|
||||
[400, -1]);
|
||||
|
||||
$self->{filename} = $filename;
|
||||
$Slic3r::GUI::Settings->{octoprint} //= {};
|
||||
|
||||
my $optgroup;
|
||||
$optgroup = Slic3r::GUI::OptionsGroup->new(
|
||||
parent => $self,
|
||||
title => 'Send to OctoPrint',
|
||||
on_change => sub {
|
||||
my ($opt_id) = @_;
|
||||
|
||||
if ($opt_id eq 'filename') {
|
||||
$self->{filename} = $optgroup->get_value($opt_id);
|
||||
} else {
|
||||
$Slic3r::GUI::Settings->{octoprint}{$opt_id} = $optgroup->get_value($opt_id);
|
||||
}
|
||||
},
|
||||
label_width => 200,
|
||||
);
|
||||
$optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
|
||||
opt_id => 'filename',
|
||||
type => 's',
|
||||
label => 'File name',
|
||||
width => 200,
|
||||
tooltip => 'The name used for labelling the print job.',
|
||||
default => $filename,
|
||||
));
|
||||
$optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
|
||||
opt_id => 'overwrite',
|
||||
type => 'bool',
|
||||
label => 'Overwrite existing file',
|
||||
tooltip => 'If selected, any existing file with the same name will be overwritten without confirmation.',
|
||||
default => $Slic3r::GUI::Settings->{octoprint}{overwrite} // 0,
|
||||
));
|
||||
$optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
|
||||
opt_id => 'start',
|
||||
type => 'bool',
|
||||
label => 'Start print',
|
||||
tooltip => 'If selected, print will start after the upload.',
|
||||
default => $Slic3r::GUI::Settings->{octoprint}{start} // 0,
|
||||
));
|
||||
|
||||
my $sizer = Wx::BoxSizer->new(wxVERTICAL);
|
||||
$sizer->Add($optgroup->sizer, 0, wxEXPAND | wxTOP | wxBOTTOM | wxLEFT | wxRIGHT, 10);
|
||||
|
||||
my $buttons = $self->CreateStdDialogButtonSizer(wxOK | wxCANCEL);
|
||||
$sizer->Add($buttons, 0, wxEXPAND | wxBOTTOM | wxLEFT | wxRIGHT, 10);
|
||||
EVT_BUTTON($self, wxID_OK, sub {
|
||||
wxTheApp->save_settings;
|
||||
$self->EndModal(wxID_OK);
|
||||
$self->Close; # needed on Linux
|
||||
});
|
||||
|
||||
$self->SetSizer($sizer);
|
||||
$sizer->SetSizeHints($self);
|
||||
|
||||
return $self;
|
||||
}
|
||||
|
||||
1;
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -57,6 +57,13 @@ sub new {
|
||||
default => $Slic3r::GUI::Settings->{_}{background_processing},
|
||||
readonly => !$Slic3r::have_threads,
|
||||
));
|
||||
$optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
|
||||
opt_id => 'threads',
|
||||
type => 'i',
|
||||
label => 'Threads',
|
||||
tooltip => $Slic3r::Config::Options->{threads}{tooltip},
|
||||
default => $Slic3r::GUI::Settings->{_}{threads},
|
||||
));
|
||||
$optgroup->append_single_option_line(Slic3r::GUI::OptionsGroup::Option->new(
|
||||
opt_id => 'no_controller',
|
||||
type => 'bool',
|
||||
|
@ -521,7 +521,7 @@ sub options {
|
||||
external_perimeter_extrusion_width infill_extrusion_width solid_infill_extrusion_width
|
||||
top_infill_extrusion_width support_material_extrusion_width
|
||||
infill_overlap bridge_flow_ratio
|
||||
xy_size_compensation threads resolution overridable compatible_printers
|
||||
xy_size_compensation resolution overridable compatible_printers
|
||||
print_settings_id
|
||||
)
|
||||
}
|
||||
@ -755,7 +755,6 @@ sub build {
|
||||
{
|
||||
my $optgroup = $page->new_optgroup('Other');
|
||||
$optgroup->append_single_option_line('xy_size_compensation');
|
||||
$optgroup->append_single_option_line('threads') if $Slic3r::have_threads;
|
||||
$optgroup->append_single_option_line('resolution');
|
||||
}
|
||||
}
|
||||
@ -832,14 +831,13 @@ sub _update {
|
||||
|
||||
my $config = $self->{config};
|
||||
|
||||
if ($config->spiral_vase && !($config->perimeters == 1 && $config->top_solid_layers == 0 && $config->fill_density == 0 && $config->infill_only_where_needed == 0 && $config->support_material == 0)) {
|
||||
if ($config->spiral_vase && !($config->perimeters == 1 && $config->top_solid_layers == 0 && $config->fill_density == 0 && $config->support_material == 0)) {
|
||||
my $dialog = Wx::MessageDialog->new($self,
|
||||
"The Spiral Vase mode requires:\n"
|
||||
. "- one perimeter\n"
|
||||
. "- no top solid layers\n"
|
||||
. "- 0% fill density\n"
|
||||
. "- no support material\n"
|
||||
. "- no infill where necessary\n"
|
||||
. "\nShall I adjust those settings in order to enable Spiral Vase?",
|
||||
'Spiral Vase', wxICON_WARNING | wxYES | wxNO);
|
||||
if ($dialog->ShowModal() == wxID_YES) {
|
||||
@ -848,7 +846,6 @@ sub _update {
|
||||
$new_conf->set("top_solid_layers", 0);
|
||||
$new_conf->set("fill_density", 0);
|
||||
$new_conf->set("support_material", 0);
|
||||
$new_conf->set("infill_only_where_needed", 0);
|
||||
$self->load_config($new_conf);
|
||||
} else {
|
||||
my $new_conf = Slic3r::Config->new;
|
||||
@ -1012,12 +1009,7 @@ sub build {
|
||||
$optgroup->append_single_option_line('filament_colour', 0);
|
||||
$optgroup->append_single_option_line('filament_diameter', 0);
|
||||
$optgroup->append_single_option_line('extrusion_multiplier', 0);
|
||||
$optgroup->append_single_option_line('filament_density', 0);
|
||||
$optgroup->append_single_option_line('filament_cost', 0);
|
||||
}
|
||||
|
||||
|
||||
|
||||
{
|
||||
my $optgroup = $page->new_optgroup('Temperature (°C)');
|
||||
|
||||
@ -1039,6 +1031,11 @@ sub build {
|
||||
$optgroup->append_line($line);
|
||||
}
|
||||
}
|
||||
{
|
||||
my $optgroup = $page->new_optgroup('Optional information');
|
||||
$optgroup->append_single_option_line('filament_density', 0);
|
||||
$optgroup->append_single_option_line('filament_cost', 0);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
@ -1082,9 +1079,8 @@ sub build {
|
||||
$optgroup->append_single_option_line('min_print_speed');
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
my $page = $self->add_options_page('Custom G-code', 'cog.png');
|
||||
my $page = $self->add_options_page('Custom G-code', 'script.png');
|
||||
{
|
||||
my $optgroup = $page->new_optgroup('Start G-code',
|
||||
label_width => 0,
|
||||
@ -1104,6 +1100,19 @@ sub build {
|
||||
$optgroup->append_single_option_line($option);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
my $page = $self->add_options_page('Notes', 'note.png');
|
||||
{
|
||||
my $optgroup = $page->new_optgroup('Notes',
|
||||
label_width => 0,
|
||||
);
|
||||
my $option = $optgroup->get_option('filament_notes', 0);
|
||||
$option->full_width(1);
|
||||
$option->height(250);
|
||||
$optgroup->append_single_option_line($option);
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
my $page = $self->add_options_page('Overrides', 'wrench.png');
|
||||
@ -1398,7 +1407,7 @@ sub build {
|
||||
}
|
||||
}
|
||||
{
|
||||
my $page = $self->add_options_page('Custom G-code', 'cog.png');
|
||||
my $page = $self->add_options_page('Custom G-code', 'script.png');
|
||||
{
|
||||
my $optgroup = $page->new_optgroup('Start G-code',
|
||||
label_width => 0,
|
||||
|
@ -48,7 +48,7 @@ sub BUILD {
|
||||
|
||||
$self->_cooling_buffer(Slic3r::GCode::CoolingBuffer->new($self->_gcodegen));
|
||||
|
||||
$self->_spiral_vase(Slic3r::GCode::SpiralVase->new(config => $self->config))
|
||||
$self->_spiral_vase(Slic3r::GCode::SpiralVase->new($self->config))
|
||||
if $self->config->spiral_vase;
|
||||
|
||||
$self->_vibration_limit(Slic3r::GCode::VibrationLimit->new(config => $self->config))
|
||||
@ -323,10 +323,10 @@ sub process_layer {
|
||||
|
||||
# check whether we're going to apply spiralvase logic
|
||||
if (defined $self->_spiral_vase) {
|
||||
$self->_spiral_vase->enable(
|
||||
($layer->id > 0 || $self->print->config->brim_width == 0
|
||||
|| $self->print->config->interior_brim_width == 0 || $self->print->config->brim_connections_width == 0)
|
||||
&& ($layer->id >= $self->print->config->skirt_height && !$self->print->has_infinite_skirt)
|
||||
$self->_spiral_vase->set_enable(
|
||||
$layer->id > 0
|
||||
&& ($self->print->config->skirts == 0
|
||||
|| ($layer->id >= $self->print->config->skirt_height && !$self->print->has_infinite_skirt))
|
||||
&& !defined(first { $_->region->config->bottom_solid_layers > $layer->id } @{$layer->regions})
|
||||
&& !defined(first { $_->perimeters->items_count > 1 } @{$layer->regions})
|
||||
&& !defined(first { $_->fills->items_count > 0 } @{$layer->regions})
|
||||
@ -462,11 +462,7 @@ sub process_layer {
|
||||
|
||||
# extrude brim
|
||||
if (!$self->_brim_done) {
|
||||
my $extr = $self->print->regions->[0]->config->perimeter_extruder-1;
|
||||
if (my $o = first { $_->config->raft_layers > 0 } @{$self->objects}) {
|
||||
$extr = $o->config->support_material_extruder-1;
|
||||
}
|
||||
$gcode .= $self->_gcodegen->set_extruder($extr);
|
||||
$gcode .= $self->_gcodegen->set_extruder($self->print->brim_extruder-1);
|
||||
$self->_gcodegen->set_origin(Slic3r::Pointf->new(0,0));
|
||||
$self->_gcodegen->avoid_crossing_perimeters->set_use_external_mp(1);
|
||||
$gcode .= $self->_gcodegen->extrude($_, 'brim', $object->config->support_material_speed)
|
||||
|
@ -3,7 +3,7 @@ package Slic3r::Print::Object;
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use List::Util qw(min max sum first);
|
||||
use List::Util qw(min max sum first any);
|
||||
use Slic3r::Flow ':roles';
|
||||
use Slic3r::Geometry qw(X Y Z PI scale unscale chained_path epsilon);
|
||||
use Slic3r::Geometry::Clipper qw(diff diff_ex intersection intersection_ex union union_ex
|
||||
@ -459,7 +459,7 @@ sub generate_support_material {
|
||||
$self->_support_material->generate($self);
|
||||
|
||||
$self->set_step_done(STEP_SUPPORTMATERIAL);
|
||||
my $stats = "Weight: %.1fg, Cost: %.1f" , $self->print->total_weight, $self->print->total_cost;
|
||||
my $stats = sprintf "Weight: %.1fg, Cost: %.1f" , $self->print->total_weight, $self->print->total_cost;
|
||||
$self->print->status_cb->(85, $stats);
|
||||
}
|
||||
|
||||
@ -488,9 +488,9 @@ sub _support_material {
|
||||
# fill_surfaces but we only turn them into VOID surfaces, thus preserving the boundaries.
|
||||
sub clip_fill_surfaces {
|
||||
my $self = shift;
|
||||
# sanity check for incompatible options:
|
||||
# spiral_vase and infill_only_where_needed
|
||||
return unless $self->config->infill_only_where_needed and not $self->config->spiral_vase;
|
||||
|
||||
return unless $self->config->infill_only_where_needed
|
||||
&& any { $_->config->fill_density > 0 } @{$self->print->regions};
|
||||
|
||||
# We only want infill under ceilings; this is almost like an
|
||||
# internal support material.
|
||||
@ -548,6 +548,8 @@ sub clip_fill_surfaces {
|
||||
|
||||
# apply new internal infill to regions
|
||||
foreach my $layerm (@{$lower_layer->regions}) {
|
||||
next if $layerm->region->config->fill_density == 0;
|
||||
|
||||
my (@internal, @other) = ();
|
||||
foreach my $surface (map $_->clone, @{$layerm->fill_surfaces}) {
|
||||
if ($surface->surface_type == S_TYPE_INTERNAL || $surface->surface_type == S_TYPE_INTERNALVOID) {
|
||||
|
@ -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)],
|
||||
);
|
||||
|
32
package/win/slic3r.exe.manifest
Normal file
32
package/win/slic3r.exe.manifest
Normal file
@ -0,0 +1,32 @@
|
||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
|
||||
<assemblyIdentity version="0.0.0.0" name="Slic3r" type="Win32" />
|
||||
<description>Slic3r</description>
|
||||
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
|
||||
<security>
|
||||
<requestedPrivileges>
|
||||
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
|
||||
</requestedPrivileges>
|
||||
</security>
|
||||
</trustInfo>
|
||||
<dependency>
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity type="Win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0"
|
||||
processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" />
|
||||
</dependentAssembly>
|
||||
</dependency>
|
||||
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
||||
<application>
|
||||
<!-- The ID below indicates application support for Windows Vista -->
|
||||
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
|
||||
<!-- The ID below indicates application support for Windows 7 -->
|
||||
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
|
||||
<!-- The ID below indicates application support for Windows 8 -->
|
||||
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
|
||||
<!-- The ID below indicates application support for Windows 8.1 -->
|
||||
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
|
||||
<!-- The ID below indicates application support for Windows 10 -->
|
||||
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
|
||||
</application>
|
||||
</compatibility>
|
||||
</assembly>
|
@ -22,4 +22,4 @@ BEGIN
|
||||
VALUE "Translation", 0x409, 1252
|
||||
END
|
||||
END
|
||||
|
||||
1 Manifest slic3r.exe.manifest
|
||||
|
@ -29,6 +29,7 @@ my %cli_options = ();
|
||||
'debug' => \$Slic3r::debug,
|
||||
'gui' => \$opt{gui},
|
||||
'o|output=s' => \$opt{output},
|
||||
'j|threads=i' => \$opt{threads},
|
||||
|
||||
'save=s' => \$opt{save},
|
||||
'load=s@' => \$opt{load},
|
||||
@ -103,6 +104,7 @@ if ((!@ARGV || $opt{gui}) && !$opt{save} && eval "require Slic3r::GUI; 1") {
|
||||
$Slic3r::GUI::datadir = Slic3r::decode_path($opt{datadir} // '');
|
||||
$Slic3r::GUI::no_controller = $opt{no_controller};
|
||||
$Slic3r::GUI::autosave = Slic3r::decode_path($opt{autosave} // '');
|
||||
$Slic3r::GUI::threads = $opt{threads};
|
||||
}
|
||||
$gui = Slic3r::GUI->new;
|
||||
setlocale(LC_NUMERIC, 'C');
|
||||
@ -260,6 +262,7 @@ if (@ARGV) { # slicing from command line
|
||||
);
|
||||
|
||||
$sprint->apply_config($config);
|
||||
$sprint->config->set('threads', $opt{threads}) if $opt{threads};
|
||||
$sprint->set_model($model);
|
||||
|
||||
if ($opt{export_svg}) {
|
||||
@ -290,7 +293,7 @@ sub usage {
|
||||
my $j = '';
|
||||
if ($Slic3r::have_threads) {
|
||||
$j = <<"EOF";
|
||||
-j, --threads <num> Number of threads to use (1+, default: $config->{threads})
|
||||
-j, --threads <num> Number of threads to use
|
||||
EOF
|
||||
}
|
||||
|
||||
@ -459,7 +462,7 @@ $j
|
||||
--extra-perimeters Add more perimeters when needed (default: yes)
|
||||
--avoid-crossing-perimeters Optimize travel moves so that no perimeters are crossed (default: no)
|
||||
--thin-walls Detect single-width walls (default: yes)
|
||||
--overhangs Experimental option to use bridge flow, speed and fan for overhangs
|
||||
--detect-bridging-perimeters Detect bridging perimeters and apply bridge flow, speed and fan
|
||||
(default: yes)
|
||||
|
||||
Support material options:
|
||||
|
@ -2,7 +2,7 @@ cmake_minimum_required (VERSION 2.8)
|
||||
project (slic3r)
|
||||
|
||||
# only on newer GCCs: -ftemplate-backtrace-limit=0
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -DM_PI=3.14159265358979323846 -D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DBOOST_ASIO_DISABLE_KQUEUE")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -DM_PI=3.14159265358979323846 -D_GLIBCXX_USE_C99 -DHAS_BOOL -DNOGDI -DBOOST_ASIO_DISABLE_KQUEUE")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} -Wall -DSLIC3R_DEBUG")
|
||||
|
||||
if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.7.0)
|
||||
@ -14,7 +14,8 @@ endif(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.7.0)
|
||||
set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
IF(CMAKE_HOST_APPLE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-framework IOKit -framework CoreFoundation")
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -stdlib=libc++ -DBOOST_THREAD_DONT_USE_CHRONO -DBOOST_NO_CXX11_RVALUE_REFERENCES -DBOOST_THREAD_USES_MOVE")
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-framework IOKit -framework CoreFoundation -lc++")
|
||||
ELSE(CMAKE_HOST_APPLE)
|
||||
set(CMAKE_EXE_LINKER_FLAGS "-static-libgcc -static-libstdc++")
|
||||
ENDIF(CMAKE_HOST_APPLE)
|
||||
@ -54,6 +55,8 @@ add_library(libslic3r STATIC
|
||||
${LIBDIR}/libslic3r/Flow.cpp
|
||||
${LIBDIR}/libslic3r/GCode.cpp
|
||||
${LIBDIR}/libslic3r/GCode/CoolingBuffer.cpp
|
||||
${LIBDIR}/libslic3r/GCode/SpiralVase.cpp
|
||||
${LIBDIR}/libslic3r/GCodeReader.cpp
|
||||
${LIBDIR}/libslic3r/GCodeSender.cpp
|
||||
${LIBDIR}/libslic3r/GCodeWriter.cpp
|
||||
${LIBDIR}/libslic3r/Geometry.cpp
|
||||
@ -82,6 +85,7 @@ add_library(libslic3r STATIC
|
||||
${LIBDIR}/libslic3r/SVG.cpp
|
||||
${LIBDIR}/libslic3r/TriangleMesh.cpp
|
||||
)
|
||||
|
||||
add_library(admesh STATIC
|
||||
${LIBDIR}/admesh/connect.c
|
||||
${LIBDIR}/admesh/normals.c
|
||||
@ -90,6 +94,8 @@ add_library(admesh STATIC
|
||||
${LIBDIR}/admesh/stlinit.c
|
||||
${LIBDIR}/admesh/util.c
|
||||
)
|
||||
set_property(TARGET admesh PROPERTY C_STANDARD 99)
|
||||
|
||||
add_library(clipper STATIC ${LIBDIR}/clipper.cpp)
|
||||
add_library(expat STATIC
|
||||
${LIBDIR}/expat/xmlparse.c
|
||||
|
@ -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') {
|
||||
|
BIN
var/script.png
Executable file
BIN
var/script.png
Executable file
Binary file not shown.
After Width: | Height: | Size: 748 B |
23
xs/Build.PL
23
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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
@ -9,6 +9,8 @@
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/erase.hpp>
|
||||
#include <boost/algorithm/string/predicate.hpp>
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/property_tree/ini_parser.hpp>
|
||||
@ -106,7 +108,6 @@ bool unescape_string_cstyle(const std::string &str, std::string &str_out)
|
||||
|
||||
bool unescape_strings_cstyle(const std::string &str, std::vector<std::string> &out)
|
||||
{
|
||||
out.clear();
|
||||
if (str.empty())
|
||||
return true;
|
||||
|
||||
@ -221,6 +222,12 @@ ConfigDef::add(const t_config_option_key &opt_key, const ConfigOptionDef &def)
|
||||
return &this->options[opt_key];
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigDef::has(const t_config_option_key &opt_key) const
|
||||
{
|
||||
return this->options.count(opt_key) > 0;
|
||||
}
|
||||
|
||||
const ConfigOptionDef*
|
||||
ConfigDef::get(const t_config_option_key &opt_key) const
|
||||
{
|
||||
@ -292,12 +299,27 @@ ConfigBase::serialize(const t_config_option_key &opt_key) const {
|
||||
}
|
||||
|
||||
bool
|
||||
ConfigBase::set_deserialize(const t_config_option_key &opt_key, std::string str, bool append) {
|
||||
ConfigBase::set_deserialize(t_config_option_key opt_key, std::string str, bool append) {
|
||||
const ConfigOptionDef* optdef = this->def->get(opt_key);
|
||||
if (optdef == NULL) throw UnknownOptionException();
|
||||
if (optdef == NULL) {
|
||||
// If we didn't find an option, look for any other option having this as an alias.
|
||||
for (const auto &opt : this->def->options) {
|
||||
for (const t_config_option_key &opt_key2 : opt.second.aliases) {
|
||||
if (opt_key2 == opt_key) {
|
||||
opt_key = opt_key2;
|
||||
optdef = &opt.second;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (optdef != NULL) break;
|
||||
}
|
||||
if (optdef == NULL)
|
||||
throw UnknownOptionException();
|
||||
}
|
||||
|
||||
if (!optdef->shortcut.empty()) {
|
||||
for (std::vector<t_config_option_key>::const_iterator it = optdef->shortcut.begin(); it != optdef->shortcut.end(); ++it) {
|
||||
if (!this->set_deserialize(*it, str)) return false;
|
||||
for (const t_config_option_key &shortcut : optdef->shortcut) {
|
||||
if (!this->set_deserialize(shortcut, str)) return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@ -377,7 +399,9 @@ ConfigBase::load(const std::string &file)
|
||||
pt::read_ini(file, tree);
|
||||
BOOST_FOREACH(const pt::ptree::value_type &v, tree) {
|
||||
try {
|
||||
this->set_deserialize(v.first.c_str(), v.second.get_value<std::string>().c_str());
|
||||
t_config_option_key opt_key = v.first;
|
||||
std::string value = v.second.get_value<std::string>();
|
||||
this->set_deserialize(opt_key, value);
|
||||
} catch (UnknownOptionException &e) {
|
||||
// ignore
|
||||
}
|
||||
@ -508,56 +532,109 @@ DynamicConfig::clear() {
|
||||
this->options.clear();
|
||||
}
|
||||
|
||||
void
|
||||
DynamicConfig::read_cli(const std::vector<std::string> &tokens, t_config_option_keys* extra)
|
||||
{
|
||||
std::vector<const char*> _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<const char*>(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<std::string,std::string> 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<std::string> 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<ConfigOptionBool>(opt_key, true)) {
|
||||
opt->value = !boost::starts_with(token, "no-");
|
||||
} else if (ConfigOptionBools* opt = this->opt<ConfigOptionBools>(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<ConfigOptionBool>(opt_key, true)) {
|
||||
opt->value = !no;
|
||||
} else if (ConfigOptionBools* opt = this->opt<ConfigOptionBools>(opt_key, true)) {
|
||||
if (!existing) opt->values.clear(); // remove the default values
|
||||
opt->values.push_back(!no);
|
||||
} else if (ConfigOptionStrings* opt = this->opt<ConfigOptionStrings>(opt_key, true)) {
|
||||
if (!existing) opt->values.clear(); // remove the default values
|
||||
opt->deserialize(value, true);
|
||||
} else if (ConfigOptionFloats* opt = this->opt<ConfigOptionFloats>(opt_key, true)) {
|
||||
if (!existing) opt->values.clear(); // remove the default values
|
||||
opt->deserialize(value, true);
|
||||
} else if (ConfigOptionPoints* opt = this->opt<ConfigOptionPoints>(opt_key, true)) {
|
||||
if (!existing) opt->values.clear(); // remove the default values
|
||||
opt->deserialize(value, true);
|
||||
} else {
|
||||
extra->push_back(token);
|
||||
this->set_deserialize(opt_key, value, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -614,4 +691,27 @@ ConfigOptionPoint3::deserialize(std::string str, bool append) {
|
||||
return true;
|
||||
};
|
||||
|
||||
bool
|
||||
ConfigOptionPoints::deserialize(std::string str, bool append) {
|
||||
if (!append) this->values.clear();
|
||||
|
||||
std::vector<std::string> 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<coordf_t>(tokens[i]);
|
||||
point.y = boost::lexical_cast<coordf_t>(tokens[++i]);
|
||||
this->values.push_back(point);
|
||||
}
|
||||
} catch (boost::bad_lexical_cast &e) {
|
||||
printf("%s\n", e.what());
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -248,6 +248,7 @@ class ConfigOptionStrings : public ConfigOptionVector<std::string>
|
||||
};
|
||||
|
||||
bool deserialize(std::string str, bool append = false) {
|
||||
if (!append) this->values.clear();
|
||||
return unescape_strings_cstyle(str, this->values);
|
||||
};
|
||||
};
|
||||
@ -390,24 +391,7 @@ class ConfigOptionPoints : public ConfigOptionVector<Pointf>
|
||||
return vv;
|
||||
};
|
||||
|
||||
bool deserialize(std::string str, bool append = false) {
|
||||
if (!append) this->values.clear();
|
||||
std::istringstream is(str);
|
||||
std::string point_str;
|
||||
while (std::getline(is, point_str, ',')) {
|
||||
Pointf point;
|
||||
std::istringstream iss(point_str);
|
||||
std::string coord_str;
|
||||
if (std::getline(iss, coord_str, 'x')) {
|
||||
std::istringstream(coord_str) >> point.x;
|
||||
if (std::getline(iss, coord_str, 'x')) {
|
||||
std::istringstream(coord_str) >> point.y;
|
||||
}
|
||||
}
|
||||
this->values.push_back(point);
|
||||
}
|
||||
return true;
|
||||
};
|
||||
bool deserialize(std::string str, bool append = false);
|
||||
};
|
||||
|
||||
class ConfigOptionBool : public ConfigOptionSingle<bool>
|
||||
@ -642,6 +626,7 @@ class ConfigDef
|
||||
t_optiondef_map options;
|
||||
ConfigOptionDef* add(const t_config_option_key &opt_key, ConfigOptionType type);
|
||||
ConfigOptionDef* add(const t_config_option_key &opt_key, const ConfigOptionDef &def);
|
||||
bool has(const t_config_option_key &opt_key) const;
|
||||
const ConfigOptionDef* get(const t_config_option_key &opt_key) const;
|
||||
void merge(const ConfigDef &other);
|
||||
};
|
||||
@ -669,7 +654,7 @@ class ConfigBase
|
||||
bool equals(ConfigBase &other);
|
||||
t_config_option_keys diff(ConfigBase &other);
|
||||
std::string serialize(const t_config_option_key &opt_key) const;
|
||||
bool set_deserialize(const t_config_option_key &opt_key, std::string str, bool append = false);
|
||||
virtual bool set_deserialize(t_config_option_key opt_key, std::string str, bool append = false);
|
||||
double get_abs_value(const t_config_option_key &opt_key) const;
|
||||
double get_abs_value(const t_config_option_key &opt_key, double ratio_over) const;
|
||||
void setenv_();
|
||||
@ -693,6 +678,7 @@ class DynamicConfig : public virtual ConfigBase
|
||||
t_config_option_keys keys() const;
|
||||
void erase(const t_config_option_key &opt_key);
|
||||
void clear();
|
||||
void read_cli(const std::vector<std::string> &tokens, t_config_option_keys* extra);
|
||||
void read_cli(const int argc, const char **argv, t_config_option_keys* extra);
|
||||
|
||||
private:
|
||||
|
@ -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
|
||||
{
|
||||
|
@ -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;
|
||||
|
@ -1,3 +1,9 @@
|
||||
//#define DEBUG_RECTILINEAR
|
||||
#ifdef DEBUG_RECTILINEAR
|
||||
#undef NDEBUG
|
||||
#include "../SVG.hpp"
|
||||
#endif
|
||||
|
||||
#include "../ClipperUtils.hpp"
|
||||
#include "../ExPolygon.hpp"
|
||||
#include "../PolylineCollection.hpp"
|
||||
@ -7,17 +13,16 @@
|
||||
|
||||
#include "FillRectilinear.hpp"
|
||||
|
||||
//#define DEBUG_RECTILINEAR
|
||||
#ifdef DEBUG_RECTILINEAR
|
||||
#include "../SVG.hpp"
|
||||
#endif
|
||||
|
||||
namespace Slic3r {
|
||||
|
||||
void
|
||||
FillRectilinear::_fill_single_direction(ExPolygon expolygon,
|
||||
const direction_t &direction, coord_t x_shift, Polylines* out)
|
||||
{
|
||||
// Remove almost collinear points (vertical ones might break this algorithm
|
||||
// because of rounding).
|
||||
expolygon.remove_vertical_collinear_points(1);
|
||||
|
||||
// rotate polygons so that we can work with vertical lines here
|
||||
expolygon.rotate(-direction.first);
|
||||
|
||||
@ -58,6 +63,27 @@ FillRectilinear::_fill_single_direction(ExPolygon expolygon,
|
||||
// Whenever between two intersection points we find vertices of the original polygon,
|
||||
// store them in the 'skipped' member of the latter point.
|
||||
|
||||
struct IntersectionPoint : Point {
|
||||
enum ipType { ipTypeLower, ipTypeUpper, ipTypeMiddle };
|
||||
ipType type;
|
||||
|
||||
// skipped contains the polygon points accumulated between the previous intersection
|
||||
// point and the current one, in the original polygon winding order (does not contain
|
||||
// either points)
|
||||
Points skipped;
|
||||
|
||||
// next contains a polygon portion connecting this point to the first intersection
|
||||
// point found following the polygon in any direction but having:
|
||||
// x > this->x || (x == this->x && y > this->y)
|
||||
// (it doesn't contain *this but it contains the target intersection point)
|
||||
Points next;
|
||||
|
||||
IntersectionPoint() : Point() {};
|
||||
IntersectionPoint(coord_t x, coord_t y, ipType _type) : Point(x,y), type(_type) {};
|
||||
};
|
||||
typedef std::map<coord_t,IntersectionPoint> vertical_t; // <y,point>
|
||||
typedef std::map<coord_t,vertical_t> grid_t; // <x,<y,point>>
|
||||
|
||||
grid_t grid;
|
||||
{
|
||||
const Polygons polygons = expolygon;
|
||||
|
@ -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<coord_t,IntersectionPoint> vertical_t; // <y,point>
|
||||
typedef std::map<coord_t,vertical_t> grid_t; // <x,<y,point>>
|
||||
};
|
||||
|
||||
class FillAlignedRectilinear : public FillRectilinear
|
||||
|
95
xs/src/libslic3r/GCode/SpiralVase.cpp
Normal file
95
xs/src/libslic3r/GCode/SpiralVase.cpp
Normal file
@ -0,0 +1,95 @@
|
||||
#include "SpiralVase.hpp"
|
||||
#include <sstream>
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
29
xs/src/libslic3r/GCode/SpiralVase.hpp
Normal file
29
xs/src/libslic3r/GCode/SpiralVase.hpp
Normal file
@ -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
|
91
xs/src/libslic3r/GCodeReader.cpp
Normal file
91
xs/src/libslic3r/GCodeReader.cpp
Normal file
@ -0,0 +1,91 @@
|
||||
#include "GCodeReader.hpp"
|
||||
#include <boost/algorithm/string/classification.hpp>
|
||||
#include <boost/algorithm/string/split.hpp>
|
||||
#include <iostream>
|
||||
|
||||
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<std::string> 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;
|
||||
}
|
||||
|
||||
}
|
64
xs/src/libslic3r/GCodeReader.hpp
Normal file
64
xs/src/libslic3r/GCodeReader.hpp
Normal file
@ -0,0 +1,64 @@
|
||||
#ifndef slic3r_GCodeReader_hpp_
|
||||
#define slic3r_GCodeReader_hpp_
|
||||
|
||||
#include "libslic3r.h"
|
||||
#include <cmath>
|
||||
#include <cstdlib>
|
||||
#include <functional>
|
||||
#include <string>
|
||||
#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<char,std::string> 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<void(GCodeReader&, GCodeLine&)> 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_ */
|
@ -1,4 +1,6 @@
|
||||
#include "../IO.hpp"
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
#include <string.h>
|
||||
#include <map>
|
||||
#include <string>
|
||||
@ -495,107 +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, "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n");
|
||||
fprintf(file, "<amf unit=\"millimeter\">\n");
|
||||
fprintf(file, "<metadata type=\"cad\">Slic3r %s</metadata>\n", SLIC3R_VERSION);
|
||||
using namespace std;
|
||||
|
||||
ofstream file;
|
||||
file.open(output_file, ios::out | ios::trunc);
|
||||
|
||||
file << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl
|
||||
<< "<amf unit=\"millimeter\">" << endl
|
||||
<< "<metadata type=\"cad\">Slic3r " << SLIC3R_VERSION << "</metadata>" << 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, " <material id=\"%s\">\n", material.first.c_str());
|
||||
file << " <material id=\"" << material.first << "\">" << endl;
|
||||
for (const auto &attr : material.second->attributes)
|
||||
fprintf(file, " <metadata type=\"%s\">%s</metadata>\n", attr.first.c_str(), attr.second.c_str());
|
||||
file << " <metadata type=\"" << attr.first << "\">" << attr.second << "</metadata>" << endl;
|
||||
for (const std::string &key : material.second->config.keys())
|
||||
fprintf(file, " <metadata type=\"slic3r.%s\">%s</metadata>\n", key.c_str(), material.second->config.serialize(key).c_str());
|
||||
fprintf(file, " </material>\n");
|
||||
file << " <metadata type=\"slic3r." << key << "\">"
|
||||
<< material.second->config.serialize(key) << "</metadata>" << endl;
|
||||
file << " </material>" << 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, " <object id=\"%zu\">\n", object_id);
|
||||
file << " <object id=\"" << object_id << "\">" << endl;
|
||||
|
||||
for (const std::string &key : object->config.keys())
|
||||
fprintf(file, " <metadata type=\"slic3r.%s\">%s</metadata>\n", key.c_str(), object->config.serialize(key).c_str());
|
||||
if (! object->name.empty())
|
||||
fprintf(file, " <metadata type=\"name\">%s</metadata>\n", object->name.c_str());
|
||||
file << " <metadata type=\"slic3r." << key << "\">"
|
||||
<< object->config.serialize(key) << "</metadata>" << endl;
|
||||
|
||||
if (!object->name.empty())
|
||||
file << " <metadata type=\"name\">" << object->name << "</metadata>" << endl;
|
||||
|
||||
//FIXME Store the layer height ranges (ModelObject::layer_height_ranges)
|
||||
fprintf(file, " <mesh>\n");
|
||||
fprintf(file, " <vertices>\n");
|
||||
std::vector<int> vertices_offsets;
|
||||
int num_vertices = 0;
|
||||
//FIXME: Store the layer height ranges (ModelObject::layer_height_ranges)
|
||||
file << " <mesh>" << endl;
|
||||
file << " <vertices>" << endl;
|
||||
|
||||
std::vector<size_t> vertices_offsets;
|
||||
size_t num_vertices = 0;
|
||||
|
||||
for (ModelVolume *volume : object->volumes) {
|
||||
volume->mesh.require_shared_vertices();
|
||||
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) {
|
||||
fprintf(file, " <vertex>\n");
|
||||
fprintf(file, " <coordinates>\n");
|
||||
fprintf(file, " <x>%f</x>\n", stl.v_shared[i].x);
|
||||
fprintf(file, " <y>%f</y>\n", stl.v_shared[i].y);
|
||||
fprintf(file, " <z>%f</z>\n", stl.v_shared[i].z);
|
||||
fprintf(file, " </coordinates>\n");
|
||||
fprintf(file, " </vertex>\n");
|
||||
}
|
||||
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.
|
||||
file << " <vertex>" << endl
|
||||
<< " <coordinates>" << endl
|
||||
<< " <x>" << (stl.v_shared[i].x - object->origin_translation.x) << "</x>" << endl
|
||||
<< " <y>" << (stl.v_shared[i].y - object->origin_translation.y) << "</y>" << endl
|
||||
<< " <z>" << (stl.v_shared[i].z - object->origin_translation.z) << "</z>" << endl
|
||||
<< " </coordinates>" << endl
|
||||
<< " </vertex>" << endl;
|
||||
|
||||
num_vertices += stl.stats.shared_vertices;
|
||||
}
|
||||
fprintf(file, " </vertices>\n");
|
||||
for (size_t i_volume = 0; i_volume < object->volumes.size(); ++ i_volume) {
|
||||
file << " </vertices>" << 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, " <volume>\n");
|
||||
file << " <volume>" << endl;
|
||||
else
|
||||
fprintf(file, " <volume materialid=\"%s\">\n", volume->material_id().c_str());
|
||||
file << " <volume materialid=\"" << volume->material_id() << "\">" << endl;
|
||||
|
||||
for (const std::string &key : volume->config.keys())
|
||||
fprintf(file, " <metadata type=\"slic3r.%s\">%s</metadata>\n", key.c_str(), volume->config.serialize(key).c_str());
|
||||
if (! volume->name.empty())
|
||||
fprintf(file, " <metadata type=\"name\">%s</metadata>\n", volume->name.c_str());
|
||||
file << " <metadata type=\"slic3r." << key << "\">"
|
||||
<< volume->config.serialize(key) << "</metadata>" << endl;
|
||||
|
||||
if (!volume->name.empty())
|
||||
file << " <metadata type=\"name\">" << volume->name << "</metadata>" << endl;
|
||||
|
||||
if (volume->modifier)
|
||||
fprintf(file, " <metadata type=\"slic3r.modifier\">1</metadata>\n");
|
||||
for (int i = 0; i < volume->mesh.stl.stats.number_of_facets; ++ i) {
|
||||
fprintf(file, " <triangle>\n");
|
||||
file << " <metadata type=\"slic3r.modifier\">1</metadata>" << endl;
|
||||
|
||||
for (int i = 0; i < volume->mesh.stl.stats.number_of_facets; ++i) {
|
||||
file << " <triangle>" << endl;
|
||||
for (int j = 0; j < 3; ++ j)
|
||||
fprintf(file, " <v%d>%d</v%d>\n", j+1, volume->mesh.stl.v_indices[i].vertex[j] + vertices_offset, j+1);
|
||||
fprintf(file, " </triangle>\n");
|
||||
}
|
||||
fprintf(file, " </volume>\n");
|
||||
}
|
||||
fprintf(file, " </mesh>\n");
|
||||
fprintf(file, " </object>\n");
|
||||
if (! object->instances.empty()) {
|
||||
for (ModelInstance *instance : object->instances) {
|
||||
char buf[512];
|
||||
sprintf(buf,
|
||||
" <instance objectid=\"%zu\">\n"
|
||||
" <deltax>%lf</deltax>\n"
|
||||
" <deltay>%lf</deltay>\n"
|
||||
" <rz>%lf</rz>\n"
|
||||
" <scale>%lf</scale>\n"
|
||||
" </instance>\n",
|
||||
object_id,
|
||||
instance->offset.x,
|
||||
instance->offset.y,
|
||||
instance->rotation,
|
||||
instance->scaling_factor);
|
||||
//FIXME missing instance->scaling_factor
|
||||
instances.append(buf);
|
||||
file << " <v" << (j+1) << ">"
|
||||
<< (volume->mesh.stl.v_indices[i].vertex[j] + vertices_offset)
|
||||
<< "</v" << (j+1) << ">" << endl;
|
||||
file << " </triangle>" << endl;
|
||||
}
|
||||
file << " </volume>" << endl;
|
||||
}
|
||||
file << " </mesh>" << endl;
|
||||
file << " </object>" << endl;
|
||||
|
||||
for (const ModelInstance* instance : object->instances)
|
||||
instances
|
||||
<< " <instance objectid=\"" << object_id << "\">" << endl
|
||||
<< " <deltax>" << instance->offset.x + object->origin_translation.x << "</deltax>" << endl
|
||||
<< " <deltay>" << instance->offset.y + object->origin_translation.y << "</deltay>" << endl
|
||||
<< " <rz>%" << instance->rotation << "</rz>" << endl
|
||||
<< " <scale>" << instance->scaling_factor << "</scale>" << endl
|
||||
<< " </instance>" << endl;
|
||||
}
|
||||
if (! instances.empty()) {
|
||||
fprintf(file, " <constellation id=\"1\">\n");
|
||||
fwrite(instances.data(), instances.size(), 1, file);
|
||||
fprintf(file, " </constellation>\n");
|
||||
}
|
||||
fprintf(file, "</amf>\n");
|
||||
fclose(file);
|
||||
|
||||
std::string instances_str = instances.str();
|
||||
if (!instances_str.empty())
|
||||
file << " <constellation id=\"1\">" << endl
|
||||
<< instances_str
|
||||
<< " </constellation>" << endl;
|
||||
|
||||
file << "</amf>" << endl;
|
||||
|
||||
file.close();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -148,6 +148,33 @@ 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) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
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
|
||||
|
@ -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;
|
||||
|
@ -187,6 +187,7 @@ Print::invalidate_state_by_config_options(const std::vector<t_config_option_key>
|
||||
|| *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)
|
||||
{
|
||||
@ -660,7 +672,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.";
|
||||
@ -882,7 +894,7 @@ Print::_make_brim()
|
||||
}
|
||||
}
|
||||
|
||||
std::auto_ptr<Fill> filler(Fill::new_from_type(ipRectilinear));
|
||||
std::unique_ptr<Fill> filler(Fill::new_from_type(ipRectilinear));
|
||||
filler->min_spacing = flow.spacing();
|
||||
filler->dont_adjust = true;
|
||||
filler->density = 1;
|
||||
|
@ -214,6 +214,7 @@ class Print
|
||||
std::set<size_t> object_extruders() const;
|
||||
std::set<size_t> support_material_extruders() const;
|
||||
std::set<size_t> extruders() const;
|
||||
size_t brim_extruder() const;
|
||||
void _simplify_slices(double distance);
|
||||
double max_allowed_layer_height() const;
|
||||
bool has_support_material() const;
|
||||
|
@ -1,4 +1,6 @@
|
||||
#include "PrintConfig.hpp"
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
namespace Slic3r {
|
||||
@ -214,6 +216,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.";
|
||||
@ -226,6 +229,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.";
|
||||
@ -386,7 +390,7 @@ PrintConfigDef::PrintConfigDef()
|
||||
def = this->add("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;
|
||||
{
|
||||
@ -462,6 +466,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);
|
||||
@ -558,6 +563,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.";
|
||||
@ -818,7 +824,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("overridable", coStrings);
|
||||
@ -923,7 +929,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";
|
||||
@ -1123,6 +1129,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.";
|
||||
@ -1162,6 +1169,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.";
|
||||
@ -1174,6 +1182,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.";
|
||||
@ -1320,6 +1329,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.";
|
||||
@ -1404,7 +1414,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;
|
||||
{
|
||||
@ -1423,6 +1432,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.";
|
||||
@ -1443,6 +1453,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.";
|
||||
@ -1590,6 +1601,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<float>(value);
|
||||
if (v != 0)
|
||||
value = boost::lexical_cast<std::string>(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<float>(value);
|
||||
value = boost::lexical_cast<std::string>(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;
|
||||
|
@ -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
|
||||
@ -624,6 +627,7 @@ class CLIConfig
|
||||
ConfigOptionString save;
|
||||
ConfigOptionFloat scale;
|
||||
ConfigOptionPoint3 scale_to_fit;
|
||||
ConfigOptionBool threads;
|
||||
|
||||
CLIConfig() : ConfigBase(), StaticConfig() {
|
||||
this->def = &cli_config_def;
|
||||
@ -647,6 +651,7 @@ class CLIConfig
|
||||
OPT_PTR(save);
|
||||
OPT_PTR(scale);
|
||||
OPT_PTR(scale_to_fit);
|
||||
OPT_PTR(threads);
|
||||
|
||||
return NULL;
|
||||
};
|
||||
|
@ -57,7 +57,7 @@ SLAPrint::slice()
|
||||
|
||||
// generate infill
|
||||
if (this->config.fill_density < 100) {
|
||||
std::auto_ptr<Fill> fill(Fill::new_from_type(this->config.fill_pattern.value));
|
||||
std::unique_ptr<Fill> 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(_fill->clone());
|
||||
std::unique_ptr<Fill> fill(_fill->clone());
|
||||
fill->layer_id = i;
|
||||
fill->z = layer.print_z;
|
||||
|
||||
|
@ -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<X>;
|
||||
friend class TriangleMeshSlicer<Y>;
|
||||
friend class TriangleMeshSlicer<Z>;
|
||||
|
@ -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");
|
||||
|
@ -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__
|
||||
|
@ -45,6 +45,8 @@
|
||||
double min_object_distance();
|
||||
%name{_load} void load(std::string file);
|
||||
%name{_save} void save(std::string file);
|
||||
std::vector<std::string> read_cli(std::vector<std::string> _argv)
|
||||
%code{% THIS->read_cli(_argv, &RETVAL); %};
|
||||
};
|
||||
|
||||
%name{Slic3r::Config::Static} class StaticPrintConfig {
|
||||
|
@ -4,6 +4,7 @@
|
||||
#include <xsinit.h>
|
||||
#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<PrintConfig*>(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();
|
||||
|
@ -224,6 +224,7 @@ _constant()
|
||||
RETVAL.push_back(*e);
|
||||
}
|
||||
%};
|
||||
int brim_extruder();
|
||||
void clear_filament_stats()
|
||||
%code%{
|
||||
THIS->filament_stats.clear();
|
||||
|
@ -198,6 +198,10 @@ CoolingBuffer* O_OBJECT_SLIC3R
|
||||
Ref<CoolingBuffer> O_OBJECT_SLIC3R_T
|
||||
Clone<CoolingBuffer> O_OBJECT_SLIC3R_T
|
||||
|
||||
SpiralVase* O_OBJECT_SLIC3R
|
||||
Ref<SpiralVase> O_OBJECT_SLIC3R_T
|
||||
Clone<SpiralVase> O_OBJECT_SLIC3R_T
|
||||
|
||||
GCode* O_OBJECT_SLIC3R
|
||||
Ref<GCode> O_OBJECT_SLIC3R_T
|
||||
Clone<GCode> O_OBJECT_SLIC3R_T
|
||||
|
Loading…
x
Reference in New Issue
Block a user