基础的切片和质量控制
This commit is contained in:
2
.gitignore
vendored
Normal file
2
.gitignore
vendored
Normal file
@@ -0,0 +1,2 @@
|
||||
__pycache__
|
||||
uploads
|
||||
674
LICENSE
Normal file
674
LICENSE
Normal file
@@ -0,0 +1,674 @@
|
||||
GNU GENERAL PUBLIC LICENSE
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
Preamble
|
||||
|
||||
The GNU General Public License is a free, copyleft license for
|
||||
software and other kinds of works.
|
||||
|
||||
The licenses for most software and other practical works are designed
|
||||
to take away your freedom to share and change the works. By contrast,
|
||||
the GNU General Public License is intended to guarantee your freedom to
|
||||
share and change all versions of a program--to make sure it remains free
|
||||
software for all its users. We, the Free Software Foundation, use the
|
||||
GNU General Public License for most of our software; it applies also to
|
||||
any other work released this way by its authors. You can apply it to
|
||||
your programs, too.
|
||||
|
||||
When we speak of free software, we are referring to freedom, not
|
||||
price. Our General Public Licenses are designed to make sure that you
|
||||
have the freedom to distribute copies of free software (and charge for
|
||||
them if you wish), that you receive source code or can get it if you
|
||||
want it, that you can change the software or use pieces of it in new
|
||||
free programs, and that you know you can do these things.
|
||||
|
||||
To protect your rights, we need to prevent others from denying you
|
||||
these rights or asking you to surrender the rights. Therefore, you have
|
||||
certain responsibilities if you distribute copies of the software, or if
|
||||
you modify it: responsibilities to respect the freedom of others.
|
||||
|
||||
For example, if you distribute copies of such a program, whether
|
||||
gratis or for a fee, you must pass on to the recipients the same
|
||||
freedoms that you received. You must make sure that they, too, receive
|
||||
or can get the source code. And you must show them these terms so they
|
||||
know their rights.
|
||||
|
||||
Developers that use the GNU GPL protect your rights with two steps:
|
||||
(1) assert copyright on the software, and (2) offer you this License
|
||||
giving you legal permission to copy, distribute and/or modify it.
|
||||
|
||||
For the developers' and authors' protection, the GPL clearly explains
|
||||
that there is no warranty for this free software. For both users' and
|
||||
authors' sake, the GPL requires that modified versions be marked as
|
||||
changed, so that their problems will not be attributed erroneously to
|
||||
authors of previous versions.
|
||||
|
||||
Some devices are designed to deny users access to install or run
|
||||
modified versions of the software inside them, although the manufacturer
|
||||
can do so. This is fundamentally incompatible with the aim of
|
||||
protecting users' freedom to change the software. The systematic
|
||||
pattern of such abuse occurs in the area of products for individuals to
|
||||
use, which is precisely where it is most unacceptable. Therefore, we
|
||||
have designed this version of the GPL to prohibit the practice for those
|
||||
products. If such problems arise substantially in other domains, we
|
||||
stand ready to extend this provision to those domains in future versions
|
||||
of the GPL, as needed to protect the freedom of users.
|
||||
|
||||
Finally, every program is threatened constantly by software patents.
|
||||
States should not allow patents to restrict development and use of
|
||||
software on general-purpose computers, but in those that do, we wish to
|
||||
avoid the special danger that patents applied to a free program could
|
||||
make it effectively proprietary. To prevent this, the GPL assures that
|
||||
patents cannot be used to render the program non-free.
|
||||
|
||||
The precise terms and conditions for copying, distribution and
|
||||
modification follow.
|
||||
|
||||
TERMS AND CONDITIONS
|
||||
|
||||
0. Definitions.
|
||||
|
||||
"This License" refers to version 3 of the GNU General Public License.
|
||||
|
||||
"Copyright" also means copyright-like laws that apply to other kinds of
|
||||
works, such as semiconductor masks.
|
||||
|
||||
"The Program" refers to any copyrightable work licensed under this
|
||||
License. Each licensee is addressed as "you". "Licensees" and
|
||||
"recipients" may be individuals or organizations.
|
||||
|
||||
To "modify" a work means to copy from or adapt all or part of the work
|
||||
in a fashion requiring copyright permission, other than the making of an
|
||||
exact copy. The resulting work is called a "modified version" of the
|
||||
earlier work or a work "based on" the earlier work.
|
||||
|
||||
A "covered work" means either the unmodified Program or a work based
|
||||
on the Program.
|
||||
|
||||
To "propagate" a work means to do anything with it that, without
|
||||
permission, would make you directly or secondarily liable for
|
||||
infringement under applicable copyright law, except executing it on a
|
||||
computer or modifying a private copy. Propagation includes copying,
|
||||
distribution (with or without modification), making available to the
|
||||
public, and in some countries other activities as well.
|
||||
|
||||
To "convey" a work means any kind of propagation that enables other
|
||||
parties to make or receive copies. Mere interaction with a user through
|
||||
a computer network, with no transfer of a copy, is not conveying.
|
||||
|
||||
An interactive user interface displays "Appropriate Legal Notices"
|
||||
to the extent that it includes a convenient and prominently visible
|
||||
feature that (1) displays an appropriate copyright notice, and (2)
|
||||
tells the user that there is no warranty for the work (except to the
|
||||
extent that warranties are provided), that licensees may convey the
|
||||
work under this License, and how to view a copy of this License. If
|
||||
the interface presents a list of user commands or options, such as a
|
||||
menu, a prominent item in the list meets this criterion.
|
||||
|
||||
1. Source Code.
|
||||
|
||||
The "source code" for a work means the preferred form of the work
|
||||
for making modifications to it. "Object code" means any non-source
|
||||
form of a work.
|
||||
|
||||
A "Standard Interface" means an interface that either is an official
|
||||
standard defined by a recognized standards body, or, in the case of
|
||||
interfaces specified for a particular programming language, one that
|
||||
is widely used among developers working in that language.
|
||||
|
||||
The "System Libraries" of an executable work include anything, other
|
||||
than the work as a whole, that (a) is included in the normal form of
|
||||
packaging a Major Component, but which is not part of that Major
|
||||
Component, and (b) serves only to enable use of the work with that
|
||||
Major Component, or to implement a Standard Interface for which an
|
||||
implementation is available to the public in source code form. A
|
||||
"Major Component", in this context, means a major essential component
|
||||
(kernel, window system, and so on) of the specific operating system
|
||||
(if any) on which the executable work runs, or a compiler used to
|
||||
produce the work, or an object code interpreter used to run it.
|
||||
|
||||
The "Corresponding Source" for a work in object code form means all
|
||||
the source code needed to generate, install, and (for an executable
|
||||
work) run the object code and to modify the work, including scripts to
|
||||
control those activities. However, it does not include the work's
|
||||
System Libraries, or general-purpose tools or generally available free
|
||||
programs which are used unmodified in performing those activities but
|
||||
which are not part of the work. For example, Corresponding Source
|
||||
includes interface definition files associated with source files for
|
||||
the work, and the source code for shared libraries and dynamically
|
||||
linked subprograms that the work is specifically designed to require,
|
||||
such as by intimate data communication or control flow between those
|
||||
subprograms and other parts of the work.
|
||||
|
||||
The Corresponding Source need not include anything that users
|
||||
can regenerate automatically from other parts of the Corresponding
|
||||
Source.
|
||||
|
||||
The Corresponding Source for a work in source code form is that
|
||||
same work.
|
||||
|
||||
2. Basic Permissions.
|
||||
|
||||
All rights granted under this License are granted for the term of
|
||||
copyright on the Program, and are irrevocable provided the stated
|
||||
conditions are met. This License explicitly affirms your unlimited
|
||||
permission to run the unmodified Program. The output from running a
|
||||
covered work is covered by this License only if the output, given its
|
||||
content, constitutes a covered work. This License acknowledges your
|
||||
rights of fair use or other equivalent, as provided by copyright law.
|
||||
|
||||
You may make, run and propagate covered works that you do not
|
||||
convey, without conditions so long as your license otherwise remains
|
||||
in force. You may convey covered works to others for the sole purpose
|
||||
of having them make modifications exclusively for you, or provide you
|
||||
with facilities for running those works, provided that you comply with
|
||||
the terms of this License in conveying all material for which you do
|
||||
not control copyright. Those thus making or running the covered works
|
||||
for you must do so exclusively on your behalf, under your direction
|
||||
and control, on terms that prohibit them from making any copies of
|
||||
your copyrighted material outside their relationship with you.
|
||||
|
||||
Conveying under any other circumstances is permitted solely under
|
||||
the conditions stated below. Sublicensing is not allowed; section 10
|
||||
makes it unnecessary.
|
||||
|
||||
3. Protecting Users' Legal Rights From Anti-Circumvention Law.
|
||||
|
||||
No covered work shall be deemed part of an effective technological
|
||||
measure under any applicable law fulfilling obligations under article
|
||||
11 of the WIPO copyright treaty adopted on 20 December 1996, or
|
||||
similar laws prohibiting or restricting circumvention of such
|
||||
measures.
|
||||
|
||||
When you convey a covered work, you waive any legal power to forbid
|
||||
circumvention of technological measures to the extent such circumvention
|
||||
is effected by exercising rights under this License with respect to
|
||||
the covered work, and you disclaim any intention to limit operation or
|
||||
modification of the work as a means of enforcing, against the work's
|
||||
users, your or third parties' legal rights to forbid circumvention of
|
||||
technological measures.
|
||||
|
||||
4. Conveying Verbatim Copies.
|
||||
|
||||
You may convey verbatim copies of the Program's source code as you
|
||||
receive it, in any medium, provided that you conspicuously and
|
||||
appropriately publish on each copy an appropriate copyright notice;
|
||||
keep intact all notices stating that this License and any
|
||||
non-permissive terms added in accord with section 7 apply to the code;
|
||||
keep intact all notices of the absence of any warranty; and give all
|
||||
recipients a copy of this License along with the Program.
|
||||
|
||||
You may charge any price or no price for each copy that you convey,
|
||||
and you may offer support or warranty protection for a fee.
|
||||
|
||||
5. Conveying Modified Source Versions.
|
||||
|
||||
You may convey a work based on the Program, or the modifications to
|
||||
produce it from the Program, in the form of source code under the
|
||||
terms of section 4, provided that you also meet all of these conditions:
|
||||
|
||||
a) The work must carry prominent notices stating that you modified
|
||||
it, and giving a relevant date.
|
||||
|
||||
b) The work must carry prominent notices stating that it is
|
||||
released under this License and any conditions added under section
|
||||
7. This requirement modifies the requirement in section 4 to
|
||||
"keep intact all notices".
|
||||
|
||||
c) You must license the entire work, as a whole, under this
|
||||
License to anyone who comes into possession of a copy. This
|
||||
License will therefore apply, along with any applicable section 7
|
||||
additional terms, to the whole of the work, and all its parts,
|
||||
regardless of how they are packaged. This License gives no
|
||||
permission to license the work in any other way, but it does not
|
||||
invalidate such permission if you have separately received it.
|
||||
|
||||
d) If the work has interactive user interfaces, each must display
|
||||
Appropriate Legal Notices; however, if the Program has interactive
|
||||
interfaces that do not display Appropriate Legal Notices, your
|
||||
work need not make them do so.
|
||||
|
||||
A compilation of a covered work with other separate and independent
|
||||
works, which are not by their nature extensions of the covered work,
|
||||
and which are not combined with it such as to form a larger program,
|
||||
in or on a volume of a storage or distribution medium, is called an
|
||||
"aggregate" if the compilation and its resulting copyright are not
|
||||
used to limit the access or legal rights of the compilation's users
|
||||
beyond what the individual works permit. Inclusion of a covered work
|
||||
in an aggregate does not cause this License to apply to the other
|
||||
parts of the aggregate.
|
||||
|
||||
6. Conveying Non-Source Forms.
|
||||
|
||||
You may convey a covered work in object code form under the terms
|
||||
of sections 4 and 5, provided that you also convey the
|
||||
machine-readable Corresponding Source under the terms of this License,
|
||||
in one of these ways:
|
||||
|
||||
a) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by the
|
||||
Corresponding Source fixed on a durable physical medium
|
||||
customarily used for software interchange.
|
||||
|
||||
b) Convey the object code in, or embodied in, a physical product
|
||||
(including a physical distribution medium), accompanied by a
|
||||
written offer, valid for at least three years and valid for as
|
||||
long as you offer spare parts or customer support for that product
|
||||
model, to give anyone who possesses the object code either (1) a
|
||||
copy of the Corresponding Source for all the software in the
|
||||
product that is covered by this License, on a durable physical
|
||||
medium customarily used for software interchange, for a price no
|
||||
more than your reasonable cost of physically performing this
|
||||
conveying of source, or (2) access to copy the
|
||||
Corresponding Source from a network server at no charge.
|
||||
|
||||
c) Convey individual copies of the object code with a copy of the
|
||||
written offer to provide the Corresponding Source. This
|
||||
alternative is allowed only occasionally and noncommercially, and
|
||||
only if you received the object code with such an offer, in accord
|
||||
with subsection 6b.
|
||||
|
||||
d) Convey the object code by offering access from a designated
|
||||
place (gratis or for a charge), and offer equivalent access to the
|
||||
Corresponding Source in the same way through the same place at no
|
||||
further charge. You need not require recipients to copy the
|
||||
Corresponding Source along with the object code. If the place to
|
||||
copy the object code is a network server, the Corresponding Source
|
||||
may be on a different server (operated by you or a third party)
|
||||
that supports equivalent copying facilities, provided you maintain
|
||||
clear directions next to the object code saying where to find the
|
||||
Corresponding Source. Regardless of what server hosts the
|
||||
Corresponding Source, you remain obligated to ensure that it is
|
||||
available for as long as needed to satisfy these requirements.
|
||||
|
||||
e) Convey the object code using peer-to-peer transmission, provided
|
||||
you inform other peers where the object code and Corresponding
|
||||
Source of the work are being offered to the general public at no
|
||||
charge under subsection 6d.
|
||||
|
||||
A separable portion of the object code, whose source code is excluded
|
||||
from the Corresponding Source as a System Library, need not be
|
||||
included in conveying the object code work.
|
||||
|
||||
A "User Product" is either (1) a "consumer product", which means any
|
||||
tangible personal property which is normally used for personal, family,
|
||||
or household purposes, or (2) anything designed or sold for incorporation
|
||||
into a dwelling. In determining whether a product is a consumer product,
|
||||
doubtful cases shall be resolved in favor of coverage. For a particular
|
||||
product received by a particular user, "normally used" refers to a
|
||||
typical or common use of that class of product, regardless of the status
|
||||
of the particular user or of the way in which the particular user
|
||||
actually uses, or expects or is expected to use, the product. A product
|
||||
is a consumer product regardless of whether the product has substantial
|
||||
commercial, industrial or non-consumer uses, unless such uses represent
|
||||
the only significant mode of use of the product.
|
||||
|
||||
"Installation Information" for a User Product means any methods,
|
||||
procedures, authorization keys, or other information required to install
|
||||
and execute modified versions of a covered work in that User Product from
|
||||
a modified version of its Corresponding Source. The information must
|
||||
suffice to ensure that the continued functioning of the modified object
|
||||
code is in no case prevented or interfered with solely because
|
||||
modification has been made.
|
||||
|
||||
If you convey an object code work under this section in, or with, or
|
||||
specifically for use in, a User Product, and the conveying occurs as
|
||||
part of a transaction in which the right of possession and use of the
|
||||
User Product is transferred to the recipient in perpetuity or for a
|
||||
fixed term (regardless of how the transaction is characterized), the
|
||||
Corresponding Source conveyed under this section must be accompanied
|
||||
by the Installation Information. But this requirement does not apply
|
||||
if neither you nor any third party retains the ability to install
|
||||
modified object code on the User Product (for example, the work has
|
||||
been installed in ROM).
|
||||
|
||||
The requirement to provide Installation Information does not include a
|
||||
requirement to continue to provide support service, warranty, or updates
|
||||
for a work that has been modified or installed by the recipient, or for
|
||||
the User Product in which it has been modified or installed. Access to a
|
||||
network may be denied when the modification itself materially and
|
||||
adversely affects the operation of the network or violates the rules and
|
||||
protocols for communication across the network.
|
||||
|
||||
Corresponding Source conveyed, and Installation Information provided,
|
||||
in accord with this section must be in a format that is publicly
|
||||
documented (and with an implementation available to the public in
|
||||
source code form), and must require no special password or key for
|
||||
unpacking, reading or copying.
|
||||
|
||||
7. Additional Terms.
|
||||
|
||||
"Additional permissions" are terms that supplement the terms of this
|
||||
License by making exceptions from one or more of its conditions.
|
||||
Additional permissions that are applicable to the entire Program shall
|
||||
be treated as though they were included in this License, to the extent
|
||||
that they are valid under applicable law. If additional permissions
|
||||
apply only to part of the Program, that part may be used separately
|
||||
under those permissions, but the entire Program remains governed by
|
||||
this License without regard to the additional permissions.
|
||||
|
||||
When you convey a copy of a covered work, you may at your option
|
||||
remove any additional permissions from that copy, or from any part of
|
||||
it. (Additional permissions may be written to require their own
|
||||
removal in certain cases when you modify the work.) You may place
|
||||
additional permissions on material, added by you to a covered work,
|
||||
for which you have or can give appropriate copyright permission.
|
||||
|
||||
Notwithstanding any other provision of this License, for material you
|
||||
add to a covered work, you may (if authorized by the copyright holders of
|
||||
that material) supplement the terms of this License with terms:
|
||||
|
||||
a) Disclaiming warranty or limiting liability differently from the
|
||||
terms of sections 15 and 16 of this License; or
|
||||
|
||||
b) Requiring preservation of specified reasonable legal notices or
|
||||
author attributions in that material or in the Appropriate Legal
|
||||
Notices displayed by works containing it; or
|
||||
|
||||
c) Prohibiting misrepresentation of the origin of that material, or
|
||||
requiring that modified versions of such material be marked in
|
||||
reasonable ways as different from the original version; or
|
||||
|
||||
d) Limiting the use for publicity purposes of names of licensors or
|
||||
authors of the material; or
|
||||
|
||||
e) Declining to grant rights under trademark law for use of some
|
||||
trade names, trademarks, or service marks; or
|
||||
|
||||
f) Requiring indemnification of licensors and authors of that
|
||||
material by anyone who conveys the material (or modified versions of
|
||||
it) with contractual assumptions of liability to the recipient, for
|
||||
any liability that these contractual assumptions directly impose on
|
||||
those licensors and authors.
|
||||
|
||||
All other non-permissive additional terms are considered "further
|
||||
restrictions" within the meaning of section 10. If the Program as you
|
||||
received it, or any part of it, contains a notice stating that it is
|
||||
governed by this License along with a term that is a further
|
||||
restriction, you may remove that term. If a license document contains
|
||||
a further restriction but permits relicensing or conveying under this
|
||||
License, you may add to a covered work material governed by the terms
|
||||
of that license document, provided that the further restriction does
|
||||
not survive such relicensing or conveying.
|
||||
|
||||
If you add terms to a covered work in accord with this section, you
|
||||
must place, in the relevant source files, a statement of the
|
||||
additional terms that apply to those files, or a notice indicating
|
||||
where to find the applicable terms.
|
||||
|
||||
Additional terms, permissive or non-permissive, may be stated in the
|
||||
form of a separately written license, or stated as exceptions;
|
||||
the above requirements apply either way.
|
||||
|
||||
8. Termination.
|
||||
|
||||
You may not propagate or modify a covered work except as expressly
|
||||
provided under this License. Any attempt otherwise to propagate or
|
||||
modify it is void, and will automatically terminate your rights under
|
||||
this License (including any patent licenses granted under the third
|
||||
paragraph of section 11).
|
||||
|
||||
However, if you cease all violation of this License, then your
|
||||
license from a particular copyright holder is reinstated (a)
|
||||
provisionally, unless and until the copyright holder explicitly and
|
||||
finally terminates your license, and (b) permanently, if the copyright
|
||||
holder fails to notify you of the violation by some reasonable means
|
||||
prior to 60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, you do not qualify to receive new licenses for the same
|
||||
material under section 10.
|
||||
|
||||
9. Acceptance Not Required for Having Copies.
|
||||
|
||||
You are not required to accept this License in order to receive or
|
||||
run a copy of the Program. Ancillary propagation of a covered work
|
||||
occurring solely as a consequence of using peer-to-peer transmission
|
||||
to receive a copy likewise does not require acceptance. However,
|
||||
nothing other than this License grants you permission to propagate or
|
||||
modify any covered work. These actions infringe copyright if you do
|
||||
not accept this License. Therefore, by modifying or propagating a
|
||||
covered work, you indicate your acceptance of this License to do so.
|
||||
|
||||
10. Automatic Licensing of Downstream Recipients.
|
||||
|
||||
Each time you convey a covered work, the recipient automatically
|
||||
receives a license from the original licensors, to run, modify and
|
||||
propagate that work, subject to this License. You are not responsible
|
||||
for enforcing compliance by third parties with this License.
|
||||
|
||||
An "entity transaction" is a transaction transferring control of an
|
||||
organization, or substantially all assets of one, or subdividing an
|
||||
organization, or merging organizations. If propagation of a covered
|
||||
work results from an entity transaction, each party to that
|
||||
transaction who receives a copy of the work also receives whatever
|
||||
licenses to the work the party's predecessor in interest had or could
|
||||
give under the previous paragraph, plus a right to possession of the
|
||||
Corresponding Source of the work from the predecessor in interest, if
|
||||
the predecessor has it or can get it with reasonable efforts.
|
||||
|
||||
You may not impose any further restrictions on the exercise of the
|
||||
rights granted or affirmed under this License. For example, you may
|
||||
not impose a license fee, royalty, or other charge for exercise of
|
||||
rights granted under this License, and you may not initiate litigation
|
||||
(including a cross-claim or counterclaim in a lawsuit) alleging that
|
||||
any patent claim is infringed by making, using, selling, offering for
|
||||
sale, or importing the Program or any portion of it.
|
||||
|
||||
11. Patents.
|
||||
|
||||
A "contributor" is a copyright holder who authorizes use under this
|
||||
License of the Program or a work on which the Program is based. The
|
||||
work thus licensed is called the contributor's "contributor version".
|
||||
|
||||
A contributor's "essential patent claims" are all patent claims
|
||||
owned or controlled by the contributor, whether already acquired or
|
||||
hereafter acquired, that would be infringed by some manner, permitted
|
||||
by this License, of making, using, or selling its contributor version,
|
||||
but do not include claims that would be infringed only as a
|
||||
consequence of further modification of the contributor version. For
|
||||
purposes of this definition, "control" includes the right to grant
|
||||
patent sublicenses in a manner consistent with the requirements of
|
||||
this License.
|
||||
|
||||
Each contributor grants you a non-exclusive, worldwide, royalty-free
|
||||
patent license under the contributor's essential patent claims, to
|
||||
make, use, sell, offer for sale, import and otherwise run, modify and
|
||||
propagate the contents of its contributor version.
|
||||
|
||||
In the following three paragraphs, a "patent license" is any express
|
||||
agreement or commitment, however denominated, not to enforce a patent
|
||||
(such as an express permission to practice a patent or covenant not to
|
||||
sue for patent infringement). To "grant" such a patent license to a
|
||||
party means to make such an agreement or commitment not to enforce a
|
||||
patent against the party.
|
||||
|
||||
If you convey a covered work, knowingly relying on a patent license,
|
||||
and the Corresponding Source of the work is not available for anyone
|
||||
to copy, free of charge and under the terms of this License, through a
|
||||
publicly available network server or other readily accessible means,
|
||||
then you must either (1) cause the Corresponding Source to be so
|
||||
available, or (2) arrange to deprive yourself of the benefit of the
|
||||
patent license for this particular work, or (3) arrange, in a manner
|
||||
consistent with the requirements of this License, to extend the patent
|
||||
license to downstream recipients. "Knowingly relying" means you have
|
||||
actual knowledge that, but for the patent license, your conveying the
|
||||
covered work in a country, or your recipient's use of the covered work
|
||||
in a country, would infringe one or more identifiable patents in that
|
||||
country that you have reason to believe are valid.
|
||||
|
||||
If, pursuant to or in connection with a single transaction or
|
||||
arrangement, you convey, or propagate by procuring conveyance of, a
|
||||
covered work, and grant a patent license to some of the parties
|
||||
receiving the covered work authorizing them to use, propagate, modify
|
||||
or convey a specific copy of the covered work, then the patent license
|
||||
you grant is automatically extended to all recipients of the covered
|
||||
work and works based on it.
|
||||
|
||||
A patent license is "discriminatory" if it does not include within
|
||||
the scope of its coverage, prohibits the exercise of, or is
|
||||
conditioned on the non-exercise of one or more of the rights that are
|
||||
specifically granted under this License. You may not convey a covered
|
||||
work if you are a party to an arrangement with a third party that is
|
||||
in the business of distributing software, under which you make payment
|
||||
to the third party based on the extent of your activity of conveying
|
||||
the work, and under which the third party grants, to any of the
|
||||
parties who would receive the covered work from you, a discriminatory
|
||||
patent license (a) in connection with copies of the covered work
|
||||
conveyed by you (or copies made from those copies), or (b) primarily
|
||||
for and in connection with specific products or compilations that
|
||||
contain the covered work, unless you entered into that arrangement,
|
||||
or that patent license was granted, prior to 28 March 2007.
|
||||
|
||||
Nothing in this License shall be construed as excluding or limiting
|
||||
any implied license or other defenses to infringement that may
|
||||
otherwise be available to you under applicable patent law.
|
||||
|
||||
12. No Surrender of Others' Freedom.
|
||||
|
||||
If conditions are imposed on you (whether by court order, agreement or
|
||||
otherwise) that contradict the conditions of this License, they do not
|
||||
excuse you from the conditions of this License. If you cannot convey a
|
||||
covered work so as to satisfy simultaneously your obligations under this
|
||||
License and any other pertinent obligations, then as a consequence you may
|
||||
not convey it at all. For example, if you agree to terms that obligate you
|
||||
to collect a royalty for further conveying from those to whom you convey
|
||||
the Program, the only way you could satisfy both those terms and this
|
||||
License would be to refrain entirely from conveying the Program.
|
||||
|
||||
13. Use with the GNU Affero General Public License.
|
||||
|
||||
Notwithstanding any other provision of this License, you have
|
||||
permission to link or combine any covered work with a work licensed
|
||||
under version 3 of the GNU Affero General Public License into a single
|
||||
combined work, and to convey the resulting work. The terms of this
|
||||
License will continue to apply to the part which is the covered work,
|
||||
but the special requirements of the GNU Affero General Public License,
|
||||
section 13, concerning interaction through a network will apply to the
|
||||
combination as such.
|
||||
|
||||
14. Revised Versions of this License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions of
|
||||
the GNU General Public License from time to time. Such new versions will
|
||||
be similar in spirit to the present version, but may differ in detail to
|
||||
address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the
|
||||
Program specifies that a certain numbered version of the GNU General
|
||||
Public License "or any later version" applies to it, you have the
|
||||
option of following the terms and conditions either of that numbered
|
||||
version or of any later version published by the Free Software
|
||||
Foundation. If the Program does not specify a version number of the
|
||||
GNU General Public License, you may choose any version ever published
|
||||
by the Free Software Foundation.
|
||||
|
||||
If the Program specifies that a proxy can decide which future
|
||||
versions of the GNU General Public License can be used, that proxy's
|
||||
public statement of acceptance of a version permanently authorizes you
|
||||
to choose that version for the Program.
|
||||
|
||||
Later license versions may give you additional or different
|
||||
permissions. However, no additional obligations are imposed on any
|
||||
author or copyright holder as a result of your choosing to follow a
|
||||
later version.
|
||||
|
||||
15. Disclaimer of Warranty.
|
||||
|
||||
THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
|
||||
APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
|
||||
HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
|
||||
OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
|
||||
THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
||||
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
|
||||
IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
|
||||
ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
|
||||
|
||||
16. Limitation of Liability.
|
||||
|
||||
IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
|
||||
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
|
||||
THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
|
||||
GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
|
||||
USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
|
||||
DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
|
||||
PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
|
||||
EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGES.
|
||||
|
||||
17. Interpretation of Sections 15 and 16.
|
||||
|
||||
If the disclaimer of warranty and limitation of liability provided
|
||||
above cannot be given local legal effect according to their terms,
|
||||
reviewing courts shall apply local law that most closely approximates
|
||||
an absolute waiver of all civil liability in connection with the
|
||||
Program, unless a warranty or assumption of liability accompanies a
|
||||
copy of the Program in return for a fee.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
How to Apply These Terms to Your New Programs
|
||||
|
||||
If you develop a new program, and you want it to be of the greatest
|
||||
possible use to the public, the best way to achieve this is to make it
|
||||
free software which everyone can redistribute and change under these terms.
|
||||
|
||||
To do so, attach the following notices to the program. It is safest
|
||||
to attach them to the start of each source file to most effectively
|
||||
state the exclusion of warranty; and each file should have at least
|
||||
the "copyright" line and a pointer to where the full notice is found.
|
||||
|
||||
<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 General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
|
||||
Also add information on how to contact you by electronic and paper mail.
|
||||
|
||||
If the program does terminal interaction, make it output a short
|
||||
notice like this when it starts in an interactive mode:
|
||||
|
||||
<program> Copyright (C) <year> <name of author>
|
||||
This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
|
||||
This is free software, and you are welcome to redistribute it
|
||||
under certain conditions; type `show c' for details.
|
||||
|
||||
The hypothetical commands `show w' and `show c' should show the appropriate
|
||||
parts of the General Public License. Of course, your program's commands
|
||||
might be different; for a GUI interface, you would use an "about box".
|
||||
|
||||
You should also get your employer (if you work as a programmer) or school,
|
||||
if any, to sign a "copyright disclaimer" for the program, if necessary.
|
||||
For more information on this, and how to apply and follow the GNU GPL, see
|
||||
<https://www.gnu.org/licenses/>.
|
||||
|
||||
The GNU General Public License does not permit incorporating your program
|
||||
into proprietary programs. If your program is a subroutine library, you
|
||||
may consider it more useful to permit linking proprietary applications with
|
||||
the library. If this is what you want to do, use the GNU Lesser General
|
||||
Public License instead of this License. But first, please read
|
||||
<https://www.gnu.org/licenses/why-not-lgpl.html>.
|
||||
82
app/__init__.py
Normal file
82
app/__init__.py
Normal file
@@ -0,0 +1,82 @@
|
||||
import os
|
||||
import json
|
||||
from flask import Flask, request, session, current_app
|
||||
from flask_sqlalchemy import SQLAlchemy
|
||||
from flask_login import LoginManager
|
||||
from sqlalchemy import event
|
||||
from sqlalchemy.engine import Engine
|
||||
|
||||
db = SQLAlchemy()
|
||||
login_manager = LoginManager()
|
||||
|
||||
@event.listens_for(Engine, "connect")
|
||||
def set_sqlite_pragma(dbapi_connection, connection_record):
|
||||
if dbapi_connection.__class__.__module__ == "sqlite3":
|
||||
cursor = dbapi_connection.cursor()
|
||||
cursor.execute("PRAGMA journal_mode=WAL")
|
||||
cursor.execute("PRAGMA synchronous=NORMAL")
|
||||
cursor.close()
|
||||
|
||||
# Load all i18n jsons
|
||||
i18n_dict = {}
|
||||
|
||||
def load_i18n(app):
|
||||
global i18n_dict
|
||||
i18n_dir = os.path.join(app.root_path, '..', 'assets', 'i18n')
|
||||
if os.path.exists(i18n_dir):
|
||||
for f in os.listdir(i18n_dir):
|
||||
if f.endswith('.json'):
|
||||
lang_code = f.replace('.json', '')
|
||||
with open(os.path.join(i18n_dir, f), 'r', encoding='utf-8') as jf:
|
||||
i18n_dict[lang_code] = json.load(jf)
|
||||
|
||||
def get_locale():
|
||||
# 用户手动选择的语言保存在 cookie 中优先
|
||||
lang = request.cookies.get('lang')
|
||||
if lang in i18n_dict:
|
||||
return lang
|
||||
|
||||
# Check accept_languages with our available dict keys
|
||||
best_match = request.accept_languages.best_match(list(i18n_dict.keys()))
|
||||
return best_match if best_match else 'en'
|
||||
|
||||
def _t(key):
|
||||
lang = get_locale()
|
||||
# Fallback to english if language missing or key missing
|
||||
if lang in i18n_dict and key in i18n_dict[lang]:
|
||||
return i18n_dict[lang][key]
|
||||
if 'en' in i18n_dict and key in i18n_dict['en']:
|
||||
return i18n_dict['en'][key]
|
||||
return key # fallback to the key itself
|
||||
|
||||
def create_app():
|
||||
app = Flask(__name__, static_url_path='/assets', static_folder='../assets')
|
||||
app.config['SECRET_KEY'] = 'your-secret-key-change-it-in-production'
|
||||
app.config['SQLALCHEMY_DATABASE_URI'] = 'sqlite:///aio_3d.db'
|
||||
app.config['SQLALCHEMY_ENGINE_OPTIONS'] = {'connect_args': {'timeout': 15}}
|
||||
app.config['UPLOAD_FOLDER'] = os.path.abspath(os.path.join(app.root_path, '..', 'uploads'))
|
||||
|
||||
os.makedirs(app.config['UPLOAD_FOLDER'], exist_ok=True)
|
||||
|
||||
load_i18n(app)
|
||||
|
||||
db.init_app(app)
|
||||
login_manager.init_app(app)
|
||||
|
||||
# Inject translation function into jinja
|
||||
@app.context_processor
|
||||
def inject_i18n():
|
||||
return dict(_=_t)
|
||||
|
||||
login_manager.login_view = 'auth.login'
|
||||
|
||||
with app.app_context():
|
||||
from . import models
|
||||
db.create_all()
|
||||
|
||||
from .routes import main_bp, auth_bp, admin_bp
|
||||
app.register_blueprint(main_bp)
|
||||
app.register_blueprint(auth_bp)
|
||||
app.register_blueprint(admin_bp)
|
||||
|
||||
return app
|
||||
31
app/models.py
Normal file
31
app/models.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from datetime import datetime
|
||||
from flask_login import UserMixin
|
||||
from . import db, login_manager
|
||||
|
||||
@login_manager.user_loader
|
||||
def load_user(user_id):
|
||||
return User.query.get(int(user_id))
|
||||
|
||||
class User(UserMixin, db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
username = db.Column(db.String(100), unique=True, nullable=False)
|
||||
password_hash = db.Column(db.String(200))
|
||||
is_admin = db.Column(db.Boolean, default=False)
|
||||
is_guest = db.Column(db.Boolean, default=True)
|
||||
guest_cookie_id = db.Column(db.String(100), unique=True, nullable=True) # 用于绑定不同设备的Guest
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
print_files = db.relationship('PrintFile', backref='uploader', lazy=True)
|
||||
|
||||
class PrintFile(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
filename = db.Column(db.String(255), nullable=False)
|
||||
original_filename = db.Column(db.String(255), nullable=False) # 保存原有名称
|
||||
file_type = db.Column(db.String(10)) # stl 或者 gcode
|
||||
user_id = db.Column(db.Integer, db.ForeignKey('user.id'), nullable=False)
|
||||
created_at = db.Column(db.DateTime, default=datetime.utcnow)
|
||||
status = db.Column(db.String(50), default='waiting') # waiting, slicing, sliced, failed
|
||||
|
||||
class SystemConfig(db.Model):
|
||||
id = db.Column(db.Integer, primary_key=True)
|
||||
key = db.Column(db.String(50), unique=True, nullable=False)
|
||||
value = db.Column(db.String(255), nullable=False)
|
||||
229
app/routes.py
Normal file
229
app/routes.py
Normal file
@@ -0,0 +1,229 @@
|
||||
from flask import Blueprint, render_template, request, redirect, url_for, flash, current_app, session, make_response, send_file, abort, jsonify
|
||||
from flask_login import login_user, logout_user, login_required, current_user
|
||||
from werkzeug.security import generate_password_hash, check_password_hash
|
||||
from werkzeug.utils import secure_filename
|
||||
from .models import db, User, PrintFile, SystemConfig
|
||||
import os
|
||||
import uuid
|
||||
import configparser
|
||||
from datetime import datetime
|
||||
from .tasks import slice_stl_task
|
||||
|
||||
main_bp = Blueprint('main', __name__)
|
||||
|
||||
def get_quality_presets():
|
||||
preset_dir = os.path.join(current_app.root_path, '..', 'print_config', 'presets', 'creality', 'base')
|
||||
presets = []
|
||||
if os.path.exists(preset_dir):
|
||||
for f in os.listdir(preset_dir):
|
||||
if f.startswith('base_global_') and f.endswith('.inst.cfg'):
|
||||
config = configparser.ConfigParser()
|
||||
try:
|
||||
config.read(os.path.join(preset_dir, f))
|
||||
name = config.get('general', 'name', fallback=f)
|
||||
presets.append((f, name))
|
||||
except Exception as e:
|
||||
pass
|
||||
# Custom sort order or alphanumeric
|
||||
return sorted(presets, key=lambda x: x[1])
|
||||
|
||||
auth_bp = Blueprint('auth', __name__, url_prefix='/auth')
|
||||
admin_bp = Blueprint('admin', __name__, url_prefix='/admin')
|
||||
|
||||
# Guest User Middleware
|
||||
@main_bp.before_app_request
|
||||
def assign_guest_cookie():
|
||||
if not current_user.is_authenticated:
|
||||
guest_id = request.cookies.get('guest_id')
|
||||
if not guest_id:
|
||||
guest_id = str(uuid.uuid4())
|
||||
user = User(username=f'guest_{guest_id[:8]}', is_guest=True, guest_cookie_id=guest_id)
|
||||
db.session.add(user)
|
||||
db.session.commit()
|
||||
login_user(user)
|
||||
# We will set the cookie in the response after request, see below
|
||||
request.guest_id_to_set = guest_id
|
||||
else:
|
||||
user = User.query.filter_by(guest_cookie_id=guest_id).first()
|
||||
if user:
|
||||
login_user(user)
|
||||
|
||||
@main_bp.after_app_request
|
||||
def set_guest_cookie(response):
|
||||
if hasattr(request, 'guest_id_to_set'):
|
||||
response.set_cookie('guest_id', request.guest_id_to_set, max_age=60*60*24*365) # 1 year
|
||||
return response
|
||||
|
||||
# --- Main Routes ---
|
||||
|
||||
@main_bp.route('/')
|
||||
def index():
|
||||
return render_template('index.html')
|
||||
|
||||
@main_bp.route('/set_language/<lang>')
|
||||
def set_language(lang):
|
||||
from app import i18n_dict
|
||||
if lang not in i18n_dict:
|
||||
lang = 'en'
|
||||
# return to previous page
|
||||
response = make_response(redirect(request.referrer or url_for('main.index')))
|
||||
response.set_cookie('lang', lang, max_age=60*60*24*365)
|
||||
return response
|
||||
|
||||
@main_bp.route('/slice', methods=['GET', 'POST'])
|
||||
@login_required
|
||||
def slice_page():
|
||||
if request.method == 'POST':
|
||||
if 'file' not in request.files:
|
||||
flash('No file part', 'danger')
|
||||
return redirect(request.url)
|
||||
file = request.files['file']
|
||||
if file.filename == '':
|
||||
flash('No selected file', 'danger')
|
||||
return redirect(request.url)
|
||||
if file and file.filename.lower().endswith('.stl'):
|
||||
original_filename = file.filename # Do not use secure_filename to keep Chinese characters
|
||||
ext = os.path.splitext(original_filename)[1].lower()
|
||||
if not ext:
|
||||
ext = '.stl'
|
||||
timestamp = datetime.now().strftime('%Y%m%d%H%M%S')
|
||||
unique_filename = f"{timestamp}_{uuid.uuid4().hex}{ext}"
|
||||
filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], unique_filename)
|
||||
file.save(filepath)
|
||||
|
||||
print_file = PrintFile(
|
||||
filename=unique_filename,
|
||||
original_filename=original_filename,
|
||||
file_type='stl',
|
||||
user_id=current_user.id,
|
||||
status='waiting'
|
||||
)
|
||||
db.session.add(print_file)
|
||||
db.session.commit()
|
||||
|
||||
# Start slicing task
|
||||
quality_preset = request.form.get('quality', 'base_global_standard.inst.cfg')
|
||||
slice_stl_task(print_file.id, filepath, quality_preset)
|
||||
flash('File uploaded and slicing started!', 'success')
|
||||
response = make_response(redirect(url_for('main.files')))
|
||||
response.set_cookie('last_quality_preset', quality_preset, max_age=60*60*24*365)
|
||||
return response
|
||||
|
||||
presets = get_quality_presets()
|
||||
last_quality = request.cookies.get('last_quality_preset', 'base_global_standard.inst.cfg')
|
||||
return render_template('slice.html', presets=presets, last_quality=last_quality)
|
||||
|
||||
@main_bp.route('/files')
|
||||
@login_required
|
||||
def files():
|
||||
# Order by newest first
|
||||
user_files = PrintFile.query.filter_by(user_id=current_user.id).order_by(PrintFile.created_at.desc()).all()
|
||||
return render_template('files.html', files=user_files)
|
||||
|
||||
@main_bp.route('/api/files_status')
|
||||
@login_required
|
||||
def files_status():
|
||||
files = PrintFile.query.filter_by(user_id=current_user.id).all()
|
||||
return jsonify({str(f.id): f.status for f in files})
|
||||
|
||||
@main_bp.route('/download/<int:file_id>')
|
||||
@login_required
|
||||
def download_gcode(file_id):
|
||||
print_file = PrintFile.query.get_or_404(file_id)
|
||||
if print_file.user_id != current_user.id and not current_user.is_admin:
|
||||
abort(403)
|
||||
if print_file.status != 'sliced':
|
||||
flash('File is not ready yet.', 'warning')
|
||||
return redirect(url_for('main.files'))
|
||||
|
||||
gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode'
|
||||
filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
|
||||
|
||||
if os.path.exists(filepath):
|
||||
safe_name = print_file.original_filename.rsplit('.', 1)[0] + '.gcode'
|
||||
return send_file(filepath, as_attachment=True, download_name=safe_name)
|
||||
flash('GCode file not found. It might have been deleted.', 'danger')
|
||||
return redirect(url_for('main.files'))
|
||||
|
||||
@main_bp.route('/preview_gcode/<int:file_id>')
|
||||
@login_required
|
||||
def preview_gcode(file_id):
|
||||
print_file = PrintFile.query.get_or_404(file_id)
|
||||
if print_file.user_id != current_user.id and not current_user.is_admin:
|
||||
abort(403)
|
||||
|
||||
gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode'
|
||||
filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
|
||||
|
||||
content = "File not found or not ready."
|
||||
line_count = 0
|
||||
if os.path.exists(filepath):
|
||||
with open(filepath, 'r') as f:
|
||||
lines = f.readlines()
|
||||
line_count = len(lines)
|
||||
content = "".join(lines[:500]) # Preview first 500 lines
|
||||
if line_count > 500:
|
||||
content += f"\n... \n[Preview truncated. Total lines: {line_count}. Please download to view full file.]"
|
||||
|
||||
return render_template('gcode_preview.html', file=print_file, content=content, line_count=line_count)
|
||||
|
||||
@main_bp.route('/delete_file/<int:file_id>', methods=['POST'])
|
||||
@login_required
|
||||
def delete_file(file_id):
|
||||
print_file = PrintFile.query.get_or_404(file_id)
|
||||
if print_file.user_id != current_user.id and not current_user.is_admin:
|
||||
abort(403)
|
||||
|
||||
stl_path = os.path.join(current_app.config['UPLOAD_FOLDER'], print_file.filename)
|
||||
gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode'
|
||||
gcode_path = os.path.join(current_app.config['UPLOAD_FOLDER'], gcode_filename)
|
||||
|
||||
if os.path.exists(stl_path):
|
||||
os.remove(stl_path)
|
||||
if os.path.exists(gcode_path):
|
||||
os.remove(gcode_path)
|
||||
|
||||
db.session.delete(print_file)
|
||||
db.session.commit()
|
||||
flash(f"Deleted {print_file.original_filename} successfully.", 'success')
|
||||
return redirect(url_for('main.files'))
|
||||
|
||||
# --- Auth Routes ---
|
||||
|
||||
@auth_bp.route('/login', methods=['GET', 'POST'])
|
||||
def login():
|
||||
if request.method == 'POST':
|
||||
username = request.form.get('username')
|
||||
password = request.form.get('password')
|
||||
user = User.query.filter_by(username=username, is_guest=False).first()
|
||||
if user and check_password_hash(user.password_hash, password):
|
||||
login_user(user)
|
||||
return redirect(url_for('main.index'))
|
||||
flash('Invalid username or password', 'danger')
|
||||
return render_template('login.html')
|
||||
|
||||
@auth_bp.route('/logout')
|
||||
@login_required
|
||||
def logout():
|
||||
logout_user()
|
||||
response = make_response(redirect(url_for('main.index')))
|
||||
response.delete_cookie('guest_id') # Optionally clear guest cookie
|
||||
return response
|
||||
|
||||
# --- Admin Routes ---
|
||||
|
||||
@admin_bp.before_request
|
||||
def require_admin():
|
||||
if not current_user.is_authenticated or not current_user.is_admin:
|
||||
flash('Admin access required', 'danger')
|
||||
return redirect(url_for('main.index'))
|
||||
|
||||
@admin_bp.route('/settings')
|
||||
def settings():
|
||||
configs = SystemConfig.query.all()
|
||||
return render_template('admin_settings.html', configs=configs)
|
||||
|
||||
@admin_bp.route('/users')
|
||||
def users():
|
||||
all_users = User.query.order_by(User.created_at.desc()).all()
|
||||
return render_template('admin_users.html', users=all_users)
|
||||
85
app/tasks.py
Normal file
85
app/tasks.py
Normal file
@@ -0,0 +1,85 @@
|
||||
from huey import SqliteHuey
|
||||
import subprocess
|
||||
import os
|
||||
from .models import db, PrintFile, SystemConfig
|
||||
|
||||
huey = SqliteHuey(filename='huey_queue.db')
|
||||
|
||||
import configparser
|
||||
|
||||
@huey.task()
|
||||
def slice_stl_task(file_id, stl_filepath, quality_preset=None):
|
||||
# This is run by the Huey worker
|
||||
# We need to create an app context to interact with the database
|
||||
from app import create_app
|
||||
app = create_app()
|
||||
with app.app_context():
|
||||
print_file = PrintFile.query.get(file_id)
|
||||
if not print_file:
|
||||
return
|
||||
|
||||
# Cache variables and commit slicing status
|
||||
gcode_filename = print_file.filename.rsplit('.', 1)[0] + '.gcode'
|
||||
gcode_filepath = os.path.join(app.config['UPLOAD_FOLDER'], gcode_filename)
|
||||
print_file.status = 'slicing'
|
||||
db.session.commit()
|
||||
|
||||
# Remove DB session to avoid locking the sqlite db during long slicing operations
|
||||
db.session.remove()
|
||||
|
||||
try:
|
||||
# Create Cura engine options
|
||||
# use our local minimal configurations detached from the entire Cura framework
|
||||
print_config_path = os.path.abspath(os.path.join(app.root_path, '..', 'print_config'))
|
||||
printers_path = os.path.join(print_config_path, 'printers')
|
||||
extruders_path = os.path.join(print_config_path, 'extruders')
|
||||
materials_path = os.path.join(print_config_path, 'materials')
|
||||
presets_path = os.path.join(print_config_path, 'presets')
|
||||
env = os.environ.copy()
|
||||
env["CURA_ENGINE_SEARCH_PATH"] = f"{printers_path}:{extruders_path}:{materials_path}:{presets_path}"
|
||||
|
||||
command = [
|
||||
"CuraEngine", "slice",
|
||||
"-j", os.path.join(printers_path, "creality_ender3v3se.def.json")
|
||||
]
|
||||
|
||||
# Apply quality presets if any
|
||||
if quality_preset:
|
||||
config = configparser.ConfigParser()
|
||||
preset_path = os.path.join(presets_path, 'creality', 'base', quality_preset)
|
||||
if os.path.exists(preset_path):
|
||||
config.read(preset_path)
|
||||
if config.has_section('values'):
|
||||
for key, val in config.items('values'):
|
||||
command.extend(['-s', f"{key}={val}"])
|
||||
|
||||
command.extend([
|
||||
"-l", stl_filepath,
|
||||
"-o", gcode_filepath
|
||||
])
|
||||
|
||||
app.logger.info(f"Running command: {' '.join(command)}")
|
||||
process = subprocess.Popen(command, stdout=subprocess.PIPE, stderr=subprocess.PIPE, env=env)
|
||||
stdout, stderr = process.communicate()
|
||||
|
||||
# Re-fetch print_file and update status
|
||||
print_file = PrintFile.query.get(file_id)
|
||||
if not print_file:
|
||||
return
|
||||
|
||||
if process.returncode == 0:
|
||||
print_file.status = 'sliced'
|
||||
else:
|
||||
print_file.status = 'failed'
|
||||
app.logger.error(f"CuraEngine Error: {stderr.decode()}")
|
||||
|
||||
except Exception as e:
|
||||
# Re-fetch in case of exception
|
||||
print_file = PrintFile.query.get(file_id)
|
||||
if print_file:
|
||||
print_file.status = 'failed'
|
||||
app.logger.error(f"Subprocess Exception: {e}")
|
||||
|
||||
db.session.commit()
|
||||
db.session.remove()
|
||||
|
||||
21
app/templates/admin_settings.html
Normal file
21
app/templates/admin_settings.html
Normal file
@@ -0,0 +1,21 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2">System Settings</h1>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-body">
|
||||
<h5>CuraEngine Configurations</h5>
|
||||
<hr>
|
||||
<form method="POST">
|
||||
<div class="mb-3">
|
||||
<label for="concurrent_slices" class="form-label">Concurrent Slices (Queue Worker limit)</label>
|
||||
<input type="number" class="form-control" id="concurrent_slices" value="2" min="1" max="10">
|
||||
</div>
|
||||
<button type="button" class="btn btn-primary" onclick="alert('Settings saved (demo)')">Save Settings</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
42
app/templates/admin_users.html
Normal file
42
app/templates/admin_users.html
Normal file
@@ -0,0 +1,42 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2">User Management</h1>
|
||||
</div>
|
||||
|
||||
<div class="table-responsive">
|
||||
<table class="table table-striped table-sm">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>ID</th>
|
||||
<th>Username</th>
|
||||
<th>Role</th>
|
||||
<th>Created At</th>
|
||||
<th>Actions</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for user in users %}
|
||||
<tr>
|
||||
<td>{{ user.id }}</td>
|
||||
<td>{{ user.username }}</td>
|
||||
<td>
|
||||
{% if user.is_admin %}
|
||||
<span class="badge bg-danger">Admin</span>
|
||||
{% elif user.is_guest %}
|
||||
<span class="badge bg-secondary">Guest</span>
|
||||
{% else %}
|
||||
<span class="badge bg-primary">User</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td>{{ user.created_at.strftime('%Y-%m-%d %H:%M') }}</td>
|
||||
<td>
|
||||
<button class="btn btn-sm btn-outline-danger" {% if user.id == current_user.id %}disabled{% endif %}>Delete</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
{% endblock %}
|
||||
135
app/templates/base.html
Normal file
135
app/templates/base.html
Normal file
@@ -0,0 +1,135 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>AIO 3D Slicer</title>
|
||||
<!-- Bootstrap 5 CSS -->
|
||||
<link href="{{ url_for('static', filename='css/bootstrap.min.css') }}" rel="stylesheet">
|
||||
<!-- Bootstrap Icons -->
|
||||
<link href="{{ url_for('static', filename='css/bootstrap-icons.css') }}" rel="stylesheet">
|
||||
<style>
|
||||
body { padding-top: 56px; font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; background-color: #f8f9fa; }
|
||||
.sidebar { position: fixed; top: 56px; bottom: 0; left: 0; z-index: 100; padding: 0; box-shadow: inset -1px 0 0 rgba(0, 0, 0, .1); background-color: #fff; }
|
||||
.sidebar-sticky { position: relative; top: 0; height: calc(100vh - 56px); padding-top: 1rem; overflow-x: hidden; overflow-y: auto; }
|
||||
|
||||
.nav-pills .nav-link { border-radius: 0.5rem; padding: 0.75rem 1rem; font-weight: 500; transition: all 0.2s ease; margin-bottom: 0.25rem; }
|
||||
.nav-pills .nav-link:hover { background-color: rgba(13,110,253,0.05); color: #0d6efd !important; }
|
||||
.nav-pills .nav-link.active { background-color: #0d6efd; color: white !important; box-shadow: 0 4px 6px rgba(13,110,253,0.3); }
|
||||
|
||||
.navbar-brand { font-size: 1.25rem; letter-spacing: 0.5px; }
|
||||
.card { border: none; border-radius: 0.75rem; overflow: hidden; }
|
||||
.card-header { border-bottom: 1px solid rgba(0,0,0,.05); background-color: transparent; }
|
||||
|
||||
.toast-container { margin-bottom: 20px; margin-right: 20px; }
|
||||
.toast { border-radius: 0.5rem; box-shadow: 0 0.5rem 1rem rgba(0,0,0,.15); opacity: 0.95; }
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top shadow-sm">
|
||||
<div class="container-fluid">
|
||||
<a class="navbar-brand fw-bold" href="{{ url_for('main.index') }}"><i class="bi bi-printer me-2"></i>AIO 3D Slicer</a>
|
||||
<div class="d-flex text-light align-items-center">
|
||||
<div class="dropdown me-3">
|
||||
<button class="btn btn-sm btn-outline-light dropdown-toggle" type="button" id="langDropdown" data-bs-toggle="dropdown" aria-expanded="false">
|
||||
<i class="bi bi-globe me-1"></i>{{ _('Language') }}
|
||||
</button>
|
||||
<ul class="dropdown-menu dropdown-menu-end shadow" aria-labelledby="langDropdown">
|
||||
<li><a class="dropdown-item {% if request.cookies.get('lang') == 'en' %}active{% endif %}" href="{{ url_for('main.set_language', lang='en') }}"><i class="bi bi-translate me-2"></i>English</a></li>
|
||||
<li><a class="dropdown-item {% if request.cookies.get('lang') == 'zh-cn' %}active{% endif %}" href="{{ url_for('main.set_language', lang='zh-cn') }}"><i class="bi bi-translate me-2"></i>中文 (简体)</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
|
||||
{% if current_user.is_authenticated %}
|
||||
{% if current_user.is_guest %}
|
||||
<span class="me-3 text-secondary"><i class="bi bi-incognito me-1"></i>{{ _('Guest') }} ({{ current_user.username }})</span>
|
||||
<a href="{{ url_for('auth.login') }}" class="btn btn-outline-light btn-sm rounded-pill px-3">{{ _('Login') }}</a>
|
||||
{% else %}
|
||||
<span class="me-3 text-success fw-semibold"><i class="bi bi-person-circle me-1"></i>{{ current_user.username }}</span>
|
||||
<a href="{{ url_for('auth.logout') }}" class="btn btn-outline-light btn-sm rounded-pill px-3">{{ _('Logout') }}</a>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
</div>
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<div class="container-fluid">
|
||||
<div class="row">
|
||||
<nav id="sidebarMenu" class="col-md-3 col-lg-2 d-md-block bg-white sidebar collapse border-end">
|
||||
<div class="sidebar-sticky pt-3 px-2">
|
||||
<ul class="nav flex-column nav-pills gap-1">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark {% if request.endpoint == 'main.index' %}active text-white shadow-sm{% endif %}" href="{{ url_for('main.index') }}">
|
||||
<i class="bi bi-house-door me-2"></i>{{ _('Home') }}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark {% if request.endpoint == 'main.slice_page' %}active text-white shadow-sm{% endif %}" href="{{ url_for('main.slice_page') }}">
|
||||
<i class="bi bi-box me-2"></i>{{ _('New Slice') }}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark {% if request.endpoint == 'main.files' %}active text-white shadow-sm{% endif %}" href="{{ url_for('main.files') }}">
|
||||
<i class="bi bi-folder2-open me-2"></i>{{ _('My Files') }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
{% if current_user.is_authenticated and current_user.is_admin %}
|
||||
<h6 class="sidebar-heading d-flex justify-content-between align-items-center px-3 mt-4 mb-2 text-muted fw-bold text-uppercase" style="font-size: 0.75rem;">
|
||||
<span><i class="bi bi-shield-lock me-1"></i>{{ _('Admin Options') }}</span>
|
||||
</h6>
|
||||
<ul class="nav flex-column nav-pills gap-1 mb-2">
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark {% if request.endpoint == 'admin.settings' %}active text-white shadow-sm{% endif %}" href="{{ url_for('admin.settings') }}">
|
||||
<i class="bi bi-gear me-2"></i>{{ _('System Settings') }}
|
||||
</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark {% if request.endpoint == 'admin.users' %}active text-white shadow-sm{% endif %}" href="{{ url_for('admin.users') }}">
|
||||
<i class="bi bi-people me-2"></i>{{ _('User Management') }}
|
||||
</a>
|
||||
</li>
|
||||
</ul>
|
||||
{% endif %}
|
||||
</div>
|
||||
</nav>
|
||||
|
||||
<main class="col-md-9 ms-sm-auto col-lg-10 px-md-4 mt-4 bg-light min-vh-100 pb-5">
|
||||
|
||||
<!-- Toast Notification Container -->
|
||||
<div class="toast-container position-fixed bottom-0 end-0 p-3" style="z-index: 1055;">
|
||||
{% with messages = get_flashed_messages(with_categories=true) %}
|
||||
{% if messages %}
|
||||
{% for category, message in messages %}
|
||||
{% set toast_class = 'bg-success text-white' if category == 'success' else 'bg-danger text-white' if category == 'danger' else 'bg-warning text-dark' if category == 'warning' else 'bg-primary text-white' %}
|
||||
<div class="toast align-items-center border-0 {{ toast_class }}" role="alert" aria-live="assertive" aria-atomic="true">
|
||||
<div class="d-flex">
|
||||
<div class="toast-body fw-medium">
|
||||
{{ message }}
|
||||
</div>
|
||||
<button type="button" class="btn-close btn-close-white me-2 m-auto" data-bs-dismiss="toast" aria-label="Close"></button>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
{% endif %}
|
||||
{% endwith %}
|
||||
</div>
|
||||
|
||||
{% block content %}{% endblock %}
|
||||
</main>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script src="{{ url_for('static', filename='js/bootstrap.bundle.min.js') }}"></script>
|
||||
<script>
|
||||
// Initialize Toasts automatically
|
||||
document.addEventListener('DOMContentLoaded', function () {
|
||||
var toastElList = [].slice.call(document.querySelectorAll('.toast'))
|
||||
var toastList = toastElList.map(function (toastEl) {
|
||||
return new bootstrap.Toast(toastEl, { delay: 3000 }).show()
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
132
app/templates/files.html
Normal file
132
app/templates/files.html
Normal file
@@ -0,0 +1,132 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-4 border-bottom">
|
||||
<h1 class="h2"><i class="bi bi-files me-2 text-warning"></i>{{ _('My Files') }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm border-0">
|
||||
<div class="card-body p-0">
|
||||
<div class="table-responsive">
|
||||
<table class="table table-hover table-striped mb-0 align-middle">
|
||||
<thead class="table-light">
|
||||
<tr>
|
||||
<th class="ps-4 fw-semibold text-secondary">{{ _('Date Uploaded') }}</th>
|
||||
<th class="fw-semibold text-secondary">{{ _('Original Name') }}</th>
|
||||
<th class="fw-semibold text-secondary">{{ _('Status') }}</th>
|
||||
<th class="pe-4 fw-semibold text-secondary">{{ _('Actions') }}</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
{% for file in files %}
|
||||
<tr id="file-row-{{ file.id }}" data-status="{{ file.status }}">
|
||||
<td class="ps-4 text-muted"><i class="bi bi-clock me-1"></i>{{ file.created_at.strftime('%Y-%m-%d %H:%M:%S') }}</td>
|
||||
<td class="fw-medium">{{ file.original_filename }}</td>
|
||||
<td id="status-{{ file.id }}">
|
||||
{% if file.status == 'waiting' or file.status == 'uploaded' %}
|
||||
<span class="badge bg-info text-dark rounded-pill fw-normal px-2" title="{{ _('Waiting in queue for slicing') }}"><i class="bi bi-hourglass-split me-1"></i>{{ _('Waiting') }}...</span>
|
||||
{% elif file.status == 'slicing' %}
|
||||
<span class="badge bg-warning text-dark rounded-pill fw-normal px-2"><i class="bi bi-gear-wide-connected bi-spin me-1"></i>{{ _('Slicing') }}...</span>
|
||||
{% elif file.status == 'sliced' %}
|
||||
<span class="badge bg-success rounded-pill fw-normal px-2"><i class="bi bi-check-circle me-1"></i>{{ _('Sliced') }}</span>
|
||||
{% elif file.status == 'failed' %}
|
||||
<span class="badge bg-danger rounded-pill fw-normal px-2"><i class="bi bi-x-circle me-1"></i>{{ _('Failed') }}</span>
|
||||
{% endif %}
|
||||
</td>
|
||||
<td class="pe-4">
|
||||
<div class="d-flex gap-2" id="actions-container-{{ file.id }}">
|
||||
{% if file.status == 'sliced' %}
|
||||
<a href="{{ url_for('main.download_gcode', file_id=file.id) }}" class="btn btn-sm btn-outline-primary shadow-sm" title="{{ _('Download GCode') }}"><i class="bi bi-download"></i></a>
|
||||
<a href="{{ url_for('main.preview_gcode', file_id=file.id) }}" class="btn btn-sm btn-outline-info shadow-sm" title="{{ _('GCode Preview') }}"><i class="bi bi-eye"></i></a>
|
||||
{% endif %}
|
||||
<form action="{{ url_for('main.delete_file', file_id=file.id) }}" method="POST" onsubmit="return confirm('{{ _('Are you sure you want to delete this file?') }}');">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger shadow-sm" title="{{ _('Delete') }}"><i class="bi bi-trash3"></i></button>
|
||||
</form>
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
{% else %}
|
||||
<tr>
|
||||
<td colspan="4" class="text-center text-muted py-5">
|
||||
<i class="bi bi-folder-x display-4 d-block mb-3 opacity-50"></i>
|
||||
{{ _('No files uploaded yet.') }}
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
document.addEventListener('DOMContentLoaded', function() {
|
||||
const checkInterval = 1000;
|
||||
let pollTimer = null;
|
||||
|
||||
function fetchStatus() {
|
||||
fetch(`{{ url_for('main.files_status') }}`)
|
||||
.then(response => response.json())
|
||||
.then(data => {
|
||||
let hasPending = false;
|
||||
for (const [id, status] of Object.entries(data)) {
|
||||
const tr = document.getElementById('file-row-' + id);
|
||||
if (!tr) continue;
|
||||
|
||||
const currentStatus = tr.getAttribute('data-status');
|
||||
if (currentStatus !== status) {
|
||||
// Change DOM state
|
||||
tr.setAttribute('data-status', status);
|
||||
const statusTd = document.getElementById('status-' + id);
|
||||
const actionsTd = document.getElementById('actions-container-' + id);
|
||||
|
||||
// Update Status Badge HTML correctly preserving translations
|
||||
if (status === 'waiting' || status === 'uploaded') statusTd.innerHTML = '<span class="badge bg-info text-dark rounded-pill fw-normal px-2" title="{{ _("Waiting in queue for slicing") }}"><i class="bi bi-hourglass-split me-1"></i>{{ _("Waiting") }}...</span>';
|
||||
else if (status === 'slicing') statusTd.innerHTML = '<span class="badge bg-warning text-dark rounded-pill fw-normal px-2"><i class="bi bi-gear-wide-connected bi-spin me-1"></i>{{ _("Slicing") }}...</span>';
|
||||
else if (status === 'sliced') statusTd.innerHTML = '<span class="badge bg-success rounded-pill fw-normal px-2"><i class="bi bi-check-circle me-1"></i>{{ _("Sliced") }}</span>';
|
||||
else if (status === 'failed') statusTd.innerHTML = '<span class="badge bg-danger rounded-pill fw-normal px-2"><i class="bi bi-x-circle me-1"></i>{{ _("Failed") }}</span>';
|
||||
|
||||
// Update Actions HTML
|
||||
let actionsHtml = '';
|
||||
if (status === 'sliced') {
|
||||
const downloadUrl = `{{ url_for('main.download_gcode', file_id=999999999) }}`.replace('999999999', id);
|
||||
const previewUrl = `{{ url_for('main.preview_gcode', file_id=999999999) }}`.replace('999999999', id);
|
||||
actionsHtml += `<a href="${downloadUrl}" class="btn btn-sm btn-outline-primary shadow-sm" title="{{ _('Download GCode') }}"><i class="bi bi-download"></i></a>\n`;
|
||||
actionsHtml += `<a href="${previewUrl}" class="btn btn-sm btn-outline-info shadow-sm" title="{{ _('GCode Preview') }}"><i class="bi bi-eye"></i></a>\n`;
|
||||
}
|
||||
const deleteUrl = `{{ url_for('main.delete_file', file_id=999999999) }}`.replace('999999999', id);
|
||||
actionsHtml += `<form action="${deleteUrl}" method="POST" onsubmit="return confirm('{{ _('Are you sure you want to delete this file?') }}');">
|
||||
<button type="submit" class="btn btn-sm btn-outline-danger shadow-sm" title="{{ _('Delete') }}"><i class="bi bi-trash3"></i></button>
|
||||
</form>`;
|
||||
actionsTd.innerHTML = actionsHtml;
|
||||
}
|
||||
|
||||
if (status === 'waiting' || status === 'uploaded' || status === 'slicing') {
|
||||
hasPending = true;
|
||||
}
|
||||
}
|
||||
|
||||
// Stop polling if there are no more pending files in the user's scope
|
||||
if (!hasPending && pollTimer) {
|
||||
clearInterval(pollTimer);
|
||||
pollTimer = null;
|
||||
}
|
||||
})
|
||||
.catch(error => console.error('Error fetching file statuses:', error));
|
||||
}
|
||||
|
||||
// Check initially if we have any pending slices
|
||||
let needsPolling = false;
|
||||
document.querySelectorAll('tr[id^="file-row-"]').forEach(row => {
|
||||
const st = row.getAttribute('data-status');
|
||||
if (st === 'waiting' || st === 'uploaded' || st === 'slicing') {
|
||||
needsPolling = true;
|
||||
}
|
||||
});
|
||||
|
||||
if (needsPolling) {
|
||||
pollTimer = setInterval(fetchStatus, checkInterval);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
22
app/templates/gcode_preview.html
Normal file
22
app/templates/gcode_preview.html
Normal file
@@ -0,0 +1,22 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2">GCode Preview: {{ file.original_filename }}</h1>
|
||||
<a href="{{ url_for('main.files') }}" class="btn btn-secondary btn-sm">Back to Files</a>
|
||||
</div>
|
||||
|
||||
<div class="card shadow-sm mb-4">
|
||||
<div class="card-header bg-info text-dark d-flex justify-content-between">
|
||||
<span>File Info</span>
|
||||
<span>Total Lines: {{ line_count }}</span>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<p class="card-text text-muted mb-1">Below is a text preview of the generated GCode (first 500 lines).</p>
|
||||
<pre class="bg-dark text-light p-3 rounded" style="max-height: 500px; overflow-y: auto; font-size: 13px;"><code>{{ content }}</code></pre>
|
||||
</div>
|
||||
<div class="card-footer">
|
||||
<a href="{{ url_for('main.download_gcode', file_id=file.id) }}" class="btn btn-primary">Download Full GCode File</a>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
18
app/templates/index.html
Normal file
18
app/templates/index.html
Normal file
@@ -0,0 +1,18 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2">{{ _('Dashboard') }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-4">
|
||||
<div class="card text-white bg-primary mb-3 shadow-sm border-0">
|
||||
<div class="card-header border-0 fs-5 fw-medium"><i class="bi bi-bar-chart-fill me-2"></i>{{ _('Total Prints') }}</div>
|
||||
<div class="card-body mt-2">
|
||||
<h5 class="card-title">{{ _('You have sliced') }} <b class="fs-1 mx-2">{{ current_user.print_files|length }}</b> {{ _('files') }}</h5>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
26
app/templates/login.html
Normal file
26
app/templates/login.html
Normal file
@@ -0,0 +1,26 @@
|
||||
{% extends "base.html" %}
|
||||
|
||||
{% block content %}
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-md-6 mt-5">
|
||||
<div class="card shadow-sm">
|
||||
<div class="card-header bg-primary text-white">
|
||||
<h4 class="mb-0">Login</h4>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
<form method="POST" action="{{ url_for('auth.login') }}">
|
||||
<div class="mb-3">
|
||||
<label for="username" class="form-label">Username</label>
|
||||
<input type="text" class="form-control" name="username" id="username" required>
|
||||
</div>
|
||||
<div class="mb-3">
|
||||
<label for="password" class="form-label">Password</label>
|
||||
<input type="password" class="form-control" name="password" id="password" required>
|
||||
</div>
|
||||
<button type="submit" class="btn btn-primary w-100">Login</button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endblock %}
|
||||
234
app/templates/slice.html
Normal file
234
app/templates/slice.html
Normal file
@@ -0,0 +1,234 @@
|
||||
{% extends 'base.html' %}
|
||||
|
||||
{% block content %}
|
||||
<div class="d-flex justify-content-between flex-wrap flex-md-nowrap align-items-center pt-3 pb-2 mb-3 border-bottom">
|
||||
<h1 class="h2"><i class="bi bi-cloud-arrow-up me-2 text-primary"></i>{{ _('Upload & Slice STL') }}</h1>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="col-md-6 mb-4 mb-md-0">
|
||||
<div class="card shadow-sm h-100">
|
||||
<div class="card-body p-4">
|
||||
<form id="upload-form" method="POST" enctype="multipart/form-data">
|
||||
<div class="mb-4">
|
||||
<label class="form-label fw-bold text-secondary">{{ _('Select STL File') }}</label>
|
||||
<div id="drop-zone" class="border rounded p-4 text-center position-relative" style="border: 2px dashed #0d6efd !important; cursor: pointer; transition: all 0.3s ease; background-color: #f8f9fa;">
|
||||
<i class="bi bi-cloud-arrow-up display-4 text-primary mb-2"></i>
|
||||
<p class="mt-2 text-secondary fw-bold mb-0" id="drop-text">{{ _('Drag & Drop STL file here or Click to Select') }}</p>
|
||||
<input class="form-control position-absolute w-100 h-100 top-0 start-0 opacity-0" type="file" id="file" name="file" accept=".stl" style="cursor: pointer;" required>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div id="progress-container" class="mb-4 d-none">
|
||||
<div class="d-flex justify-content-between mb-1">
|
||||
<span class="text-secondary fw-bold small" id="progress-text">{{ _('Uploading...') }}</span>
|
||||
<span class="text-primary fw-bold small" id="progress-percent">0%</span>
|
||||
</div>
|
||||
<div class="progress rounded-pill" style="height: 10px;">
|
||||
<div id="progress-bar" class="progress-bar progress-bar-striped progress-bar-animated bg-success" role="progressbar" style="width: 0%;" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Here you can add slice configurations -->
|
||||
<div class="mb-4">
|
||||
<label for="quality" class="form-label fw-bold text-secondary">{{ _('Quality Profile') }}</label>
|
||||
<select class="form-select bg-light" id="quality" name="quality">
|
||||
{% for key, name in presets %}
|
||||
<option value="{{ key }}" {% if key == last_quality %}selected{% endif %}>{{ _(name) }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
|
||||
<button type="submit" id="submit-btn" class="btn btn-success fw-bold px-4 py-2 w-100 shadow-sm"><i class="bi bi-gear-fill me-2" id="submit-icon"></i><span id="submit-text">{{ _('Upload & Slice') }}</span></button>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="col-md-6">
|
||||
<div class="card shadow-sm h-100">
|
||||
<div class="card-body p-0 position-relative">
|
||||
<div id="stl_viewer_container" style="height: 400px; width: 100%; border-radius: 0.375rem; overflow: hidden; background: #f8f9fa;">
|
||||
<!-- STL Viewer Integration Point -->
|
||||
<div id="viewer_placeholder" class="text-muted text-center position-absolute top-50 start-50 translate-middle">
|
||||
<i class="bi bi-box display-1 text-secondary opacity-50 mb-3 d-block"></i>
|
||||
<h5>{{ _('3D Preview Area') }}</h5><small>{{ _('Upload a file to display') }}</small>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<!-- Three.js + STLLoader + OrbitControls -->
|
||||
<script src="{{ url_for('static', filename='js/three.min.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/OrbitControls.js') }}"></script>
|
||||
<script src="{{ url_for('static', filename='js/STLLoader.js') }}"></script>
|
||||
|
||||
<script>
|
||||
const fileInput = document.getElementById('file');
|
||||
const dropZone = document.getElementById('drop-zone');
|
||||
const dropText = document.getElementById('drop-text');
|
||||
const uploadForm = document.getElementById('upload-form');
|
||||
const progressContainer = document.getElementById('progress-container');
|
||||
const progressBar = document.getElementById('progress-bar');
|
||||
const progressPercent = document.getElementById('progress-percent');
|
||||
const submitBtn = document.getElementById('submit-btn');
|
||||
const submitIcon = document.getElementById('submit-icon');
|
||||
const submitText = document.getElementById('submit-text');
|
||||
|
||||
function preventDefaults(e) { e.preventDefault(); e.stopPropagation(); }
|
||||
['dragenter', 'dragover', 'dragleave', 'drop'].forEach(eventName => {
|
||||
dropZone.addEventListener(eventName, preventDefaults, false);
|
||||
});
|
||||
['dragenter', 'dragover'].forEach(eventName => {
|
||||
dropZone.addEventListener(eventName, () => {
|
||||
dropZone.style.backgroundColor = '#e9ecef';
|
||||
dropZone.style.borderColor = '#0b5ed7';
|
||||
}, false);
|
||||
});
|
||||
['dragleave', 'drop'].forEach(eventName => {
|
||||
dropZone.addEventListener(eventName, () => {
|
||||
dropZone.style.backgroundColor = '#f8f9fa';
|
||||
dropZone.style.borderColor = '#0d6efd';
|
||||
}, false);
|
||||
});
|
||||
dropZone.addEventListener('drop', e => {
|
||||
if(e.dataTransfer.files.length) {
|
||||
fileInput.files = e.dataTransfer.files;
|
||||
fileInput.dispatchEvent(new Event('change'));
|
||||
}
|
||||
});
|
||||
|
||||
fileInput.addEventListener('change', function(e) {
|
||||
const file = e.target.files[0];
|
||||
if(!file) return;
|
||||
|
||||
dropText.innerText = file.name;
|
||||
document.getElementById('viewer_placeholder').style.display = 'none';
|
||||
|
||||
const reader = new FileReader();
|
||||
reader.onload = function(event) {
|
||||
initViewer(event.target.result);
|
||||
};
|
||||
reader.readAsArrayBuffer(file);
|
||||
});
|
||||
|
||||
uploadForm.addEventListener('submit', function(e) {
|
||||
e.preventDefault();
|
||||
const file = fileInput.files[0];
|
||||
if(!file) return;
|
||||
|
||||
const formData = new FormData(uploadForm);
|
||||
progressContainer.classList.remove('d-none');
|
||||
submitBtn.disabled = true;
|
||||
submitIcon.className = 'spinner-border spinner-border-sm me-2';
|
||||
submitText.innerText = '{{ _("Uploading...") }}';
|
||||
|
||||
const xhr = new XMLHttpRequest();
|
||||
xhr.open('POST', window.location.href, true);
|
||||
|
||||
xhr.upload.onprogress = function(e) {
|
||||
if(e.lengthComputable) {
|
||||
const percent = Math.round((e.loaded / e.total) * 100);
|
||||
progressBar.style.width = percent + '%';
|
||||
progressBar.setAttribute('aria-valuenow', percent);
|
||||
progressPercent.innerText = percent + '%';
|
||||
}
|
||||
};
|
||||
|
||||
xhr.onload = function() {
|
||||
if(xhr.status >= 200 && xhr.status < 300) {
|
||||
progressBar.classList.remove('progress-bar-animated');
|
||||
progressBar.classList.remove('progress-bar-striped');
|
||||
submitText.innerText = '{{ _("Slicing queued!") }}';
|
||||
window.location.href = "{{ url_for('main.files') }}";
|
||||
} else {
|
||||
alert('Error: ' + xhr.statusText);
|
||||
resetUploadState();
|
||||
}
|
||||
};
|
||||
xhr.onerror = function() {
|
||||
alert('Upload failed');
|
||||
resetUploadState();
|
||||
};
|
||||
xhr.send(formData);
|
||||
});
|
||||
|
||||
function resetUploadState() {
|
||||
progressContainer.classList.add('d-none');
|
||||
submitBtn.disabled = false;
|
||||
submitIcon.className = 'bi bi-gear-fill me-2';
|
||||
submitText.innerText = '{{ _("Upload & Slice") }}';
|
||||
progressBar.style.width = '0%';
|
||||
progressPercent.innerText = '0%';
|
||||
}
|
||||
|
||||
let scene, camera, renderer, controls;
|
||||
|
||||
function initViewer(data) {
|
||||
const container = document.getElementById('stl_viewer_container');
|
||||
// Clear previous if any
|
||||
container.innerHTML = '';
|
||||
|
||||
scene = new THREE.Scene();
|
||||
scene.background = new THREE.Color( 0xf8f9fa );
|
||||
|
||||
// Setup camera
|
||||
camera = new THREE.PerspectiveCamera( 45, container.clientWidth / container.clientHeight, 1, 1000 );
|
||||
camera.position.set( 0, -150, 150 );
|
||||
|
||||
// Setup renderer
|
||||
renderer = new THREE.WebGLRenderer( { antialias: true } );
|
||||
renderer.setSize( container.clientWidth, container.clientHeight );
|
||||
container.appendChild( renderer.domElement );
|
||||
|
||||
// Add lighting
|
||||
scene.add( new THREE.AmbientLight( 0x777777 ) );
|
||||
const directionalLight = new THREE.DirectionalLight( 0xffffff, 1 );
|
||||
directionalLight.position.set( 1, 1, 2 );
|
||||
scene.add( directionalLight );
|
||||
|
||||
// Load STL
|
||||
const loader = new THREE.STLLoader();
|
||||
const geometry = loader.parse( data );
|
||||
|
||||
geometry.computeBoundingBox();
|
||||
const center = geometry.boundingBox.getCenter(new THREE.Vector3());
|
||||
geometry.center();
|
||||
|
||||
const material = new THREE.MeshPhongMaterial( { color: 0x0d6efd, specular: 0x111111, shininess: 200 } );
|
||||
const mesh = new THREE.Mesh( geometry, material );
|
||||
|
||||
// Optional: scale model to fit view automatically
|
||||
const boundingSphere = geometry.boundingBox.getBoundingSphere(new THREE.Sphere());
|
||||
const radius = boundingSphere.radius;
|
||||
camera.position.set(0, -radius * 2, radius * 2);
|
||||
|
||||
scene.add( mesh );
|
||||
|
||||
// Add controls
|
||||
controls = new THREE.OrbitControls( camera, renderer.domElement );
|
||||
controls.enableDamping = true;
|
||||
controls.target.set(0,0,0);
|
||||
controls.update();
|
||||
|
||||
animate();
|
||||
}
|
||||
|
||||
function animate() {
|
||||
requestAnimationFrame( animate );
|
||||
controls.update();
|
||||
renderer.render( scene, camera );
|
||||
}
|
||||
|
||||
// Handle window resize dynamically inside container context
|
||||
window.addEventListener('resize', function() {
|
||||
if(camera && renderer) {
|
||||
const container = document.getElementById('stl_viewer_container');
|
||||
camera.aspect = container.clientWidth / container.clientHeight;
|
||||
camera.updateProjectionMatrix();
|
||||
renderer.setSize( container.clientWidth, container.clientHeight );
|
||||
}
|
||||
});
|
||||
</script>
|
||||
{% endblock %}
|
||||
15
assets/css/README-LICENSE.txt
Normal file
15
assets/css/README-LICENSE.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
Notice regarding the CSS styles and Fonts included in this directory:
|
||||
|
||||
This project as a whole is licensed under the GNU General Public License v3.0 (GPLv3).
|
||||
However, the included CSS and Font dependencies are distributed under their own permissive licenses (which are fully compatible with GPLv3).
|
||||
|
||||
1. Bootstrap (bootstrap.min.css)
|
||||
- Copyright (c) 2011-2023 The Bootstrap Authors
|
||||
- Licensed under the MIT License
|
||||
- https://github.com/twbs/bootstrap/blob/main/LICENSE
|
||||
|
||||
2. Bootstrap Icons (bootstrap-icons.css, fonts/bootstrap-icons.woff, etc.)
|
||||
- Copyright (c) 2019-2023 The Bootstrap Authors
|
||||
- Font files are licensed under the SIL Open Font License (OFL) v1.1.
|
||||
- The CSS generated code is licensed under the MIT License.
|
||||
- https://github.com/twbs/icons/blob/main/LICENSE
|
||||
1981
assets/css/bootstrap-icons.css
vendored
Normal file
1981
assets/css/bootstrap-icons.css
vendored
Normal file
File diff suppressed because it is too large
Load Diff
6
assets/css/bootstrap.min.css
vendored
Normal file
6
assets/css/bootstrap.min.css
vendored
Normal file
File diff suppressed because one or more lines are too long
1
assets/css/bootstrap.min.css.map
Normal file
1
assets/css/bootstrap.min.css.map
Normal file
File diff suppressed because one or more lines are too long
BIN
assets/css/fonts/bootstrap-icons.woff
Normal file
BIN
assets/css/fonts/bootstrap-icons.woff
Normal file
Binary file not shown.
BIN
assets/css/fonts/bootstrap-icons.woff.1
Normal file
BIN
assets/css/fonts/bootstrap-icons.woff.1
Normal file
Binary file not shown.
BIN
assets/css/fonts/bootstrap-icons.woff2
Normal file
BIN
assets/css/fonts/bootstrap-icons.woff2
Normal file
Binary file not shown.
BIN
assets/css/fonts/bootstrap-icons.woff2.1
Normal file
BIN
assets/css/fonts/bootstrap-icons.woff2.1
Normal file
Binary file not shown.
48
assets/i18n/en.json
Normal file
48
assets/i18n/en.json
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"Language": "Language",
|
||||
"English": "English",
|
||||
"Chinese": "中文",
|
||||
"Guest": "Guest",
|
||||
"Login": "Login",
|
||||
"Logout": "Logout",
|
||||
"Home": "Home",
|
||||
"New Slice": "New Slice",
|
||||
"My Files": "My Files",
|
||||
"Admin Options": "Admin Options",
|
||||
"System Settings": "System Settings",
|
||||
"User Management": "User Management",
|
||||
"Dashboard": "Dashboard",
|
||||
"Total Prints": "Total Prints",
|
||||
"You have sliced": "You have sliced",
|
||||
"files": "files.",
|
||||
"Upload & Slice STL": "Upload & Slice STL",
|
||||
"Select STL File": "Select STL File",
|
||||
"Quality Profile": "Quality Profile",
|
||||
"Upload & Slice": "Upload & Slice",
|
||||
"3D Preview Area": "3D Preview Area",
|
||||
"Upload a file to display": "Upload a file to display",
|
||||
"Date Uploaded": "Date Uploaded",
|
||||
"Original Name": "Original Name",
|
||||
"Status": "Status",
|
||||
"Actions": "Actions",
|
||||
"Uploaded": "Uploaded",
|
||||
"Waiting": "Waiting",
|
||||
"Waiting in queue for slicing": "Waiting in queue for slicing",
|
||||
"Slicing": "Slicing",
|
||||
"Sliced": "Sliced",
|
||||
"Failed": "Failed",
|
||||
"Download GCode": "Download GCode",
|
||||
"GCode Preview": "GCode Preview",
|
||||
"Delete": "Delete",
|
||||
"No files uploaded yet.": "No files uploaded yet.",
|
||||
"Drag & Drop STL file here or Click to Select": "Drag & Drop STL file here or Click to Select",
|
||||
"Uploading...": "Uploading...",
|
||||
"Slicing queued!": "Slicing queued!",
|
||||
"Draft Quality": "Draft Quality",
|
||||
"Standard Quality": "Standard Quality",
|
||||
"High Quality": "High Quality",
|
||||
"Dynamic Quality": "Dynamic Quality",
|
||||
"Low Quality": "Low Quality",
|
||||
"Super Quality": "Super Quality",
|
||||
"Ultra Quality": "Ultra Quality"
|
||||
}
|
||||
48
assets/i18n/zh-cn.json
Normal file
48
assets/i18n/zh-cn.json
Normal file
@@ -0,0 +1,48 @@
|
||||
{
|
||||
"Language": "语言",
|
||||
"English": "English",
|
||||
"Chinese": "中文",
|
||||
"Guest": "访客",
|
||||
"Login": "登录",
|
||||
"Logout": "退出",
|
||||
"Home": "主页",
|
||||
"New Slice": "新建切片",
|
||||
"My Files": "我的文件",
|
||||
"Admin Options": "管理员选项",
|
||||
"System Settings": "系统设置",
|
||||
"User Management": "用户管理",
|
||||
"Dashboard": "仪表盘",
|
||||
"Total Prints": "总打印数",
|
||||
"You have sliced": "您已切片",
|
||||
"files": "个文件。",
|
||||
"Upload & Slice STL": "上传并切片 STL",
|
||||
"Select STL File": "选择 STL 文件",
|
||||
"Quality Profile": "质量配置",
|
||||
"Upload & Slice": "上传 & 切片",
|
||||
"3D Preview Area": "3D预览区",
|
||||
"Upload a file to display": "上传文件以显示",
|
||||
"Date Uploaded": "上传日期",
|
||||
"Original Name": "原始名称",
|
||||
"Status": "状态",
|
||||
"Actions": "操作",
|
||||
"Uploaded": "已上传",
|
||||
"Waiting": "等待",
|
||||
"Waiting in queue for slicing": "在队列中排队等待切片",
|
||||
"Slicing": "切片中",
|
||||
"Sliced": "已切片",
|
||||
"Failed": "失败",
|
||||
"Download GCode": "下载 GCode",
|
||||
"GCode Preview": "GCode 预览",
|
||||
"Delete": "删除",
|
||||
"No files uploaded yet.": "还没有上传文件。",
|
||||
"Drag & Drop STL file here or Click to Select": "将 STL 文件拖放到此处或点击选择",
|
||||
"Uploading...": "上传中...",
|
||||
"Slicing queued!": "切片已排队!",
|
||||
"Draft Quality": "草稿质量",
|
||||
"Standard Quality": "标准质量",
|
||||
"High Quality": "高质量",
|
||||
"Dynamic Quality": "动态质量",
|
||||
"Low Quality": "低质量",
|
||||
"Super Quality": "超高质量",
|
||||
"Ultra Quality": "极高质量"
|
||||
}
|
||||
1045
assets/js/OrbitControls.js
Normal file
1045
assets/js/OrbitControls.js
Normal file
File diff suppressed because it is too large
Load Diff
1045
assets/js/OrbitControls.js.1
Normal file
1045
assets/js/OrbitControls.js.1
Normal file
File diff suppressed because it is too large
Load Diff
15
assets/js/README-LICENSE.txt
Normal file
15
assets/js/README-LICENSE.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
Notice regarding the JavaScript libraries included in this directory:
|
||||
|
||||
This project as a whole is licensed under the GNU General Public License v3.0 (GPLv3).
|
||||
|
||||
However, the included JavaScript dependencies are distributed under their own permissive licenses (which are fully compatible with GPLv3).
|
||||
|
||||
1. Bootstrap (bootstrap.bundle.min.js)
|
||||
- Copyright (c) 2011-2023 The Bootstrap Authors
|
||||
- Licensed under the MIT License
|
||||
- https://github.com/twbs/bootstrap/blob/main/LICENSE
|
||||
|
||||
2. Three.js (three.min.js, OrbitControls.js, STLLoader.js)
|
||||
- Copyright © 2010-2023 three.js authors
|
||||
- Licensed under the MIT License
|
||||
- https://github.com/mrdoob/three.js/blob/dev/LICENSE
|
||||
371
assets/js/STLLoader.js
Normal file
371
assets/js/STLLoader.js
Normal file
@@ -0,0 +1,371 @@
|
||||
( function () {
|
||||
|
||||
/**
|
||||
* Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs.
|
||||
*
|
||||
* Supports both binary and ASCII encoded files, with automatic detection of type.
|
||||
*
|
||||
* The loader returns a non-indexed buffer geometry.
|
||||
*
|
||||
* Limitations:
|
||||
* Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL).
|
||||
* There is perhaps some question as to how valid it is to always assume little-endian-ness.
|
||||
* ASCII decoding assumes file is UTF-8.
|
||||
*
|
||||
* Usage:
|
||||
* const loader = new STLLoader();
|
||||
* loader.load( './models/stl/slotted_disk.stl', function ( geometry ) {
|
||||
* scene.add( new THREE.Mesh( geometry ) );
|
||||
* });
|
||||
*
|
||||
* For binary STLs geometry might contain colors for vertices. To use it:
|
||||
* // use the same code to load STL as above
|
||||
* if (geometry.hasColors) {
|
||||
* material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: true });
|
||||
* } else { .... }
|
||||
* const mesh = new THREE.Mesh( geometry, material );
|
||||
*
|
||||
* For ASCII STLs containing multiple solids, each solid is assigned to a different group.
|
||||
* Groups can be used to assign a different color by defining an array of materials with the same length of
|
||||
* geometry.groups and passing it to the Mesh constructor:
|
||||
*
|
||||
* const mesh = new THREE.Mesh( geometry, material );
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* const materials = [];
|
||||
* const nGeometryGroups = geometry.groups.length;
|
||||
*
|
||||
* const colorMap = ...; // Some logic to index colors.
|
||||
*
|
||||
* for (let i = 0; i < nGeometryGroups; i++) {
|
||||
*
|
||||
* const material = new THREE.MeshPhongMaterial({
|
||||
* color: colorMap[i],
|
||||
* wireframe: false
|
||||
* });
|
||||
*
|
||||
* }
|
||||
*
|
||||
* materials.push(material);
|
||||
* const mesh = new THREE.Mesh(geometry, materials);
|
||||
*/
|
||||
|
||||
class STLLoader extends THREE.Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
const scope = this;
|
||||
const loader = new THREE.FileLoader( this.manager );
|
||||
loader.setPath( this.path );
|
||||
loader.setResponseType( 'arraybuffer' );
|
||||
loader.setRequestHeader( this.requestHeader );
|
||||
loader.setWithCredentials( this.withCredentials );
|
||||
loader.load( url, function ( text ) {
|
||||
|
||||
try {
|
||||
|
||||
onLoad( scope.parse( text ) );
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
if ( onError ) {
|
||||
|
||||
onError( e );
|
||||
|
||||
} else {
|
||||
|
||||
console.error( e );
|
||||
|
||||
}
|
||||
|
||||
scope.manager.itemError( url );
|
||||
|
||||
}
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
}
|
||||
|
||||
parse( data ) {
|
||||
|
||||
function isBinary( data ) {
|
||||
|
||||
const reader = new DataView( data );
|
||||
const face_size = 32 / 8 * 3 + 32 / 8 * 3 * 3 + 16 / 8;
|
||||
const n_faces = reader.getUint32( 80, true );
|
||||
const expect = 80 + 32 / 8 + n_faces * face_size;
|
||||
|
||||
if ( expect === reader.byteLength ) {
|
||||
|
||||
return true;
|
||||
|
||||
} // An ASCII STL data must begin with 'solid ' as the first six bytes.
|
||||
// However, ASCII STLs lacking the SPACE after the 'd' are known to be
|
||||
// plentiful. So, check the first 5 bytes for 'solid'.
|
||||
// Several encodings, such as UTF-8, precede the text with up to 5 bytes:
|
||||
// https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding
|
||||
// Search for "solid" to start anywhere after those prefixes.
|
||||
// US-ASCII ordinal values for 's', 'o', 'l', 'i', 'd'
|
||||
|
||||
|
||||
const solid = [ 115, 111, 108, 105, 100 ];
|
||||
|
||||
for ( let off = 0; off < 5; off ++ ) {
|
||||
|
||||
// If "solid" text is matched to the current offset, declare it to be an ASCII STL.
|
||||
if ( matchDataViewAt( solid, reader, off ) ) return false;
|
||||
|
||||
} // Couldn't find "solid" text at the beginning; it is binary STL.
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function matchDataViewAt( query, reader, offset ) {
|
||||
|
||||
// Check if each byte in query matches the corresponding byte from the current offset
|
||||
for ( let i = 0, il = query.length; i < il; i ++ ) {
|
||||
|
||||
if ( query[ i ] !== reader.getUint8( offset + i, false ) ) return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function parseBinary( data ) {
|
||||
|
||||
const reader = new DataView( data );
|
||||
const faces = reader.getUint32( 80, true );
|
||||
let r,
|
||||
g,
|
||||
b,
|
||||
hasColors = false,
|
||||
colors;
|
||||
let defaultR, defaultG, defaultB, alpha; // process STL header
|
||||
// check for default color in header ("COLOR=rgba" sequence).
|
||||
|
||||
for ( let index = 0; index < 80 - 10; index ++ ) {
|
||||
|
||||
if ( reader.getUint32( index, false ) == 0x434F4C4F
|
||||
/*COLO*/
|
||||
&& reader.getUint8( index + 4 ) == 0x52
|
||||
/*'R'*/
|
||||
&& reader.getUint8( index + 5 ) == 0x3D
|
||||
/*'='*/
|
||||
) {
|
||||
|
||||
hasColors = true;
|
||||
colors = new Float32Array( faces * 3 * 3 );
|
||||
defaultR = reader.getUint8( index + 6 ) / 255;
|
||||
defaultG = reader.getUint8( index + 7 ) / 255;
|
||||
defaultB = reader.getUint8( index + 8 ) / 255;
|
||||
alpha = reader.getUint8( index + 9 ) / 255;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const dataOffset = 84;
|
||||
const faceLength = 12 * 4 + 2;
|
||||
const geometry = new THREE.BufferGeometry();
|
||||
const vertices = new Float32Array( faces * 3 * 3 );
|
||||
const normals = new Float32Array( faces * 3 * 3 );
|
||||
|
||||
for ( let face = 0; face < faces; face ++ ) {
|
||||
|
||||
const start = dataOffset + face * faceLength;
|
||||
const normalX = reader.getFloat32( start, true );
|
||||
const normalY = reader.getFloat32( start + 4, true );
|
||||
const normalZ = reader.getFloat32( start + 8, true );
|
||||
|
||||
if ( hasColors ) {
|
||||
|
||||
const packedColor = reader.getUint16( start + 48, true );
|
||||
|
||||
if ( ( packedColor & 0x8000 ) === 0 ) {
|
||||
|
||||
// facet has its own unique color
|
||||
r = ( packedColor & 0x1F ) / 31;
|
||||
g = ( packedColor >> 5 & 0x1F ) / 31;
|
||||
b = ( packedColor >> 10 & 0x1F ) / 31;
|
||||
|
||||
} else {
|
||||
|
||||
r = defaultR;
|
||||
g = defaultG;
|
||||
b = defaultB;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for ( let i = 1; i <= 3; i ++ ) {
|
||||
|
||||
const vertexstart = start + i * 12;
|
||||
const componentIdx = face * 3 * 3 + ( i - 1 ) * 3;
|
||||
vertices[ componentIdx ] = reader.getFloat32( vertexstart, true );
|
||||
vertices[ componentIdx + 1 ] = reader.getFloat32( vertexstart + 4, true );
|
||||
vertices[ componentIdx + 2 ] = reader.getFloat32( vertexstart + 8, true );
|
||||
normals[ componentIdx ] = normalX;
|
||||
normals[ componentIdx + 1 ] = normalY;
|
||||
normals[ componentIdx + 2 ] = normalZ;
|
||||
|
||||
if ( hasColors ) {
|
||||
|
||||
colors[ componentIdx ] = r;
|
||||
colors[ componentIdx + 1 ] = g;
|
||||
colors[ componentIdx + 2 ] = b;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
|
||||
geometry.setAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
|
||||
|
||||
if ( hasColors ) {
|
||||
|
||||
geometry.setAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) );
|
||||
geometry.hasColors = true;
|
||||
geometry.alpha = alpha;
|
||||
|
||||
}
|
||||
|
||||
return geometry;
|
||||
|
||||
}
|
||||
|
||||
function parseASCII( data ) {
|
||||
|
||||
const geometry = new THREE.BufferGeometry();
|
||||
const patternSolid = /solid([\s\S]*?)endsolid/g;
|
||||
const patternFace = /facet([\s\S]*?)endfacet/g;
|
||||
let faceCounter = 0;
|
||||
const patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
|
||||
const patternVertex = new RegExp( 'vertex' + patternFloat + patternFloat + patternFloat, 'g' );
|
||||
const patternNormal = new RegExp( 'normal' + patternFloat + patternFloat + patternFloat, 'g' );
|
||||
const vertices = [];
|
||||
const normals = [];
|
||||
const normal = new THREE.Vector3();
|
||||
let result;
|
||||
let groupCount = 0;
|
||||
let startVertex = 0;
|
||||
let endVertex = 0;
|
||||
|
||||
while ( ( result = patternSolid.exec( data ) ) !== null ) {
|
||||
|
||||
startVertex = endVertex;
|
||||
const solid = result[ 0 ];
|
||||
|
||||
while ( ( result = patternFace.exec( solid ) ) !== null ) {
|
||||
|
||||
let vertexCountPerFace = 0;
|
||||
let normalCountPerFace = 0;
|
||||
const text = result[ 0 ];
|
||||
|
||||
while ( ( result = patternNormal.exec( text ) ) !== null ) {
|
||||
|
||||
normal.x = parseFloat( result[ 1 ] );
|
||||
normal.y = parseFloat( result[ 2 ] );
|
||||
normal.z = parseFloat( result[ 3 ] );
|
||||
normalCountPerFace ++;
|
||||
|
||||
}
|
||||
|
||||
while ( ( result = patternVertex.exec( text ) ) !== null ) {
|
||||
|
||||
vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) );
|
||||
normals.push( normal.x, normal.y, normal.z );
|
||||
vertexCountPerFace ++;
|
||||
endVertex ++;
|
||||
|
||||
} // every face have to own ONE valid normal
|
||||
|
||||
|
||||
if ( normalCountPerFace !== 1 ) {
|
||||
|
||||
console.error( 'THREE.STLLoader: Something isn\'t right with the normal of face number ' + faceCounter );
|
||||
|
||||
} // each face have to own THREE valid vertices
|
||||
|
||||
|
||||
if ( vertexCountPerFace !== 3 ) {
|
||||
|
||||
console.error( 'THREE.STLLoader: Something isn\'t right with the vertices of face number ' + faceCounter );
|
||||
|
||||
}
|
||||
|
||||
faceCounter ++;
|
||||
|
||||
}
|
||||
|
||||
const start = startVertex;
|
||||
const count = endVertex - startVertex;
|
||||
geometry.addGroup( start, count, groupCount );
|
||||
groupCount ++;
|
||||
|
||||
}
|
||||
|
||||
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
|
||||
geometry.setAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) );
|
||||
return geometry;
|
||||
|
||||
}
|
||||
|
||||
function ensureString( buffer ) {
|
||||
|
||||
if ( typeof buffer !== 'string' ) {
|
||||
|
||||
return THREE.LoaderUtils.decodeText( new Uint8Array( buffer ) );
|
||||
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
function ensureBinary( buffer ) {
|
||||
|
||||
if ( typeof buffer === 'string' ) {
|
||||
|
||||
const array_buffer = new Uint8Array( buffer.length );
|
||||
|
||||
for ( let i = 0; i < buffer.length; i ++ ) {
|
||||
|
||||
array_buffer[ i ] = buffer.charCodeAt( i ) & 0xff; // implicitly assumes little-endian
|
||||
|
||||
}
|
||||
|
||||
return array_buffer.buffer || array_buffer;
|
||||
|
||||
} else {
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
} // start
|
||||
|
||||
|
||||
const binData = ensureBinary( data );
|
||||
return isBinary( binData ) ? parseBinary( binData ) : parseASCII( ensureString( data ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
THREE.STLLoader = STLLoader;
|
||||
|
||||
} )();
|
||||
371
assets/js/STLLoader.js.1
Normal file
371
assets/js/STLLoader.js.1
Normal file
@@ -0,0 +1,371 @@
|
||||
( function () {
|
||||
|
||||
/**
|
||||
* Description: A THREE loader for STL ASCII files, as created by Solidworks and other CAD programs.
|
||||
*
|
||||
* Supports both binary and ASCII encoded files, with automatic detection of type.
|
||||
*
|
||||
* The loader returns a non-indexed buffer geometry.
|
||||
*
|
||||
* Limitations:
|
||||
* Binary decoding supports "Magics" color format (http://en.wikipedia.org/wiki/STL_(file_format)#Color_in_binary_STL).
|
||||
* There is perhaps some question as to how valid it is to always assume little-endian-ness.
|
||||
* ASCII decoding assumes file is UTF-8.
|
||||
*
|
||||
* Usage:
|
||||
* const loader = new STLLoader();
|
||||
* loader.load( './models/stl/slotted_disk.stl', function ( geometry ) {
|
||||
* scene.add( new THREE.Mesh( geometry ) );
|
||||
* });
|
||||
*
|
||||
* For binary STLs geometry might contain colors for vertices. To use it:
|
||||
* // use the same code to load STL as above
|
||||
* if (geometry.hasColors) {
|
||||
* material = new THREE.MeshPhongMaterial({ opacity: geometry.alpha, vertexColors: true });
|
||||
* } else { .... }
|
||||
* const mesh = new THREE.Mesh( geometry, material );
|
||||
*
|
||||
* For ASCII STLs containing multiple solids, each solid is assigned to a different group.
|
||||
* Groups can be used to assign a different color by defining an array of materials with the same length of
|
||||
* geometry.groups and passing it to the Mesh constructor:
|
||||
*
|
||||
* const mesh = new THREE.Mesh( geometry, material );
|
||||
*
|
||||
* For example:
|
||||
*
|
||||
* const materials = [];
|
||||
* const nGeometryGroups = geometry.groups.length;
|
||||
*
|
||||
* const colorMap = ...; // Some logic to index colors.
|
||||
*
|
||||
* for (let i = 0; i < nGeometryGroups; i++) {
|
||||
*
|
||||
* const material = new THREE.MeshPhongMaterial({
|
||||
* color: colorMap[i],
|
||||
* wireframe: false
|
||||
* });
|
||||
*
|
||||
* }
|
||||
*
|
||||
* materials.push(material);
|
||||
* const mesh = new THREE.Mesh(geometry, materials);
|
||||
*/
|
||||
|
||||
class STLLoader extends THREE.Loader {
|
||||
|
||||
constructor( manager ) {
|
||||
|
||||
super( manager );
|
||||
|
||||
}
|
||||
|
||||
load( url, onLoad, onProgress, onError ) {
|
||||
|
||||
const scope = this;
|
||||
const loader = new THREE.FileLoader( this.manager );
|
||||
loader.setPath( this.path );
|
||||
loader.setResponseType( 'arraybuffer' );
|
||||
loader.setRequestHeader( this.requestHeader );
|
||||
loader.setWithCredentials( this.withCredentials );
|
||||
loader.load( url, function ( text ) {
|
||||
|
||||
try {
|
||||
|
||||
onLoad( scope.parse( text ) );
|
||||
|
||||
} catch ( e ) {
|
||||
|
||||
if ( onError ) {
|
||||
|
||||
onError( e );
|
||||
|
||||
} else {
|
||||
|
||||
console.error( e );
|
||||
|
||||
}
|
||||
|
||||
scope.manager.itemError( url );
|
||||
|
||||
}
|
||||
|
||||
}, onProgress, onError );
|
||||
|
||||
}
|
||||
|
||||
parse( data ) {
|
||||
|
||||
function isBinary( data ) {
|
||||
|
||||
const reader = new DataView( data );
|
||||
const face_size = 32 / 8 * 3 + 32 / 8 * 3 * 3 + 16 / 8;
|
||||
const n_faces = reader.getUint32( 80, true );
|
||||
const expect = 80 + 32 / 8 + n_faces * face_size;
|
||||
|
||||
if ( expect === reader.byteLength ) {
|
||||
|
||||
return true;
|
||||
|
||||
} // An ASCII STL data must begin with 'solid ' as the first six bytes.
|
||||
// However, ASCII STLs lacking the SPACE after the 'd' are known to be
|
||||
// plentiful. So, check the first 5 bytes for 'solid'.
|
||||
// Several encodings, such as UTF-8, precede the text with up to 5 bytes:
|
||||
// https://en.wikipedia.org/wiki/Byte_order_mark#Byte_order_marks_by_encoding
|
||||
// Search for "solid" to start anywhere after those prefixes.
|
||||
// US-ASCII ordinal values for 's', 'o', 'l', 'i', 'd'
|
||||
|
||||
|
||||
const solid = [ 115, 111, 108, 105, 100 ];
|
||||
|
||||
for ( let off = 0; off < 5; off ++ ) {
|
||||
|
||||
// If "solid" text is matched to the current offset, declare it to be an ASCII STL.
|
||||
if ( matchDataViewAt( solid, reader, off ) ) return false;
|
||||
|
||||
} // Couldn't find "solid" text at the beginning; it is binary STL.
|
||||
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function matchDataViewAt( query, reader, offset ) {
|
||||
|
||||
// Check if each byte in query matches the corresponding byte from the current offset
|
||||
for ( let i = 0, il = query.length; i < il; i ++ ) {
|
||||
|
||||
if ( query[ i ] !== reader.getUint8( offset + i, false ) ) return false;
|
||||
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
}
|
||||
|
||||
function parseBinary( data ) {
|
||||
|
||||
const reader = new DataView( data );
|
||||
const faces = reader.getUint32( 80, true );
|
||||
let r,
|
||||
g,
|
||||
b,
|
||||
hasColors = false,
|
||||
colors;
|
||||
let defaultR, defaultG, defaultB, alpha; // process STL header
|
||||
// check for default color in header ("COLOR=rgba" sequence).
|
||||
|
||||
for ( let index = 0; index < 80 - 10; index ++ ) {
|
||||
|
||||
if ( reader.getUint32( index, false ) == 0x434F4C4F
|
||||
/*COLO*/
|
||||
&& reader.getUint8( index + 4 ) == 0x52
|
||||
/*'R'*/
|
||||
&& reader.getUint8( index + 5 ) == 0x3D
|
||||
/*'='*/
|
||||
) {
|
||||
|
||||
hasColors = true;
|
||||
colors = new Float32Array( faces * 3 * 3 );
|
||||
defaultR = reader.getUint8( index + 6 ) / 255;
|
||||
defaultG = reader.getUint8( index + 7 ) / 255;
|
||||
defaultB = reader.getUint8( index + 8 ) / 255;
|
||||
alpha = reader.getUint8( index + 9 ) / 255;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
const dataOffset = 84;
|
||||
const faceLength = 12 * 4 + 2;
|
||||
const geometry = new THREE.BufferGeometry();
|
||||
const vertices = new Float32Array( faces * 3 * 3 );
|
||||
const normals = new Float32Array( faces * 3 * 3 );
|
||||
|
||||
for ( let face = 0; face < faces; face ++ ) {
|
||||
|
||||
const start = dataOffset + face * faceLength;
|
||||
const normalX = reader.getFloat32( start, true );
|
||||
const normalY = reader.getFloat32( start + 4, true );
|
||||
const normalZ = reader.getFloat32( start + 8, true );
|
||||
|
||||
if ( hasColors ) {
|
||||
|
||||
const packedColor = reader.getUint16( start + 48, true );
|
||||
|
||||
if ( ( packedColor & 0x8000 ) === 0 ) {
|
||||
|
||||
// facet has its own unique color
|
||||
r = ( packedColor & 0x1F ) / 31;
|
||||
g = ( packedColor >> 5 & 0x1F ) / 31;
|
||||
b = ( packedColor >> 10 & 0x1F ) / 31;
|
||||
|
||||
} else {
|
||||
|
||||
r = defaultR;
|
||||
g = defaultG;
|
||||
b = defaultB;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
for ( let i = 1; i <= 3; i ++ ) {
|
||||
|
||||
const vertexstart = start + i * 12;
|
||||
const componentIdx = face * 3 * 3 + ( i - 1 ) * 3;
|
||||
vertices[ componentIdx ] = reader.getFloat32( vertexstart, true );
|
||||
vertices[ componentIdx + 1 ] = reader.getFloat32( vertexstart + 4, true );
|
||||
vertices[ componentIdx + 2 ] = reader.getFloat32( vertexstart + 8, true );
|
||||
normals[ componentIdx ] = normalX;
|
||||
normals[ componentIdx + 1 ] = normalY;
|
||||
normals[ componentIdx + 2 ] = normalZ;
|
||||
|
||||
if ( hasColors ) {
|
||||
|
||||
colors[ componentIdx ] = r;
|
||||
colors[ componentIdx + 1 ] = g;
|
||||
colors[ componentIdx + 2 ] = b;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
geometry.setAttribute( 'position', new THREE.BufferAttribute( vertices, 3 ) );
|
||||
geometry.setAttribute( 'normal', new THREE.BufferAttribute( normals, 3 ) );
|
||||
|
||||
if ( hasColors ) {
|
||||
|
||||
geometry.setAttribute( 'color', new THREE.BufferAttribute( colors, 3 ) );
|
||||
geometry.hasColors = true;
|
||||
geometry.alpha = alpha;
|
||||
|
||||
}
|
||||
|
||||
return geometry;
|
||||
|
||||
}
|
||||
|
||||
function parseASCII( data ) {
|
||||
|
||||
const geometry = new THREE.BufferGeometry();
|
||||
const patternSolid = /solid([\s\S]*?)endsolid/g;
|
||||
const patternFace = /facet([\s\S]*?)endfacet/g;
|
||||
let faceCounter = 0;
|
||||
const patternFloat = /[\s]+([+-]?(?:\d*)(?:\.\d*)?(?:[eE][+-]?\d+)?)/.source;
|
||||
const patternVertex = new RegExp( 'vertex' + patternFloat + patternFloat + patternFloat, 'g' );
|
||||
const patternNormal = new RegExp( 'normal' + patternFloat + patternFloat + patternFloat, 'g' );
|
||||
const vertices = [];
|
||||
const normals = [];
|
||||
const normal = new THREE.Vector3();
|
||||
let result;
|
||||
let groupCount = 0;
|
||||
let startVertex = 0;
|
||||
let endVertex = 0;
|
||||
|
||||
while ( ( result = patternSolid.exec( data ) ) !== null ) {
|
||||
|
||||
startVertex = endVertex;
|
||||
const solid = result[ 0 ];
|
||||
|
||||
while ( ( result = patternFace.exec( solid ) ) !== null ) {
|
||||
|
||||
let vertexCountPerFace = 0;
|
||||
let normalCountPerFace = 0;
|
||||
const text = result[ 0 ];
|
||||
|
||||
while ( ( result = patternNormal.exec( text ) ) !== null ) {
|
||||
|
||||
normal.x = parseFloat( result[ 1 ] );
|
||||
normal.y = parseFloat( result[ 2 ] );
|
||||
normal.z = parseFloat( result[ 3 ] );
|
||||
normalCountPerFace ++;
|
||||
|
||||
}
|
||||
|
||||
while ( ( result = patternVertex.exec( text ) ) !== null ) {
|
||||
|
||||
vertices.push( parseFloat( result[ 1 ] ), parseFloat( result[ 2 ] ), parseFloat( result[ 3 ] ) );
|
||||
normals.push( normal.x, normal.y, normal.z );
|
||||
vertexCountPerFace ++;
|
||||
endVertex ++;
|
||||
|
||||
} // every face have to own ONE valid normal
|
||||
|
||||
|
||||
if ( normalCountPerFace !== 1 ) {
|
||||
|
||||
console.error( 'THREE.STLLoader: Something isn\'t right with the normal of face number ' + faceCounter );
|
||||
|
||||
} // each face have to own THREE valid vertices
|
||||
|
||||
|
||||
if ( vertexCountPerFace !== 3 ) {
|
||||
|
||||
console.error( 'THREE.STLLoader: Something isn\'t right with the vertices of face number ' + faceCounter );
|
||||
|
||||
}
|
||||
|
||||
faceCounter ++;
|
||||
|
||||
}
|
||||
|
||||
const start = startVertex;
|
||||
const count = endVertex - startVertex;
|
||||
geometry.addGroup( start, count, groupCount );
|
||||
groupCount ++;
|
||||
|
||||
}
|
||||
|
||||
geometry.setAttribute( 'position', new THREE.Float32BufferAttribute( vertices, 3 ) );
|
||||
geometry.setAttribute( 'normal', new THREE.Float32BufferAttribute( normals, 3 ) );
|
||||
return geometry;
|
||||
|
||||
}
|
||||
|
||||
function ensureString( buffer ) {
|
||||
|
||||
if ( typeof buffer !== 'string' ) {
|
||||
|
||||
return THREE.LoaderUtils.decodeText( new Uint8Array( buffer ) );
|
||||
|
||||
}
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
function ensureBinary( buffer ) {
|
||||
|
||||
if ( typeof buffer === 'string' ) {
|
||||
|
||||
const array_buffer = new Uint8Array( buffer.length );
|
||||
|
||||
for ( let i = 0; i < buffer.length; i ++ ) {
|
||||
|
||||
array_buffer[ i ] = buffer.charCodeAt( i ) & 0xff; // implicitly assumes little-endian
|
||||
|
||||
}
|
||||
|
||||
return array_buffer.buffer || array_buffer;
|
||||
|
||||
} else {
|
||||
|
||||
return buffer;
|
||||
|
||||
}
|
||||
|
||||
} // start
|
||||
|
||||
|
||||
const binData = ensureBinary( data );
|
||||
return isBinary( binData ) ? parseBinary( binData ) : parseASCII( ensureString( data ) );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
THREE.STLLoader = STLLoader;
|
||||
|
||||
} )();
|
||||
7
assets/js/bootstrap.bundle.min.js
vendored
Normal file
7
assets/js/bootstrap.bundle.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
6
assets/js/three.min.js
vendored
Normal file
6
assets/js/three.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
1
assets/js/three.min.js.1
Normal file
1
assets/js/three.min.js.1
Normal file
File diff suppressed because one or more lines are too long
BIN
huey_queue.db
Normal file
BIN
huey_queue.db
Normal file
Binary file not shown.
BIN
huey_queue.db-shm
Normal file
BIN
huey_queue.db-shm
Normal file
Binary file not shown.
BIN
huey_queue.db-wal
Normal file
BIN
huey_queue.db-wal
Normal file
Binary file not shown.
BIN
instance/aio_3d.db
Normal file
BIN
instance/aio_3d.db
Normal file
Binary file not shown.
BIN
instance/aio_3d.db-shm
Normal file
BIN
instance/aio_3d.db-shm
Normal file
Binary file not shown.
BIN
instance/aio_3d.db-wal
Normal file
BIN
instance/aio_3d.db-wal
Normal file
Binary file not shown.
19
parse_presets.py
Normal file
19
parse_presets.py
Normal file
@@ -0,0 +1,19 @@
|
||||
import os
|
||||
import configparser
|
||||
|
||||
def get_quality_presets():
|
||||
preset_dir = os.path.join(os.path.dirname(__file__), 'print_config', 'presets', 'creality', 'base')
|
||||
presets = []
|
||||
if os.path.exists(preset_dir):
|
||||
for f in os.listdir(preset_dir):
|
||||
if f.startswith('base_global_') and f.endswith('.inst.cfg'):
|
||||
config = configparser.ConfigParser()
|
||||
try:
|
||||
config.read(os.path.join(preset_dir, f))
|
||||
name = config.get('general', 'name', fallback=f)
|
||||
presets.append((f, name))
|
||||
except Exception as e:
|
||||
pass
|
||||
return sorted(presets, key=lambda x: x[1])
|
||||
|
||||
print(get_quality_presets())
|
||||
16
print_config/extruders/creality_base_extruder_0.def.json
Normal file
16
print_config/extruders/creality_base_extruder_0.def.json
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"version": 2,
|
||||
"name": "Extruder 1",
|
||||
"inherits": "fdmextruder",
|
||||
"metadata": {
|
||||
"machine": "creality_base",
|
||||
"position": "0"
|
||||
},
|
||||
|
||||
"overrides": {
|
||||
"extruder_nr": { "default_value": 0 },
|
||||
"machine_nozzle_size": { "default_value": 0.4 },
|
||||
"material_diameter": { "default_value": 1.75 }
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_abs
|
||||
variant = 0.2mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*8
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Ultra Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = ultra
|
||||
material = generic_abs
|
||||
variant = 0.2mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*8
|
||||
@@ -0,0 +1,17 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_petg
|
||||
variant = 0.2mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*8
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Ultra Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = ultra
|
||||
material = generic_petg
|
||||
variant = 0.2mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*8
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_pla
|
||||
variant = 0.2mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Ultra Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = ultra
|
||||
material = generic_pla
|
||||
variant = 0.2mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_abs
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
14
print_config/presets/creality/base/base_0.3_ABS_low.inst.cfg
Normal file
14
print_config/presets/creality/base/base_0.3_ABS_low.inst.cfg
Normal file
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Low Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = low
|
||||
material = generic_abs
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_abs
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_abs
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_petg
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Low Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = low
|
||||
material = generic_petg
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_petg
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_petg
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_pla
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
13
print_config/presets/creality/base/base_0.3_PLA_low.inst.cfg
Normal file
13
print_config/presets/creality/base/base_0.3_PLA_low.inst.cfg
Normal file
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Low Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = low
|
||||
material = generic_pla
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_pla
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_pla
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_tpu
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_tpu
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_tpu
|
||||
variant = 0.3mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_abs
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
14
print_config/presets/creality/base/base_0.4_ABS_low.inst.cfg
Normal file
14
print_config/presets/creality/base/base_0.4_ABS_low.inst.cfg
Normal file
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Low Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = low
|
||||
material = generic_abs
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_abs
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_abs
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_petg
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Low Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = low
|
||||
material = generic_petg
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_petg
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_petg
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_pla
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
13
print_config/presets/creality/base/base_0.4_PLA_low.inst.cfg
Normal file
13
print_config/presets/creality/base/base_0.4_PLA_low.inst.cfg
Normal file
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Low Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = low
|
||||
material = generic_pla
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_pla
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_pla
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_tpu
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_tpu
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_tpu
|
||||
variant = 0.4mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_abs
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
14
print_config/presets/creality/base/base_0.5_ABS_low.inst.cfg
Normal file
14
print_config/presets/creality/base/base_0.5_ABS_low.inst.cfg
Normal file
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Low Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = low
|
||||
material = generic_abs
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_abs
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_abs
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*4
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_petg
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Low Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = low
|
||||
material = generic_petg
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_petg
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_petg
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*4
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_pla
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
13
print_config/presets/creality/base/base_0.5_PLA_low.inst.cfg
Normal file
13
print_config/presets/creality/base/base_0.5_PLA_low.inst.cfg
Normal file
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Low Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = low
|
||||
material = generic_pla
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_pla
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_pla
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Dynamic Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = adaptive
|
||||
material = generic_tpu
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_tpu
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Super Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = super
|
||||
material = generic_tpu
|
||||
variant = 0.5mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_abs
|
||||
variant = 0.6mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*3
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_petg
|
||||
variant = 0.6mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*3
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Draft Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = draft
|
||||
material = generic_pla
|
||||
variant = 0.6mm Nozzle
|
||||
|
||||
[values]
|
||||
13
print_config/presets/creality/base/base_0.6_PLA_low.inst.cfg
Normal file
13
print_config/presets/creality/base/base_0.6_PLA_low.inst.cfg
Normal file
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Low Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = low
|
||||
material = generic_pla
|
||||
variant = 0.6mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_pla
|
||||
variant = 0.6mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Standard Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = standard
|
||||
material = generic_tpu
|
||||
variant = 0.6mm Nozzle
|
||||
|
||||
[values]
|
||||
@@ -0,0 +1,14 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Draft Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = draft
|
||||
material = generic_abs
|
||||
variant = 0.8mm Nozzle
|
||||
|
||||
[values]
|
||||
wall_thickness = =line_width*3
|
||||
@@ -0,0 +1,16 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Draft Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = draft
|
||||
material = generic_petg
|
||||
variant = 0.8mm Nozzle
|
||||
|
||||
[values]
|
||||
speed_layer_0 = 15
|
||||
wall_thickness = =line_width*3
|
||||
#retraction_extra_prime_amount = 0.5
|
||||
@@ -0,0 +1,13 @@
|
||||
[general]
|
||||
version = 4
|
||||
name = Draft Quality
|
||||
definition = creality_base
|
||||
|
||||
[metadata]
|
||||
setting_version = 19
|
||||
type = quality
|
||||
quality_type = draft
|
||||
material = generic_pla
|
||||
variant = 0.8mm Nozzle
|
||||
|
||||
[values]
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user