Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Ultimaker/Cura.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaid <daid303@gmail.com>2012-05-11 14:24:27 +0400
committerdaid <daid303@gmail.com>2012-05-11 14:24:27 +0400
commit414f7c0c49080904f410db5ed0e020e2e7ed5416 (patch)
tree6635fb27ded91a23f38e59b5ef9becdb953226d2
parent317b257be18fb5539ad338937d67fbe0e2dfd18a (diff)
parent1591a467afa6ce0e9cf8de8f07637875278023a8 (diff)
Merge branch 'master' of github.com:daid/Cura
-rw-r--r--.gitignore7
-rw-r--r--Cura/LICENSE661
-rw-r--r--Cura/alterations/end.gcode7
-rw-r--r--Cura/alterations/start.gcode20
-rw-r--r--Cura/avr_isp/stk500v2.py1
-rw-r--r--Cura/cura.py5
-rw-r--r--Cura/cura_sf/fabmetheus_utilities/euclidean.py4
-rw-r--r--Cura/cura_sf/fabmetheus_utilities/geometry/solids/triangle_mesh.py5
-rw-r--r--Cura/cura_sf/fabmetheus_utilities/settings.py18
-rw-r--r--Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py41
-rw-r--r--Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/cool.py9
-rw-r--r--Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dimension.py4
-rw-r--r--Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py2
-rw-r--r--Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/raft.py7
-rw-r--r--Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/skirt.py2
-rw-r--r--Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/speed.py2
-rw-r--r--Cura/gui/alterationPanel.py21
-rw-r--r--Cura/gui/configBase.py12
-rw-r--r--Cura/gui/configWizard.py40
-rw-r--r--Cura/gui/expertConfig.py14
-rw-r--r--Cura/gui/gcodeTextArea.py136
-rw-r--r--Cura/gui/machineCom.py14
-rw-r--r--Cura/gui/mainWindow.py133
-rw-r--r--Cura/gui/opengl.py210
-rw-r--r--Cura/gui/preferencesDialog.py19
-rw-r--r--Cura/gui/preview3d.py638
-rw-r--r--Cura/gui/printWindow.py69
-rw-r--r--Cura/gui/projectPlanner.py948
-rw-r--r--Cura/gui/simpleMode.py45
-rw-r--r--Cura/gui/sliceProgessPanel.py151
-rw-r--r--Cura/gui/toolbarUtil.py206
-rw-r--r--Cura/gui/validators.py10
-rw-r--r--Cura/images/autoplace.pngbin0 -> 410 bytes
-rw-r--r--Cura/images/copy.pngbin0 -> 485 bytes
-rw-r--r--Cura/images/exit.pngbin0 -> 713 bytes
-rw-r--r--Cura/images/move-down.pngbin0 -> 623 bytes
-rw-r--r--Cura/images/move-up.pngbin0 -> 672 bytes
-rw-r--r--Cura/images/object-3d-off.pngbin0 -> 50761 bytes
-rw-r--r--Cura/images/object-3d-on.pngbin0 -> 49687 bytes
-rw-r--r--Cura/images/object-add.pngbin0 -> 926 bytes
-rw-r--r--Cura/images/object-max-size.pngbin0 -> 49621 bytes
-rw-r--r--Cura/images/object-mirror-x-off.pngbin0 -> 50390 bytes
-rw-r--r--Cura/images/object-mirror-x-on.pngbin0 -> 50591 bytes
-rw-r--r--Cura/images/object-mirror-y-off.pngbin0 -> 50385 bytes
-rw-r--r--Cura/images/object-mirror-y-on.pngbin0 -> 50469 bytes
-rw-r--r--Cura/images/object-mirror-z-off.pngbin0 -> 50408 bytes
-rw-r--r--Cura/images/object-mirror-z-on.pngbin0 -> 48614 bytes
-rw-r--r--Cura/images/object-mul-x-add.pngbin0 -> 49280 bytes
-rw-r--r--Cura/images/object-mul-x-sub.pngbin0 -> 50961 bytes
-rw-r--r--Cura/images/object-mul-y-add.pngbin0 -> 51479 bytes
-rw-r--r--Cura/images/object-mul-y-sub.pngbin0 -> 51484 bytes
-rw-r--r--Cura/images/object-remove.pngbin0 -> 941 bytes
-rw-r--r--Cura/images/object-rotate.pngbin0 -> 51946 bytes
-rw-r--r--Cura/images/object-scale.pngbin0 -> 52886 bytes
-rw-r--r--Cura/images/object-swap-xz-off.pngbin0 -> 50192 bytes
-rw-r--r--Cura/images/object-swap-xz-on.pngbin0 -> 50936 bytes
-rw-r--r--Cura/images/object-swap-yz-off.pngbin0 -> 50231 bytes
-rw-r--r--Cura/images/object-swap-yz-on.pngbin0 -> 50328 bytes
-rw-r--r--Cura/images/object-top-off.pngbin0 -> 51035 bytes
-rw-r--r--Cura/images/object-top-on.pngbin0 -> 50975 bytes
-rw-r--r--Cura/images/open.pngbin0 -> 423 bytes
-rw-r--r--Cura/images/preferences.pngbin0 -> 690 bytes
-rw-r--r--Cura/images/print-move-home.pngbin0 -> 635 bytes
-rw-r--r--Cura/images/print-move-x-1.pngbin0 -> 561 bytes
-rw-r--r--Cura/images/print-move-x-10.pngbin0 -> 595 bytes
-rw-r--r--Cura/images/print-move-x-100.pngbin0 -> 586 bytes
-rw-r--r--Cura/images/print-move-x1.pngbin0 -> 533 bytes
-rw-r--r--Cura/images/print-move-x10.pngbin0 -> 572 bytes
-rw-r--r--Cura/images/print-move-x100.pngbin0 -> 563 bytes
-rw-r--r--Cura/images/print-move-y-1.pngbin0 -> 620 bytes
-rw-r--r--Cura/images/print-move-y-10.pngbin0 -> 644 bytes
-rw-r--r--Cura/images/print-move-y-100.pngbin0 -> 633 bytes
-rw-r--r--Cura/images/print-move-y1.pngbin0 -> 608 bytes
-rw-r--r--Cura/images/print-move-y10.pngbin0 -> 623 bytes
-rw-r--r--Cura/images/print-move-y100.pngbin0 -> 609 bytes
-rw-r--r--Cura/images/print-move-z-0.1.pngbin0 -> 600 bytes
-rw-r--r--Cura/images/print-move-z-1.pngbin0 -> 577 bytes
-rw-r--r--Cura/images/print-move-z-10.pngbin0 -> 608 bytes
-rw-r--r--Cura/images/print-move-z0.1.pngbin0 -> 588 bytes
-rw-r--r--Cura/images/print-move-z1.pngbin0 -> 559 bytes
-rw-r--r--Cura/images/print-move-z10.pngbin0 -> 593 bytes
-rw-r--r--Cura/images/save.pngbin0 -> 563 bytes
-rw-r--r--Cura/images/set-profile.pngbin0 -> 681 bytes
-rw-r--r--Cura/images/slice.pngbin0 -> 546 bytes
-rw-r--r--Cura/images/view-gcode-off.pngbin0 -> 48526 bytes
-rw-r--r--Cura/images/view-gcode-on.pngbin0 -> 48690 bytes
-rw-r--r--Cura/images/view-mixed-off.pngbin0 -> 49681 bytes
-rw-r--r--Cura/images/view-mixed-on.pngbin0 -> 49869 bytes
-rw-r--r--Cura/images/view-normal-off.pngbin0 -> 49872 bytes
-rw-r--r--Cura/images/view-normal-on.pngbin0 -> 50901 bytes
-rw-r--r--Cura/images/view-transparent-off.pngbin0 -> 53022 bytes
-rw-r--r--Cura/images/view-transparent-on.pngbin0 -> 53417 bytes
-rw-r--r--Cura/images/view-xray-off.pngbin0 -> 52962 bytes
-rw-r--r--Cura/images/view-xray-on.pngbin0 -> 53349 bytes
-rw-r--r--Cura/util/exporer.py26
-rw-r--r--Cura/util/gcodeInterpreter.py53
-rw-r--r--Cura/util/profile.py276
-rw-r--r--Cura/util/sliceRun.py28
-rw-r--r--Cura/util/stl.py15
-rw-r--r--Cura/util/util3d.py9
100 files changed, 3245 insertions, 623 deletions
diff --git a/.gitignore b/.gitignore
index 9b967ebc85..78b5a66955 100644
--- a/.gitignore
+++ b/.gitignore
@@ -12,3 +12,10 @@ Printrun
Cura/current_profile.ini
Cura/preferences.ini
cura.sh
+pypy
+python
+drivers
+printrun.bat
+cura.bat
+object-mirror.png
+object.png
diff --git a/Cura/LICENSE b/Cura/LICENSE
new file mode 100644
index 0000000000..dba13ed2dd
--- /dev/null
+++ b/Cura/LICENSE
@@ -0,0 +1,661 @@
+ GNU AFFERO GENERAL PUBLIC LICENSE
+ Version 3, 19 November 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. <http://fsf.org/>
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+ Preamble
+
+ The GNU Affero General Public License is a free, copyleft license for
+software and other kinds of works, specifically designed to ensure
+cooperation with the community in the case of network server software.
+
+ The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works. By contrast,
+our General Public Licenses are intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.
+
+ When we speak of free software, we are referring to freedom, not
+price. Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+ Developers that use our General Public Licenses protect your rights
+with two steps: (1) assert copyright on the software, and (2) offer
+you this License which gives you legal permission to copy, distribute
+and/or modify the software.
+
+ A secondary benefit of defending all users' freedom is that
+improvements made in alternate versions of the program, if they
+receive widespread use, become available for other developers to
+incorporate. Many developers of free software are heartened and
+encouraged by the resulting cooperation. However, in the case of
+software used on network servers, this result may fail to come about.
+The GNU General Public License permits making a modified version and
+letting the public access it on a server without ever releasing its
+source code to the public.
+
+ The GNU Affero General Public License is designed specifically to
+ensure that, in such cases, the modified source code becomes available
+to the community. It requires the operator of a network server to
+provide the source code of the modified version running there to the
+users of that server. Therefore, public use of a modified version, on
+a publicly accessible server, gives the public access to the source
+code of the modified version.
+
+ An older license, called the Affero General Public License and
+published by Affero, was designed to accomplish similar goals. This is
+a different license, not a version of the Affero GPL, but Affero has
+released a new version of the Affero GPL which permits relicensing under
+this license.
+
+ The precise terms and conditions for copying, distribution and
+modification follow.
+
+ TERMS AND CONDITIONS
+
+ 0. Definitions.
+
+ "This License" refers to version 3 of the GNU Affero General Public License.
+
+ "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+ "The Program" refers to any copyrightable work licensed under this
+License. Each licensee is addressed as "you". "Licensees" and
+"recipients" may be individuals or organizations.
+
+ To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy. The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+ A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+ To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy. Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+ To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies. Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+ An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License. If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+ 1. Source Code.
+
+ The "source code" for a work means the preferred form of the work
+for making modifications to it. "Object code" means any non-source
+form of a work.
+
+ A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+ The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form. A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+ The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities. However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work. For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+ The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+ The Corresponding Source for a work in source code form is that
+same work.
+
+ 2. Basic Permissions.
+
+ All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met. This License explicitly affirms your unlimited
+permission to run the unmodified Program. The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work. This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+ You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force. You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright. Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+ Conveying under any other circumstances is permitted solely under
+the conditions stated below. Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+ 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+ No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+ When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+ 4. Conveying Verbatim Copies.
+
+ You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+ You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+ 5. Conveying Modified Source Versions.
+
+ You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+ a) The work must carry prominent notices stating that you modified
+ it, and giving a relevant date.
+
+ b) The work must carry prominent notices stating that it is
+ released under this License and any conditions added under section
+ 7. This requirement modifies the requirement in section 4 to
+ "keep intact all notices".
+
+ c) You must license the entire work, as a whole, under this
+ License to anyone who comes into possession of a copy. This
+ License will therefore apply, along with any applicable section 7
+ additional terms, to the whole of the work, and all its parts,
+ regardless of how they are packaged. This License gives no
+ permission to license the work in any other way, but it does not
+ invalidate such permission if you have separately received it.
+
+ d) If the work has interactive user interfaces, each must display
+ Appropriate Legal Notices; however, if the Program has interactive
+ interfaces that do not display Appropriate Legal Notices, your
+ work need not make them do so.
+
+ A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit. Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+ 6. Conveying Non-Source Forms.
+
+ You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+ a) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by the
+ Corresponding Source fixed on a durable physical medium
+ customarily used for software interchange.
+
+ b) Convey the object code in, or embodied in, a physical product
+ (including a physical distribution medium), accompanied by a
+ written offer, valid for at least three years and valid for as
+ long as you offer spare parts or customer support for that product
+ model, to give anyone who possesses the object code either (1) a
+ copy of the Corresponding Source for all the software in the
+ product that is covered by this License, on a durable physical
+ medium customarily used for software interchange, for a price no
+ more than your reasonable cost of physically performing this
+ conveying of source, or (2) access to copy the
+ Corresponding Source from a network server at no charge.
+
+ c) Convey individual copies of the object code with a copy of the
+ written offer to provide the Corresponding Source. This
+ alternative is allowed only occasionally and noncommercially, and
+ only if you received the object code with such an offer, in accord
+ with subsection 6b.
+
+ d) Convey the object code by offering access from a designated
+ place (gratis or for a charge), and offer equivalent access to the
+ Corresponding Source in the same way through the same place at no
+ further charge. You need not require recipients to copy the
+ Corresponding Source along with the object code. If the place to
+ copy the object code is a network server, the Corresponding Source
+ may be on a different server (operated by you or a third party)
+ that supports equivalent copying facilities, provided you maintain
+ clear directions next to the object code saying where to find the
+ Corresponding Source. Regardless of what server hosts the
+ Corresponding Source, you remain obligated to ensure that it is
+ available for as long as needed to satisfy these requirements.
+
+ e) Convey the object code using peer-to-peer transmission, provided
+ you inform other peers where the object code and Corresponding
+ Source of the work are being offered to the general public at no
+ charge under subsection 6d.
+
+ A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+ A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling. In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage. For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product. A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+ "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source. The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+ If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information. But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+ The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed. Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+ Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+ 7. Additional Terms.
+
+ "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law. If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+ When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it. (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.) You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+ Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+ a) Disclaiming warranty or limiting liability differently from the
+ terms of sections 15 and 16 of this License; or
+
+ b) Requiring preservation of specified reasonable legal notices or
+ author attributions in that material or in the Appropriate Legal
+ Notices displayed by works containing it; or
+
+ c) Prohibiting misrepresentation of the origin of that material, or
+ requiring that modified versions of such material be marked in
+ reasonable ways as different from the original version; or
+
+ d) Limiting the use for publicity purposes of names of licensors or
+ authors of the material; or
+
+ e) Declining to grant rights under trademark law for use of some
+ trade names, trademarks, or service marks; or
+
+ f) Requiring indemnification of licensors and authors of that
+ material by anyone who conveys the material (or modified versions of
+ it) with contractual assumptions of liability to the recipient, for
+ any liability that these contractual assumptions directly impose on
+ those licensors and authors.
+
+ All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10. If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term. If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+ If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+ Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+ 8. Termination.
+
+ You may not propagate or modify a covered work except as expressly
+provided under this License. Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+ However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+ Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+ Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License. If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+ 9. Acceptance Not Required for Having Copies.
+
+ You are not required to accept this License in order to receive or
+run a copy of the Program. Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance. However,
+nothing other than this License grants you permission to propagate or
+modify any covered work. These actions infringe copyright if you do
+not accept this License. Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+ 10. Automatic Licensing of Downstream Recipients.
+
+ Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License. You are not responsible
+for enforcing compliance by third parties with this License.
+
+ An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations. If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+ You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License. For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+ 11. Patents.
+
+ A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based. The
+work thus licensed is called the contributor's "contributor version".
+
+ A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version. For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+ Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+ In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement). To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+ If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients. "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+ If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+ A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License. You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+ Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+ 12. No Surrender of Others' Freedom.
+
+ If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License. If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all. For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+ 13. Remote Network Interaction; Use with the GNU General Public License.
+
+ Notwithstanding any other provision of this License, if you modify the
+Program, your modified version must prominently offer all users
+interacting with it remotely through a computer network (if your version
+supports such interaction) an opportunity to receive the Corresponding
+Source of your version by providing access to the Corresponding Source
+from a network server at no charge, through some standard or customary
+means of facilitating copying of software. This Corresponding Source
+shall include the Corresponding Source for any work covered by version 3
+of the GNU General Public License that is incorporated pursuant to the
+following paragraph.
+
+ Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU General Public License into a single
+combined work, and to convey the resulting work. The terms of this
+License will continue to apply to the part which is the covered work,
+but the work with which it is combined will remain governed by version
+3 of the GNU General Public License.
+
+ 14. Revised Versions of this License.
+
+ The Free Software Foundation may publish revised and/or new versions of
+the GNU Affero General Public License from time to time. Such new versions
+will be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+ Each version is given a distinguishing version number. If the
+Program specifies that a certain numbered version of the GNU Affero General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation. If the Program does not specify a version number of the
+GNU Affero General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+ If the Program specifies that a proxy can decide which future
+versions of the GNU Affero General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+ Later license versions may give you additional or different
+permissions. However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+ 15. Disclaimer of Warranty.
+
+ THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+ 16. Limitation of Liability.
+
+ IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+ 17. Interpretation of Sections 15 and 16.
+
+ If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+ END OF TERMS AND CONDITIONS
+
+ How to Apply These Terms to Your New Programs
+
+ If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+ To do so, attach the following notices to the program. It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+ <one line to give the program's name and a brief idea of what it does.>
+ Copyright (C) <year> <name of author>
+
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU Affero General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU Affero General Public License for more details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>.
+
+Also add information on how to contact you by electronic and paper mail.
+
+ If your software can interact with users remotely through a computer
+network, you should also make sure that it provides a way for users to
+get its source. For example, if your program is a web application, its
+interface could display a "Source" link that leads users to an archive
+of the code. There are many ways you could offer source, and different
+solutions will be better for different programs; see section 13 for the
+specific requirements.
+
+ You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU AGPL, see
+<http://www.gnu.org/licenses/>.
diff --git a/Cura/alterations/end.gcode b/Cura/alterations/end.gcode
deleted file mode 100644
index 4061667ec4..0000000000
--- a/Cura/alterations/end.gcode
+++ /dev/null
@@ -1,7 +0,0 @@
-M104 S0 ;extruder heat off
-G91 ;relative positioning
-G1 Z+10 E-5 F400 ;move Z up a bit and retract filament by 5mm
-G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
-M84 ;steppers off
-G90 ;absolute positioning
-
diff --git a/Cura/alterations/start.gcode b/Cura/alterations/start.gcode
deleted file mode 100644
index 7db5699cfd..0000000000
--- a/Cura/alterations/start.gcode
+++ /dev/null
@@ -1,20 +0,0 @@
-G21 ;metric values
-G90 ;absolute positioning
-
-G28 X0 Y0 ;move X/Y to min endstops
-G28 Z0 ;move Z to min endstops
-
-; if your prints start too high, try changing the Z0.0 below
-; to Z1.0 - the number after the Z is the actual, physical
-; height of the nozzle in mm. This can take some messing around
-; with to get just right...
-G92 X0 Y0 Z0 E0 ;reset software position to front/left/z=0.0
-G1 Z15.0 F400 ;move the platform down 15mm
-G92 E0 ;zero the extruded length
-
-G1 F75 E5 ;extrude 5mm of feed stock
-G1 F75 E3.5 ;reverse feed stock by 1.5mm
-G92 E0 ;zero the extruded length again
-
-G1 X100 Y100 F3500 ;go to the middle of the platform
-G1 Z0.0 F400 ;back to Z=0 and start the print!
diff --git a/Cura/avr_isp/stk500v2.py b/Cura/avr_isp/stk500v2.py
index e076e669c2..58991b59c6 100644
--- a/Cura/avr_isp/stk500v2.py
+++ b/Cura/avr_isp/stk500v2.py
@@ -24,6 +24,7 @@ class Stk500v2(ispBase.IspBase):
#Reset the controller
self.serial.setDTR(1)
+ time.sleep(0.1)
self.serial.setDTR(0)
time.sleep(0.2)
diff --git a/Cura/cura.py b/Cura/cura.py
index b65ac355ae..14dc53b1e5 100644
--- a/Cura/cura.py
+++ b/Cura/cura.py
@@ -46,10 +46,15 @@ __license__ = 'GNU Affero General Public License http://www.gnu.org/licenses/agp
def main():
parser = OptionParser(usage="usage: %prog [options] <filename>.stl")
parser.add_option("-p", "--profile", action="store", type="string", dest="profile", help="Use these profile settings instead of loading current_profile.ini")
+ parser.add_option("-P", "--project", action="store_true", dest="openprojectplanner", help="Open the project planner")
parser.add_option("-r", "--print", action="store", type="string", dest="printfile", help="Open the printing interface, instead of the normal cura interface.")
(options, args) = parser.parse_args()
if options.profile != None:
profile.loadGlobalProfileFromString(options.profile)
+ if options.openprojectplanner != None:
+ from gui import projectPlanner
+ projectPlanner.main()
+ return
if options.printfile != None:
from gui import printWindow
printWindow.startPrintInterface(options.printfile)
diff --git a/Cura/cura_sf/fabmetheus_utilities/euclidean.py b/Cura/cura_sf/fabmetheus_utilities/euclidean.py
index 24708e0258..f9c3148394 100644
--- a/Cura/cura_sf/fabmetheus_utilities/euclidean.py
+++ b/Cura/cura_sf/fabmetheus_utilities/euclidean.py
@@ -882,7 +882,7 @@ def getHalfSimplifiedLoop( loop, radius, remainder ):
'Get the loop with half of the points inside the channel removed.'
if len(loop) < 2:
return loop
- channelRadius = radius * .01
+ channelRadius = abs(radius * .01)
simplified = []
addIndex = 0
if remainder == 1:
@@ -899,7 +899,7 @@ def getHalfSimplifiedPath(path, radius, remainder):
'Get the path with half of the points inside the channel removed.'
if len(path) < 2:
return path
- channelRadius = radius * .01
+ channelRadius = abs(radius * .01)
simplified = [path[0]]
for pointIndex in xrange(1, len(path) - 1):
point = path[pointIndex]
diff --git a/Cura/cura_sf/fabmetheus_utilities/geometry/solids/triangle_mesh.py b/Cura/cura_sf/fabmetheus_utilities/geometry/solids/triangle_mesh.py
index 0cfffdcc51..550f400689 100644
--- a/Cura/cura_sf/fabmetheus_utilities/geometry/solids/triangle_mesh.py
+++ b/Cura/cura_sf/fabmetheus_utilities/geometry/solids/triangle_mesh.py
@@ -448,7 +448,8 @@ def getLoopsFromCorrectMesh( edges, faces, vertexes, z ):
p0 = loop[-1]
for p1 in loop:
if euclidean.isLineIntersectingLoops(loops[idx+1:], p0, p1):
- print('Warning, the triangle mesh slice intersects itself in getLoopsFromCorrectMesh in triangle_mesh.')
+ if not warning:
+ print('Warning, the triangle mesh slice intersects itself in getLoopsFromCorrectMesh in triangle_mesh.')
print('Model error(intersect): (%f, %f, %f) (%f, %f, %f)' % (p0.real, p0.imag, z, p1.real, p1.imag, z))
warning = True
p0 = p1
@@ -823,7 +824,7 @@ class TriangleMesh( group.Group ):
halfHeight = 0.5 * self.layerHeight
self.zoneArrangement = ZoneArrangement(self.layerHeight, self.getTransformedVertexes())
layerTop = self.cornerMaximum.z - halfHeight * 0.5
- z = self.cornerMinimum.z + halfHeight
+ z = halfHeight
layerCount = int((layerTop - z) / self.layerHeight) + 1
while z < layerTop:
getLoopLayerAppend(self.loopLayers, layerCount, z).loops = self.getLoopsFromMesh(self.zoneArrangement.getEmptyZ(z))
diff --git a/Cura/cura_sf/fabmetheus_utilities/settings.py b/Cura/cura_sf/fabmetheus_utilities/settings.py
index f95c2d28a4..f5d76296cd 100644
--- a/Cura/cura_sf/fabmetheus_utilities/settings.py
+++ b/Cura/cura_sf/fabmetheus_utilities/settings.py
@@ -113,6 +113,9 @@ def getProfileInformation():
'SwapYZ': storedSetting("swap_yz"),
'Scale': storedSettingFloat("model_scale"),
'Rotate': storedSettingFloat("model_rotate_base"),
+ 'CenterX': storedSettingFloat("machine_center_x"),
+ 'CenterY': storedSettingFloat("machine_center_y"),
+ 'AlternativeCenterFile': storedSetting("alternative_center"),
},'scale': {
'Activate_Scale': "False",
'XY_Plane_Scale_ratio': DEFSET,
@@ -125,8 +128,8 @@ def getProfileInformation():
'SVG_Viewer': DEFSET,
},'preface': {
'Meta': DEFSET,
- 'Set_Positioning_to_Absolute': DEFSET,
- 'Set_Units_to_Millimeters': DEFSET,
+ 'Set_Positioning_to_Absolute': "False",
+ 'Set_Units_to_Millimeters': "False",
'Start_at_Home': DEFSET,
'Turn_Extruder_Off_at_Shut_Down': DEFSET,
'Turn_Extruder_Off_at_Start_Up': DEFSET,
@@ -135,11 +138,11 @@ def getProfileInformation():
'Widen_Width_over_Edge_Width_ratio': DEFSET,
},'inset': {
'Add_Custom_Code_for_Temperature_Reading': "False",
- 'Infill_in_Direction_of_Bridge': "True",
+ 'Infill_in_Direction_of_Bridge': ifSettingAboveZero('fill_density'),
'Infill_Width': storedSettingFloat("nozzle_size"),
'Loop_Order_Choice': DEFSET,
'Overlap_Removal_Width_over_Perimeter_Width_ratio': DEFSET,
- 'Turn_Extruder_Heater_Off_at_Shut_Down': DEFSET,
+ 'Turn_Extruder_Heater_Off_at_Shut_Down': "False",
'Volume_Fraction_ratio': DEFSET,
},'fill': {
'Activate_Fill': "True",
@@ -171,7 +174,7 @@ def getProfileInformation():
'Surrounding_Angle_degrees': DEFSET,
'Thread_Sequence_Choice': storedSetting('sequence'),
},'multiply': {
- 'Activate_Multiply': "True",
+ 'Activate_Multiply': "False",
'Center_X_mm': storedSettingFloat("machine_center_x"),
'Center_Y_mm': storedSettingFloat("machine_center_y"),
'Number_of_Columns_integer': storedSetting('model_multiply_x'),
@@ -237,6 +240,7 @@ def getProfileInformation():
'Support_Gap_over_Perimeter_Extrusion_Width_ratio': calcSupportDistanceRatio,
'Support_Material_Choice_': storedSetting('support'),
'Support_Minimum_Angle_degrees': DEFSET,
+ 'Support_Margin_mm': storedSettingFloat('support_margin'),
},'skirt': {
'Skirt_line_count': storedSetting("skirt_line_count"),
'Convex': "True",
@@ -379,7 +383,7 @@ def getProfileInformation():
'Retraction_Distance_millimeters': storedSettingFloat('retraction_amount'),
'Restart_Extra_Distance_millimeters': storedSettingFloat('retraction_extra'),
},'alteration': {
- 'Activate_Alteration': "True",
+ 'Activate_Alteration': storedSetting('add_start_end_gcode'),
'Name_of_End_File': "end.gcode",
'Name_of_Start_File': "start.gcode",
'Remove_Redundant_Mcode': "True",
@@ -398,7 +402,7 @@ def getProfileInformation():
'gcode_step': DEFSET,
'gcode_time_segment': DEFSET,
'gcode_small': DEFSET,
- 'File_Extension': DEFSET,
+ 'File_Extension': storedSetting('gcode_extension'),
'Name_of_Replace_File': DEFSET,
'Save_Penultimate_Gcode': "False",
}
diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py
index ae949b3daa..b3ad845e30 100644
--- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py
+++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/carve.py
@@ -185,8 +185,11 @@ class CarveRepository:
self.flipZ = settings.BooleanSetting().getFromValue('FlipZ', self, False)
self.swapXZ = settings.BooleanSetting().getFromValue('SwapXZ', self, False)
self.swapYZ = settings.BooleanSetting().getFromValue('SwapYZ', self, False)
+ self.centerX = settings.FloatSpin().getFromValue(0.0, 'CenterX', self, 1000.0, 0.0)
+ self.centerY = settings.FloatSpin().getFromValue(0.0, 'CenterY', self, 1000.0, 0.0)
self.scale = settings.FloatSpin().getFromValue( 0.1, 'Scale', self, 10.0, 1.0 )
self.rotate = settings.FloatSpin().getFromValue( -180.0, 'Rotate', self, 180.0, 0.0 )
+ self.alternativeCenter = settings.StringSetting().getFromValue('AlternativeCenterFile', self, '')
def execute(self):
@@ -219,16 +222,6 @@ class CarveSkein:
mat10 = math.sin(rotate) * scaleX
mat11 = math.cos(rotate) * scaleY
- minZ = carving.getMinimumZ()
- minSize = carving.getCarveCornerMinimum()
- maxSize = carving.getCarveCornerMaximum()
- for v in carving.vertexes:
- v.z -= minZ
- v.x -= minSize.x + (maxSize.x - minSize.x) / 2
- v.y -= minSize.y + (maxSize.y - minSize.y) / 2
- #v.x += self.machineCenter.x
- #v.y += self.machineCenter.y
-
for i in xrange(0, len(carving.vertexes)):
x = carving.vertexes[i].x
y = carving.vertexes[i].y
@@ -242,6 +235,34 @@ class CarveSkein:
x * mat10 + y * mat11,
z * scaleZ)
+ if repository.alternativeCenter.value != '':
+ carving2 = svg_writer.getCarving(repository.alternativeCenter.value)
+ for i in xrange(0, len(carving2.vertexes)):
+ x = carving2.vertexes[i].x
+ y = carving2.vertexes[i].y
+ z = carving2.vertexes[i].z
+ if swapXZ:
+ x, z = z, x
+ if swapYZ:
+ y, z = z, y
+ carving2.vertexes[i] = Vector3(
+ x * mat00 + y * mat01,
+ x * mat10 + y * mat11,
+ z * scaleZ)
+ minZ = carving2.getMinimumZ()
+ minSize = carving2.getCarveCornerMinimum()
+ maxSize = carving2.getCarveCornerMaximum()
+ else:
+ minZ = carving.getMinimumZ()
+ minSize = carving.getCarveCornerMinimum()
+ maxSize = carving.getCarveCornerMaximum()
+ for v in carving.vertexes:
+ v.z -= minZ
+ v.x -= minSize.x + (maxSize.x - minSize.x) / 2
+ v.y -= minSize.y + (maxSize.y - minSize.y) / 2
+ v.x += repository.centerX.value
+ v.y += repository.centerY.value
+
layerHeight = repository.layerHeight.value
edgeWidth = repository.edgeWidth.value
carving.setCarveLayerHeight(layerHeight)
diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/cool.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/cool.py
index 5a4f54916e..eb363a8cdd 100644
--- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/cool.py
+++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/cool.py
@@ -223,6 +223,8 @@ class CoolSkein:
def addCoolTemperature(self, remainingOrbitTime):
'Parse a gcode line and add it to the cool skein.'
+ if self.repository.minimumLayerTime.value < 0.0001:
+ return
layerCool = self.repository.maximumCool.value * remainingOrbitTime / self.repository.minimumLayerTime.value
if self.isBridgeLayer:
layerCool = max(self.repository.bridgeCool.value, layerCool)
@@ -404,9 +406,10 @@ class CoolSkein:
def setMultiplier(self, remainingOrbitTime):
'Set the feed and flow rate multiplier.'
layerTimeActive = self.getLayerTimeActive()
- self.multiplier = min(1.0, layerTimeActive / (remainingOrbitTime + layerTimeActive))
-
-
+ if remainingOrbitTime + layerTimeActive > 0.00001:
+ self.multiplier = min(1.0, layerTimeActive / (remainingOrbitTime + layerTimeActive))
+ else:
+ self.multiplier = 1.0
def main():
'Display the cool dialog.'
diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dimension.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dimension.py
index ce89001e4d..cf8f6bed58 100644
--- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dimension.py
+++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/dimension.py
@@ -387,6 +387,10 @@ class DimensionSkein:
elif firstWord == '(<layer>':
self.layerIndex += 1
settings.printProgress(self.layerIndex, 'dimension')
+ elif firstWord == '(</layer>)':
+ if self.totalExtrusionDistance > 0.0 and not self.repository.relativeExtrusionDistance.value:
+ self.distanceFeedRate.addLine('G92 E0')
+ self.totalExtrusionDistance = 0.0
elif firstWord == 'M101':
if self.addRetraction:
self.addLinearMoveExtrusionDistanceLine(self.restartDistance * self.retractionRatio)
diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py
index 00e255405d..62c18e2aff 100644
--- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py
+++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/export_plugins/static_plugins/gcode_small.py
@@ -92,6 +92,8 @@ class GcodeSmallSkein:
return
if firstWord[0] == '(':
return
+ if firstWord == 'M108' or firstWord == 'M113':
+ return
if firstWord != 'G1':
self.output.write(line + '\n')
return
diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/raft.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/raft.py
index 1fc1c868f1..8de6c3d38d 100644
--- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/raft.py
+++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/raft.py
@@ -400,6 +400,8 @@ class RaftRepository:
self.supportChoiceExteriorOnly = settings.MenuRadio().getFromMenuButtonDisplay(self.supportMaterialChoice, 'Exterior Only', self, False)
self.supportMinimumAngle = settings.FloatSpin().getFromValue(40.0, 'Support Minimum Angle (degrees):', self, 80.0, 60.0)
self.executeTitle = 'Raft'
+ self.supportMargin = settings.FloatSpin().getFromValue(
+ 1.0, 'Support Margin (mm):', self, 5.0, 3.0)
def execute(self):
'Raft button has been clicked.'
@@ -596,6 +598,7 @@ class RaftSkein:
self.cornerMinimumComplex = self.cornerMinimum.dropAxis()
originalExtent = self.cornerMaximumComplex - self.cornerMinimumComplex
self.raftOutsetRadius = self.repository.raftMargin.value + self.repository.raftAdditionalMarginOverLengthPercent.value * 0.01 * max(originalExtent.real, originalExtent.imag)
+ self.supportOutsetRadius = self.repository.supportMargin.value
self.setBoundaryLayers()
outsetSeparateLoops = intercircle.getInsetSeparateLoopsFromLoops(self.boundaryLayers[0].loops, -self.raftOutsetRadius, 0.8)
self.interfaceIntersectionsTable = {}
@@ -711,7 +714,7 @@ class RaftSkein:
if self.layerIndex == 0:
feedRateMinuteMultiplied *= self.objectFirstLayerFeedRateInfillMultiplier
if supportFlowRateMultiplied != None:
- supportFlowRateMultiplied *= self.objectFirstLayerFlowRateInfillMultiplier
+ supportFlowRateMultiplied = self.operatingFlowRate * self.objectFirstLayerFlowRateInfillMultiplier
self.addFlowRate(supportFlowRateMultiplied)
for path in paths:
self.distanceFeedRate.addGcodeFromFeedRateThreadZ(feedRateMinuteMultiplied, path, self.travelFeedRateMinute, z)
@@ -1035,7 +1038,7 @@ class RaftSkein:
euclidean.joinXIntersectionsTables(aboveXIntersectionsTable, xIntersectionsTable)
for supportLayerIndex in xrange(len(self.supportLayers)):
supportLayer = self.supportLayers[supportLayerIndex]
- self.extendXIntersections(supportLayer.supportLoops, self.raftOutsetRadius, supportLayer.xIntersectionsTable)
+ self.extendXIntersections(supportLayer.supportLoops, self.supportOutsetRadius, supportLayer.xIntersectionsTable)
for supportLayer in self.supportLayers:
euclidean.subtractXIntersectionsTable(supportLayer.xIntersectionsTable, supportLayer.fillXIntersectionsTable)
self.addSegmentTablesToSupportLayers()
diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/skirt.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/skirt.py
index 4a87d47134..51f3549c5b 100644
--- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/skirt.py
+++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/skirt.py
@@ -171,6 +171,8 @@ class SkirtSkein:
def addSkirt(self, z):
'At skirt at z to gcode output.'
+ if len(self.outsetLoops) < 1 or len(self.outsetLoops[0]) < 1:
+ return
self.setSkirtFeedFlowTemperature()
self.distanceFeedRate.addLine('(<skirt>)')
oldTemperature = self.oldTemperatureInput
diff --git a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/speed.py b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/speed.py
index cac112ef34..0653f57ff1 100644
--- a/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/speed.py
+++ b/Cura/cura_sf/skeinforge_application/skeinforge_plugins/craft_plugins/speed.py
@@ -312,7 +312,7 @@ class SpeedSkein:
self.distanceFeedRate.addTagBracketedLine('objectFirstLayerFeedRateInfillMultiplier', self.repository.objectFirstLayerFeedRateInfillMultiplier.value)
self.distanceFeedRate.addTagBracketedLine('operatingFeedRatePerSecond', self.feedRatePerSecond )
if self.repository.addFlowRate.value:
- self.distanceFeedRate.addTagBracketedLine('objectFirstLayerFlowRateInfillMultiplier', self.repository.objectFirstLayerFlowRateInfillMultiplier.value)
+ self.distanceFeedRate.addTagBracketedLine('objectFirstLayerFlowRateInfillMultiplier', self.repository.objectFirstLayerFlowRateInfillMultiplier.value * self.repository.bottomLayerFlowRateMultiplier.value)
self.distanceFeedRate.addTagBracketedLine('operatingFlowRate', self.repository.flowRateSetting.value )
orbitalFeedRatePerSecond = self.feedRatePerSecond * self.repository.orbitalFeedRateOverOperatingFeedRate.value
self.distanceFeedRate.addTagBracketedLine('orbitalFeedRatePerSecond', orbitalFeedRatePerSecond )
diff --git a/Cura/gui/alterationPanel.py b/Cura/gui/alterationPanel.py
index 2692b7fad3..c47772d72e 100644
--- a/Cura/gui/alterationPanel.py
+++ b/Cura/gui/alterationPanel.py
@@ -1,21 +1,26 @@
-import wx
+import wx,wx.stc
import sys,math,threading,os
+from gui import gcodeTextArea
from util import profile
class alterationPanel(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent,-1)
- self.alterationFileList = ['start.gcode', 'end.gcode', 'support_start.gcode', 'support_end.gcode', 'replace.csv']
+ self.alterationFileList = ['start.gcode', 'end.gcode', 'support_start.gcode', 'support_end.gcode', 'nextobject.gcode', 'replace.csv']
+ if int(profile.getPreference('extruder_amount')) > 1:
+ self.alterationFileList.append('switchExtruder.gcode')
self.currentFile = None
- self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB)
- self.textArea.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
+ #self.textArea = wx.TextCtrl(self, style=wx.TE_MULTILINE|wx.TE_DONTWRAP|wx.TE_PROCESS_TAB)
+ #self.textArea.SetFont(wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL))
+ self.textArea = gcodeTextArea.GcodeTextArea(self)
self.list = wx.ListBox(self, choices=self.alterationFileList, style=wx.LB_SINGLE)
self.list.SetSelection(0)
self.Bind(wx.EVT_LISTBOX, self.OnSelect, self.list)
self.textArea.Bind(wx.EVT_KILL_FOCUS, self.OnFocusLost, self.textArea)
+ self.textArea.Bind(wx.stc.EVT_STC_CHANGE, self.OnFocusLost, self.textArea)
sizer = wx.GridBagSizer()
sizer.Add(self.list, (0,0), span=(1,1), flag=wx.EXPAND)
@@ -32,11 +37,9 @@ class alterationPanel(wx.Panel):
self.currentFile = self.list.GetSelection()
def loadFile(self, filename):
- self.textArea.SetValue(unicode(profile.getAlterationFileContents(filename, False), "utf-8"))
+ self.textArea.SetValue(profile.getAlterationFile(filename))
def OnFocusLost(self, e):
if self.currentFile == self.list.GetSelection():
- filename = profile.getAlterationFilePath(self.alterationFileList[self.list.GetSelection()])
- f = open(filename, "wb")
- f.write(self.textArea.GetValue().encode("utf-8"))
- f.close()
+ profile.setAlterationFile(self.alterationFileList[self.list.GetSelection()], self.textArea.GetValue())
+
diff --git a/Cura/gui/configBase.py b/Cura/gui/configBase.py
index aeaaaf87d5..79a7d24875 100644
--- a/Cura/gui/configBase.py
+++ b/Cura/gui/configBase.py
@@ -64,7 +64,7 @@ class configWindowBase(wx.Frame):
self.popup.text.SetLabel(setting.helpText)
self.popup.text.Wrap(350)
self.popup.Fit()
- if os.name == 'darwin':
+ if sys.platform == 'darwin':
x, y = self.ClientToScreenXY(0, 0)
sx, sy = self.GetClientSizeTuple()
else:
@@ -189,10 +189,6 @@ class settingNotify():
self.func = func
def validate(self):
- try:
- f = float(self.setting.GetValue())
- self.func(f)
- return validators.SUCCESS, ''
- except ValueError:
- self.func()
- return validators.SUCCESS, ''
+ self.func()
+ return validators.SUCCESS, ''
+
diff --git a/Cura/gui/configWizard.py b/Cura/gui/configWizard.py
index 151a083951..5efd633937 100644
--- a/Cura/gui/configWizard.py
+++ b/Cura/gui/configWizard.py
@@ -97,7 +97,6 @@ class MachineSelectPage(InfoPage):
profile.putPreference('machine_width', '205')
profile.putPreference('machine_depth', '205')
profile.putPreference('machine_height', '200')
- profile.putPreference('steps_per_e', '865.888')
profile.putProfileSetting('nozzle_size', '0.4')
profile.putProfileSetting('machine_center_x', '100')
profile.putProfileSetting('machine_center_y', '100')
@@ -175,17 +174,24 @@ class UltimakerCheckupPage(InfoPage):
def OnRun(self):
wx.CallAfter(self.AddProgressText, "Connecting to machine...")
self.comm = machineCom.MachineCom()
+
+ if not self.comm.isOpen():
+ wx.CallAfter(self.AddProgressText, "Error: Failed to open serial port to machine")
+ wx.CallAfter(self.AddProgressText, "If this keeps happening, try disconnecting and reconnecting the USB cable")
+ return
wx.CallAfter(self.AddProgressText, "Checking start message...")
if self.DoCommCommandWithTimeout(None, 'start') == False:
wx.CallAfter(self.AddProgressText, "Error: Missing start message.")
self.comm.close()
return
-
+
+ #Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found.
+ time.sleep(3)
+
wx.CallAfter(self.AddProgressText, "Disabling step motors...")
if self.DoCommCommandWithTimeout('M84') == False:
wx.CallAfter(self.AddProgressText, "Error: Missing reply to Deactivate steppers (M84).")
- wx.CallAfter(self.AddProgressText, "Possible cause: Temperature MIN/MAX.\nCheck temperature sensor connections.")
self.comm.close()
return
@@ -287,9 +293,10 @@ class UltimakerCheckupPage(InfoPage):
t.start()
while True:
line = self.comm.readline()
- if line == '':
+ if line == '' or line == None:
self.comm.close()
return False
+ print line.rstrip()
if line.startswith(replyStart):
break
t.cancel()
@@ -323,6 +330,9 @@ class UltimakerCalibrationPage(InfoPage):
class UltimakerCalibrateStepsPerEPage(InfoPage):
def __init__(self, parent):
super(UltimakerCalibrateStepsPerEPage, self).__init__(parent, "Ultimaker Calibration")
+
+ if profile.getPreference('steps_per_e') == '0':
+ profile.putPreference('steps_per_e', '865.888')
self.AddText("Calibrating the Steps Per E requires some manual actions.")
self.AddText("First remove any filament from your machine.")
@@ -364,12 +374,20 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
self.extrudeButton.Enable(False)
currentEValue = float(self.stepsPerEInput.GetValue())
self.comm = machineCom.MachineCom()
+ if not self.comm.isOpen():
+ wx.MessageBox("Error: Failed to open serial port to machine\nIf this keeps happening, try disconnecting and reconnecting the USB cable", 'Printer error', wx.OK | wx.ICON_INFORMATION)
+ self.heatButton.Enable(True)
+ self.extrudeButton.Enable(True)
+ return
while True:
line = self.comm.readline()
if line == '':
return
if line.startswith('start'):
break
+ #Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found.
+ time.sleep(3)
+
self.sendGCommand('M302') #Disable cold extrusion protection
self.sendGCommand("M92 E%f" % (currentEValue));
self.sendGCommand("G92 E0");
@@ -383,18 +401,32 @@ class UltimakerCalibrateStepsPerEPage(InfoPage):
threading.Thread(target=self.OnHeatRun).start()
def OnHeatRun(self):
+ self.heatButton.Enable(False)
+ self.extrudeButton.Enable(False)
self.comm = machineCom.MachineCom()
+ if not self.comm.isOpen():
+ wx.MessageBox("Error: Failed to open serial port to machine\nIf this keeps happening, try disconnecting and reconnecting the USB cable", 'Printer error', wx.OK | wx.ICON_INFORMATION)
+ self.heatButton.Enable(True)
+ self.extrudeButton.Enable(True)
+ return
while True:
line = self.comm.readline()
if line == '':
+ self.heatButton.Enable(True)
+ self.extrudeButton.Enable(True)
return
if line.startswith('start'):
break
+ #Wait 3 seconds for the SD card init to timeout if we have SD in our firmware but there is no SD card found.
+ time.sleep(3)
+
self.sendGCommand('M104 S200') #Set the temperature to 200C, should be enough to get PLA and ABS out.
wx.MessageBox('Wait till you can remove the filament from the machine, and press OK.\n(Temperature is set to 200C)', 'Machine heatup', wx.OK | wx.ICON_INFORMATION)
self.sendGCommand('M104 S0')
time.sleep(1)
self.comm.close()
+ self.heatButton.Enable(True)
+ self.extrudeButton.Enable(True)
def sendGCommand(self, cmd):
self.comm.sendCommand(cmd) #Disable cold extrusion protection
diff --git a/Cura/gui/expertConfig.py b/Cura/gui/expertConfig.py
index 786c587f04..8c2f9cf4cd 100644
--- a/Cura/gui/expertConfig.py
+++ b/Cura/gui/expertConfig.py
@@ -26,23 +26,25 @@ class expertConfigWindow(configBase.configWindowBase):
configBase.TitleRow(left, "Cool")
c = configBase.SettingRow(left, "Minimum feedrate (mm/s)", 'cool_min_feedrate', '5', 'The minimal layer time can cause the print to slow down so much it starts to ooze. The minimal feedrate protects against this. Even if a print gets slown down it will never be slower then this minimal feedrate.')
validators.validFloat(c, 0.0)
- c = configBase.SettingRow(left, "Fan on layer number", 'fan_layer', '0', 'The layer at which the fan is turned on. The first layer is layer 0.')
+ c = configBase.SettingRow(left, "Fan on layer number", 'fan_layer', '0', 'The layer at which the fan is turned on. The first layer is layer 0. The first layer can stick better if you turn on the fan on, on the 2nd layer.')
validators.validInt(c, 0)
c = configBase.SettingRow(left, "Fan speed (%)", 'fan_speed', '100', 'When the fan is turned on, it is enabled at this speed setting.')
validators.validInt(c, 0, 100)
configBase.TitleRow(left, "Raft (if enabled)")
- c = configBase.SettingRow(left, "Raft extra margin (mm)", 'raft_margin', '3.0', 'If the raft is enabled, this is the extra raft area around the object which is also rafted. Increasing this margin will create a stronger raft.')
+ c = configBase.SettingRow(left, "Extra margin (mm)", 'raft_margin', '3.0', 'If the raft is enabled, this is the extra raft area around the object which is also rafted. Increasing this margin will create a stronger raft.')
validators.validFloat(c, 0.0)
- c = configBase.SettingRow(left, "Raft base material amount (%)", 'raft_base_material_amount', '100', 'The base layer is the first layer put down as a raft. This layer has thick strong lines and is put firmly on the bed to prevent warping. This setting adjust the amount of material used for the base layer.')
+ c = configBase.SettingRow(left, "Base material amount (%)", 'raft_base_material_amount', '100', 'The base layer is the first layer put down as a raft. This layer has thick strong lines and is put firmly on the bed to prevent warping. This setting adjust the amount of material used for the base layer.')
validators.validFloat(c, 0.0)
- c = configBase.SettingRow(left, "Raft interface material amount (%)", 'raft_interface_material_amount', '100', 'The interface layer is a weak thin layer between the base layer and the printed object. It is designed to has little material to make it easy to break the base off the printed object. This setting adjusts the amount of material used for the interface layer.')
+ c = configBase.SettingRow(left, "Interface material amount (%)", 'raft_interface_material_amount', '100', 'The interface layer is a weak thin layer between the base layer and the printed object. It is designed to has little material to make it easy to break the base off the printed object. This setting adjusts the amount of material used for the interface layer.')
validators.validFloat(c, 0.0)
configBase.TitleRow(left, "Support")
- c = configBase.SettingRow(left, "Support material amount (%)", 'support_rate', '100', 'Amount of material used for support, less material gives a weaker support structure which is easier to remove.')
+ c = configBase.SettingRow(left, "Material amount (%)", 'support_rate', '100', 'Amount of material used for support, less material gives a weaker support structure which is easier to remove.')
validators.validFloat(c, 0.0)
- c = configBase.SettingRow(left, "Support distance from object (mm)", 'support_distance', '0.5', 'Distance between the support structure and the object.')
+ c = configBase.SettingRow(left, "Distance from object (mm)", 'support_distance', '0.5', 'Distance between the support structure and the object. Empty gap in which no support structure is printed.')
+ validators.validFloat(c, 0.0)
+ c = configBase.SettingRow(left, "Extra margin (mm)", 'support_margin', '3.0', 'Extra margin which is used to extend the support lines outwards. A margin of 0 generates support structure only directly underneath the model.')
validators.validFloat(c, 0.0)
configBase.TitleRow(right, "Infill")
diff --git a/Cura/gui/gcodeTextArea.py b/Cura/gui/gcodeTextArea.py
new file mode 100644
index 0000000000..8cdb482ab4
--- /dev/null
+++ b/Cura/gui/gcodeTextArea.py
@@ -0,0 +1,136 @@
+import wx, wx.stc
+import sys,math,os
+
+from util import profile
+
+class GcodeTextArea(wx.stc.StyledTextCtrl):
+ def __init__(self, parent):
+ super(GcodeTextArea, self).__init__(parent)
+
+ self.SetLexer(wx.stc.STC_LEX_CONTAINER)
+ self.Bind(wx.stc.EVT_STC_STYLENEEDED, self.OnStyle)
+
+ fontSize = wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize()
+ fontName = wx.Font(wx.SystemSettings.GetFont(wx.SYS_ANSI_VAR_FONT).GetPointSize(), wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL).GetFaceName()
+ self.SetStyleBits(5)
+ self.StyleSetSpec(0, "face:%s,size:%d" % (fontName, fontSize))
+ self.StyleSetSpec(1, "fore:#006000,face:%s,size:%d" % (fontName, fontSize))
+ self.IndicatorSetStyle(0, wx.stc.STC_INDIC_TT)
+ self.IndicatorSetForeground(0, "#0000FF")
+ self.IndicatorSetStyle(1, wx.stc.STC_INDIC_SQUIGGLE)
+ self.IndicatorSetForeground(1, "#FF0000")
+ self.SetWrapMode(wx.stc.STC_WRAP_NONE)
+ self.SetScrollWidth(1000)
+ if sys.platform == 'darwin':
+ self.Bind(wx.EVT_KEY_DOWN, self.OnMacKeyDown)
+
+ #GCodes and MCodes as supported by Marlin
+ #GCode 21 is not really supported by Marlin, but we still do not report it as error as it's often used.
+ self.supportedGCodes = [0,1,2,3,4,21,28,90,91,92]
+ self.supportedMCodes = [17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,42,80,81,82,83,84,85,92,104,105,106,107,109,114,115,117,119,140,190,201,202,203,204,205,206,220,221,240,301,302,303,400,500,501,502,503,999]
+
+ def OnMacKeyDown(self, e):
+ code = e.GetKeyCode();
+ stopPropagation = True
+ #Command
+ if e.CmdDown():
+ if code == wx._core.WXK_LEFT:
+ self.GotoLine(self.GetCurrentLine())
+ elif code == wx._core.WXK_RIGHT:
+ self.GotoPos(self.GetLineEndPosition(self.GetCurrentLine()))
+ elif code == wx._core.WXK_UP:
+ self.GotoPos(0)
+ elif code == wx._core.WXK_DOWN:
+ self.GotoPos(self.GetLength())
+ else:
+ stopPropagation = False
+ # Control
+ elif e.GetModifiers() & 0xF0:
+ if code == 65: # A
+ self.GotoLine(self.GetCurrentLine())
+ elif code == 69: # E
+ self.GotoPos(self.GetLineEndPosition(self.GetCurrentLine()))
+ else:
+ stopPropagation = False
+ else:
+ stopPropagation = False
+ # Event propagation
+ if stopPropagation:
+ e.StopPropagation()
+ else:
+ e.Skip()
+
+ def OnStyle(self, e):
+ lineNr = self.LineFromPosition(self.GetEndStyled())
+ while self.PositionFromLine(lineNr) > -1:
+ line = self.GetLine(lineNr)
+ start = self.PositionFromLine(lineNr)
+ length = self.LineLength(lineNr)
+ self.StartStyling(start, 255)
+ self.SetStyling(length, 0)
+ if ';' in line:
+ pos = line.index(';')
+ self.StartStyling(start + pos, 31)
+ self.SetStyling(length - pos, 1)
+ length = pos
+
+ pos = 0
+ while pos < length:
+ if line[pos] in " \t\n\r":
+ while pos < length and line[pos] in " \t\n\r":
+ pos += 1
+ else:
+ end = pos
+ while end < length and not line[end] in " \t\n\r":
+ end += 1
+ if self.checkGCodePart(line[pos:end], start + pos):
+ self.StartStyling(start + pos, 0x20)
+ self.SetStyling(end - pos, 0x20)
+ pos = end
+ lineNr += 1
+
+ def checkGCodePart(self, part, pos):
+ if len(part) < 2:
+ self.StartStyling(pos, 0x40)
+ self.SetStyling(1, 0x40)
+ return True
+ if not part[0] in "GMXYZFESTBPIDCJ":
+ self.StartStyling(pos, 0x40)
+ self.SetStyling(1, 0x40)
+ return True
+ if part[1] == '{':
+ if part[-1] != '}':
+ return True
+ tag = part[2:-1]
+ if not profile.isProfileSetting(tag) and not profile.isPreference(tag):
+ self.StartStyling(pos + 2, 0x40)
+ self.SetStyling(len(tag), 0x40)
+ return True
+ elif part[0] in "GM":
+ try:
+ code = int(part[1:])
+ except (ValueError):
+ self.StartStyling(pos + 1, 0x40)
+ self.SetStyling(len(part) - 1, 0x40)
+ return True
+ if part[0] == 'G':
+ if not code in self.supportedGCodes:
+ return True
+ if part[0] == 'M':
+ if not code in self.supportedMCodes:
+ return True
+ else:
+ try:
+ float(part[1:])
+ except (ValueError):
+ self.StartStyling(pos + 1, 0x40)
+ self.SetStyling(len(part) - 1, 0x40)
+ return True
+ return False
+
+ def GetValue(self):
+ return self.GetText()
+
+ def SetValue(self, s):
+ self.SetText(s)
+
diff --git a/Cura/gui/machineCom.py b/Cura/gui/machineCom.py
index 5157fbe87d..6e6e7e4315 100644
--- a/Cura/gui/machineCom.py
+++ b/Cura/gui/machineCom.py
@@ -153,12 +153,15 @@ class MachineCom():
programmer = stk500v2.Stk500v2()
for port in serialList():
try:
+ print "Connecting to: %s %i" % (port, baudrate)
programmer.connect(port)
programmer.close()
- print "Connecting to: %s %i" % (port, baudrate)
+ time.sleep(1)
self.serial = Serial(port, baudrate, timeout=2)
break
- except ispBase.IspError:
+ except ispBase.IspError as (e):
+ print "Error while connecting to %s %i" % (port, baudrate)
+ print e
pass
except:
print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0]
@@ -170,6 +173,7 @@ class MachineCom():
self.serial = Serial(port, baudrate, timeout=2)
except:
print "Unexpected error while connecting to serial port:" + port, sys.exc_info()[0]
+ print self.serial
def readline(self):
if self.serial == None:
@@ -184,6 +188,12 @@ class MachineCom():
self.serial.close()
self.serial = None
+ def __del__(self):
+ self.close()
+
+ def isOpen(self):
+ return self.serial != None
+
def sendCommand(self, cmd):
if self.serial == None:
return
diff --git a/Cura/gui/mainWindow.py b/Cura/gui/mainWindow.py
index 261f6402fe..d4b8f55f70 100644
--- a/Cura/gui/mainWindow.py
+++ b/Cura/gui/mainWindow.py
@@ -14,6 +14,7 @@ from gui import configWizard
from gui import machineCom
from gui import printWindow
from gui import simpleMode
+from gui import projectPlanner
from gui import icon
from util import profile
from util import version
@@ -40,7 +41,7 @@ class mainWindow(configBase.configWindowBase):
menubar = wx.MenuBar()
fileMenu = wx.Menu()
i = fileMenu.Append(-1, 'Load model file...')
- self.Bind(wx.EVT_MENU, self.OnLoadModel, i)
+ self.Bind(wx.EVT_MENU, lambda e: self._showModelLoadDialog(1), i)
fileMenu.AppendSeparator()
i = fileMenu.Append(-1, 'Open Profile...')
self.Bind(wx.EVT_MENU, self.OnLoadProfile, i)
@@ -50,12 +51,15 @@ class mainWindow(configBase.configWindowBase):
i = fileMenu.Append(-1, 'Preferences...')
self.Bind(wx.EVT_MENU, self.OnPreferences, i)
fileMenu.AppendSeparator()
+ i = fileMenu.Append(-1, 'Open project planner...')
+ self.Bind(wx.EVT_MENU, self.OnProjectPlanner, i)
+ fileMenu.AppendSeparator()
i = fileMenu.Append(wx.ID_EXIT, 'Quit')
self.Bind(wx.EVT_MENU, self.OnQuit, i)
menubar.Append(fileMenu, '&File')
simpleMenu = wx.Menu()
- i = simpleMenu.Append(-1, 'Switch to simple mode...')
+ i = simpleMenu.Append(-1, 'Switch to Quickprint...')
self.Bind(wx.EVT_MENU, self.OnSimpleSwitch, i)
menubar.Append(simpleMenu, 'Simple')
@@ -80,8 +84,11 @@ class mainWindow(configBase.configWindowBase):
menubar.Append(helpMenu, 'Help')
self.SetMenuBar(menubar)
- self.lastPath = ""
- self.filename = profile.getPreference('lastFile')
+ if profile.getPreference('lastFile') != '':
+ self.filelist = profile.getPreference('lastFile').split(';')
+ self.SetTitle(self.filelist[-1] + ' - Cura - ' + version.getVersion())
+ else:
+ self.filelist = []
self.progressPanelList = []
#Preview window
@@ -107,7 +114,7 @@ class mainWindow(configBase.configWindowBase):
validators.validFloat(c, 0.0, 100.0)
configBase.TitleRow(left, "Skirt")
- c = configBase.SettingRow(left, "Line count", 'skirt_line_count', '1', 'The skirt is a line drawn around the object at the first layer. This helps to prime your extruder, and to see if the object fits on your platform.\nSetting this to 0 will disable the skirt.')
+ c = configBase.SettingRow(left, "Line count", 'skirt_line_count', '1', 'The skirt is a line drawn around the object at the first layer. This helps to prime your extruder, and to see if the object fits on your platform.\nSetting this to 0 will disable the skirt. Multiple skirt lines can help priming your extruder better for small objects.')
validators.validInt(c, 0, 10)
c = configBase.SettingRow(left, "Start distance (mm)", 'skirt_gap', '6.0', 'The distance between the skirt and the first layer.\nThis is the minimal distance, multiple skirt lines will be put outwards from this distance.')
validators.validFloat(c, 0.0)
@@ -124,7 +131,7 @@ class mainWindow(configBase.configWindowBase):
validators.warningAbove(c, 260.0, "Temperatures above 260C could damage your machine, be careful!")
configBase.TitleRow(right, "Support")
- c = configBase.SettingRow(right, "Support type", 'support', ['None', 'Exterior Only', 'Everywhere', 'Empty Layers Only'], 'Type of support structure build.\nNone does not do any support.\nExterior only only creates support on the outside.\nEverywhere creates support even on the insides of the model.\nOnly on empty layers is for stacked objects.')
+ c = configBase.SettingRow(right, "Support type", 'support', ['None', 'Exterior Only', 'Everywhere', 'Empty Layers Only'], 'Type of support structure build.\n"Exterior only" is the most commonly used support setting.\n\nNone does not do any support.\nExterior only only creates support on the outside.\nEverywhere creates support even on the insides of the model.\nOnly on empty layers is for stacked objects.')
c = configBase.SettingRow(right, "Add raft", 'enable_raft', False, 'A raft is a few layers of lines below the bottom of the object. It prevents warping. Full raft settings can be found in the expert settings.\nFor PLA this is usually not required. But if you print with ABS it is almost required.')
configBase.TitleRow(right, "Filament")
@@ -149,18 +156,18 @@ class mainWindow(configBase.configWindowBase):
configBase.TitleRow(left, "Retraction")
c = configBase.SettingRow(left, "Minimal travel (mm)", 'retraction_min_travel', '5.0', 'Minimal amount of travel needed for a retraction to happen at all. To make sure you do not get a lot of retractions in a small area')
validators.validFloat(c, 0.0)
- c = configBase.SettingRow(left, "Speed (mm/s)", 'retraction_speed', '13.5', 'Speed at which the filament is retracted')
+ c = configBase.SettingRow(left, "Speed (mm/s)", 'retraction_speed', '40.0', 'Speed at which the filament is retracted, a higher retraction speed works better. But a very high retraction speed can lead to filament grinding.')
validators.validFloat(c, 0.1)
- c = configBase.SettingRow(left, "Distance (mm)", 'retraction_amount', '0.0', 'Amount of retraction, set at 0 for no retraction at all.')
+ c = configBase.SettingRow(left, "Distance (mm)", 'retraction_amount', '0.0', 'Amount of retraction, set at 0 for no retraction at all. A value of 2.0mm seems to generate good results.')
validators.validFloat(c, 0.0)
- c = configBase.SettingRow(left, "Extra length on start (mm)", 'retraction_extra', '0.0', 'Extra extrusion amount when restarting after a retraction, to better "Prime" your extruder')
+ c = configBase.SettingRow(left, "Extra length on start (mm)", 'retraction_extra', '0.0', 'Extra extrusion amount when restarting after a retraction, to better "Prime" your extruder after retraction.')
validators.validFloat(c, 0.0)
configBase.TitleRow(right, "Speed")
- c = configBase.SettingRow(right, "Travel speed (mm/s)", 'travel_speed', '150', 'Speed at which travel moves are done')
+ c = configBase.SettingRow(right, "Travel speed (mm/s)", 'travel_speed', '150', 'Speed at which travel moves are done, a high quality build Ultimaker can reach speeds of 250mm/s. But some machines might miss steps then.')
validators.validFloat(c, 1.0)
- validators.warningAbove(c, 300.0, "It is highly unlikely that your machine can achieve a travel speed above 150mm/s")
- c = configBase.SettingRow(right, "Max Z speed (mm/s)", 'max_z_speed', '1.0', 'Speed at which Z moves are done.')
+ validators.warningAbove(c, 300.0, "It is highly unlikely that your machine can achieve a travel speed above 300mm/s")
+ c = configBase.SettingRow(right, "Max Z speed (mm/s)", 'max_z_speed', '1.0', 'Speed at which Z moves are done. When you Z axis is properly lubercated you can increase this for less Z blob.')
validators.validFloat(c, 0.5)
c = configBase.SettingRow(right, "Bottom layer speed (mm/s)", 'bottom_layer_speed', '25', 'Print speed for the bottom layer, you want to print the first layer slower so it sticks better to the printer bed.')
validators.validFloat(c, 0.0)
@@ -182,27 +189,44 @@ class mainWindow(configBase.configWindowBase):
loadButton = wx.Button(self, -1, 'Load Model')
sliceButton = wx.Button(self, -1, 'Slice to GCode')
printButton = wx.Button(self, -1, 'Print GCode')
- self.Bind(wx.EVT_BUTTON, self.OnLoadModel, loadButton)
+ self.Bind(wx.EVT_BUTTON, lambda e: self._showModelLoadDialog(1), loadButton)
self.Bind(wx.EVT_BUTTON, self.OnSlice, sliceButton)
self.Bind(wx.EVT_BUTTON, self.OnPrint, printButton)
+
+ extruderCount = int(profile.getPreference('extruder_amount'))
+ if extruderCount > 1:
+ loadButton2 = wx.Button(self, -1, 'Load Dual')
+ self.Bind(wx.EVT_BUTTON, lambda e: self._showModelLoadDialog(2), loadButton2)
+ if extruderCount > 2:
+ loadButton3 = wx.Button(self, -1, 'Load Tripple')
+ self.Bind(wx.EVT_BUTTON, lambda e: self._showModelLoadDialog(3), loadButton3)
+ if extruderCount > 2:
+ loadButton4 = wx.Button(self, -1, 'Load Quad')
+ self.Bind(wx.EVT_BUTTON, lambda e: self._showModelLoadDialog(4), loadButton4)
+
#Also bind double clicking the 3D preview to load an STL file.
- self.preview3d.glCanvas.Bind(wx.EVT_LEFT_DCLICK, self.OnLoadModel, self.preview3d.glCanvas)
+ self.preview3d.glCanvas.Bind(wx.EVT_LEFT_DCLICK, lambda e: self._showModelLoadDialog(1), self.preview3d.glCanvas)
#Main sizer, to position the preview window, buttons and tab control
sizer = wx.GridBagSizer()
self.SetSizer(sizer)
sizer.Add(nb, (0,0), span=(1,1), flag=wx.EXPAND)
- sizer.Add(self.preview3d, (0,1), span=(1,3), flag=wx.EXPAND)
- sizer.AddGrowableCol(2)
+ sizer.Add(self.preview3d, (0,1), span=(1,2+extruderCount), flag=wx.EXPAND)
+ sizer.AddGrowableCol(2 + extruderCount)
sizer.AddGrowableRow(0)
sizer.Add(loadButton, (1,1), flag=wx.RIGHT, border=5)
- sizer.Add(sliceButton, (1,2), flag=wx.RIGHT, border=5)
- sizer.Add(printButton, (1,3), flag=wx.RIGHT, border=5)
+ if extruderCount > 1:
+ sizer.Add(loadButton2, (1,2), flag=wx.RIGHT, border=5)
+ if extruderCount > 2:
+ sizer.Add(loadButton3, (1,3), flag=wx.RIGHT, border=5)
+ if extruderCount > 3:
+ sizer.Add(loadButton4, (1,4), flag=wx.RIGHT, border=5)
+ sizer.Add(sliceButton, (1,1+extruderCount), flag=wx.RIGHT, border=5)
+ sizer.Add(printButton, (1,2+extruderCount), flag=wx.RIGHT, border=5)
self.sizer = sizer
- if self.filename != "None":
- self.preview3d.loadModelFile(self.filename)
- self.lastPath = os.path.split(self.filename)[0]
+ if len(self.filelist) > 0:
+ self.preview3d.loadModelFiles(self.filelist)
self.updateProfileToControls()
@@ -212,21 +236,19 @@ class mainWindow(configBase.configWindowBase):
self.Show(True)
def OnLoadProfile(self, e):
- dlg=wx.FileDialog(self, "Select profile file to load", self.lastPath, style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
+ dlg=wx.FileDialog(self, "Select profile file to load", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard("ini files (*.ini)|*.ini")
if dlg.ShowModal() == wx.ID_OK:
profileFile = dlg.GetPath()
- self.lastPath = os.path.split(profileFile)[0]
profile.loadGlobalProfile(profileFile)
self.updateProfileToControls()
dlg.Destroy()
def OnSaveProfile(self, e):
- dlg=wx.FileDialog(self, "Select profile file to save", self.lastPath, style=wx.FD_SAVE)
+ dlg=wx.FileDialog(self, "Select profile file to save", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
dlg.SetWildcard("ini files (*.ini)|*.ini")
if dlg.ShowModal() == wx.ID_OK:
profileFile = dlg.GetPath()
- self.lastPath = os.path.split(profileFile)[0]
profile.saveGlobalProfile(profileFile)
dlg.Destroy()
@@ -244,7 +266,7 @@ class mainWindow(configBase.configWindowBase):
machineCom.InstallFirmware(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../firmware/default.hex"))
def OnCustomFirmware(self, e):
- dlg=wx.FileDialog(self, "Open firmware to upload", self.lastPath, style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
+ dlg=wx.FileDialog(self, "Open firmware to upload", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX")
if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetPath()
@@ -257,25 +279,49 @@ class mainWindow(configBase.configWindowBase):
configWizard.configWizard()
self.updateProfileToControls()
- def OnLoadModel(self, e):
- dlg=wx.FileDialog(self, "Open file to print", self.lastPath, style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
- dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")
+ def _showOpenDialog(self, title, wildcard = "STL files (*.stl)|*.stl;*.STL"):
+ dlg=wx.FileDialog(self, title, os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
+ dlg.SetWildcard(wildcard)
if dlg.ShowModal() == wx.ID_OK:
- self.filename=dlg.GetPath()
- profile.putPreference('lastFile', self.filename)
- if not(os.path.exists(self.filename)):
- return
- self.lastPath = os.path.split(self.filename)[0]
- self.preview3d.loadModelFile(self.filename)
- self.preview3d.setViewMode("Model - Normal")
+ filename = dlg.GetPath()
+ dlg.Destroy()
+ if not(os.path.exists(filename)):
+ return False
+ profile.putPreference('lastFile', filename)
+ return filename
dlg.Destroy()
+ return False
+
+ def _showModelLoadDialog(self, amount):
+ filelist = []
+ for i in xrange(0, amount):
+ filelist.append(self._showOpenDialog("Open file to print"))
+ if filelist[-1] == False:
+ return
+ self.SetTitle(filelist[-1] + ' - Cura - ' + version.getVersion())
+ self.filelist = filelist
+ profile.putPreference('lastFile', ';'.join(self.filelist))
+ self.preview3d.loadModelFiles(self.filelist)
+ self.preview3d.setViewMode("Normal")
+
+ def OnLoadModel(self, e):
+ self._showModelLoadDialog(1)
+
+ def OnLoadModel2(self, e):
+ self._showModelLoadDialog(2)
+
+ def OnLoadModel3(self, e):
+ self._showModelLoadDialog(3)
+
+ def OnLoadModel4(self, e):
+ self._showModelLoadDialog(4)
def OnSlice(self, e):
- if self.filename == None:
+ if len(self.filelist) < 1:
wx.MessageBox('You need to load a file before you can slice it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
return
#Create a progress panel and add it to the window. The progress panel will start the Skein operation.
- spp = sliceProgessPanel.sliceProgessPanel(self, self, self.filename)
+ spp = sliceProgessPanel.sliceProgessPanel(self, self, self.filelist)
self.sizer.Add(spp, (len(self.progressPanelList)+2,0), span=(1,4), flag=wx.EXPAND)
self.sizer.Layout()
newSize = self.GetSize();
@@ -284,18 +330,23 @@ class mainWindow(configBase.configWindowBase):
self.progressPanelList.append(spp)
def OnPrint(self, e):
- if self.filename == None:
+ if len(self.filelist) < 1:
wx.MessageBox('You need to load a file and slice it before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
return
- if not os.path.exists(self.filename[: self.filename.rfind('.')] + "_export.gcode"):
+ if not os.path.exists(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode"):
wx.MessageBox('You need to slice the file to GCode before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
return
- printWindow.printFile(self.filename[: self.filename.rfind('.')] + "_export.gcode")
+ printWindow.printFile(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode")
def OnExpertOpen(self, e):
ecw = expertConfig.expertConfigWindow()
ecw.Centre()
ecw.Show(True)
+
+ def OnProjectPlanner(self, e):
+ pp = projectPlanner.projectPlanner()
+ pp.Centre()
+ pp.Show(True)
def removeSliceProgress(self, spp):
self.progressPanelList.remove(spp)
diff --git a/Cura/gui/opengl.py b/Cura/gui/opengl.py
index 583b141437..e5204cff69 100644
--- a/Cura/gui/opengl.py
+++ b/Cura/gui/opengl.py
@@ -1,3 +1,7 @@
+import math
+
+from util import util3d
+from util import profile
try:
import OpenGL
@@ -17,7 +21,9 @@ def InitGL(window, view3D, zoom):
glViewport(0,0, size.GetWidth(), size.GetHeight())
glLightfv(GL_LIGHT0, GL_POSITION, [1.0, 1.0, 1.0, 0.0])
+ glLightfv(GL_LIGHT1, GL_POSITION, [1.0, 1.0, 1.0, 0.0])
+ glEnable(GL_NORMALIZE)
glEnable(GL_LIGHTING)
glEnable(GL_LIGHT0)
glEnable(GL_DEPTH_TEST)
@@ -32,7 +38,7 @@ def InitGL(window, view3D, zoom):
glLoadIdentity()
aspect = float(size.GetWidth()) / float(size.GetHeight())
if view3D:
- gluPerspective(90.0, aspect, 1.0, 1000.0)
+ gluPerspective(45.0, aspect, 1.0, 1000.0)
else:
glOrtho(-aspect, aspect, -1, 1, -1000.0, 1000.0)
@@ -77,7 +83,128 @@ def DrawMachine(machineSize):
glVertex3f(0, machineSize.y, machineSize.z)
glEnd()
+ glPushMatrix()
+ glTranslate(-5,-5,0)
+ glLineWidth(2)
+ glColor3f(0.5,0,0)
+ glBegin(GL_LINES)
+ glVertex3f(0,0,0)
+ glVertex3f(20,0,0)
+ glEnd()
+ glColor3f(0,0.5,0)
+ glBegin(GL_LINES)
+ glVertex3f(0,0,0)
+ glVertex3f(0,20,0)
+ glEnd()
+ glColor3f(0,0,0.5)
+ glBegin(GL_LINES)
+ glVertex3f(0,0,0)
+ glVertex3f(0,0,20)
+ glEnd()
+
+ glDisable(GL_DEPTH_TEST)
+ #X
+ glColor3f(1,0,0)
+ glPushMatrix()
+ glTranslate(23,0,0)
+ noZ = ResetMatrixRotationAndScale()
+ glBegin(GL_LINES)
+ glVertex3f(-0.8,1,0)
+ glVertex3f(0.8,-1,0)
+ glVertex3f(0.8,1,0)
+ glVertex3f(-0.8,-1,0)
+ glEnd()
+ glPopMatrix()
+
+ #Y
+ glColor3f(0,1,0)
+ glPushMatrix()
+ glTranslate(0,23,0)
+ ResetMatrixRotationAndScale()
+ glBegin(GL_LINES)
+ glVertex3f(-0.8, 1,0)
+ glVertex3f( 0.0, 0,0)
+ glVertex3f( 0.8, 1,0)
+ glVertex3f(-0.8,-1,0)
+ glEnd()
+ glPopMatrix()
+
+ #Z
+ if not noZ:
+ glColor3f(0,0,1)
+ glPushMatrix()
+ glTranslate(0,0,23)
+ ResetMatrixRotationAndScale()
+ glBegin(GL_LINES)
+ glVertex3f(-0.8, 1,0)
+ glVertex3f( 0.8, 1,0)
+ glVertex3f( 0.8, 1,0)
+ glVertex3f(-0.8,-1,0)
+ glVertex3f(-0.8,-1,0)
+ glVertex3f( 0.8,-1,0)
+ glEnd()
+ glPopMatrix()
+
+ glPopMatrix()
+ glEnable(GL_DEPTH_TEST)
+
+def ResetMatrixRotationAndScale():
+ matrix = glGetFloatv(GL_MODELVIEW_MATRIX)
+ noZ = False
+ if matrix[3][2] > 0:
+ return False
+ scale2D = matrix[0][0]
+ matrix[0][0] = 1.0
+ matrix[1][0] = 0.0
+ matrix[2][0] = 0.0
+ matrix[0][1] = 0.0
+ matrix[1][1] = 1.0
+ matrix[2][1] = 0.0
+ matrix[0][2] = 0.0
+ matrix[1][2] = 0.0
+ matrix[2][2] = 1.0
+
+ if matrix[3][2] != 0.0:
+ matrix[3][0] /= -matrix[3][2] / 100
+ matrix[3][1] /= -matrix[3][2] / 100
+ matrix[3][2] = -100
+ else:
+ matrix[0][0] = scale2D
+ matrix[1][1] = scale2D
+ matrix[2][2] = scale2D
+ matrix[3][2] = -100
+ noZ = True
+
+ glLoadMatrixf(matrix)
+ return noZ
+
+def DrawBox(vMin, vMax):
+ glBegin(GL_LINE_LOOP)
+ glVertex3f(vMin.x, vMin.y, vMin.z)
+ glVertex3f(vMax.x, vMin.y, vMin.z)
+ glVertex3f(vMax.x, vMax.y, vMin.z)
+ glVertex3f(vMin.x, vMax.y, vMin.z)
+ glEnd()
+
+ glBegin(GL_LINE_LOOP)
+ glVertex3f(vMin.x, vMin.y, vMax.z)
+ glVertex3f(vMax.x, vMin.y, vMax.z)
+ glVertex3f(vMax.x, vMax.y, vMax.z)
+ glVertex3f(vMin.x, vMax.y, vMax.z)
+ glEnd()
+ glBegin(GL_LINES)
+ glVertex3f(vMin.x, vMin.y, vMin.z)
+ glVertex3f(vMin.x, vMin.y, vMax.z)
+ glVertex3f(vMax.x, vMin.y, vMin.z)
+ glVertex3f(vMax.x, vMin.y, vMax.z)
+ glVertex3f(vMax.x, vMax.y, vMin.z)
+ glVertex3f(vMax.x, vMax.y, vMax.z)
+ glVertex3f(vMin.x, vMax.y, vMin.z)
+ glVertex3f(vMin.x, vMax.y, vMax.z)
+ glEnd()
+
def DrawSTL(mesh):
+ glEnable(GL_CULL_FACE)
for face in mesh.faces:
glBegin(GL_TRIANGLES)
v1 = face.v[0]
@@ -92,3 +219,84 @@ def DrawSTL(mesh):
glVertex3f(v3.x, v3.y, v3.z)
glVertex3f(v2.x, v2.y, v2.z)
glEnd()
+
+def DrawGCodeLayer(layer):
+ filamentRadius = profile.getProfileSettingFloat('filament_diameter') / 2
+ filamentArea = math.pi * filamentRadius * filamentRadius
+ lineWidth = profile.getProfileSettingFloat('nozzle_size') / 2 / 10
+
+ fillCycle = 0
+ fillColorCycle = [[0.5,0.5,0.0],[0.0,0.5,0.5],[0.5,0.0,0.5]]
+
+ glDisable(GL_CULL_FACE)
+ for path in layer:
+ if path.type == 'move':
+ glColor3f(0,0,1)
+ if path.type == 'extrude':
+ if path.pathType == 'FILL':
+ glColor3fv(fillColorCycle[fillCycle])
+ fillCycle = (fillCycle + 1) % len(fillColorCycle)
+ elif path.pathType == 'WALL-INNER':
+ glColor3fv([0,1,0])
+ elif path.pathType == 'SUPPORT':
+ glColor3fv([0,1,1])
+ elif path.pathType == 'SKIRT':
+ glColor3fv([0,0.5,0.5])
+ else:
+ glColor3fv([1,0,0])
+ if path.type == 'retract':
+ glColor3fv([0,1,1])
+ if path.type == 'extrude':
+ drawLength = 0.0
+ prevNormal = None
+ for i in xrange(0, len(path.list)-1):
+ v0 = path.list[i]
+ v1 = path.list[i+1]
+
+ # Calculate line width from ePerDistance (needs layer thickness and filament diameter)
+ dist = (v0 - v1).vsize()
+ if dist > 0 and path.layerThickness > 0:
+ extrusionMMperDist = (v1.e - v0.e) / dist
+ lineWidth = extrusionMMperDist * filamentArea / path.layerThickness / 2
+
+ drawLength += (v0 - v1).vsize()
+ normal = (v0 - v1).cross(util3d.Vector3(0,0,1))
+ normal.normalize()
+
+ vv2 = v0 + normal * lineWidth
+ vv3 = v1 + normal * lineWidth
+ vv0 = v0 - normal * lineWidth
+ vv1 = v1 - normal * lineWidth
+
+ glBegin(GL_QUADS)
+ glVertex3f(vv0.x, vv0.y, vv0.z - 0.01)
+ glVertex3f(vv1.x, vv1.y, vv1.z - 0.01)
+ glVertex3f(vv3.x, vv3.y, vv3.z - 0.01)
+ glVertex3f(vv2.x, vv2.y, vv2.z - 0.01)
+ glEnd()
+ if prevNormal != None:
+ n = (normal + prevNormal)
+ n.normalize()
+ vv4 = v0 + n * lineWidth
+ vv5 = v0 - n * lineWidth
+ glBegin(GL_QUADS)
+ glVertex3f(vv2.x, vv2.y, vv2.z)
+ glVertex3f(vv4.x, vv4.y, vv4.z)
+ glVertex3f(prevVv3.x, prevVv3.y, prevVv3.z)
+ glVertex3f(v0.x, v0.y, v0.z)
+
+ glVertex3f(vv0.x, vv0.y, vv0.z)
+ glVertex3f(vv5.x, vv5.y, vv5.z)
+ glVertex3f(prevVv1.x, prevVv1.y, prevVv1.z)
+ glVertex3f(v0.x, v0.y, v0.z)
+ glEnd()
+
+ prevNormal = normal
+ prevVv1 = vv1
+ prevVv3 = vv3
+ else:
+ glBegin(GL_LINE_STRIP)
+ for v in path.list:
+ glVertex3f(v.x, v.y, v.z)
+ glEnd()
+ glEnable(GL_CULL_FACE)
diff --git a/Cura/gui/preferencesDialog.py b/Cura/gui/preferencesDialog.py
index 81734c28ca..41bded92aa 100644
--- a/Cura/gui/preferencesDialog.py
+++ b/Cura/gui/preferencesDialog.py
@@ -7,6 +7,7 @@ import ConfigParser
from gui import configBase
from gui import validators
from gui import machineCom
+from util import profile
class preferencesDialog(configBase.configWindowBase):
def __init__(self, parent):
@@ -14,6 +15,8 @@ class preferencesDialog(configBase.configWindowBase):
wx.EVT_CLOSE(self, self.OnClose)
+ self.oldExtruderAmount = int(profile.getPreference('extruder_amount'))
+
left, right, main = self.CreateConfigPanel(self)
configBase.TitleRow(left, 'Machine settings')
c = configBase.SettingRow(left, 'Steps per E', 'steps_per_e', '0', 'Amount of steps per mm filament extrusion', type = 'preference')
@@ -24,6 +27,14 @@ class preferencesDialog(configBase.configWindowBase):
validators.validFloat(c, 10.0)
c = configBase.SettingRow(left, 'Machine height (mm)', 'machine_height', '200', 'Size of the machine in mm', type = 'preference')
validators.validFloat(c, 10.0)
+ c = configBase.SettingRow(left, 'Extruder count', 'extruder_amount', ['1', '2', '3', '4'], 'Amount of extruders in your machine.', type = 'preference')
+
+ for i in xrange(1, self.oldExtruderAmount):
+ configBase.TitleRow(left, 'Extruder %d' % (i+1))
+ c = configBase.SettingRow(left, 'Offset X', 'extruder_offset_x%d' % (i), '0.0', 'The offset of your secondary extruder compared to the primary.', type = 'preference')
+ validators.validFloat(c)
+ c = configBase.SettingRow(left, 'Offset Y', 'extruder_offset_y%d' % (i), '0.0', 'The offset of your secondary extruder compared to the primary.', type = 'preference')
+ validators.validFloat(c)
configBase.TitleRow(left, 'Filament settings')
c = configBase.SettingRow(left, 'Filament density (kg/m3)', 'filament_density', '1300', 'Weight of the filament per m3. Around 1300 for PLA. And around 1040 for ABS. This value is used to estimate the weight if the filament used for the print.', type = 'preference')
@@ -38,13 +49,19 @@ class preferencesDialog(configBase.configWindowBase):
c = configBase.SettingRow(left, 'Baudrate', 'serial_baud', '250000', 'Speed of the serial port communication\nNeeds to match your firmware settings\nCommon values are 250000, 115200, 57600', type = 'preference')
configBase.TitleRow(left, 'Slicer settings')
- c = configBase.SettingRow(left, 'Slicer selection', 'slicer', ['Cura (Skeinforge based)', 'Slic3r'], 'Which slicer to use to slice objects. Usually the Cura engine produces the best results. But Slic3r is developing fast and is faster with slicing.', type = 'preference')
+ #c = configBase.SettingRow(left, 'Slicer selection', 'slicer', ['Cura (Skeinforge based)', 'Slic3r'], 'Which slicer to use to slice objects. Usually the Cura engine produces the best results. But Slic3r is developing fast and is faster with slicing.', type = 'preference')
c = configBase.SettingRow(left, 'Save profile on slice', 'save_profile', False, 'When slicing save the profile as [stl_file]_profile.ini next to the model.', type = 'preference')
+ self.okButton = wx.Button(left, -1, 'Ok')
+ left.GetSizer().Add(self.okButton, (left.GetSizer().GetRows(), 1))
+ self.okButton.Bind(wx.EVT_BUTTON, self.OnClose)
+
self.MakeModal(True)
main.Fit()
self.Fit()
def OnClose(self, e):
+ if self.oldExtruderAmount != int(profile.getPreference('extruder_amount')):
+ wx.MessageBox('After changing the amount of extruders you need to restart Cura for full effect.', 'Extruder amount warning.', wx.OK | wx.ICON_INFORMATION)
self.MakeModal(False)
self.Destroy()
diff --git a/Cura/gui/preview3d.py b/Cura/gui/preview3d.py
index 92ce6db9fb..372ec4e38e 100644
--- a/Cura/gui/preview3d.py
+++ b/Cura/gui/preview3d.py
@@ -1,11 +1,6 @@
from __future__ import division
-import sys
-import math
-import threading
-import re
-import time
-import os
+import sys, math, threading, re, time, os
from wx import glcanvas
import wx
@@ -20,107 +15,94 @@ except:
hasOpenGLlibs = False
from gui import opengl
+from gui import toolbarUtil
from util import profile
from util import gcodeInterpreter
from util import stl
from util import util3d
+class previewObject():
+ def __init__(self):
+ self.mesh = None
+ self.filename = None
+ self.displayList = None
+ self.dirty = False
+
class previewPanel(wx.Panel):
def __init__(self, parent):
- wx.Panel.__init__(self, parent,-1)
+ super(previewPanel, self).__init__(parent,-1)
self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_3DDKSHADOW))
self.SetMinSize((440,320))
self.glCanvas = PreviewGLCanvas(self)
- self.init = 0
- self.triangleMesh = None
+ self.objectList = []
+ self.errorList = []
self.gcode = None
- self.modelFilename = None
- self.loadingProgressAmount = 0
+ self.objectsMinV = None
+ self.objectsMaxV = None
self.loadThread = None
- self.machineSize = util3d.Vector3(float(profile.getPreference('machine_width')), float(profile.getPreference('machine_depth')), float(profile.getPreference('machine_height')))
+ self.machineSize = util3d.Vector3(profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height'))
self.machineCenter = util3d.Vector3(float(profile.getProfileSetting('machine_center_x')), float(profile.getProfileSetting('machine_center_y')), 0)
- self.toolbar = wx.ToolBar( self, -1 )
- self.toolbar.SetToolBitmapSize( ( 21, 21 ) )
+ self.toolbar = toolbarUtil.Toolbar(self)
- button = wx.Button(self.toolbar, -1, "3D", size=(21*2,21))
- self.toolbar.AddControl(button)
- self.Bind(wx.EVT_BUTTON, self.On3DClick, button)
-
- button = wx.Button(self.toolbar, -1, "Top", size=(21*2,21))
- self.toolbar.AddControl(button)
- self.Bind(wx.EVT_BUTTON, self.OnTopClick, button)
+ group = []
+ toolbarUtil.RadioButton(self.toolbar, group, 'object-3d-on.png', 'object-3d-off.png', '3D view', callback=self.On3DClick)
+ toolbarUtil.RadioButton(self.toolbar, group, 'object-top-on.png', 'object-top-off.png', 'Topdown view', callback=self.OnTopClick)
+ self.toolbar.AddSeparator()
- self.viewSelect = wx.ComboBox(self.toolbar, -1, 'Model - Normal', choices=['Model - Normal', 'Model - Transparent', 'Model - X-Ray', 'GCode', 'Mixed'], style=wx.CB_DROPDOWN|wx.CB_READONLY)
- self.toolbar.AddControl(self.viewSelect)
- self.viewSelect.Bind(wx.EVT_COMBOBOX, self.OnViewChange)
- self.glCanvas.viewMode = self.viewSelect.GetValue()
+ group = []
+ self.normalViewButton = toolbarUtil.RadioButton(self.toolbar, group, 'view-normal-on.png', 'view-normal-off.png', 'Normal model view', callback=self.OnViewChange)
+ self.transparentViewButton = toolbarUtil.RadioButton(self.toolbar, group, 'view-transparent-on.png', 'view-transparent-off.png', 'Transparent model view', callback=self.OnViewChange)
+ self.xrayViewButton = toolbarUtil.RadioButton(self.toolbar, group, 'view-xray-on.png', 'view-xray-off.png', 'X-Ray view', callback=self.OnViewChange)
+ self.gcodeViewButton = toolbarUtil.RadioButton(self.toolbar, group, 'view-gcode-on.png', 'view-gcode-off.png', 'GCode view', callback=self.OnViewChange)
+ self.mixedViewButton = toolbarUtil.RadioButton(self.toolbar, group, 'view-mixed-on.png', 'view-mixed-off.png', 'Mixed model/GCode view', callback=self.OnViewChange)
+ self.toolbar.AddSeparator()
self.layerSpin = wx.SpinCtrl(self.toolbar, -1, '', size=(21*4,21), style=wx.SP_ARROW_KEYS)
self.toolbar.AddControl(self.layerSpin)
self.Bind(wx.EVT_SPINCTRL, self.OnLayerNrChange, self.layerSpin)
-
- self.toolbar2 = wx.ToolBar( self, -1 )
- self.toolbar2.SetToolBitmapSize( ( 21, 21 ) )
- self.toolbar2.AddControl(wx.StaticText(self.toolbar2, -1, 'Flip'))
-
- self.flipX = wx.CheckBox(self.toolbar2, -1, "X")
- self.flipX.SetValue(profile.getProfileSetting('flip_x') == 'True')
- self.toolbar2.AddControl(self.flipX)
- self.Bind(wx.EVT_CHECKBOX, self.OnFlipXClick, self.flipX)
- self.flipY = wx.CheckBox(self.toolbar2, -1, "Y")
- self.flipY.SetValue(profile.getProfileSetting('flip_y') == 'True')
- self.toolbar2.AddControl(self.flipY)
- self.Bind(wx.EVT_CHECKBOX, self.OnFlipYClick, self.flipY)
- self.flipZ = wx.CheckBox(self.toolbar2, -1, "Z")
- self.flipZ.SetValue(profile.getProfileSetting('flip_z') == 'True')
- self.toolbar2.AddControl(self.flipZ)
- self.Bind(wx.EVT_CHECKBOX, self.OnFlipZClick, self.flipZ)
-
- self.swapXZ = wx.CheckBox(self.toolbar2, -1, "XZ")
- self.swapXZ.SetValue(profile.getProfileSetting('swap_xz') == 'True')
- self.toolbar2.AddControl(self.swapXZ)
- self.Bind(wx.EVT_CHECKBOX, self.OnSwapXZClick, self.swapXZ)
-
- self.swapYZ = wx.CheckBox(self.toolbar2, -1, "YZ")
- self.swapYZ.SetValue(profile.getProfileSetting('swap_yz') == 'True')
- self.toolbar2.AddControl(self.swapYZ)
- self.Bind(wx.EVT_CHECKBOX, self.OnSwapYZClick, self.swapYZ)
-
- self.toolbar2.InsertSeparator(self.toolbar2.GetToolsCount())
- self.toolbar2.AddControl(wx.StaticText(self.toolbar2, -1, 'Scale'))
+
+ self.toolbar2 = toolbarUtil.Toolbar(self)
+
+ # Mirror
+ self.mirrorX = toolbarUtil.ToggleButton(self.toolbar2, 'flip_x', 'object-mirror-x-on.png', 'object-mirror-x-off.png', 'Mirror X', callback=self.updateModelTransform)
+ self.mirrorY = toolbarUtil.ToggleButton(self.toolbar2, 'flip_y', 'object-mirror-y-on.png', 'object-mirror-y-off.png', 'Mirror Y', callback=self.updateModelTransform)
+ self.mirrorZ = toolbarUtil.ToggleButton(self.toolbar2, 'flip_z', 'object-mirror-z-on.png', 'object-mirror-z-off.png', 'Mirror Z', callback=self.updateModelTransform)
+ self.toolbar2.AddSeparator()
+
+ # Swap
+ self.swapXZ = toolbarUtil.ToggleButton(self.toolbar2, 'swap_xz', 'object-swap-xz-on.png', 'object-swap-xz-off.png', 'Swap XZ', callback=self.updateModelTransform)
+ self.swapYZ = toolbarUtil.ToggleButton(self.toolbar2, 'swap_yz', 'object-swap-yz-on.png', 'object-swap-yz-off.png', 'Swap YZ', callback=self.updateModelTransform)
+ self.toolbar2.AddSeparator()
+
+ # Scale
+ self.scaleReset = toolbarUtil.NormalButton(self.toolbar2, self.OnScaleReset, 'object-scale.png', 'Reset model scale')
self.scale = wx.TextCtrl(self.toolbar2, -1, profile.getProfileSetting('model_scale'), size=(21*2,21))
self.toolbar2.AddControl(self.scale)
- self.Bind(wx.EVT_TEXT, self.OnScale, self.scale)
-
- self.toolbar2.InsertSeparator(self.toolbar2.GetToolsCount())
- self.toolbar2.AddControl(wx.StaticText(self.toolbar2, -1, 'Copy'))
- self.mulXsub = wx.Button(self.toolbar2, -1, '-', size=(21,21))
- self.toolbar2.AddControl(self.mulXsub)
- self.Bind(wx.EVT_BUTTON, self.OnMulXSubClick, self.mulXsub)
- self.mulXadd = wx.Button(self.toolbar2, -1, '+', size=(21,21))
- self.toolbar2.AddControl(self.mulXadd)
- self.Bind(wx.EVT_BUTTON, self.OnMulXAddClick, self.mulXadd)
-
- self.mulYsub = wx.Button(self.toolbar2, -1, '-', size=(21,21))
- self.toolbar2.AddControl(self.mulYsub)
- self.Bind(wx.EVT_BUTTON, self.OnMulYSubClick, self.mulYsub)
- self.mulYadd = wx.Button(self.toolbar2, -1, '+', size=(21,21))
- self.toolbar2.AddControl(self.mulYadd)
- self.Bind(wx.EVT_BUTTON, self.OnMulYAddClick, self.mulYadd)
-
- self.toolbar2.InsertSeparator(self.toolbar2.GetToolsCount())
- self.toolbar2.AddControl(wx.StaticText(self.toolbar2, -1, 'Rot'))
+ self.scale.Bind(wx.EVT_TEXT, self.OnScale)
+ self.scaleMax = toolbarUtil.NormalButton(self.toolbar2, self.OnScaleMax, 'object-max-size.png', 'Scale object to fix machine size')
+
+ self.toolbar2.AddSeparator()
+
+ # Multiply
+ #self.mulXadd = toolbarUtil.NormalButton(self.toolbar2, self.OnMulXAddClick, 'object-mul-x-add.png', 'Increase number of models on X axis')
+ #self.mulXsub = toolbarUtil.NormalButton(self.toolbar2, self.OnMulXSubClick, 'object-mul-x-sub.png', 'Decrease number of models on X axis')
+ #self.mulYadd = toolbarUtil.NormalButton(self.toolbar2, self.OnMulYAddClick, 'object-mul-y-add.png', 'Increase number of models on Y axis')
+ #self.mulYsub = toolbarUtil.NormalButton(self.toolbar2, self.OnMulYSubClick, 'object-mul-y-sub.png', 'Decrease number of models on Y axis')
+ #self.toolbar2.AddSeparator()
+
+ # Rotate
+ self.rotateReset = toolbarUtil.NormalButton(self.toolbar2, self.OnRotateReset, 'object-rotate.png', 'Reset model rotation')
self.rotate = wx.SpinCtrl(self.toolbar2, -1, profile.getProfileSetting('model_rotate_base'), size=(21*3,21), style=wx.SP_WRAP|wx.SP_ARROW_KEYS)
self.rotate.SetRange(0, 360)
+ self.rotate.Bind(wx.EVT_TEXT, self.OnRotate)
self.toolbar2.AddControl(self.rotate)
- self.Bind(wx.EVT_SPINCTRL, self.OnRotate, self.rotate)
-
+
self.toolbar2.Realize()
- self.updateToolbar()
+ self.OnViewChange()
sizer = wx.BoxSizer(wx.VERTICAL)
sizer.Add(self.toolbar, 0, flag=wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT, border=1)
@@ -128,58 +110,64 @@ class previewPanel(wx.Panel):
sizer.Add(self.toolbar2, 0, flag=wx.EXPAND|wx.BOTTOM|wx.LEFT|wx.RIGHT, border=1)
self.SetSizer(sizer)
- def OnFlipXClick(self, e):
- profile.putProfileSetting('flip_x', str(self.flipX.GetValue()))
- self.updateModelTransform()
-
- def OnFlipYClick(self, e):
- profile.putProfileSetting('flip_y', str(self.flipY.GetValue()))
- self.updateModelTransform()
-
- def OnFlipZClick(self, e):
- profile.putProfileSetting('flip_z', str(self.flipZ.GetValue()))
- self.updateModelTransform()
-
- def OnSwapXZClick(self, e):
- profile.putProfileSetting('swap_xz', str(self.swapXZ.GetValue()))
- self.updateModelTransform()
-
- def OnSwapYZClick(self, e):
- profile.putProfileSetting('swap_yz', str(self.swapYZ.GetValue()))
- self.updateModelTransform()
-
def OnMulXAddClick(self, e):
profile.putProfileSetting('model_multiply_x', str(max(1, int(profile.getProfileSetting('model_multiply_x'))+1)))
- self.updateModelTransform()
+ self.glCanvas.Refresh()
def OnMulXSubClick(self, e):
profile.putProfileSetting('model_multiply_x', str(max(1, int(profile.getProfileSetting('model_multiply_x'))-1)))
- self.updateModelTransform()
+ self.glCanvas.Refresh()
def OnMulYAddClick(self, e):
profile.putProfileSetting('model_multiply_y', str(max(1, int(profile.getProfileSetting('model_multiply_y'))+1)))
- self.updateModelTransform()
+ self.glCanvas.Refresh()
def OnMulYSubClick(self, e):
profile.putProfileSetting('model_multiply_y', str(max(1, int(profile.getProfileSetting('model_multiply_y'))-1)))
- self.updateModelTransform()
+ self.glCanvas.Refresh()
+
+ def OnScaleReset(self, e):
+ self.scale.SetValue('1.0')
+ self.OnScale(None)
def OnScale(self, e):
- profile.putProfileSetting('model_scale', self.scale.GetValue())
- self.updateModelTransform()
+ scale = 1.0
+ if self.scale.GetValue() != '':
+ scale = self.scale.GetValue()
+ profile.putProfileSetting('model_scale', scale)
+ self.glCanvas.Refresh()
+ def OnScaleMax(self, e):
+ if self.objectsMinV == None:
+ return
+ vMin = self.objectsMinV
+ vMax = self.objectsMaxV
+ scaleX1 = (self.machineSize.x - self.machineCenter.x) / ((vMax.x - vMin.x) / 2)
+ scaleY1 = (self.machineSize.y - self.machineCenter.y) / ((vMax.y - vMin.y) / 2)
+ scaleX2 = (self.machineCenter.x) / ((vMax.x - vMin.x) / 2)
+ scaleY2 = (self.machineCenter.y) / ((vMax.y - vMin.y) / 2)
+ scaleZ = self.machineSize.z / (vMax.z - vMin.z)
+ scale = min(scaleX1, scaleY1, scaleX2, scaleY2, scaleZ)
+ self.scale.SetValue(str(scale))
+ profile.putProfileSetting('model_scale', self.scale.GetValue())
+ self.glCanvas.Refresh()
+
+ def OnRotateReset(self, e):
+ self.rotate.SetValue(0)
+ self.OnRotate(None)
+
def OnRotate(self, e):
profile.putProfileSetting('model_rotate_base', self.rotate.GetValue())
self.updateModelTransform()
- def On3DClick(self, e):
+ def On3DClick(self):
self.glCanvas.yaw = 30
self.glCanvas.pitch = 60
- self.glCanvas.zoom = 150
+ self.glCanvas.zoom = 300
self.glCanvas.view3D = True
self.glCanvas.Refresh()
- def OnTopClick(self, e):
+ def OnTopClick(self):
self.glCanvas.view3D = False
self.glCanvas.zoom = 100
self.glCanvas.offsetX = 0
@@ -187,33 +175,40 @@ class previewPanel(wx.Panel):
self.glCanvas.Refresh()
def OnLayerNrChange(self, e):
- self.gcodeDirty = True
self.glCanvas.Refresh()
- def updateCenterX(self, x):
- self.machineCenter.x = x
- self.moveModel()
+ def updateCenterX(self):
+ self.machineCenter.x = profile.getProfileSettingFloat('machine_center_x')
self.glCanvas.Refresh()
- def updateCenterY(self, y):
- self.machineCenter.y = y
- self.moveModel()
+ def updateCenterY(self):
+ self.machineCenter.y = profile.getProfileSettingFloat('machine_center_y')
self.glCanvas.Refresh()
def setViewMode(self, mode):
- self.viewSelect.SetValue(mode)
- self.glCanvas.viewMode = self.viewSelect.GetValue()
+ if mode == "Normal":
+ self.normalViewButton.SetValue(True)
+ if mode == "GCode":
+ self.gcodeViewButton.SetValue(True)
+ self.glCanvas.viewMode = mode
wx.CallAfter(self.glCanvas.Refresh)
- def loadModelFile(self, filename):
- if self.modelFilename != filename:
- self.modelFileTime = None
- self.gcodeFileTime = None
- self.logFileTime = None
+ def loadModelFiles(self, filelist):
+ while len(filelist) > len(self.objectList):
+ self.objectList.append(previewObject())
+ for idx in xrange(len(filelist), len(self.objectList)):
+ self.objectList[idx].mesh = None
+ self.objectList[idx].filename = None
+ for idx in xrange(0, len(filelist)):
+ obj = self.objectList[idx]
+ if obj.filename != filelist[idx]:
+ obj.fileTime = None
+ self.gcodeFileTime = None
+ self.logFileTime = None
+ obj.filename = filelist[idx]
- self.modelFilename = filename
- self.gcodeFilename = filename[: filename.rfind('.')] + "_export.gcode"
- self.logFilename = filename[: filename.rfind('.')] + "_export.log"
+ self.gcodeFilename = filelist[0][: filelist[0].rfind('.')] + "_export.gcode"
+ self.logFilename = filelist[0][: filelist[0].rfind('.')] + "_export.log"
#Do the STL file loading in a background thread so we don't block the UI.
if self.loadThread != None and self.loadThread.isAlive():
self.loadThread.join()
@@ -221,35 +216,31 @@ class previewPanel(wx.Panel):
self.loadThread.daemon = True
self.loadThread.start()
- def loadReModelFile(self, filename):
+ def loadReModelFiles(self, filelist):
#Only load this again if the filename matches the file we have already loaded (for auto loading GCode after slicing)
- if self.modelFilename != filename:
- return False
- self.loadModelFile(filename)
+ for idx in xrange(0, len(filelist)):
+ if self.objectList[idx].filename != filelist[idx]:
+ return False
+ self.loadModelFiles(filelist)
return True
def doFileLoadThread(self):
- if os.path.isfile(self.modelFilename) and self.modelFileTime != os.stat(self.modelFilename).st_mtime:
- self.modelFileTime = os.stat(self.modelFilename).st_mtime
- triangleMesh = stl.stlModel()
- triangleMesh.load(self.modelFilename)
- triangleMesh.origonalVertexes = list(triangleMesh.vertexes)
- for i in xrange(0, len(triangleMesh.origonalVertexes)):
- triangleMesh.origonalVertexes[i] = triangleMesh.origonalVertexes[i].copy()
- triangleMesh.getMinimumZ()
- self.modelDirty = False
- self.errorList = []
- self.triangleMesh = triangleMesh
- self.updateModelTransform()
- wx.CallAfter(self.updateToolbar)
- wx.CallAfter(self.glCanvas.Refresh)
+ for obj in self.objectList:
+ if obj.filename != None and os.path.isfile(obj.filename) and obj.fileTime != os.stat(obj.filename).st_mtime:
+ obj.ileTime = os.stat(obj.filename).st_mtime
+ mesh = stl.stlModel()
+ mesh.load(obj.filename)
+ obj.dirty = False
+ obj.mesh = mesh
+ self.updateModelTransform()
+ wx.CallAfter(self.updateToolbar)
+ wx.CallAfter(self.glCanvas.Refresh)
if os.path.isfile(self.gcodeFilename) and self.gcodeFileTime != os.stat(self.gcodeFilename).st_mtime:
self.gcodeFileTime = os.stat(self.gcodeFilename).st_mtime
gcode = gcodeInterpreter.gcode()
gcode.progressCallback = self.loadProgress
gcode.load(self.gcodeFilename)
- self.loadingProgressAmount = 0
self.gcodeDirty = False
self.errorList = []
self.gcode = gcode
@@ -271,32 +262,35 @@ class previewPanel(wx.Panel):
wx.CallAfter(self.glCanvas.Refresh)
def loadProgress(self, progress):
- self.loadingProgressAmount = progress
- wx.CallAfter(self.glCanvas.Refresh)
+ pass
def updateToolbar(self):
- self.layerSpin.Show(self.gcode != None)
+ self.gcodeViewButton.Show(self.gcode != None)
+ self.mixedViewButton.Show(self.gcode != None)
+ self.layerSpin.Show(self.glCanvas.viewMode == "GCode" or self.glCanvas.viewMode == "Mixed")
if self.gcode != None:
- self.layerSpin.SetRange(1, len(self.gcode.layerList))
+ self.layerSpin.SetRange(1, len(self.gcode.layerList) - 1)
self.toolbar.Realize()
- def OnViewChange(self, e):
- self.glCanvas.viewMode = self.viewSelect.GetValue()
+ def OnViewChange(self):
+ if self.normalViewButton.GetValue():
+ self.glCanvas.viewMode = "Normal"
+ elif self.transparentViewButton.GetValue():
+ self.glCanvas.viewMode = "Transparent"
+ elif self.xrayViewButton.GetValue():
+ self.glCanvas.viewMode = "X-Ray"
+ elif self.gcodeViewButton.GetValue():
+ self.glCanvas.viewMode = "GCode"
+ elif self.mixedViewButton.GetValue():
+ self.glCanvas.viewMode = "Mixed"
+ self.updateToolbar()
self.glCanvas.Refresh()
def updateModelTransform(self, f=0):
- if self.triangleMesh == None:
- return
- scale = 1.0
- rotate = 0.0
- try:
- scale = profile.getProfileSettingFloat('model_scale')
- rotate = profile.getProfileSettingFloat('model_rotate_base') / 180.0 * math.pi
- except:
- pass
- scaleX = scale
- scaleY = scale
- scaleZ = scale
+ rotate = profile.getProfileSettingFloat('model_rotate_base') / 180.0 * math.pi
+ scaleX = 1.0
+ scaleY = 1.0
+ scaleZ = 1.0
if profile.getProfileSetting('flip_x') == 'True':
scaleX = -scaleX
if profile.getProfileSetting('flip_y') == 'True':
@@ -310,41 +304,54 @@ class previewPanel(wx.Panel):
mat10 = math.sin(rotate) * scaleX
mat11 = math.cos(rotate) * scaleY
- for i in xrange(0, len(self.triangleMesh.origonalVertexes)):
- x = self.triangleMesh.origonalVertexes[i].x
- y = self.triangleMesh.origonalVertexes[i].y
- z = self.triangleMesh.origonalVertexes[i].z
- if swapXZ:
- x, z = z, x
- if swapYZ:
- y, z = z, y
- self.triangleMesh.vertexes[i].x = x * mat00 + y * mat01
- self.triangleMesh.vertexes[i].y = x * mat10 + y * mat11
- self.triangleMesh.vertexes[i].z = z * scaleZ
-
- for face in self.triangleMesh.faces:
- v1 = face.v[0]
- v2 = face.v[1]
- v3 = face.v[2]
- face.normal = (v2 - v1).cross(v3 - v1)
- face.normal.normalize()
-
- self.moveModel()
-
- def moveModel(self):
- if self.triangleMesh == None:
+ if len(self.objectList) < 1 or self.objectList[0].mesh == None:
return
- minZ = self.triangleMesh.getMinimumZ()
- min = self.triangleMesh.getMinimum()
- max = self.triangleMesh.getMaximum()
- for v in self.triangleMesh.vertexes:
- v.z -= minZ
- v.x -= min.x + (max.x - min.x) / 2
- v.y -= min.y + (max.y - min.y) / 2
- v.x += self.machineCenter.x
- v.y += self.machineCenter.y
- self.triangleMesh.getMinimumZ()
- self.modelDirty = True
+
+ for obj in self.objectList:
+ if obj.mesh == None:
+ continue
+
+ for i in xrange(0, len(obj.mesh.origonalVertexes)):
+ x = obj.mesh.origonalVertexes[i].x
+ y = obj.mesh.origonalVertexes[i].y
+ z = obj.mesh.origonalVertexes[i].z
+ if swapXZ:
+ x, z = z, x
+ if swapYZ:
+ y, z = z, y
+ obj.mesh.vertexes[i].x = x * mat00 + y * mat01
+ obj.mesh.vertexes[i].y = x * mat10 + y * mat11
+ obj.mesh.vertexes[i].z = z * scaleZ
+
+ for face in obj.mesh.faces:
+ v1 = face.v[0]
+ v2 = face.v[1]
+ v3 = face.v[2]
+ face.normal = (v2 - v1).cross(v3 - v1)
+ face.normal.normalize()
+
+ minV = self.objectList[0].mesh.getMinimum()
+ maxV = self.objectList[0].mesh.getMaximum()
+ for obj in self.objectList:
+ if obj.mesh == None:
+ continue
+
+ obj.mesh.getMinimumZ()
+ minV = minV.min(obj.mesh.getMinimum())
+ maxV = maxV.max(obj.mesh.getMaximum())
+
+ self.objectsMaxV = maxV
+ self.objectsMinV = minV
+ for obj in self.objectList:
+ if obj.mesh == None:
+ continue
+
+ for v in obj.mesh.vertexes:
+ v.z -= minV.z
+ v.x -= minV.x + (maxV.x - minV.x) / 2
+ v.y -= minV.y + (maxV.y - minV.y) / 2
+ obj.mesh.getMinimumZ()
+ obj.dirty = True
self.glCanvas.Refresh()
class PreviewGLCanvas(glcanvas.GLCanvas):
@@ -360,12 +367,14 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel)
self.yaw = 30
self.pitch = 60
- self.zoom = 150
+ self.zoom = 300
self.offsetX = 0
self.offsetY = 0
self.view3D = True
- self.modelDisplayList = None
self.gcodeDisplayList = None
+ self.gcodeDisplayListMade = None
+ self.gcodeDisplayListCount = 0
+ self.objColor = [[1.0, 0.8, 0.6, 1.0], [0.2, 1.0, 0.1, 1.0], [1.0, 0.2, 0.1, 1.0], [0.1, 0.2, 1.0, 1.0]]
def OnMouseMotion(self,e):
if e.Dragging() and e.LeftIsDown():
@@ -413,8 +422,12 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
glTranslate(0,0,-self.zoom)
glRotate(-self.pitch, 1,0,0)
glRotate(self.yaw, 0,0,1)
- if self.parent.triangleMesh != None:
- glTranslate(0,0,-self.parent.triangleMesh.getMaximum().z / 2)
+ if self.viewMode == "GCode" or self.viewMode == "Mixed":
+ if self.parent.gcode != None:
+ glTranslate(0,0,-self.parent.gcode.layerList[self.parent.layerSpin.GetValue()][0].list[-1].z)
+ else:
+ if self.parent.objectsMaxV != None:
+ glTranslate(0,0,-self.parent.objectsMaxV.z * profile.getProfileSettingFloat('model_scale') / 2)
else:
glScale(1.0/self.zoom, 1.0/self.zoom, 1.0)
glTranslate(self.offsetX, self.offsetY, 0.0)
@@ -427,152 +440,87 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
machineSize = self.parent.machineSize
opengl.DrawMachine(machineSize)
- if self.parent.gcode != None:
- if self.gcodeDisplayList == None:
- self.gcodeDisplayList = glGenLists(1);
- if self.parent.gcodeDirty:
- self.parent.gcodeDirty = False
- glNewList(self.gcodeDisplayList, GL_COMPILE)
- prevLayerZ = 0.0
- curLayerZ = 0.0
-
- layerThickness = 0.0
- filamentRadius = float(profile.getProfileSetting('filament_diameter')) / 2
- filamentArea = math.pi * filamentRadius * filamentRadius
- lineWidth = float(profile.getProfileSetting('nozzle_size')) / 2 / 10
-
- curLayerNum = 0
- for layer in self.parent.gcode.layerList:
- curLayerZ = layer[0].list[1].z
- layerThickness = curLayerZ - prevLayerZ
- prevLayerZ = layer[-1].list[-1].z
- for path in layer:
- c = 1.0
- if curLayerNum != self.parent.layerSpin.GetValue():
- if curLayerNum < self.parent.layerSpin.GetValue():
- c = 0.9 - (self.parent.layerSpin.GetValue() - curLayerNum) * 0.1
- if c < 0.4:
- c = 0.4
- else:
- break
- if path.type == 'move':
- glColor3f(0,0,c)
- if path.type == 'extrude':
- if path.pathType == 'FILL':
- glColor3f(c/2,c/2,0)
- elif path.pathType == 'WALL-INNER':
- glColor3f(0,c,0)
- elif path.pathType == 'SUPPORT':
- glColor3f(0,c,c)
- elif path.pathType == 'SKIRT':
- glColor3f(0,c/2,c/2)
- else:
- glColor3f(c,0,0)
- if path.type == 'retract':
- glColor3f(0,c,c)
- if c > 0.4 and path.type == 'extrude':
- for i in xrange(0, len(path.list)-1):
- v0 = path.list[i]
- v1 = path.list[i+1]
-
- # Calculate line width from ePerDistance (needs layer thickness and filament diameter)
- dist = (v0 - v1).vsize()
- if dist > 0 and layerThickness > 0:
- extrusionMMperDist = (v1.e - v0.e) / dist
- lineWidth = extrusionMMperDist * filamentArea / layerThickness / 2
-
- normal = (v0 - v1).cross(util3d.Vector3(0,0,1))
- normal.normalize()
- v2 = v0 + normal * lineWidth
- v3 = v1 + normal * lineWidth
- v0 = v0 - normal * lineWidth
- v1 = v1 - normal * lineWidth
-
- glBegin(GL_QUADS)
- if path.pathType == 'FILL': #Remove depth buffer fighting on infill/wall overlap
- glVertex3f(v0.x, v0.y, v0.z - 0.02)
- glVertex3f(v1.x, v1.y, v1.z - 0.02)
- glVertex3f(v3.x, v3.y, v3.z - 0.02)
- glVertex3f(v2.x, v2.y, v2.z - 0.02)
- else:
- glVertex3f(v0.x, v0.y, v0.z - 0.01)
- glVertex3f(v1.x, v1.y, v1.z - 0.01)
- glVertex3f(v3.x, v3.y, v3.z - 0.01)
- glVertex3f(v2.x, v2.y, v2.z - 0.01)
- glEnd()
-
- #for v in path['list']:
- # glBegin(GL_TRIANGLE_FAN)
- # glVertex3f(v.x, v.y, v.z - 0.001)
- # for i in xrange(0, 16+1):
- # if path['pathType'] == 'FILL': #Remove depth buffer fighting on infill/wall overlap
- # glVertex3f(v.x + math.cos(math.pi*2/16*i) * lineWidth, v.y + math.sin(math.pi*2/16*i) * lineWidth, v.z - 0.02)
- # else:
- # glVertex3f(v.x + math.cos(math.pi*2/16*i) * lineWidth, v.y + math.sin(math.pi*2/16*i) * lineWidth, v.z - 0.01)
- # glEnd()
- else:
- glBegin(GL_LINE_STRIP)
- for v in path.list:
- glVertex3f(v.x, v.y, v.z)
- glEnd()
- curLayerNum += 1
- glEndList()
- if self.viewMode == "GCode" or self.viewMode == "Mixed":
- glCallList(self.gcodeDisplayList)
+ if self.parent.gcode != None and self.parent.gcodeDirty:
+ if self.gcodeDisplayListCount < len(self.parent.gcode.layerList) or self.gcodeDisplayList == None:
+ if self.gcodeDisplayList != None:
+ glDeleteLists(self.gcodeDisplayList, self.gcodeDisplayListCount)
+ self.gcodeDisplayList = glGenLists(len(self.parent.gcode.layerList));
+ self.gcodeDisplayListCount = len(self.parent.gcode.layerList)
+ self.parent.gcodeDirty = False
+ self.gcodeDisplayListMade = 0
- if self.parent.triangleMesh != None:
- if self.modelDisplayList == None:
- self.modelDisplayList = glGenLists(1);
- if self.parent.modelDirty:
- self.parent.modelDirty = False
- multiX = int(profile.getProfileSetting('model_multiply_x'))
- multiY = int(profile.getProfileSetting('model_multiply_y'))
- modelSize = self.parent.triangleMesh.getMaximum() - self.parent.triangleMesh.getMinimum()
- glNewList(self.modelDisplayList, GL_COMPILE)
- glPushMatrix()
- glTranslate(-(modelSize.x+10)*(multiX-1)/2,-(modelSize.y+10)*(multiY-1)/2, 0)
- for mx in xrange(0, multiX):
- for my in xrange(0, multiY):
- glPushMatrix()
- glTranslate((modelSize.x+10)*mx,(modelSize.y+10)*my, 0)
- opengl.DrawSTL(self.parent.triangleMesh)
- glPopMatrix()
- glPopMatrix()
+ if self.parent.gcode != None and self.gcodeDisplayListMade < len(self.parent.gcode.layerList):
+ glNewList(self.gcodeDisplayList + self.gcodeDisplayListMade, GL_COMPILE)
+ opengl.DrawGCodeLayer(self.parent.gcode.layerList[self.gcodeDisplayListMade])
+ glEndList()
+ self.gcodeDisplayListMade += 1
+ self.Refresh()
+
+ if self.parent.gcode != None and (self.viewMode == "GCode" or self.viewMode == "Mixed"):
+ glEnable(GL_COLOR_MATERIAL)
+ glEnable(GL_LIGHTING)
+ drawUpToLayer = min(self.gcodeDisplayListMade, self.parent.layerSpin.GetValue() + 1)
+ for i in xrange(0, drawUpToLayer):
+ c = 1.0
+ if i < self.parent.layerSpin.GetValue():
+ c = 0.9 - (drawUpToLayer - i) * 0.1
+ if c < 0.4:
+ c = (0.4 + c) / 2
+ if c < 0.1:
+ c = 0.1
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, [0,0,0,0])
+ glLightfv(GL_LIGHT0, GL_AMBIENT, [c,c,c,c])
+ glCallList(self.gcodeDisplayList + i)
+ glDisable(GL_LIGHTING)
+ glDisable(GL_COLOR_MATERIAL)
+ glMaterialfv(GL_FRONT_AND_BACK, GL_AMBIENT, [0.2, 0.2, 0.2, 1.0]);
+ glMaterialfv(GL_FRONT_AND_BACK, GL_DIFFUSE, [0.8, 0.8, 0.8, 1.0]);
+
+ glColor3f(1.0,1.0,1.0)
+ glTranslate(self.parent.machineCenter.x, self.parent.machineCenter.y, 0)
+ for obj in self.parent.objectList:
+ if obj.mesh == None:
+ continue
+ if obj.displayList == None:
+ obj.displayList = glGenLists(1);
+ if obj.dirty:
+ obj.dirty = False
+ glNewList(obj.displayList, GL_COMPILE)
+ opengl.DrawSTL(obj.mesh)
glEndList()
- if self.viewMode == "Model - Transparent" or self.viewMode == "Mixed":
- glLightfv(GL_LIGHT0, GL_DIFFUSE, [0.5, 0.4, 0.3, 1.0])
- glLightfv(GL_LIGHT0, GL_AMBIENT, [0.1, 0.1, 0.1, 0.0])
+ if self.viewMode == "Transparent" or self.viewMode == "Mixed":
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, map(lambda x: x / 2, self.objColor[self.parent.objectList.index(obj)]))
+ glLightfv(GL_LIGHT0, GL_AMBIENT, map(lambda x: x / 10, self.objColor[self.parent.objectList.index(obj)]))
#If we want transparent, then first render a solid black model to remove the printer size lines.
if self.viewMode != "Mixed":
glDisable(GL_BLEND)
- glDisable(GL_LIGHTING)
- glColor3f(0,0,0)
- glCallList(self.modelDisplayList)
- glColor3f(1,1,1)
+ glColor3f(0.0,0.0,0.0)
+ self.drawModel(obj)
+ glColor3f(1.0,1.0,1.0)
#After the black model is rendered, render the model again but now with lighting and no depth testing.
glDisable(GL_DEPTH_TEST)
glEnable(GL_LIGHTING)
glEnable(GL_BLEND)
glBlendFunc(GL_ONE, GL_ONE)
glEnable(GL_LIGHTING)
- glCallList(self.modelDisplayList)
- elif self.viewMode == "Model - X-Ray":
+ self.drawModel(obj)
+ elif self.viewMode == "X-Ray":
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE)
glDisable(GL_DEPTH_TEST)
glEnable(GL_STENCIL_TEST);
glStencilFunc(GL_ALWAYS, 1, 1)
glStencilOp(GL_INCR, GL_INCR, GL_INCR)
- glCallList(self.modelDisplayList)
+ self.drawModel(obj)
glStencilOp (GL_KEEP, GL_KEEP, GL_KEEP);
glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE)
glStencilFunc(GL_EQUAL, 0, 1);
glColor(1, 1, 1)
- glCallList(self.modelDisplayList)
+ self.drawModel(obj)
glStencilFunc(GL_EQUAL, 1, 1);
glColor(1, 0, 0)
- glCallList(self.modelDisplayList)
+ self.drawModel(obj)
glPushMatrix()
glLoadIdentity()
@@ -598,22 +546,38 @@ class PreviewGLCanvas(glcanvas.GLCanvas):
glDisable(GL_STENCIL_TEST);
glEnable(GL_DEPTH_TEST)
- elif self.viewMode == "Model - Normal":
- glLightfv(GL_LIGHT0, GL_DIFFUSE, [1.0, 0.8, 0.6, 1.0])
- glLightfv(GL_LIGHT0, GL_AMBIENT, [0.2, 0.2, 0.2, 0.0])
+ elif self.viewMode == "Normal":
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, self.objColor[self.parent.objectList.index(obj)])
+ glLightfv(GL_LIGHT0, GL_AMBIENT, map(lambda x: x / 5, self.objColor[self.parent.objectList.index(obj)]))
glEnable(GL_LIGHTING)
- glCallList(self.modelDisplayList)
+ self.drawModel(obj)
- if self.viewMode == "Model - Normal" or self.viewMode == "Model - Transparent" or self.viewMode == "Model - X-Ray":
- glDisable(GL_LIGHTING)
- glDisable(GL_DEPTH_TEST)
- glDisable(GL_BLEND)
- glColor3f(1,0,0)
- glTranslate(self.parent.machineCenter.x, self.parent.machineCenter.y, 0)
- glBegin(GL_LINES)
- for err in self.parent.errorList:
- glVertex3f(err[0].x, err[0].y, err[0].z)
- glVertex3f(err[1].x, err[1].y, err[1].z)
- glEnd()
-
+ if self.viewMode == "Normal" or self.viewMode == "Transparent" or self.viewMode == "X-Ray":
+ glDisable(GL_LIGHTING)
+ glDisable(GL_DEPTH_TEST)
+ glDisable(GL_BLEND)
+ glColor3f(1,0,0)
+ glBegin(GL_LINES)
+ for err in self.parent.errorList:
+ glVertex3f(err[0].x, err[0].y, err[0].z)
+ glVertex3f(err[1].x, err[1].y, err[1].z)
+ glEnd()
+ glEnable(GL_DEPTH_TEST)
glFlush()
+
+ def drawModel(self, obj):
+ multiX = 1 #int(profile.getProfileSetting('model_multiply_x'))
+ multiY = 1 #int(profile.getProfileSetting('model_multiply_y'))
+ modelScale = profile.getProfileSettingFloat('model_scale')
+ modelSize = (obj.mesh.getMaximum() - obj.mesh.getMinimum()) * modelScale
+ glPushMatrix()
+ glTranslate(-(modelSize.x+10)*(multiX-1)/2,-(modelSize.y+10)*(multiY-1)/2, 0)
+ for mx in xrange(0, multiX):
+ for my in xrange(0, multiY):
+ glPushMatrix()
+ glTranslate((modelSize.x+10)*mx,(modelSize.y+10)*my, 0)
+ glScalef(modelScale, modelScale, modelScale)
+ glCallList(obj.displayList)
+ glPopMatrix()
+ glPopMatrix()
+
diff --git a/Cura/gui/printWindow.py b/Cura/gui/printWindow.py
index 96538271f7..7fc25442c4 100644
--- a/Cura/gui/printWindow.py
+++ b/Cura/gui/printWindow.py
@@ -1,7 +1,8 @@
from __future__ import absolute_import
import __init__
-import wx, threading, re, subprocess, sys
+import wx, threading, re, subprocess, sys, os
+from wx.lib import buttons
from gui import machineCom
from gui import icon
@@ -50,6 +51,24 @@ class printProcessMonitor():
self.handle = None
self.thread = None
+class PrintCommandButton(buttons.GenBitmapButton):
+ def __init__(self, parent, command, bitmapFilename, size=(20,20)):
+ self.bitmap = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilename))
+ super(PrintCommandButton, self).__init__(parent.directControlPanel, -1, self.bitmap, size=size)
+
+ self.command = command
+ self.parent = parent
+
+ self.SetBezelWidth(1)
+ self.SetUseFocusIndicator(False)
+
+ self.Bind(wx.EVT_BUTTON, self.OnClick)
+
+ def OnClick(self, e):
+ self.parent.sendCommand("G91")
+ self.parent.sendCommand(self.command)
+ e.Skip()
+
class printWindow(wx.Frame):
"Main user interface window"
def __init__(self):
@@ -95,9 +114,42 @@ class printWindow(wx.Frame):
self.sizer.Add(self.printButton, pos=(2,1))
self.sizer.Add(self.cancelButton, pos=(3,1))
self.sizer.Add(self.progress, pos=(4,0), span=(1,2), flag=wx.EXPAND)
-
+
self.sizer.Add(wx.StaticText(self.panel, -1, "Temp:"), pos=(0,3))
self.sizer.Add(self.temperatureSelect, pos=(0,4))
+
+ self.directControlPanel = wx.Panel(self.panel)
+ self.sizer.Add(self.directControlPanel, pos=(1,3), span=(5,4))
+
+ sizer = wx.GridBagSizer(2, 2)
+ self.directControlPanel.SetSizer(sizer)
+ sizer.Add(PrintCommandButton(self, 'G1 Y100 F6000', 'print-move-y100.png'), pos=(0,3))
+ sizer.Add(PrintCommandButton(self, 'G1 Y10 F6000', 'print-move-y10.png'), pos=(1,3))
+ sizer.Add(PrintCommandButton(self, 'G1 Y1 F6000', 'print-move-y1.png'), pos=(2,3))
+
+ sizer.Add(PrintCommandButton(self, 'G1 Y-1 F6000', 'print-move-y-1.png'), pos=(4,3))
+ sizer.Add(PrintCommandButton(self, 'G1 Y-10 F6000', 'print-move-y-10.png'), pos=(5,3))
+ sizer.Add(PrintCommandButton(self, 'G1 Y-100 F6000', 'print-move-y-100.png'), pos=(6,3))
+
+ sizer.Add(PrintCommandButton(self, 'G1 X-100 F6000', 'print-move-x-100.png'), pos=(3,0))
+ sizer.Add(PrintCommandButton(self, 'G1 X-10 F6000', 'print-move-x-10.png'), pos=(3,1))
+ sizer.Add(PrintCommandButton(self, 'G1 X-1 F6000', 'print-move-x-1.png'), pos=(3,2))
+
+ sizer.Add(PrintCommandButton(self, 'G28 X0 Y0', 'print-move-home.png'), pos=(3,3))
+
+ sizer.Add(PrintCommandButton(self, 'G1 X1 F6000', 'print-move-x1.png'), pos=(3,4))
+ sizer.Add(PrintCommandButton(self, 'G1 X10 F6000', 'print-move-x10.png'), pos=(3,5))
+ sizer.Add(PrintCommandButton(self, 'G1 X100 F6000', 'print-move-x100.png'), pos=(3,6))
+
+ sizer.Add(PrintCommandButton(self, 'G1 Z10 F200', 'print-move-z10.png'), pos=(0,7))
+ sizer.Add(PrintCommandButton(self, 'G1 Z1 F200', 'print-move-z1.png'), pos=(1,7))
+ sizer.Add(PrintCommandButton(self, 'G1 Z0.1 F200', 'print-move-z0.1.png'), pos=(2,7))
+
+ sizer.Add(PrintCommandButton(self, 'G28 Z0', 'print-move-home.png'), pos=(3,7))
+
+ sizer.Add(PrintCommandButton(self, 'G1 Z-0.1 F200', 'print-move-z-0.1.png'), pos=(4,7))
+ sizer.Add(PrintCommandButton(self, 'G1 Z-1 F200', 'print-move-z-1.png'), pos=(5,7))
+ sizer.Add(PrintCommandButton(self, 'G1 Z-10 F200', 'print-move-z-10.png'), pos=(6,7))
self.sizer.AddGrowableRow(3)
self.sizer.AddGrowableCol(0)
@@ -122,19 +174,16 @@ class printWindow(wx.Frame):
#self.loadButton.Enable(self.printIdx == None)
self.printButton.Enable(self.machineConnected and self.gcodeList != None and self.printIdx == None)
self.cancelButton.Enable(self.printIdx != None)
+ self.temperatureSelect.Enable(self.machineConnected)
+ self.directControlPanel.Enable(self.machineConnected)
def UpdateProgress(self):
status = ""
if self.gcode != None:
status += "Filament: %.2fm %.2fg\n" % (self.gcode.extrusionAmount / 1000, self.gcode.calculateWeight() * 1000)
- cost_kg = float(profile.getPreference('filament_cost_kg'))
- cost_meter = float(profile.getPreference('filament_cost_meter'))
- if cost_kg > 0.0 and cost_meter > 0.0:
- status += "Filament cost: %.2f / %.2f\n" % (self.gcode.calculateWeight() * cost_kg, self.gcode.extrusionAmount / 1000 * cost_meter)
- elif cost_kg > 0.0:
- status += "Filament cost: %.2f\n" % (self.gcode.calculateWeight() * cost_kg)
- elif cost_meter > 0.0:
- status += "Filament cost: %.2f\n" % (self.gcode.extrusionAmount / 1000 * cost_meter)
+ cost = self.gcode.calculateCost()
+ if cost != False:
+ status += "Filament cost: %s\n" % (cost)
status += "Print time: %02d:%02d\n" % (int(self.gcode.totalMoveTimeMinute / 60), int(self.gcode.totalMoveTimeMinute % 60))
if self.printIdx == None:
self.progress.SetValue(0)
diff --git a/Cura/gui/projectPlanner.py b/Cura/gui/projectPlanner.py
new file mode 100644
index 0000000000..3d0e44bc94
--- /dev/null
+++ b/Cura/gui/projectPlanner.py
@@ -0,0 +1,948 @@
+from __future__ import absolute_import
+import __init__
+
+import wx, os, platform, types, webbrowser, math, subprocess, threading, time
+import ConfigParser
+
+from wx import glcanvas
+import wx
+try:
+ import OpenGL
+ OpenGL.ERROR_CHECKING = False
+ from OpenGL.GLU import *
+ from OpenGL.GL import *
+ hasOpenGLlibs = True
+except:
+ print "Failed to find PyOpenGL: http://pyopengl.sourceforge.net/"
+ hasOpenGLlibs = False
+
+from gui import opengl
+from gui import toolbarUtil
+from gui import icon
+from gui import configBase
+from gui import validators
+from gui import printWindow
+from util import profile
+from util import util3d
+from util import stl
+from util import sliceRun
+from util import gcodeInterpreter
+from util import exporer
+
+class Action(object):
+ pass
+
+class ProjectObject(stl.stlModel):
+ def __init__(self, parent, filename):
+ super(ProjectObject, self).__init__()
+
+ self.load(filename)
+
+ self.parent = parent
+ self.filename = filename
+ self.scale = 1.0
+ self.rotate = 0.0
+ self.flipX = False
+ self.flipY = False
+ self.flipZ = False
+ self.swapXZ = False
+ self.swapYZ = False
+ self.extruder = 0
+ self.profile = None
+
+ self.modelDisplayList = None
+ self.modelDirty = False
+
+ self.origonalVertexes = list(self.vertexes)
+ for i in xrange(0, len(self.origonalVertexes)):
+ self.origonalVertexes[i] = self.origonalVertexes[i].copy()
+ self.getMinimumZ()
+
+ self.centerX = -self.getMinimum().x + 5
+ self.centerY = -self.getMinimum().y + 5
+
+ self.updateModelTransform()
+
+ self.centerX = -self.getMinimum().x + 5
+ self.centerY = -self.getMinimum().y + 5
+
+ def updateModelTransform(self):
+ rotate = self.rotate / 180.0 * math.pi
+ scaleX = 1.0
+ scaleY = 1.0
+ scaleZ = 1.0
+ if self.flipX:
+ scaleX = -scaleX
+ if self.flipY:
+ scaleY = -scaleY
+ if self.flipZ:
+ scaleZ = -scaleZ
+ swapXZ = self.swapXZ
+ swapYZ = self.swapYZ
+ mat00 = math.cos(rotate) * scaleX
+ mat01 =-math.sin(rotate) * scaleY
+ mat10 = math.sin(rotate) * scaleX
+ mat11 = math.cos(rotate) * scaleY
+
+ for i in xrange(0, len(self.origonalVertexes)):
+ x = self.origonalVertexes[i].x
+ y = self.origonalVertexes[i].y
+ z = self.origonalVertexes[i].z
+ if swapXZ:
+ x, z = z, x
+ if swapYZ:
+ y, z = z, y
+ self.vertexes[i].x = x * mat00 + y * mat01
+ self.vertexes[i].y = x * mat10 + y * mat11
+ self.vertexes[i].z = z * scaleZ
+
+ for face in self.faces:
+ v1 = face.v[0]
+ v2 = face.v[1]
+ v3 = face.v[2]
+ face.normal = (v2 - v1).cross(v3 - v1)
+ face.normal.normalize()
+
+ minZ = self.getMinimumZ()
+ minV = self.getMinimum()
+ maxV = self.getMaximum()
+ for v in self.vertexes:
+ v.z -= minZ
+ v.x -= minV.x + (maxV.x - minV.x) / 2
+ v.y -= minV.y + (maxV.y - minV.y) / 2
+ self.getMinimumZ()
+ self.modelDirty = True
+
+ def clone(self):
+ p = ProjectObject(self.parent, self.filename)
+
+ p.centerX = self.centerX + 5
+ p.centerY = self.centerY + 5
+
+ p.filename = self.filename
+ p.scale = self.scale
+ p.rotate = self.rotate
+ p.flipX = self.flipX
+ p.flipY = self.flipY
+ p.flipZ = self.flipZ
+ p.swapXZ = self.swapXZ
+ p.swapYZ = self.swapYZ
+ p.extruder = self.extruder
+ p.profile = self.profile
+
+ p.updateModelTransform()
+
+ return p
+
+ def clampXY(self):
+ if self.centerX < -self.getMinimum().x * self.scale + self.parent.extruderOffset[self.extruder].x:
+ self.centerX = -self.getMinimum().x * self.scale + self.parent.extruderOffset[self.extruder].x
+ if self.centerY < -self.getMinimum().y * self.scale + self.parent.extruderOffset[self.extruder].y:
+ self.centerY = -self.getMinimum().y * self.scale + self.parent.extruderOffset[self.extruder].y
+ if self.centerX > self.parent.machineSize.x + self.parent.extruderOffset[self.extruder].x - self.getMaximum().x * self.scale:
+ self.centerX = self.parent.machineSize.x + self.parent.extruderOffset[self.extruder].x - self.getMaximum().x * self.scale
+ if self.centerY > self.parent.machineSize.y + self.parent.extruderOffset[self.extruder].y - self.getMaximum().y * self.scale:
+ self.centerY = self.parent.machineSize.y + self.parent.extruderOffset[self.extruder].y - self.getMaximum().y * self.scale
+
+class projectPlanner(wx.Frame):
+ "Main user interface window"
+ def __init__(self):
+ super(projectPlanner, self).__init__(None, title='Cura - Project Planner')
+
+ self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
+ wx.EVT_CLOSE(self, self.OnClose)
+ #self.SetIcon(icon.getMainIcon())
+
+ self.list = []
+ self.selection = None
+
+ self.machineSize = util3d.Vector3(profile.getPreferenceFloat('machine_width'), profile.getPreferenceFloat('machine_depth'), profile.getPreferenceFloat('machine_height'))
+ self.headSizeMin = util3d.Vector3(profile.getPreferenceFloat('extruder_head_size_min_x'), profile.getPreferenceFloat('extruder_head_size_min_y'),0)
+ self.headSizeMax = util3d.Vector3(profile.getPreferenceFloat('extruder_head_size_max_x'), profile.getPreferenceFloat('extruder_head_size_max_y'),0)
+
+ self.extruderOffset = [
+ util3d.Vector3(0,0,0),
+ util3d.Vector3(profile.getPreferenceFloat('extruder_offset_x1'), profile.getPreferenceFloat('extruder_offset_y1'), 0),
+ util3d.Vector3(profile.getPreferenceFloat('extruder_offset_x2'), profile.getPreferenceFloat('extruder_offset_y2'), 0),
+ util3d.Vector3(profile.getPreferenceFloat('extruder_offset_x3'), profile.getPreferenceFloat('extruder_offset_y3'), 0)]
+
+ self.toolbarPanel = wx.Panel(self, -1)
+ self.toolbar = toolbarUtil.Toolbar(self.toolbarPanel)
+
+ toolbarUtil.NormalButton(self.toolbar, self.OnLoadProject, 'open.png', 'Open project')
+ toolbarUtil.NormalButton(self.toolbar, self.OnSaveProject, 'save.png', 'Save project')
+ self.toolbar.AddSeparator()
+ group = []
+ toolbarUtil.RadioButton(self.toolbar, group, 'object-3d-on.png', 'object-3d-off.png', '3D view', callback=self.On3DClick)
+ toolbarUtil.RadioButton(self.toolbar, group, 'object-top-on.png', 'object-top-off.png', 'Topdown view', callback=self.OnTopClick).SetValue(True)
+ self.toolbar.AddSeparator()
+ toolbarUtil.NormalButton(self.toolbar, self.OnQuit, 'exit.png', 'Close project planner')
+ self.toolbar.AddSeparator()
+ toolbarUtil.NormalButton(self.toolbar, self.OnPreferences, 'preferences.png', 'Project planner preferences')
+
+ self.toolbar.Realize()
+
+ self.toolbar2Panel = wx.Panel(self, -1)
+ self.toolbar2 = toolbarUtil.Toolbar(self.toolbar2Panel)
+ toolbarUtil.NormalButton(self.toolbar2, self.OnAddModel, 'object-add.png', 'Add model')
+ toolbarUtil.NormalButton(self.toolbar2, self.OnRemModel, 'object-remove.png', 'Remove model')
+ self.toolbar2.AddSeparator()
+ toolbarUtil.NormalButton(self.toolbar2, self.OnMoveUp, 'move-up.png', 'Move model up in print list')
+ toolbarUtil.NormalButton(self.toolbar2, self.OnMoveDown, 'move-down.png', 'Move model down in print list')
+ toolbarUtil.NormalButton(self.toolbar2, self.OnCopy, 'copy.png', 'Make a copy of the current selected object')
+ toolbarUtil.NormalButton(self.toolbar2, self.OnSetCustomProfile, 'set-profile.png', 'Set a custom profile to be used to slice a specific object.')
+ self.toolbar2.AddSeparator()
+ toolbarUtil.NormalButton(self.toolbar2, self.OnAutoPlace, 'autoplace.png', 'Automaticly organize the objects on the platform.')
+ toolbarUtil.NormalButton(self.toolbar2, self.OnSlice, 'slice.png', 'Slice to project into a gcode file.')
+ self.toolbar2.Realize()
+
+ sizer = wx.GridBagSizer(2,2)
+ self.SetSizer(sizer)
+ self.preview = PreviewGLCanvas(self)
+ self.listbox = wx.ListBox(self, -1, choices=[])
+ self.addButton = wx.Button(self, -1, "Add")
+ self.remButton = wx.Button(self, -1, "Remove")
+ self.sliceButton = wx.Button(self, -1, "Slice")
+ self.autoPlaceButton = wx.Button(self, -1, "Auto Place")
+
+ sizer.Add(self.toolbarPanel, (0,0), span=(1,1), flag=wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT)
+ sizer.Add(self.toolbar2Panel, (0,1), span=(1,2), flag=wx.EXPAND|wx.TOP|wx.LEFT|wx.RIGHT)
+ sizer.Add(self.preview, (1,0), span=(4,1), flag=wx.EXPAND)
+ sizer.Add(self.listbox, (1,1), span=(1,2), flag=wx.EXPAND)
+ sizer.Add(self.addButton, (2,1), span=(1,1))
+ sizer.Add(self.remButton, (2,2), span=(1,1))
+ sizer.Add(self.sliceButton, (3,1), span=(1,1))
+ sizer.Add(self.autoPlaceButton, (3,2), span=(1,1))
+ sizer.AddGrowableCol(0)
+ sizer.AddGrowableRow(1)
+
+ self.addButton.Bind(wx.EVT_BUTTON, self.OnAddModel)
+ self.remButton.Bind(wx.EVT_BUTTON, self.OnRemModel)
+ self.sliceButton.Bind(wx.EVT_BUTTON, self.OnSlice)
+ self.autoPlaceButton.Bind(wx.EVT_BUTTON, self.OnAutoPlace)
+ self.listbox.Bind(wx.EVT_LISTBOX, self.OnListSelect)
+
+ panel = wx.Panel(self, -1)
+ sizer.Add(panel, (4,1), span=(1,2))
+
+ sizer = wx.GridBagSizer(2,2)
+ panel.SetSizer(sizer)
+
+ self.scaleCtrl = wx.TextCtrl(panel, -1, '')
+ self.rotateCtrl = wx.SpinCtrl(panel, -1, '', size=(21*4,21), style=wx.SP_ARROW_KEYS)
+ self.rotateCtrl.SetRange(0, 360)
+
+ sizer.Add(wx.StaticText(panel, -1, 'Scale'), (0,0), flag=wx.ALIGN_CENTER_VERTICAL)
+ sizer.Add(self.scaleCtrl, (0,1), flag=wx.ALIGN_BOTTOM|wx.EXPAND)
+ sizer.Add(wx.StaticText(panel, -1, 'Rotate'), (1,0), flag=wx.ALIGN_CENTER_VERTICAL)
+ sizer.Add(self.rotateCtrl, (1,1), flag=wx.ALIGN_BOTTOM|wx.EXPAND)
+
+ if int(profile.getPreference('extruder_amount')) > 1:
+ self.extruderCtrl = wx.ComboBox(panel, -1, '1', choices=map(str, range(1, int(profile.getPreference('extruder_amount'))+1)), style=wx.CB_DROPDOWN|wx.CB_READONLY)
+ sizer.Add(wx.StaticText(panel, -1, 'Extruder'), (2,0), flag=wx.ALIGN_CENTER_VERTICAL)
+ sizer.Add(self.extruderCtrl, (2,1), flag=wx.ALIGN_BOTTOM|wx.EXPAND)
+ self.extruderCtrl.Bind(wx.EVT_COMBOBOX, self.OnExtruderChange)
+
+ self.scaleCtrl.Bind(wx.EVT_TEXT, self.OnScaleChange)
+ self.rotateCtrl.Bind(wx.EVT_SPINCTRL, self.OnRotateChange)
+
+ self.SetSize((800,600))
+
+ def OnClose(self, e):
+ self.Destroy()
+
+ def OnQuit(self, e):
+ self.Close()
+
+ def OnPreferences(self, e):
+ prefDialog = preferencesDialog(self)
+ prefDialog.Centre()
+ prefDialog.Show(True)
+
+ def OnSaveProject(self, e):
+ dlg=wx.FileDialog(self, "Save project file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
+ dlg.SetWildcard("Project files (*.curaproject)|*.curaproject")
+ if dlg.ShowModal() == wx.ID_OK:
+ cp = ConfigParser.ConfigParser()
+ i = 0
+ for item in self.list:
+ section = 'model_%d' % (i)
+ cp.add_section(section)
+ cp.set(section, 'filename', item.filename.encode("utf-8"))
+ cp.set(section, 'centerX', str(item.centerX))
+ cp.set(section, 'centerY', str(item.centerY))
+ cp.set(section, 'scale', str(item.scale))
+ cp.set(section, 'rotate', str(item.rotate))
+ cp.set(section, 'flipX', str(item.flipX))
+ cp.set(section, 'flipY', str(item.flipY))
+ cp.set(section, 'flipZ', str(item.flipZ))
+ cp.set(section, 'swapXZ', str(item.swapXZ))
+ cp.set(section, 'swapYZ', str(item.swapYZ))
+ cp.set(section, 'extruder', str(item.extruder+1))
+ if item.profile != None:
+ cp.set(section, 'profile', item.profile)
+ i += 1
+ cp.write(open(dlg.GetPath(), "w"))
+ dlg.Destroy()
+
+ def OnLoadProject(self, e):
+ dlg=wx.FileDialog(self, "Open project file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
+ dlg.SetWildcard("Project files (*.curaproject)|*.curaproject")
+ if dlg.ShowModal() == wx.ID_OK:
+ cp = ConfigParser.ConfigParser()
+ cp.read(dlg.GetPath())
+ self.list = []
+ i = 0
+ while cp.has_section('model_%d' % (i)):
+ section = 'model_%d' % (i)
+
+ item = ProjectObject(self, unicode(cp.get(section, 'filename'), "utf-8"))
+ item.centerX = float(cp.get(section, 'centerX'))
+ item.centerY = float(cp.get(section, 'centerY'))
+ item.scale = float(cp.get(section, 'scale'))
+ item.rotate = float(cp.get(section, 'rotate'))
+ item.flipX = cp.get(section, 'flipX') == 'True'
+ item.flipY = cp.get(section, 'flipY') == 'True'
+ item.flipZ = cp.get(section, 'flipZ') == 'True'
+ item.swapXZ = cp.get(section, 'swapXZ') == 'True'
+ item.swapYZ = cp.get(section, 'swapYZ') == 'True'
+ if cp.has_option(section, 'extruder'):
+ item.extuder = int(cp.get(section, 'extruder')) - 1
+ if cp.has_option(section, 'profile'):
+ item.profile = cp.get(section, 'profile')
+ item.updateModelTransform()
+ i += 1
+
+ self.list.append(item)
+
+ self.selected = self.list[0]
+ self._updateListbox()
+ self.OnListSelect(None)
+ self.preview.Refresh()
+
+ dlg.Destroy()
+
+ def On3DClick(self):
+ self.preview.yaw = 30
+ self.preview.pitch = 60
+ self.preview.zoom = 300
+ self.preview.view3D = True
+ self.preview.Refresh()
+
+ def OnTopClick(self):
+ self.preview.view3D = False
+ self.preview.zoom = self.machineSize.x / 2 + 10
+ self.preview.offsetX = 0
+ self.preview.offsetY = 0
+ self.preview.Refresh()
+
+ def OnListSelect(self, e):
+ if self.listbox.GetSelection() == -1:
+ return
+ self.selection = self.list[self.listbox.GetSelection()]
+ self.scaleCtrl.SetValue(str(self.selection.scale))
+ self.rotateCtrl.SetValue(int(self.selection.rotate))
+ if int(profile.getPreference('extruder_amount')) > 1:
+ self.extruderCtrl.SetValue(str(self.selection.extruder+1))
+ self.preview.Refresh()
+
+ def OnAddModel(self, e):
+ dlg=wx.FileDialog(self, "Open file to print", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST|wx.FD_MULTIPLE)
+ dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")
+ if dlg.ShowModal() == wx.ID_OK:
+ for filename in dlg.GetPaths():
+ item = ProjectObject(self, filename)
+ profile.putPreference('lastFile', item.filename)
+ self.list.append(item)
+ self.selection = item
+ self._updateListbox()
+ self.OnListSelect(None)
+ self.preview.Refresh()
+ dlg.Destroy()
+
+ def OnRemModel(self, e):
+ if self.selection == None:
+ return
+ self.list.remove(self.selection)
+ self._updateListbox()
+ self.preview.Refresh()
+
+ def OnMoveUp(self, e):
+ if self.selection == None:
+ return
+ i = self.listbox.GetSelection()
+ if i == 0:
+ return
+ self.list.remove(self.selection)
+ self.list.insert(i-1, self.selection)
+ self._updateListbox()
+ self.preview.Refresh()
+
+ def OnMoveDown(self, e):
+ if self.selection == None:
+ return
+ i = self.listbox.GetSelection()
+ if i == len(self.list) - 1:
+ return
+ self.list.remove(self.selection)
+ self.list.insert(i+1, self.selection)
+ self._updateListbox()
+ self.preview.Refresh()
+
+ def OnCopy(self, e):
+ if self.selection == None:
+ return
+
+ item = self.selection.clone()
+ self.list.append(item)
+ self.selection = item
+
+ self._updateListbox()
+ self.preview.Refresh()
+
+ def OnSetCustomProfile(self, e):
+ if self.selection == None:
+ return
+
+ dlg=wx.FileDialog(self, "Select profile", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
+ dlg.SetWildcard("Profile files (*.ini)|*.ini;*.INI")
+ if dlg.ShowModal() == wx.ID_OK:
+ self.selection.profile = dlg.GetPath()
+ else:
+ self.selection.profile = None
+ self._updateListbox()
+ dlg.Destroy()
+
+ def _updateListbox(self):
+ self.listbox.Clear()
+ for item in self.list:
+ if item.profile != None:
+ self.listbox.AppendAndEnsureVisible(os.path.split(item.filename)[1] + " *")
+ else:
+ self.listbox.AppendAndEnsureVisible(os.path.split(item.filename)[1])
+ if self.selection in self.list:
+ self.listbox.SetSelection(self.list.index(self.selection))
+ elif len(self.list) > 0:
+ self.selection = self.list[0]
+ self.listbox.SetSelection(0)
+ else:
+ self.selection = None
+ self.listbox.SetSelection(-1)
+
+ def OnAutoPlace(self, e):
+ bestAllowedSize = int(self.machineSize.y)
+ bestArea = self._doAutoPlace(bestAllowedSize)
+ for i in xrange(10, int(self.machineSize.y), 10):
+ area = self._doAutoPlace(i)
+ if area < bestArea:
+ bestAllowedSize = i
+ bestArea = area
+ self._doAutoPlace(bestAllowedSize)
+ for item in self.list:
+ item.clampXY()
+ self.preview.Refresh()
+
+ def _doAutoPlace(self, allowedSizeY):
+ extraSizeMin = self.headSizeMin
+ extraSizeMax = self.headSizeMax
+ if profile.getProfileSettingFloat('skirt_line_count') > 0:
+ skirtSize = profile.getProfileSettingFloat('skirt_line_count') * profile.calculateEdgeWidth() + profile.getProfileSettingFloat('skirt_gap')
+ extraSizeMin = extraSizeMin + util3d.Vector3(skirtSize, skirtSize, 0)
+ extraSizeMax = extraSizeMax + util3d.Vector3(skirtSize, skirtSize, 0)
+
+ if extraSizeMin.x > extraSizeMax.x:
+ posX = self.machineSize.x
+ dirX = -1
+ else:
+ posX = 0
+ dirX = 1
+ posY = 0
+ dirY = 1
+
+ minX = self.machineSize.x
+ minY = self.machineSize.y
+ maxX = 0
+ maxY = 0
+ for item in self.list:
+ item.centerX = posX + item.getMaximum().x * item.scale * dirX
+ item.centerY = posY + item.getMaximum().y * item.scale * dirY
+ if item.centerY + item.getSize().y >= allowedSizeY:
+ if dirX < 0:
+ posX = minX - extraSizeMax.x - 1
+ else:
+ posX = maxX + extraSizeMin.x + 1
+ posY = 0
+ item.centerX = posX + item.getMaximum().x * item.scale * dirX
+ item.centerY = posY + item.getMaximum().y * item.scale * dirY
+ posY += item.getSize().y * item.scale * dirY + extraSizeMin.y + 1
+ minX = min(minX, item.centerX - item.getSize().x * item.scale / 2)
+ minY = min(minY, item.centerY - item.getSize().y * item.scale / 2)
+ maxX = max(maxX, item.centerX + item.getSize().x * item.scale / 2)
+ maxY = max(maxY, item.centerY + item.getSize().y * item.scale / 2)
+
+ for item in self.list:
+ if dirX < 0:
+ item.centerX -= minX / 2
+ else:
+ item.centerX += (self.machineSize.x - maxX) / 2
+ item.centerY += (self.machineSize.y - maxY) / 2
+
+ if minX < 0 or maxX > self.machineSize.x:
+ return ((maxX - minX) + (maxY - minY)) * 100
+
+ return (maxX - minX) + (maxY - minY)
+
+ def OnSlice(self, e):
+ put = profile.setTempOverride
+ oldProfile = profile.getGlobalProfileString()
+
+ put('model_multiply_x', '1')
+ put('model_multiply_y', '1')
+ put('enable_raft', 'False')
+ put('add_start_end_gcode', 'False')
+ put('gcode_extension', 'project_tmp')
+
+ clearZ = 0
+ actionList = []
+ for item in self.list:
+ if item.profile != None and os.path.isfile(item.profile):
+ profile.loadGlobalProfile(item.profile)
+ put('machine_center_x', item.centerX - self.extruderOffset[item.extruder].x)
+ put('machine_center_y', item.centerY - self.extruderOffset[item.extruder].y)
+ put('model_scale', item.scale)
+ put('flip_x', item.flipX)
+ put('flip_y', item.flipY)
+ put('flip_z', item.flipZ)
+ put('model_rotate_base', item.rotate)
+ put('swap_xz', item.swapXZ)
+ put('swap_yz', item.swapYZ)
+
+ action = Action()
+ action.sliceCmd = sliceRun.getSliceCommand(item.filename)
+ action.centerX = item.centerX
+ action.centerY = item.centerY
+ action.extruder = item.extruder
+ action.filename = item.filename
+ clearZ = max(clearZ, item.getMaximum().z * item.scale)
+ action.clearZ = clearZ
+ actionList.append(action)
+
+ if item.profile != None:
+ profile.loadGlobalProfileFromString(oldProfile)
+
+ #Restore the old profile.
+ profile.resetTempOverride()
+
+ dlg=wx.FileDialog(self, "Save project gcode file", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_SAVE)
+ dlg.SetWildcard("GCode file (*.gcode)|*.gcode")
+ if dlg.ShowModal() != wx.ID_OK:
+ dlg.Destroy()
+ return
+ resultFilename = dlg.GetPath()
+ dlg.Destroy()
+
+ pspw = ProjectSliceProgressWindow(actionList, resultFilename)
+ pspw.extruderOffset = self.extruderOffset
+ pspw.Centre()
+ pspw.Show(True)
+
+ def OnScaleChange(self, e):
+ if self.selection == None:
+ return
+ try:
+ self.selection.scale = float(self.scaleCtrl.GetValue())
+ except ValueError:
+ self.selection.scale = 1.0
+ self.preview.Refresh()
+
+ def OnRotateChange(self, e):
+ if self.selection == None:
+ return
+ self.selection.rotate = float(self.rotateCtrl.GetValue())
+ self.selection.updateModelTransform()
+ self.preview.Refresh()
+
+ def OnExtruderChange(self, e):
+ if self.selection == None:
+ return
+ self.selection.extruder = int(self.extruderCtrl.GetValue()) - 1
+ self.preview.Refresh()
+
+class PreviewGLCanvas(glcanvas.GLCanvas):
+ def __init__(self, parent):
+ attribList = (glcanvas.WX_GL_RGBA, glcanvas.WX_GL_DOUBLEBUFFER, glcanvas.WX_GL_DEPTH_SIZE, 24, glcanvas.WX_GL_STENCIL_SIZE, 8)
+ glcanvas.GLCanvas.__init__(self, parent, attribList = attribList)
+ self.parent = parent
+ self.context = glcanvas.GLContext(self)
+ wx.EVT_PAINT(self, self.OnPaint)
+ wx.EVT_SIZE(self, self.OnSize)
+ wx.EVT_ERASE_BACKGROUND(self, self.OnEraseBackground)
+ wx.EVT_LEFT_DOWN(self, self.OnMouseLeftDown)
+ wx.EVT_MOTION(self, self.OnMouseMotion)
+ wx.EVT_MOUSEWHEEL(self, self.OnMouseWheel)
+ self.yaw = 30
+ self.pitch = 60
+ self.zoom = self.parent.machineSize.x / 2 + 10
+ self.offsetX = 0
+ self.offsetY = 0
+ self.view3D = False
+ self.allowDrag = False
+
+ def OnMouseLeftDown(self,e):
+ self.allowDrag = True
+
+ def OnMouseMotion(self,e):
+ if self.allowDrag and e.Dragging() and e.LeftIsDown():
+ if self.view3D:
+ self.yaw += e.GetX() - self.oldX
+ self.pitch -= e.GetY() - self.oldY
+ if self.pitch > 170:
+ self.pitch = 170
+ if self.pitch < 10:
+ self.pitch = 10
+ else:
+ item = self.parent.selection
+ if item != None:
+ item.centerX += float(e.GetX() - self.oldX) * self.zoom / self.GetSize().GetHeight() * 2
+ item.centerY -= float(e.GetY() - self.oldY) * self.zoom / self.GetSize().GetHeight() * 2
+ item.clampXY()
+ self.Refresh()
+ else:
+ self.allowDrag = False
+ if e.Dragging() and e.RightIsDown():
+ if self.view3D:
+ self.zoom += e.GetY() - self.oldY
+ if self.zoom < 1:
+ self.zoom = 1
+ self.Refresh()
+ self.oldX = e.GetX()
+ self.oldY = e.GetY()
+
+ def OnMouseWheel(self,e):
+ if self.view3D:
+ self.zoom *= 1.0 - float(e.GetWheelRotation() / e.GetWheelDelta()) / 10.0
+ if self.zoom < 1.0:
+ self.zoom = 1.0
+ self.Refresh()
+
+ def OnEraseBackground(self,event):
+ #Workaround for windows background redraw flicker.
+ pass
+
+ def OnSize(self,event):
+ self.Refresh()
+
+ def OnPaint(self,event):
+ dc = wx.PaintDC(self)
+ if not hasOpenGLlibs:
+ dc.Clear()
+ dc.DrawText("No PyOpenGL installation found.\nNo preview window available.", 10, 10)
+ return
+ self.SetCurrent(self.context)
+ opengl.InitGL(self, self.view3D, self.zoom)
+ if self.view3D:
+ glTranslate(0,0,-self.zoom)
+ glRotate(-self.pitch, 1,0,0)
+ glRotate(self.yaw, 0,0,1)
+ if False: #self.parent.triangleMesh != None:
+ glTranslate(0,0,-self.parent.triangleMesh.getMaximum().z / 2)
+ else:
+ glScale(1.0/self.zoom, 1.0/self.zoom, 1.0)
+ glTranslate(self.offsetX, self.offsetY, 0.0)
+ glTranslate(-self.parent.machineSize.x/2, -self.parent.machineSize.y/2, 0)
+
+ self.OnDraw()
+ self.SwapBuffers()
+
+ def OnDraw(self):
+ machineSize = self.parent.machineSize
+ opengl.DrawMachine(machineSize)
+ extraSizeMin = self.parent.headSizeMin
+ extraSizeMax = self.parent.headSizeMax
+ if profile.getProfileSettingFloat('skirt_line_count') > 0:
+ skirtSize = profile.getProfileSettingFloat('skirt_line_count') * profile.calculateEdgeWidth() + profile.getProfileSettingFloat('skirt_gap')
+ extraSizeMin = extraSizeMin + util3d.Vector3(skirtSize, skirtSize, 0)
+ extraSizeMax = extraSizeMax + util3d.Vector3(skirtSize, skirtSize, 0)
+
+ for item in self.parent.list:
+ item.validPlacement = True
+ item.gotHit = False
+
+ for idx1 in xrange(0, len(self.parent.list)):
+ item = self.parent.list[idx1]
+ iMin1 = item.getMinimum() * item.scale + util3d.Vector3(item.centerX, item.centerY, 0) - extraSizeMin - self.parent.extruderOffset[item.extruder]
+ iMax1 = item.getMaximum() * item.scale + util3d.Vector3(item.centerX, item.centerY, 0) + extraSizeMax - self.parent.extruderOffset[item.extruder]
+ for idx2 in xrange(0, idx1):
+ item2 = self.parent.list[idx2]
+ iMin2 = item2.getMinimum() * item2.scale + util3d.Vector3(item2.centerX, item2.centerY, 0)
+ iMax2 = item2.getMaximum() * item2.scale + util3d.Vector3(item2.centerX, item2.centerY, 0)
+ if item != item2 and iMax1.x >= iMin2.x and iMin1.x <= iMax2.x and iMax1.y >= iMin2.y and iMin1.y <= iMax2.y:
+ item.validPlacement = False
+ item2.gotHit = True
+
+ seenSelected = False
+ for item in self.parent.list:
+ if item == self.parent.selection:
+ seenSelected = True
+ if item.modelDisplayList == None:
+ item.modelDisplayList = glGenLists(1);
+ if item.modelDirty:
+ item.modelDirty = False
+ modelSize = item.getMaximum() - item.getMinimum()
+ glNewList(item.modelDisplayList, GL_COMPILE)
+ opengl.DrawSTL(item)
+ glEndList()
+
+ if item.validPlacement:
+ if self.parent.selection == item:
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, [1.0, 0.9, 0.7, 1.0])
+ glLightfv(GL_LIGHT0, GL_AMBIENT, [0.2, 0.3, 0.2, 0.0])
+ else:
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, [1.0, 0.8, 0.6, 1.0])
+ glLightfv(GL_LIGHT0, GL_AMBIENT, [0.2, 0.1, 0.1, 0.0])
+ else:
+ if self.parent.selection == item:
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, [1.0, 0.0, 0.0, 0.0])
+ glLightfv(GL_LIGHT0, GL_AMBIENT, [0.2, 0.0, 0.0, 0.0])
+ else:
+ glLightfv(GL_LIGHT0, GL_DIFFUSE, [1.0, 0.0, 0.0, 0.0])
+ glLightfv(GL_LIGHT0, GL_AMBIENT, [0.2, 0.0, 0.0, 0.0])
+ glPushMatrix()
+
+ glEnable(GL_LIGHTING)
+ glTranslate(item.centerX, item.centerY, 0)
+ glPushMatrix()
+ glEnable(GL_NORMALIZE)
+ glScalef(item.scale, item.scale, item.scale)
+ glCallList(item.modelDisplayList)
+ glPopMatrix()
+
+ vMin = item.getMinimum() * item.scale
+ vMax = item.getMaximum() * item.scale
+ vMinHead = vMin - extraSizeMin - self.parent.extruderOffset[item.extruder]
+ vMaxHead = vMax + extraSizeMax - self.parent.extruderOffset[item.extruder]
+
+ glDisable(GL_LIGHTING)
+
+ if self.parent.selection == item:
+ if item.gotHit:
+ glColor3f(1.0,0.0,0.3)
+ else:
+ glColor3f(1.0,0.0,1.0)
+ opengl.DrawBox(vMin, vMax)
+ if item.gotHit:
+ glColor3f(1.0,0.3,0.0)
+ else:
+ glColor3f(1.0,1.0,0.0)
+ opengl.DrawBox(vMinHead, vMaxHead)
+ elif seenSelected:
+ if item.gotHit:
+ glColor3f(0.5,0.0,0.1)
+ else:
+ glColor3f(0.5,0.0,0.5)
+ opengl.DrawBox(vMinHead, vMaxHead)
+ else:
+ if item.gotHit:
+ glColor3f(0.7,0.1,0.0)
+ else:
+ glColor3f(0.7,0.7,0.0)
+ opengl.DrawBox(vMin, vMax)
+
+ glPopMatrix()
+
+ glFlush()
+
+class ProjectSliceProgressWindow(wx.Frame):
+ def __init__(self, actionList, resultFilename):
+ super(ProjectSliceProgressWindow, self).__init__(None, title='Cura')
+ self.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_BTNFACE))
+
+ self.actionList = actionList
+ self.resultFilename = resultFilename
+ self.abort = False
+ self.prevStep = 'start'
+ self.totalDoneFactor = 0.0
+ self.startTime = time.time()
+ self.sliceStartTime = time.time()
+
+ self.sizer = wx.GridBagSizer(2, 2)
+ self.statusText = wx.StaticText(self, -1, "Building: %s" % (resultFilename))
+ self.progressGauge = wx.Gauge(self, -1)
+ self.progressGauge.SetRange(10000)
+ self.progressGauge2 = wx.Gauge(self, -1)
+ self.progressGauge2.SetRange(len(self.actionList))
+ self.abortButton = wx.Button(self, -1, "Abort")
+ self.sizer.Add(self.statusText, (0,0), span=(1,3))
+ self.sizer.Add(self.progressGauge, (1, 0), span=(1,3), flag=wx.EXPAND)
+ self.sizer.Add(self.progressGauge2, (2, 0), span=(1,3), flag=wx.EXPAND)
+
+ self.sizer.Add(self.abortButton, (3,0), span=(1,3), flag=wx.ALIGN_CENTER)
+ self.sizer.AddGrowableCol(0)
+ self.sizer.AddGrowableRow(0)
+
+ self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)
+ self.SetSizer(self.sizer)
+ self.Layout()
+ self.Fit()
+
+ threading.Thread(target=self.OnRun).start()
+
+ def OnAbort(self, e):
+ if self.abort:
+ self.Close()
+ else:
+ self.abort = True
+ self.abortButton.SetLabel('Close')
+
+ def SetProgress(self, stepName, layer, maxLayer):
+ if self.prevStep != stepName:
+ self.totalDoneFactor += sliceRun.sliceStepTimeFactor[self.prevStep]
+ newTime = time.time()
+ #print "#####" + str(newTime-self.startTime) + " " + self.prevStep + " -> " + stepName
+ self.startTime = newTime
+ self.prevStep = stepName
+
+ progresValue = ((self.totalDoneFactor + sliceRun.sliceStepTimeFactor[stepName] * layer / maxLayer) / sliceRun.totalRunTimeFactor) * 10000
+ self.progressGauge.SetValue(int(progresValue))
+ self.statusText.SetLabel(stepName + " [" + str(layer) + "/" + str(maxLayer) + "]")
+
+ def OnRun(self):
+ resultFile = open(self.resultFilename, "w")
+ put = profile.setTempOverride
+ for action in self.actionList:
+ wx.CallAfter(self.SetTitle, "Building: [%d/%d]" % (self.actionList.index(action) + 1, len(self.actionList)))
+ p = subprocess.Popen(action.sliceCmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
+ line = p.stdout.readline()
+
+ maxValue = 1
+ self.progressLog = []
+ while(len(line) > 0):
+ line = line.rstrip()
+ if line[0:9] == "Progress[" and line[-1:] == "]":
+ progress = line[9:-1].split(":")
+ if len(progress) > 2:
+ maxValue = int(progress[2])
+ wx.CallAfter(self.SetProgress, progress[0], int(progress[1]), maxValue)
+ else:
+ print line
+ self.progressLog.append(line)
+ wx.CallAfter(self.statusText.SetLabel, line)
+ if self.abort:
+ p.terminate()
+ wx.CallAfter(self.statusText.SetLabel, "Aborted by user.")
+ resultFile.close()
+ return
+ line = p.stdout.readline()
+ self.returnCode = p.wait()
+
+ put('machine_center_x', action.centerX - self.extruderOffset[action.extruder].x)
+ put('machine_center_y', action.centerY - self.extruderOffset[action.extruder].y)
+ put('clear_z', action.clearZ)
+ put('extruder', action.extruder)
+
+ if action == self.actionList[0]:
+ resultFile.write(';TYPE:CUSTOM\n')
+ resultFile.write('T%d\n' % (action.extruder))
+ currentExtruder = action.extruder
+ resultFile.write(profile.getAlterationFileContents('start.gcode'))
+ else:
+ #reset the extrusion length, and move to the next object center.
+ resultFile.write(';TYPE:CUSTOM\n')
+ resultFile.write(profile.getAlterationFileContents('nextobject.gcode'))
+ resultFile.write(';PRINTNR:%d\n' % self.actionList.index(action))
+ profile.resetTempOverride()
+
+ f = open(action.filename[: action.filename.rfind('.')] + "_export.project_tmp", "r")
+ data = f.read(4096)
+ while data != '':
+ resultFile.write(data)
+ data = f.read(4096)
+ f.close()
+ os.remove(action.filename[: action.filename.rfind('.')] + "_export.project_tmp")
+
+ wx.CallAfter(self.progressGauge.SetValue, 10000)
+ self.totalDoneFactor = 0.0
+ wx.CallAfter(self.progressGauge2.SetValue, self.actionList.index(action) + 1)
+
+ resultFile.write(';TYPE:CUSTOM\n')
+ resultFile.write(profile.getAlterationFileContents('end.gcode'))
+ resultFile.close()
+
+ gcode = gcodeInterpreter.gcode()
+ gcode.load(self.resultFilename)
+
+ self.abort = True
+ sliceTime = time.time() - self.sliceStartTime
+ status = "Build: %s" % (self.resultFilename)
+ status += "\nSlicing took: %02d:%02d" % (sliceTime / 60, sliceTime % 60)
+ status += "\nFilament: %.2fm %.2fg" % (gcode.extrusionAmount / 1000, gcode.calculateWeight() * 1000)
+ status += "\nPrint time: %02d:%02d" % (int(gcode.totalMoveTimeMinute / 60), int(gcode.totalMoveTimeMinute % 60))
+ cost = gcode.calculateCost()
+ if cost != False:
+ status += "\nCost: %s" % (cost)
+ wx.CallAfter(self.statusText.SetLabel, status)
+ wx.CallAfter(self.OnSliceDone)
+
+ def OnSliceDone(self):
+ self.abortButton.Destroy()
+ self.closeButton = wx.Button(self, -1, "Close")
+ self.printButton = wx.Button(self, -1, "Print")
+ self.sizer.Add(self.closeButton, (3,0), span=(1,1))
+ self.sizer.Add(self.printButton, (3,1), span=(1,1))
+ if exporer.hasExporer():
+ self.openFileLocationButton = wx.Button(self, -1, "Open file location")
+ self.Bind(wx.EVT_BUTTON, self.OnOpenFileLocation, self.openFileLocationButton)
+ self.sizer.Add(self.openFileLocationButton, (3,2), span=(1,1))
+ self.Bind(wx.EVT_BUTTON, self.OnAbort, self.closeButton)
+ self.Bind(wx.EVT_BUTTON, self.OnPrint, self.printButton)
+ self.Layout()
+ self.Fit()
+
+ def OnOpenFileLocation(self, e):
+ exporer.openExporer(self.resultFilename)
+
+ def OnPrint(self, e):
+ printWindow.printFile(self.resultFilename)
+
+class preferencesDialog(configBase.configWindowBase):
+ def __init__(self, parent):
+ super(preferencesDialog, self).__init__(title="Project Planner Preferences")
+
+ self.parent = parent
+ wx.EVT_CLOSE(self, self.OnClose)
+
+ extruderAmount = int(profile.getPreference('extruder_amount'))
+
+ left, right, main = self.CreateConfigPanel(self)
+ configBase.TitleRow(left, 'Machine head size')
+ c = configBase.SettingRow(left, 'Head size - X towards home (mm)', 'extruder_head_size_min_x', '0', 'Size of your printer head in the X direction, on the Ultimaker your fan is in this direction.', type = 'preference')
+ validators.validFloat(c, 0.1)
+ c = configBase.SettingRow(left, 'Head size - X towards end (mm)', 'extruder_head_size_max_x', '0', 'Size of your printer head in the X direction.', type = 'preference')
+ validators.validFloat(c, 0.1)
+ c = configBase.SettingRow(left, 'Head size - Y towards home (mm)', 'extruder_head_size_min_y', '0', 'Size of your printer head in the Y direction.', type = 'preference')
+ validators.validFloat(c, 0.1)
+ c = configBase.SettingRow(left, 'Head size - Y towards end (mm)', 'extruder_head_size_max_y', '0', 'Size of your printer head in the Y direction.', type = 'preference')
+ validators.validFloat(c, 0.1)
+
+ self.okButton = wx.Button(left, -1, 'Ok')
+ left.GetSizer().Add(self.okButton, (left.GetSizer().GetRows(), 1))
+ self.okButton.Bind(wx.EVT_BUTTON, self.OnClose)
+
+ self.MakeModal(True)
+ main.Fit()
+ self.Fit()
+
+ def OnClose(self, e):
+ self.parent.headSizeMin = util3d.Vector3(profile.getPreferenceFloat('extruder_head_size_min_x'), profile.getPreferenceFloat('extruder_head_size_min_y'),0)
+ self.parent.headSizeMax = util3d.Vector3(profile.getPreferenceFloat('extruder_head_size_max_x'), profile.getPreferenceFloat('extruder_head_size_max_y'),0)
+
+ self.MakeModal(False)
+ self.Destroy()
+
+def main():
+ app = wx.App(False)
+ projectPlanner().Show(True)
+ app.MainLoop()
+
+if __name__ == '__main__':
+ main()
diff --git a/Cura/gui/simpleMode.py b/Cura/gui/simpleMode.py
index 0141ed6a4f..63928fd3ee 100644
--- a/Cura/gui/simpleMode.py
+++ b/Cura/gui/simpleMode.py
@@ -16,9 +16,9 @@ from util import profile
from util import version
class simpleModeWindow(configBase.configWindowBase):
- "Main user interface window for simple mode"
+ "Main user interface window for Quickprint mode"
def __init__(self):
- super(simpleModeWindow, self).__init__(title='Cura - Simple mode - ' + version.getVersion())
+ super(simpleModeWindow, self).__init__(title='Cura - Quickprint - ' + version.getVersion())
wx.EVT_CLOSE(self, self.OnClose)
#self.SetIcon(icon.getMainIcon())
@@ -51,8 +51,11 @@ class simpleModeWindow(configBase.configWindowBase):
menubar.Append(helpMenu, 'Help')
self.SetMenuBar(menubar)
- self.lastPath = ""
- self.filename = profile.getPreference('lastFile')
+ if profile.getPreference('lastFile') != '':
+ self.filelist = profile.getPreference('lastFile').split(';')
+ self.SetTitle(self.filelist[-1] + ' - Cura - ' + version.getVersion())
+ else:
+ self.filelist = []
self.progressPanelList = []
#Preview window
@@ -67,7 +70,7 @@ class simpleModeWindow(configBase.configWindowBase):
self.printMaterialPLA = wx.RadioButton(configPanel, -1, 'PLA', style=wx.RB_GROUP)
self.printMaterialABS = wx.RadioButton(configPanel, -1, 'ABS')
self.printMaterialDiameter = wx.TextCtrl(configPanel, -1, profile.getProfileSetting('filament_diameter'))
-
+
self.printSupport = wx.CheckBox(configPanel, -1, 'Print support structure')
sizer = wx.GridBagSizer()
@@ -116,9 +119,8 @@ class simpleModeWindow(configBase.configWindowBase):
sizer.Add(printButton, (1,3), flag=wx.RIGHT, border=5)
self.sizer = sizer
- if self.filename != "None":
- self.preview3d.loadModelFile(self.filename)
- self.lastPath = os.path.split(self.filename)[0]
+ if len(self.filelist) > 0:
+ self.preview3d.loadModelFiles(self.filelist)
self.updateProfileToControls()
@@ -136,7 +138,7 @@ class simpleModeWindow(configBase.configWindowBase):
machineCom.InstallFirmware(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../firmware/default.hex"))
def OnCustomFirmware(self, e):
- dlg=wx.FileDialog(self, "Open firmware to upload", self.lastPath, style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
+ dlg=wx.FileDialog(self, "Open firmware to upload", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard("HEX file (*.hex)|*.hex;*.HEX")
if dlg.ShowModal() == wx.ID_OK:
filename = dlg.GetPath()
@@ -150,20 +152,17 @@ class simpleModeWindow(configBase.configWindowBase):
self.updateProfileToControls()
def OnLoadModel(self, e):
- dlg=wx.FileDialog(self, "Open file to print", self.lastPath, style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
+ dlg=wx.FileDialog(self, "Open file to print", os.path.split(profile.getPreference('lastFile'))[0], style=wx.FD_OPEN|wx.FD_FILE_MUST_EXIST)
dlg.SetWildcard("STL files (*.stl)|*.stl;*.STL")
if dlg.ShowModal() == wx.ID_OK:
- self.filename=dlg.GetPath()
- profile.putPreference('lastFile', self.filename)
- if not(os.path.exists(self.filename)):
- return
- self.lastPath = os.path.split(self.filename)[0]
- self.preview3d.loadModelFile(self.filename)
- self.preview3d.setViewMode("Model - Normal")
+ self.filelist = [dlg.GetPath()]
+ profile.putPreference('lastFile', ';'.join(self.filelist))
+ self.preview3d.loadModelFiles(self.filelist)
+ self.preview3d.setViewMode("Normal")
dlg.Destroy()
def OnSlice(self, e):
- if self.filename == None:
+ if len(self.filelist) < 1:
wx.MessageBox('You need to load a file before you can slice it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
return
#save the current profile so we can put it back latter
@@ -254,7 +253,7 @@ class simpleModeWindow(configBase.configWindowBase):
put('filament_density', '1.00')
put('enable_raft', 'False')
put('skirt_line_count', '1')
- else:
+ if self.printMaterialABS.GetValue():
put('filament_density', '0.85')
put('enable_raft', 'True')
put('skirt_line_count', '0')
@@ -262,7 +261,7 @@ class simpleModeWindow(configBase.configWindowBase):
put('bottom_thickness', '0.0')
#Create a progress panel and add it to the window. The progress panel will start the Skein operation.
- spp = sliceProgessPanel.sliceProgessPanel(self, self, self.filename)
+ spp = sliceProgessPanel.sliceProgessPanel(self, self, self.filelist)
self.sizer.Add(spp, (len(self.progressPanelList)+2,0), span=(1,4), flag=wx.EXPAND)
self.sizer.Layout()
newSize = self.GetSize();
@@ -274,13 +273,13 @@ class simpleModeWindow(configBase.configWindowBase):
profile.loadGlobalProfileFromString(oldProfile)
def OnPrint(self, e):
- if self.filename == None:
+ if len(self.filelist) < 1:
wx.MessageBox('You need to load a file and slice it before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
return
- if not os.path.exists(self.filename[: self.filename.rfind('.')] + "_export.gcode"):
+ if not os.path.exists(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode"):
wx.MessageBox('You need to slice the file to GCode before you can print it.', 'Print error', wx.OK | wx.ICON_INFORMATION)
return
- printWindow.printFile(self.filename[: self.filename.rfind('.')] + "_export.gcode")
+ printWindow.printFile(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode")
def OnNormalSwitch(self, e):
from gui import mainWindow
diff --git a/Cura/gui/sliceProgessPanel.py b/Cura/gui/sliceProgessPanel.py
index 6fab8c4d49..d2240a5657 100644
--- a/Cura/gui/sliceProgessPanel.py
+++ b/Cura/gui/sliceProgessPanel.py
@@ -1,45 +1,21 @@
from __future__ import absolute_import
import __init__
-import wx
-import sys
-import math
-import threading
-import subprocess
-import time
+import wx, sys, os, math, threading, subprocess, time, re
from util import profile
from util import sliceRun
+from util import exporer
+from util import gcodeInterpreter
class sliceProgessPanel(wx.Panel):
- def __init__(self, mainWindow, parent, filename):
+ def __init__(self, mainWindow, parent, filelist):
wx.Panel.__init__(self, parent, -1)
self.mainWindow = mainWindow
- self.filename = filename
+ self.filelist = filelist
self.abort = False
- #How long does each step take compared to the others. This is used to make a better scaled progress bar, and guess time left.
- self.sliceStepTimeFactor = {
- 'start': 3.3713991642,
- 'slice': 15.4984838963,
- 'preface': 5.17178297043,
- 'inset': 116.362634182,
- 'fill': 215.702672005,
- 'multiply': 21.9536788464,
- 'speed': 12.759510994,
- 'raft': 31.4580039978,
- 'skirt': 19.3436040878,
- 'skin': 1.0,
- 'joris': 1.0,
- 'comb': 23.7805759907,
- 'cool': 27.148763895,
- 'dimension': 90.4914340973
- }
- self.totalRunTimeFactor = 0
- for v in self.sliceStepTimeFactor.itervalues():
- self.totalRunTimeFactor += v
-
- box = wx.StaticBox(self, -1, filename)
+ box = wx.StaticBox(self, -1, filelist[0])
self.sizer = wx.StaticBoxSizer(box, wx.HORIZONTAL)
mainSizer = wx.BoxSizer(wx.VERTICAL)
@@ -47,7 +23,7 @@ class sliceProgessPanel(wx.Panel):
self.statusText = wx.StaticText(self, -1, "Starting...")
self.progressGauge = wx.Gauge(self, -1)
- self.progressGauge.SetRange(10000)
+ self.progressGauge.SetRange(10000 * len(filelist))
self.abortButton = wx.Button(self, -1, "X", style=wx.BU_EXACTFIT)
self.sizer.Add(self.statusText, 2, flag=wx.ALIGN_CENTER )
self.sizer.Add(self.progressGauge, 2)
@@ -60,9 +36,23 @@ class sliceProgessPanel(wx.Panel):
self.totalDoneFactor = 0.0
self.startTime = time.time()
if profile.getPreference('save_profile') == 'True':
- profile.saveGlobalProfile(self.filename[: self.filename.rfind('.')] + "_profile.ini")
- p = subprocess.Popen(sliceRun.getSliceCommand(self.filename), stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
- self.thread = WorkerThread(self, filename, p)
+ profile.saveGlobalProfile(self.filelist[0][: self.filelist[0].rfind('.')] + "_profile.ini")
+ cmdList = []
+ for filename in self.filelist:
+ idx = self.filelist.index(filename)
+ print filename, idx
+ if idx > 0:
+ profile.setTempOverride('fan_enabled', 'False')
+ profile.setTempOverride('skirt_line_count', '0')
+ profile.setTempOverride('machine_center_x', profile.getProfileSettingFloat('machine_center_x') - profile.getPreferenceFloat('extruder_offset_x%d' % (idx)))
+ profile.setTempOverride('machine_center_y', profile.getProfileSettingFloat('machine_center_y') - profile.getPreferenceFloat('extruder_offset_y%d' % (idx)))
+ profile.setTempOverride('alternative_center', self.filelist[0])
+ if len(self.filelist) > 1:
+ profile.setTempOverride('add_start_end_gcode', 'False')
+ profile.setTempOverride('gcode_extension', 'multi_extrude_tmp')
+ cmdList.append(sliceRun.getSliceCommand(filename))
+ profile.resetTempOverride()
+ self.thread = WorkerThread(self, filelist, cmdList)
def OnAbort(self, e):
if self.abort:
@@ -71,12 +61,15 @@ class sliceProgessPanel(wx.Panel):
self.abort = True
def OnShowGCode(self, e):
- self.mainWindow.preview3d.loadModelFile(self.filename)
+ self.mainWindow.preview3d.loadModelFiles(self.filelist)
self.mainWindow.preview3d.setViewMode("GCode")
def OnShowLog(self, e):
LogWindow('\n'.join(self.progressLog))
+ def OnOpenFileLocation(self, e):
+ exporer.openExporer(self.filelist[0][: self.filelist[0].rfind('.')] + "_export.gcode")
+
def OnSliceDone(self, result):
self.progressGauge.Destroy()
self.abortButton.Destroy()
@@ -87,7 +80,16 @@ class sliceProgessPanel(wx.Panel):
self.Bind(wx.EVT_BUTTON, self.OnAbort, self.abortButton)
self.sizer.Add(self.logButton, 0)
if result.returnCode == 0:
- self.statusText.SetLabel("Ready.")
+ status = "Ready: Filament: %.2fm %.2fg" % (result.gcode.extrusionAmount / 1000, result.gcode.calculateWeight() * 1000)
+ status += " Print time: %02d:%02d" % (int(result.gcode.totalMoveTimeMinute / 60), int(result.gcode.totalMoveTimeMinute % 60))
+ cost = result.gcode.calculateCost()
+ if cost != False:
+ status += " Cost: %s" % (cost)
+ self.statusText.SetLabel(status)
+ if exporer.hasExporer():
+ self.openFileLocationButton = wx.Button(self, -1, "Open file location")
+ self.Bind(wx.EVT_BUTTON, self.OnOpenFileLocation, self.openFileLocationButton)
+ self.sizer.Add(self.openFileLocationButton, 0)
self.showButton = wx.Button(self, -1, "Show result")
self.Bind(wx.EVT_BUTTON, self.OnShowGCode, self.showButton)
self.sizer.Add(self.showButton, 0)
@@ -97,34 +99,35 @@ class sliceProgessPanel(wx.Panel):
self.sizer.Layout()
self.Layout()
self.abort = True
- if self.mainWindow.preview3d.loadReModelFile(self.filename):
+ if self.mainWindow.preview3d.loadReModelFiles(self.filelist):
self.mainWindow.preview3d.setViewMode("GCode")
def SetProgress(self, stepName, layer, maxLayer):
if self.prevStep != stepName:
- self.totalDoneFactor += self.sliceStepTimeFactor[self.prevStep]
+ self.totalDoneFactor += sliceRun.sliceStepTimeFactor[self.prevStep]
newTime = time.time()
#print "#####" + str(newTime-self.startTime) + " " + self.prevStep + " -> " + stepName
self.startTime = newTime
self.prevStep = stepName
- progresValue = ((self.totalDoneFactor + self.sliceStepTimeFactor[stepName] * layer / maxLayer) / self.totalRunTimeFactor) * 10000
+ progresValue = ((self.totalDoneFactor + sliceRun.sliceStepTimeFactor[stepName] * layer / maxLayer) / sliceRun.totalRunTimeFactor) * 10000
self.progressGauge.SetValue(int(progresValue))
self.statusText.SetLabel(stepName + " [" + str(layer) + "/" + str(maxLayer) + "]")
class WorkerThread(threading.Thread):
- def __init__(self, notifyWindow, filename, process):
+ def __init__(self, notifyWindow, filelist, cmdList):
threading.Thread.__init__(self)
- self.filename = filename
+ self.filelist = filelist
self.notifyWindow = notifyWindow
- self.process = process
+ self.cmdList = cmdList
+ self.fileIdx = 0
self.start()
def run(self):
- p = self.process
+ p = subprocess.Popen(self.cmdList[self.fileIdx], stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
line = p.stdout.readline()
- maxValue = 1
self.progressLog = []
+ maxValue = 1
while(len(line) > 0):
line = line.rstrip()
if line[0:9] == "Progress[" and line[-1:] == "]":
@@ -133,7 +136,7 @@ class WorkerThread(threading.Thread):
maxValue = int(progress[2])
wx.CallAfter(self.notifyWindow.SetProgress, progress[0], int(progress[1]), maxValue)
else:
- print line
+ #print line
self.progressLog.append(line)
wx.CallAfter(self.notifyWindow.statusText.SetLabel, line)
if self.notifyWindow.abort:
@@ -142,12 +145,66 @@ class WorkerThread(threading.Thread):
return
line = p.stdout.readline()
self.returnCode = p.wait()
- logfile = open(self.filename[: self.filename.rfind('.')] + "_export.log", "w")
+ logfile = open(self.filelist[self.fileIdx][: self.filelist[self.fileIdx].rfind('.')] + "_export.log", "w")
for logLine in self.progressLog:
logfile.write(logLine)
logfile.write('\n')
logfile.close()
- wx.CallAfter(self.notifyWindow.OnSliceDone, self)
+ self.fileIdx += 1
+ if self.fileIdx == len(self.cmdList):
+ if len(self.filelist) > 1:
+ self._stitchMultiExtruder()
+ self.gcode = gcodeInterpreter.gcode()
+ self.gcode.load(self.filelist[0][:self.filelist[0].rfind('.')]+'_export.gcode')
+ wx.CallAfter(self.notifyWindow.OnSliceDone, self)
+ else:
+ self.run()
+
+ def _stitchMultiExtruder(self):
+ files = []
+ resultFile = open(self.filelist[0][:self.filelist[0].rfind('.')]+'_export.gcode', "w")
+ resultFile.write(';TYPE:CUSTOM\n')
+ resultFile.write(profile.getAlterationFileContents('start.gcode'))
+ for filename in self.filelist:
+ if os.path.isfile(filename[:filename.rfind('.')]+'_export.multi_extrude_tmp'):
+ files.append(open(filename[:filename.rfind('.')]+'_export.multi_extrude_tmp', "r"))
+ else:
+ return
+
+ currentExtruder = 0
+ resultFile.write('T%d\n' % (currentExtruder))
+ layerNr = -1
+ hasLine = True
+ while hasLine:
+ hasLine = False
+ for f in files:
+ layerHasLine = False
+ for line in f:
+ hasLine = True
+ if line.startswith(';LAYER:'):
+ break
+ if 'Z' in line:
+ lastZ = float(re.search('Z([^\s]+)', line).group(1))
+ if not layerHasLine:
+ nextExtruder = files.index(f)
+ resultFile.write(';LAYER:%d\n' % (layerNr))
+ resultFile.write(';EXTRUDER:%d\n' % (nextExtruder))
+ if nextExtruder != currentExtruder:
+ resultFile.write(';TYPE:CUSTOM\n')
+ profile.setTempOverride('extruder', nextExtruder)
+ resultFile.write(profile.getAlterationFileContents('switchExtruder.gcode'))
+ profile.resetTempOverride()
+ currentExtruder = nextExtruder
+ layerHasLine = True
+ resultFile.write(line)
+ layerNr += 1
+ for f in files:
+ f.close()
+ for filename in self.filelist:
+ os.remove(filename[:filename.rfind('.')]+'_export.multi_extrude_tmp')
+ resultFile.write(';TYPE:CUSTOM\n')
+ resultFile.write(profile.getAlterationFileContents('end.gcode'))
+ resultFile.close()
class LogWindow(wx.Frame):
def __init__(self, logText):
diff --git a/Cura/gui/toolbarUtil.py b/Cura/gui/toolbarUtil.py
new file mode 100644
index 0000000000..a609aa6e8f
--- /dev/null
+++ b/Cura/gui/toolbarUtil.py
@@ -0,0 +1,206 @@
+from __future__ import division
+
+import os, sys
+
+import wx
+from wx.lib import buttons
+
+from util import profile
+
+#######################################################
+# toolbarUtil contains help classes and functions for
+# toolbar buttons.
+#######################################################
+
+class Toolbar(wx.ToolBar):
+ def __init__(self, parent):
+ super(Toolbar, self).__init__(parent, -1, style=wx.TB_HORIZONTAL | wx.NO_BORDER)
+ self.SetToolBitmapSize( ( 21, 21 ) )
+
+ if not hasattr(parent, 'popup'):
+ # Create popup window
+ parent.popup = wx.PopupWindow(parent, flags=wx.BORDER_SIMPLE)
+ parent.popup.SetBackgroundColour(wx.SystemSettings.GetColour(wx.SYS_COLOUR_INFOBK))
+ parent.popup.text = wx.StaticText(parent.popup, -1, '')
+ parent.popup.sizer = wx.BoxSizer()
+ parent.popup.sizer.Add(parent.popup.text, flag=wx.EXPAND|wx.ALL, border=1)
+ parent.popup.SetSizer(parent.popup.sizer)
+ parent.popup.owner = None
+
+ def OnPopupDisplay(self, e):
+ self.UpdatePopup(e.GetEventObject())
+ self.GetParent().popup.Show(True)
+
+ def OnPopupHide(self, e):
+ if self.GetParent().popup.owner == e.GetEventObject():
+ self.GetParent().popup.Show(False)
+
+ def UpdatePopup(self, control):
+ popup = self.GetParent().popup
+ popup.owner = control
+ popup.text.SetLabel(control.helpText)
+ popup.text.Wrap(350)
+ popup.Fit();
+ if sys.platform == 'darwin':
+ x, y = self.GetParent().ClientToScreenXY(0, 0)
+ sx, sy = self.GetParent().GetClientSizeTuple()
+ else:
+ x, y = control.ClientToScreenXY(0, 0)
+ sx, sy = control.GetSizeTuple()
+ popup.SetPosition((x, y+sy))
+
+class ToggleButton(buttons.GenBitmapToggleButton):
+ def __init__(self, parent, profileSetting, bitmapFilenameOn, bitmapFilenameOff,
+ helpText='', id=-1, callback=None, size=(20,20)):
+ self.bitmapOn = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOn))
+ self.bitmapOff = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOff))
+
+ super(ToggleButton, self).__init__(parent, id, self.bitmapOff, size=size)
+
+ self.callback = callback
+ self.profileSetting = profileSetting
+ self.helpText = helpText
+
+ self.SetBezelWidth(1)
+ self.SetUseFocusIndicator(False)
+
+ if self.profileSetting != '':
+ self.SetValue(profile.getProfileSetting(self.profileSetting) == 'True')
+ self.Bind(wx.EVT_BUTTON, self.OnButtonProfile)
+ else:
+ self.Bind(wx.EVT_BUTTON, self.OnButton)
+
+ self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
+ self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave)
+
+ parent.AddControl(self)
+
+ def SetBitmap(self, boolValue):
+ if boolValue:
+ self.SetBitmapLabel(self.bitmapOn, False)
+ else:
+ self.SetBitmapLabel(self.bitmapOff, False)
+
+ def SetValue(self, boolValue):
+ self.SetBitmap(boolValue)
+ super(ToggleButton, self).SetValue(boolValue)
+
+ def OnButton(self, event):
+ self.SetBitmap(self.GetValue())
+ event.Skip()
+
+ def OnButtonProfile(self, event):
+ if buttons.GenBitmapToggleButton.GetValue(self):
+ self.SetBitmap(True)
+ profile.putProfileSetting(self.profileSetting, 'True')
+ else:
+ self.SetBitmap(False)
+ profile.putProfileSetting(self.profileSetting, 'False')
+ self.callback()
+ event.Skip()
+
+ def OnMouseEnter(self, event):
+ self.GetParent().OnPopupDisplay(event)
+ self.SetBitmap(True)
+ self.Refresh()
+ event.Skip()
+
+ def OnMouseLeave(self, event):
+ self.GetParent().OnPopupHide(event)
+ self.SetBitmap(self.GetValue())
+ self.Refresh()
+ event.Skip()
+
+class RadioButton(buttons.GenBitmapButton):
+ def __init__(self, parent, group, bitmapFilenameOn, bitmapFilenameOff,
+ helpText='', id=-1, callback=None, size=(20,20)):
+ self.bitmapOn = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOn))
+ self.bitmapOff = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilenameOff))
+
+ super(RadioButton, self).__init__(parent, id, self.bitmapOff, size=size)
+
+ self.group = group
+ group.append(self)
+ self.callback = callback
+ self.helpText = helpText
+ self._value = False
+
+ self.SetBezelWidth(1)
+ self.SetUseFocusIndicator(False)
+
+ self.Bind(wx.EVT_BUTTON, self.OnButton)
+
+ self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
+ self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave)
+
+ if len(group) == 1:
+ self.SetValue(True)
+
+ parent.AddControl(self)
+
+ def SetBitmap(self, boolValue):
+ if boolValue:
+ self.SetBitmapLabel(self.bitmapOn, False)
+ else:
+ self.SetBitmapLabel(self.bitmapOff, False)
+ self.Refresh()
+
+ def SetValue(self, boolValue):
+ self._value = boolValue
+ self.SetBitmap(self.GetValue())
+ if boolValue == True:
+ for other in self.group:
+ if other != self:
+ other.SetValue(False)
+
+ def GetValue(self):
+ return self._value
+
+ def OnButton(self, event):
+ self.SetValue(True)
+ self.callback()
+ event.Skip()
+
+ def OnMouseEnter(self, event):
+ self.GetParent().OnPopupDisplay(event)
+ self.SetBitmap(True)
+ self.Refresh()
+ event.Skip()
+
+ def OnMouseLeave(self, event):
+ self.GetParent().OnPopupHide(event)
+ self.SetBitmap(self.GetValue())
+ self.Refresh()
+ event.Skip()
+
+class NormalButton(buttons.GenBitmapButton):
+ def __init__(self, parent, callback, bitmapFilename,
+ helpText='', id=-1, size=(20,20)):
+ self.bitmap = wx.Bitmap(os.path.join(os.path.split(__file__)[0], "../images", bitmapFilename))
+ super(NormalButton, self).__init__(parent, id, self.bitmap, size=size)
+
+ self.helpText = helpText
+ self.callback = callback
+
+ self.SetBezelWidth(1)
+ self.SetUseFocusIndicator(False)
+
+ self.Bind(wx.EVT_ENTER_WINDOW, self.OnMouseEnter)
+ self.Bind(wx.EVT_LEAVE_WINDOW, self.OnMouseLeave)
+
+ self.Bind(wx.EVT_BUTTON, self.OnButton)
+
+ parent.AddControl(self)
+
+ def OnButton(self, event):
+ self.GetParent().OnPopupHide(event)
+ self.callback(event)
+
+ def OnMouseEnter(self, event):
+ self.GetParent().OnPopupDisplay(event)
+ event.Skip()
+
+ def OnMouseLeave(self, event):
+ self.GetParent().OnPopupHide(event)
+ event.Skip()
+
diff --git a/Cura/gui/validators.py b/Cura/gui/validators.py
index b1da7783a3..f29e8d1eb9 100644
--- a/Cura/gui/validators.py
+++ b/Cura/gui/validators.py
@@ -11,7 +11,7 @@ SUCCESS = 0
WARNING = 1
ERROR = 2
-class validFloat():
+class validFloat(object):
def __init__(self, setting, minValue = None, maxValue = None):
self.setting = setting
self.setting.validators.append(self)
@@ -29,7 +29,7 @@ class validFloat():
except (ValueError, SyntaxError):
return ERROR, '"' + str(self.setting.GetValue()) + '" is not a valid number or expression'
-class validInt():
+class validInt(object):
def __init__(self, setting, minValue = None, maxValue = None):
self.setting = setting
self.setting.validators.append(self)
@@ -47,7 +47,7 @@ class validInt():
except (ValueError, SyntaxError):
return ERROR, '"' + str(self.setting.GetValue()) + '" is not a valid whole number or expression'
-class warningAbove():
+class warningAbove(object):
def __init__(self, setting, minValueForWarning, warningMessage):
self.setting = setting
self.setting.validators.append(self)
@@ -68,7 +68,7 @@ class warningAbove():
#We already have an error by the int/float validator in this case.
return SUCCESS, ''
-class wallThicknessValidator():
+class wallThicknessValidator(object):
def __init__(self, setting):
self.setting = setting
self.setting.validators.append(self)
@@ -94,7 +94,7 @@ class wallThicknessValidator():
#We already have an error by the int/float validator in this case.
return SUCCESS, ''
-class printSpeedValidator():
+class printSpeedValidator(object):
def __init__(self, setting):
self.setting = setting
self.setting.validators.append(self)
diff --git a/Cura/images/autoplace.png b/Cura/images/autoplace.png
new file mode 100644
index 0000000000..440295c15c
--- /dev/null
+++ b/Cura/images/autoplace.png
Binary files differ
diff --git a/Cura/images/copy.png b/Cura/images/copy.png
new file mode 100644
index 0000000000..5cdeb5fc73
--- /dev/null
+++ b/Cura/images/copy.png
Binary files differ
diff --git a/Cura/images/exit.png b/Cura/images/exit.png
new file mode 100644
index 0000000000..846776e3b6
--- /dev/null
+++ b/Cura/images/exit.png
Binary files differ
diff --git a/Cura/images/move-down.png b/Cura/images/move-down.png
new file mode 100644
index 0000000000..5891219e49
--- /dev/null
+++ b/Cura/images/move-down.png
Binary files differ
diff --git a/Cura/images/move-up.png b/Cura/images/move-up.png
new file mode 100644
index 0000000000..b3d9cef97e
--- /dev/null
+++ b/Cura/images/move-up.png
Binary files differ
diff --git a/Cura/images/object-3d-off.png b/Cura/images/object-3d-off.png
new file mode 100644
index 0000000000..b9361e424e
--- /dev/null
+++ b/Cura/images/object-3d-off.png
Binary files differ
diff --git a/Cura/images/object-3d-on.png b/Cura/images/object-3d-on.png
new file mode 100644
index 0000000000..9a8b1c1706
--- /dev/null
+++ b/Cura/images/object-3d-on.png
Binary files differ
diff --git a/Cura/images/object-add.png b/Cura/images/object-add.png
new file mode 100644
index 0000000000..1b362dabd6
--- /dev/null
+++ b/Cura/images/object-add.png
Binary files differ
diff --git a/Cura/images/object-max-size.png b/Cura/images/object-max-size.png
new file mode 100644
index 0000000000..c836294072
--- /dev/null
+++ b/Cura/images/object-max-size.png
Binary files differ
diff --git a/Cura/images/object-mirror-x-off.png b/Cura/images/object-mirror-x-off.png
new file mode 100644
index 0000000000..302b2b2ca5
--- /dev/null
+++ b/Cura/images/object-mirror-x-off.png
Binary files differ
diff --git a/Cura/images/object-mirror-x-on.png b/Cura/images/object-mirror-x-on.png
new file mode 100644
index 0000000000..4d07b34954
--- /dev/null
+++ b/Cura/images/object-mirror-x-on.png
Binary files differ
diff --git a/Cura/images/object-mirror-y-off.png b/Cura/images/object-mirror-y-off.png
new file mode 100644
index 0000000000..5f72a439db
--- /dev/null
+++ b/Cura/images/object-mirror-y-off.png
Binary files differ
diff --git a/Cura/images/object-mirror-y-on.png b/Cura/images/object-mirror-y-on.png
new file mode 100644
index 0000000000..f7dfc62231
--- /dev/null
+++ b/Cura/images/object-mirror-y-on.png
Binary files differ
diff --git a/Cura/images/object-mirror-z-off.png b/Cura/images/object-mirror-z-off.png
new file mode 100644
index 0000000000..801fa983c0
--- /dev/null
+++ b/Cura/images/object-mirror-z-off.png
Binary files differ
diff --git a/Cura/images/object-mirror-z-on.png b/Cura/images/object-mirror-z-on.png
new file mode 100644
index 0000000000..c599670cd8
--- /dev/null
+++ b/Cura/images/object-mirror-z-on.png
Binary files differ
diff --git a/Cura/images/object-mul-x-add.png b/Cura/images/object-mul-x-add.png
new file mode 100644
index 0000000000..dda2ef3048
--- /dev/null
+++ b/Cura/images/object-mul-x-add.png
Binary files differ
diff --git a/Cura/images/object-mul-x-sub.png b/Cura/images/object-mul-x-sub.png
new file mode 100644
index 0000000000..dc8345d122
--- /dev/null
+++ b/Cura/images/object-mul-x-sub.png
Binary files differ
diff --git a/Cura/images/object-mul-y-add.png b/Cura/images/object-mul-y-add.png
new file mode 100644
index 0000000000..b9d4ca4bc4
--- /dev/null
+++ b/Cura/images/object-mul-y-add.png
Binary files differ
diff --git a/Cura/images/object-mul-y-sub.png b/Cura/images/object-mul-y-sub.png
new file mode 100644
index 0000000000..e5c155b0cc
--- /dev/null
+++ b/Cura/images/object-mul-y-sub.png
Binary files differ
diff --git a/Cura/images/object-remove.png b/Cura/images/object-remove.png
new file mode 100644
index 0000000000..064e523caa
--- /dev/null
+++ b/Cura/images/object-remove.png
Binary files differ
diff --git a/Cura/images/object-rotate.png b/Cura/images/object-rotate.png
new file mode 100644
index 0000000000..c54160e1de
--- /dev/null
+++ b/Cura/images/object-rotate.png
Binary files differ
diff --git a/Cura/images/object-scale.png b/Cura/images/object-scale.png
new file mode 100644
index 0000000000..6927afe96e
--- /dev/null
+++ b/Cura/images/object-scale.png
Binary files differ
diff --git a/Cura/images/object-swap-xz-off.png b/Cura/images/object-swap-xz-off.png
new file mode 100644
index 0000000000..830570e6b5
--- /dev/null
+++ b/Cura/images/object-swap-xz-off.png
Binary files differ
diff --git a/Cura/images/object-swap-xz-on.png b/Cura/images/object-swap-xz-on.png
new file mode 100644
index 0000000000..c594954952
--- /dev/null
+++ b/Cura/images/object-swap-xz-on.png
Binary files differ
diff --git a/Cura/images/object-swap-yz-off.png b/Cura/images/object-swap-yz-off.png
new file mode 100644
index 0000000000..19abb4288e
--- /dev/null
+++ b/Cura/images/object-swap-yz-off.png
Binary files differ
diff --git a/Cura/images/object-swap-yz-on.png b/Cura/images/object-swap-yz-on.png
new file mode 100644
index 0000000000..bb60079c3d
--- /dev/null
+++ b/Cura/images/object-swap-yz-on.png
Binary files differ
diff --git a/Cura/images/object-top-off.png b/Cura/images/object-top-off.png
new file mode 100644
index 0000000000..70de0298da
--- /dev/null
+++ b/Cura/images/object-top-off.png
Binary files differ
diff --git a/Cura/images/object-top-on.png b/Cura/images/object-top-on.png
new file mode 100644
index 0000000000..3e5c281388
--- /dev/null
+++ b/Cura/images/object-top-on.png
Binary files differ
diff --git a/Cura/images/open.png b/Cura/images/open.png
new file mode 100644
index 0000000000..32ec3edbb8
--- /dev/null
+++ b/Cura/images/open.png
Binary files differ
diff --git a/Cura/images/preferences.png b/Cura/images/preferences.png
new file mode 100644
index 0000000000..dab6b5190b
--- /dev/null
+++ b/Cura/images/preferences.png
Binary files differ
diff --git a/Cura/images/print-move-home.png b/Cura/images/print-move-home.png
new file mode 100644
index 0000000000..9ee717c8b1
--- /dev/null
+++ b/Cura/images/print-move-home.png
Binary files differ
diff --git a/Cura/images/print-move-x-1.png b/Cura/images/print-move-x-1.png
new file mode 100644
index 0000000000..e7358c8281
--- /dev/null
+++ b/Cura/images/print-move-x-1.png
Binary files differ
diff --git a/Cura/images/print-move-x-10.png b/Cura/images/print-move-x-10.png
new file mode 100644
index 0000000000..184a398b7c
--- /dev/null
+++ b/Cura/images/print-move-x-10.png
Binary files differ
diff --git a/Cura/images/print-move-x-100.png b/Cura/images/print-move-x-100.png
new file mode 100644
index 0000000000..08dd9a9f63
--- /dev/null
+++ b/Cura/images/print-move-x-100.png
Binary files differ
diff --git a/Cura/images/print-move-x1.png b/Cura/images/print-move-x1.png
new file mode 100644
index 0000000000..93f7a3f2ea
--- /dev/null
+++ b/Cura/images/print-move-x1.png
Binary files differ
diff --git a/Cura/images/print-move-x10.png b/Cura/images/print-move-x10.png
new file mode 100644
index 0000000000..7d32c0985a
--- /dev/null
+++ b/Cura/images/print-move-x10.png
Binary files differ
diff --git a/Cura/images/print-move-x100.png b/Cura/images/print-move-x100.png
new file mode 100644
index 0000000000..786bbf3618
--- /dev/null
+++ b/Cura/images/print-move-x100.png
Binary files differ
diff --git a/Cura/images/print-move-y-1.png b/Cura/images/print-move-y-1.png
new file mode 100644
index 0000000000..136c625fc3
--- /dev/null
+++ b/Cura/images/print-move-y-1.png
Binary files differ
diff --git a/Cura/images/print-move-y-10.png b/Cura/images/print-move-y-10.png
new file mode 100644
index 0000000000..5db06550a3
--- /dev/null
+++ b/Cura/images/print-move-y-10.png
Binary files differ
diff --git a/Cura/images/print-move-y-100.png b/Cura/images/print-move-y-100.png
new file mode 100644
index 0000000000..cc66e4e8e6
--- /dev/null
+++ b/Cura/images/print-move-y-100.png
Binary files differ
diff --git a/Cura/images/print-move-y1.png b/Cura/images/print-move-y1.png
new file mode 100644
index 0000000000..60455c49e2
--- /dev/null
+++ b/Cura/images/print-move-y1.png
Binary files differ
diff --git a/Cura/images/print-move-y10.png b/Cura/images/print-move-y10.png
new file mode 100644
index 0000000000..d2a9ff82c0
--- /dev/null
+++ b/Cura/images/print-move-y10.png
Binary files differ
diff --git a/Cura/images/print-move-y100.png b/Cura/images/print-move-y100.png
new file mode 100644
index 0000000000..db6cb3d699
--- /dev/null
+++ b/Cura/images/print-move-y100.png
Binary files differ
diff --git a/Cura/images/print-move-z-0.1.png b/Cura/images/print-move-z-0.1.png
new file mode 100644
index 0000000000..83adeb26ed
--- /dev/null
+++ b/Cura/images/print-move-z-0.1.png
Binary files differ
diff --git a/Cura/images/print-move-z-1.png b/Cura/images/print-move-z-1.png
new file mode 100644
index 0000000000..f63e016ba0
--- /dev/null
+++ b/Cura/images/print-move-z-1.png
Binary files differ
diff --git a/Cura/images/print-move-z-10.png b/Cura/images/print-move-z-10.png
new file mode 100644
index 0000000000..9e211c866e
--- /dev/null
+++ b/Cura/images/print-move-z-10.png
Binary files differ
diff --git a/Cura/images/print-move-z0.1.png b/Cura/images/print-move-z0.1.png
new file mode 100644
index 0000000000..0dad3b3a76
--- /dev/null
+++ b/Cura/images/print-move-z0.1.png
Binary files differ
diff --git a/Cura/images/print-move-z1.png b/Cura/images/print-move-z1.png
new file mode 100644
index 0000000000..c98ed52b49
--- /dev/null
+++ b/Cura/images/print-move-z1.png
Binary files differ
diff --git a/Cura/images/print-move-z10.png b/Cura/images/print-move-z10.png
new file mode 100644
index 0000000000..4cf61f4824
--- /dev/null
+++ b/Cura/images/print-move-z10.png
Binary files differ
diff --git a/Cura/images/save.png b/Cura/images/save.png
new file mode 100644
index 0000000000..8072aea326
--- /dev/null
+++ b/Cura/images/save.png
Binary files differ
diff --git a/Cura/images/set-profile.png b/Cura/images/set-profile.png
new file mode 100644
index 0000000000..a9f8c9ea1d
--- /dev/null
+++ b/Cura/images/set-profile.png
Binary files differ
diff --git a/Cura/images/slice.png b/Cura/images/slice.png
new file mode 100644
index 0000000000..e2172457b8
--- /dev/null
+++ b/Cura/images/slice.png
Binary files differ
diff --git a/Cura/images/view-gcode-off.png b/Cura/images/view-gcode-off.png
new file mode 100644
index 0000000000..714e92e31b
--- /dev/null
+++ b/Cura/images/view-gcode-off.png
Binary files differ
diff --git a/Cura/images/view-gcode-on.png b/Cura/images/view-gcode-on.png
new file mode 100644
index 0000000000..e8eb43ebc4
--- /dev/null
+++ b/Cura/images/view-gcode-on.png
Binary files differ
diff --git a/Cura/images/view-mixed-off.png b/Cura/images/view-mixed-off.png
new file mode 100644
index 0000000000..7bc094218a
--- /dev/null
+++ b/Cura/images/view-mixed-off.png
Binary files differ
diff --git a/Cura/images/view-mixed-on.png b/Cura/images/view-mixed-on.png
new file mode 100644
index 0000000000..3aacec1e88
--- /dev/null
+++ b/Cura/images/view-mixed-on.png
Binary files differ
diff --git a/Cura/images/view-normal-off.png b/Cura/images/view-normal-off.png
new file mode 100644
index 0000000000..268b737edc
--- /dev/null
+++ b/Cura/images/view-normal-off.png
Binary files differ
diff --git a/Cura/images/view-normal-on.png b/Cura/images/view-normal-on.png
new file mode 100644
index 0000000000..674aa58371
--- /dev/null
+++ b/Cura/images/view-normal-on.png
Binary files differ
diff --git a/Cura/images/view-transparent-off.png b/Cura/images/view-transparent-off.png
new file mode 100644
index 0000000000..1482327e21
--- /dev/null
+++ b/Cura/images/view-transparent-off.png
Binary files differ
diff --git a/Cura/images/view-transparent-on.png b/Cura/images/view-transparent-on.png
new file mode 100644
index 0000000000..1f63f2d4d8
--- /dev/null
+++ b/Cura/images/view-transparent-on.png
Binary files differ
diff --git a/Cura/images/view-xray-off.png b/Cura/images/view-xray-off.png
new file mode 100644
index 0000000000..9e898359d5
--- /dev/null
+++ b/Cura/images/view-xray-off.png
Binary files differ
diff --git a/Cura/images/view-xray-on.png b/Cura/images/view-xray-on.png
new file mode 100644
index 0000000000..8b7ff82f62
--- /dev/null
+++ b/Cura/images/view-xray-on.png
Binary files differ
diff --git a/Cura/util/exporer.py b/Cura/util/exporer.py
new file mode 100644
index 0000000000..8fcc65faad
--- /dev/null
+++ b/Cura/util/exporer.py
@@ -0,0 +1,26 @@
+from __future__ import absolute_import
+import __init__
+
+import sys, os, subprocess
+
+def hasExporer():
+ if sys.platform == 'win32' or sys.platform == 'cygwin' or sys.platform == 'darwin':
+ return True
+ if sys.platform == 'linux2':
+ if os.path.isfile('/usr/bin/nautilus'):
+ return True
+ if os.path.isfile('/usr/bin/dolphin'):
+ return True
+ return False
+
+def openExporer(filename):
+ if sys.platform == 'win32' or sys.platform == 'cygwin':
+ subprocess.Popen(['explorer', "/select,%s" % (filename)])
+ if sys.platform == 'darwin':
+ subprocess.Popen(['open', os.path.split(filename)[0]])
+ if sys.platform == 'linux2':
+ if os.path.isfile('/usr/bin/nautilus'):
+ subprocess.Popen(['/usr/bin/nautilus', os.path.split(filename)[0]])
+ elif os.path.isfile('/usr/bin/dolphin'):
+ subprocess.Popen(['/usr/bin/dolphin', os.path.split(filename)[0]])
+
diff --git a/Cura/util/gcodeInterpreter.py b/Cura/util/gcodeInterpreter.py
index 0518be2731..0858617879 100644
--- a/Cura/util/gcodeInterpreter.py
+++ b/Cura/util/gcodeInterpreter.py
@@ -9,13 +9,14 @@ import os
from util import util3d
from util import profile
-class gcodePath():
- def __init__(self, newType, pathType, startPoint):
+class gcodePath(object):
+ def __init__(self, newType, pathType, layerThickness, startPoint):
self.type = newType
self.pathType = pathType
+ self.layerThickness = layerThickness
self.list = [startPoint]
-class gcode():
+class gcode(object):
def __init__(self):
self.regMatch = {}
self.layerList = []
@@ -36,7 +37,18 @@ class gcode():
#Calculates the weight of the filament in kg
radius = float(profile.getProfileSetting('filament_diameter')) / 2
volumeM3 = (self.extrusionAmount * (math.pi * radius * radius)) / (1000*1000*1000)
- return volumeM3 * float(profile.getPreference('filament_density'))
+ return volumeM3 * profile.getPreferenceFloat('filament_density')
+
+ def calculateCost(self):
+ cost_kg = profile.getPreferenceFloat('filament_cost_kg')
+ cost_meter = profile.getPreferenceFloat('filament_cost_meter')
+ if cost_kg > 0.0 and cost_meter > 0.0:
+ return "%.2f / %.2f" % (self.calculateWeight() * cost_kg, self.extrusionAmount / 1000 * cost_meter)
+ elif cost_kg > 0.0:
+ return "%.2f" % (self.calculateWeight() * cost_kg)
+ elif cost_meter > 0.0:
+ return "%.2f" % (self.extrusionAmount / 1000 * cost_meter)
+ return False
def _load(self, gcodeFile):
filePos = 0
@@ -45,14 +57,16 @@ class gcode():
currentE = 0.0
totalExtrusion = 0.0
maxExtrusion = 0.0
+ currentExtruder = 0
totalMoveTimeMinute = 0.0
scale = 1.0
posAbs = True
feedRate = 3600
+ layerThickness = 0.1
pathType = 'CUSTOM';
startCodeDone = False
currentLayer = []
- currentPath = gcodePath('move', pathType, pos.copy())
+ currentPath = gcodePath('move', pathType, layerThickness, pos.copy())
currentPath.list[0].e = totalExtrusion
currentLayer.append(currentPath)
for line in gcodeFile:
@@ -76,9 +90,21 @@ class gcode():
pathType = 'WALL-INNER'
elif comment == 'skirt':
pathType = 'SKIRT'
+ if comment.startswith('LAYER:'):
+ self.layerList.append(currentLayer)
+ currentLayer = []
if pathType != "CUSTOM":
startCodeDone = True
line = line[0:line.find(';')]
+ T = self.getCodeInt(line, 'T')
+ if T is not None:
+ if currentExtruder > 0:
+ posOffset.x -= profile.getPreferenceFloat('extruder_offset_x%d' % (currentExtruder))
+ posOffset.y -= profile.getPreferenceFloat('extruder_offset_y%d' % (currentExtruder))
+ currentExtruder = T
+ if currentExtruder > 0:
+ posOffset.x += profile.getPreferenceFloat('extruder_offset_x%d' % (currentExtruder))
+ posOffset.y += profile.getPreferenceFloat('extruder_offset_y%d' % (currentExtruder))
G = self.getCodeInt(line, 'G')
if G is not None:
@@ -91,23 +117,22 @@ class gcode():
oldPos = pos.copy()
if x is not None:
if posAbs:
- pos.x = x * scale
+ pos.x = x * scale + posOffset.x
else:
pos.x += x * scale
if y is not None:
if posAbs:
- pos.y = y * scale
+ pos.y = y * scale + posOffset.y
else:
pos.y += y * scale
if z is not None:
if posAbs:
- pos.z = z * scale
+ pos.z = z * scale + posOffset.z
else:
pos.z += z * scale
#Check if we have a new layer.
- if oldPos.z < pos.z and startCodeDone and len(currentLayer) > 0:
- self.layerList.append(currentLayer)
- currentLayer = []
+ if oldPos.z != pos.z:
+ layerThickness = abs(oldPos.z - pos.z)
if f is not None:
feedRate = f
if x is not None or y is not None or z is not None:
@@ -131,7 +156,7 @@ class gcode():
if totalExtrusion > maxExtrusion:
maxExtrusion = totalExtrusion
if currentPath.type != moveType or currentPath.pathType != pathType:
- currentPath = gcodePath(moveType, pathType, currentPath.list[-1])
+ currentPath = gcodePath(moveType, pathType, layerThickness, currentPath.list[-1])
currentLayer.append(currentPath)
newPos = pos.copy()
newPos.e = totalExtrusion
@@ -200,8 +225,8 @@ class gcode():
self.layerList.append(currentLayer)
self.extrusionAmount = maxExtrusion
self.totalMoveTimeMinute = totalMoveTimeMinute
- print "Extruded a total of: %d mm of filament" % (self.extrusionAmount)
- print "Estimated print duration: %.2f minutes" % (self.totalMoveTimeMinute)
+ #print "Extruded a total of: %d mm of filament" % (self.extrusionAmount)
+ #print "Estimated print duration: %.2f minutes" % (self.totalMoveTimeMinute)
def getCodeInt(self, line, code):
if code not in self.regMatch:
diff --git a/Cura/util/profile.py b/Cura/util/profile.py
index bee1ef3fc8..2be195e740 100644
--- a/Cura/util/profile.py
+++ b/Cura/util/profile.py
@@ -3,13 +3,10 @@ from __future__ import division
#Init has to be imported first because it has code to workaround the python bug where relative imports don't work if the module is imported as a main module.
import __init__
-import ConfigParser
-import os
-import traceback
-import math
+import ConfigParser, os, traceback, math, re, zlib, base64
#########################################################
-## Profile and preferences functions
+## Default settings when none are found.
#########################################################
#Single place to store the defaults, so we have a consistent set of default settings.
@@ -20,7 +17,7 @@ profileDefaultSettings = {
'solid_layer_thickness': '0.6',
'fill_density': '20',
'skirt_line_count': '1',
- 'skirt_gap': '6.0',
+ 'skirt_gap': '3.0',
'print_speed': '50',
'print_temperature': '0',
'support': 'None',
@@ -29,15 +26,15 @@ profileDefaultSettings = {
'machine_center_x': '100',
'machine_center_y': '100',
'retraction_min_travel': '5.0',
- 'retraction_speed': '13.5',
+ 'retraction_speed': '40.0',
'retraction_amount': '0.0',
'retraction_extra': '0.0',
'travel_speed': '150',
- 'max_z_speed': '1.0',
- 'bottom_layer_speed': '25',
+ 'max_z_speed': '3.0',
+ 'bottom_layer_speed': '20',
'cool_min_layer_time': '10',
'fan_enabled': 'True',
- 'fan_layer': '0',
+ 'fan_layer': '1',
'fan_speed': '100',
'model_scale': '1.0',
'flip_x': 'False',
@@ -56,6 +53,7 @@ profileDefaultSettings = {
'fill_overlap': '15',
'support_rate': '50',
'support_distance': '0.5',
+ 'support_margin': '3.0',
'joris': 'False',
'enable_skin': 'False',
'enable_raft': 'False',
@@ -66,14 +64,86 @@ profileDefaultSettings = {
'raft_base_material_amount': '100',
'raft_interface_material_amount': '100',
'bottom_thickness': '0.3',
+
+ 'add_start_end_gcode': 'True',
+ 'gcode_extension': 'gcode',
+ 'alternative_center': '',
+ 'clear_z': '0.0',
+ 'extruder': '0',
+}
+alterationDefault = {
+#######################################################################################
+ 'start.gcode': """;Start GCode
+G21 ;metric values
+G90 ;absolute positioning
+
+G28 X0 Y0 ;move X/Y to min endstops
+G28 Z0 ;move Z to min endstops
+
+; if your prints start too high, try changing the Z0.0 below
+; to Z1.0 - the number after the Z is the actual, physical
+; height of the nozzle in mm. This can take some messing around
+; with to get just right...
+G92 X0 Y0 Z0 E0 ;reset software position to front/left/z=0.0
+G1 Z15.0 F{max_z_speed} ;move the platform down 15mm
+G92 E0 ;zero the extruded length
+
+G1 F200 E5 ;extrude 5mm of feed stock
+G1 F200 E3.5 ;reverse feed stock by 1.5mm
+G92 E0 ;zero the extruded length again
+
+;go to the middle of the platform, and move to Z=0 before starting the print.
+G1 X{machine_center_x} Y{machine_center_y} F{travel_speed}
+G1 Z0.0 F{max_z_speed}
+""",
+#######################################################################################
+ 'end.gcode': """;End GCode
+M104 S0 ;extruder heat off
+G91 ;relative positioning
+G1 Z+10 E-5 F{max_z_speed} ;move Z up a bit and retract filament by 5mm
+G28 X0 Y0 ;move X/Y to min endstops, so the head is out of the way
+M84 ;steppers off
+G90 ;absolute positioning
+""",
+#######################################################################################
+ 'support_start.gcode': '',
+ 'support_end.gcode': '',
+ 'cool_start.gcode': '',
+ 'cool_end.gcode': '',
+ 'replace.csv': '',
+#######################################################################################
+ 'nextobject.gcode': """;Move to next object on the platform. clear_z is the minimal z height we need to make sure we do not hit any objects.
+G92 E0
+G1 Z{clear_z} E-5 F{max_z_speed}
+G92 E0
+G1 X{machine_center_x} Y{machine_center_y} F{travel_speed}
+G1 F200 E5.5
+G92 E0
+G1 Z0 F{max_z_speed}
+""",
+#######################################################################################
+ 'switchExtruder.gcode': """;Switch between the current extruder and the next extruder, when printing with multiple extruders.
+G1 E-5 F5000
+G92 E0
+T{extruder}
+G1 E5 F5000
+G92 E0
+""",
}
preferencesDefaultSettings = {
'wizardDone': 'False',
'startMode': 'Simple',
- 'lastFile': 'None',
+ 'lastFile': '',
'machine_width': '205',
'machine_depth': '205',
'machine_height': '200',
+ 'extruder_amount': '1',
+ 'extruder_offset_x1': '-22.0',
+ 'extruder_offset_y1': '0.0',
+ 'extruder_offset_x2': '0.0',
+ 'extruder_offset_y2': '0.0',
+ 'extruder_offset_x3': '0.0',
+ 'extruder_offset_y3': '0.0',
'filament_density': '1300',
'steps_per_e': '0',
'serial_port': 'AUTO',
@@ -82,8 +152,18 @@ preferencesDefaultSettings = {
'save_profile': 'False',
'filament_cost_kg': '0',
'filament_cost_meter': '0',
+
+ 'extruder_head_size_min_x': '70.0',
+ 'extruder_head_size_min_y': '18.0',
+ 'extruder_head_size_max_x': '18.0',
+ 'extruder_head_size_max_y': '35.0',
}
+#########################################################
+## Profile and preferences functions
+#########################################################
+
+## Profile functions
def getDefaultProfilePath():
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../current_profile.ini"))
@@ -101,32 +181,59 @@ def loadGlobalProfileFromString(options):
global globalProfileParser
globalProfileParser = ConfigParser.ConfigParser()
globalProfileParser.add_section('profile')
- for option in options.split('#'):
+ globalProfileParser.add_section('alterations')
+ options = base64.b64decode(options)
+ options = zlib.decompress(options)
+ (profileOpts, alt) = options.split('\f', 1)
+ for option in profileOpts.split('\b'):
(key, value) = option.split('=', 1)
globalProfileParser.set('profile', key, value)
+ for option in alt.split('\b'):
+ (key, value) = option.split('=', 1)
+ globalProfileParser.set('alterations', key, value)
def getGlobalProfileString():
global globalProfileParser
if not globals().has_key('globalProfileParser'):
loadGlobalProfile(getDefaultProfilePath())
- ret = []
- for key in globalProfileParser.options('profile'):
- ret.append(key + "=" + globalProfileParser.get('profile', key))
- return '#'.join(ret)
+ p = []
+ alt = []
+ tempDone = []
+ if globalProfileParser.has_section('profile'):
+ for key in globalProfileParser.options('profile'):
+ if key in tempOverride:
+ p.append(key + "=" + unicode(tempOverride[key]))
+ tempDone.append(key)
+ else:
+ p.append(key + "=" + globalProfileParser.get('profile', key))
+ if globalProfileParser.has_section('alterations'):
+ for key in globalProfileParser.options('alterations'):
+ if key in tempOverride:
+ p.append(key + "=" + tempOverride[key])
+ tempDone.append(key)
+ else:
+ alt.append(key + "=" + globalProfileParser.get('alterations', key))
+ for key in tempOverride:
+ if key not in tempDone:
+ p.append(key + "=" + unicode(tempOverride[key]))
+ ret = '\b'.join(p) + '\f' + '\b'.join(alt)
+ ret = base64.b64encode(zlib.compress(ret, 9))
+ return ret
def getProfileSetting(name):
- if name in profileDefaultSettings:
- default = profileDefaultSettings[name]
- else:
- print "Missing default setting for: '" + name + "'"
- profileDefaultSettings[name] = ''
- default = ''
-
+ if name in tempOverride:
+ return unicode(tempOverride[name])
#Check if we have a configuration file loaded, else load the default.
if not globals().has_key('globalProfileParser'):
loadGlobalProfile(getDefaultProfilePath())
if not globalProfileParser.has_option('profile', name):
+ if name in profileDefaultSettings:
+ default = profileDefaultSettings[name]
+ else:
+ print "Missing default setting for: '" + name + "'"
+ profileDefaultSettings[name] = ''
+ default = ''
if not globalProfileParser.has_section('profile'):
globalProfileParser.add_section('profile')
globalProfileParser.set('profile', name, str(default))
@@ -148,25 +255,38 @@ def putProfileSetting(name, value):
globalProfileParser.add_section('profile')
globalProfileParser.set('profile', name, str(value))
+def isProfileSetting(name):
+ if name in profileDefaultSettings:
+ return True
+ return False
+
+## Preferences functions
global globalPreferenceParser
globalPreferenceParser = None
def getPreferencePath():
return os.path.normpath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "../preferences.ini"))
-def getPreference(name):
- if name in preferencesDefaultSettings:
- default = preferencesDefaultSettings[name]
- else:
- print "Missing default setting for: '" + name + "'"
- preferencesDefaultSettings[name] = ''
- default = ''
+def getPreferenceFloat(name):
+ try:
+ return float(eval(getPreference(name), {}, {}))
+ except (ValueError, SyntaxError):
+ return 0.0
+def getPreference(name):
+ if name in tempOverride:
+ return unicode(tempOverride[name])
global globalPreferenceParser
if globalPreferenceParser == None:
globalPreferenceParser = ConfigParser.ConfigParser()
globalPreferenceParser.read(getPreferencePath())
if not globalPreferenceParser.has_option('preference', name):
+ if name in preferencesDefaultSettings:
+ default = preferencesDefaultSettings[name]
+ else:
+ print "Missing default setting for: '" + name + "'"
+ preferencesDefaultSettings[name] = ''
+ default = ''
if not globalPreferenceParser.has_section('preference'):
globalPreferenceParser.add_section('preference')
globalPreferenceParser.set('preference', name, str(default))
@@ -182,9 +302,21 @@ def putPreference(name, value):
globalPreferenceParser.read(getPreferencePath())
if not globalPreferenceParser.has_section('preference'):
globalPreferenceParser.add_section('preference')
- globalPreferenceParser.set('preference', name, str(value).encode("utf-8"))
+ globalPreferenceParser.set('preference', name, unicode(value).encode("utf-8"))
globalPreferenceParser.write(open(getPreferencePath(), 'w'))
+def isPreference(name):
+ if name in preferencesDefaultSettings:
+ return True
+ return False
+
+## Temp overrides for multi-extruder slicing and the project planner.
+tempOverride = {}
+def setTempOverride(name, value):
+ tempOverride[name] = value
+def resetTempOverride():
+ tempOverride.clear()
+
#########################################################
## Utility functions to calculate common profile values
#########################################################
@@ -224,32 +356,64 @@ def calculateSolidLayerCount():
#########################################################
## Alteration file functions
#########################################################
-def getCuraBasePath():
- return os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), ".."))
+def replaceTagMatch(m):
+ tag = m.group(0)[1:-1]
+ if tag in ['print_speed', 'retraction_speed', 'travel_speed', 'max_z_speed', 'bottom_layer_speed', 'cool_min_feedrate']:
+ f = getProfileSettingFloat(tag) * 60
+ elif isProfileSetting(tag):
+ f = getProfileSettingFloat(tag)
+ elif isPreference(tag):
+ f = getProfileSettingFloat(tag)
+ else:
+ return tag
+ if (f % 1) == 0:
+ return str(int(f))
+ return str(f)
-def getAlterationFilePath(filename):
- return os.path.join(getCuraBasePath(), "alterations", filename)
+### Get aleration raw contents. (Used internally in Cura)
+def getAlterationFile(filename):
+ #Check if we have a configuration file loaded, else load the default.
+ if not globals().has_key('globalProfileParser'):
+ loadGlobalProfile(getDefaultProfilePath())
+
+ if not globalProfileParser.has_option('alterations', filename):
+ if filename in alterationDefault:
+ default = alterationDefault[filename]
+ else:
+ print "Missing default alteration for: '" + filename + "'"
+ alterationDefault[filename] = ''
+ default = ''
+ if not globalProfileParser.has_section('alterations'):
+ globalProfileParser.add_section('alterations')
+ #print "Using default for: %s" % (filename)
+ globalProfileParser.set('alterations', filename, default)
+ return unicode(globalProfileParser.get('alterations', filename), "utf-8")
-def getAlterationFileContents(filename, allowMagicPrefix = True):
- "Get the file from the fileName or the lowercase fileName in the alterations directories."
+def setAlterationFile(filename, value):
+ #Check if we have a configuration file loaded, else load the default.
+ if not globals().has_key('globalProfileParser'):
+ loadGlobalProfile(getDefaultProfilePath())
+ if not globalProfileParser.has_section('alterations'):
+ globalProfileParser.add_section('alterations')
+ globalProfileParser.set('alterations', filename, value.encode("utf-8"))
+ saveGlobalProfile(getDefaultProfilePath())
+
+### Get the alteration file for output. (Used by Skeinforge)
+def getAlterationFileContents(filename):
prefix = ''
- if allowMagicPrefix:
- if filename == 'start.gcode':
- #For the start code, hack the temperature and the steps per E value into it. So the temperature is reached before the start code extrusion.
- #We also set our steps per E here, if configured.
- eSteps = float(getPreference('steps_per_e'))
- if eSteps > 0:
- prefix += 'M92 E'+str(eSteps)+'\n'
- temp = getProfileSettingFloat('print_temperature')
- if temp > 0:
- prefix += 'M109 S'+str(temp)+'\n'
- elif filename == 'replace.csv':
- prefix = 'M101\nM103\n'
- fullFilename = getAlterationFilePath(filename)
- if os.path.isfile(fullFilename):
- file = open(fullFilename, "r")
- fileText = file.read()
- file.close()
- return prefix + fileText
- return prefix
+ alterationContents = getAlterationFile(filename)
+ if filename == 'start.gcode':
+ #For the start code, hack the temperature and the steps per E value into it. So the temperature is reached before the start code extrusion.
+ #We also set our steps per E here, if configured.
+ eSteps = getPreferenceFloat('steps_per_e')
+ if eSteps > 0:
+ prefix += 'M92 E%f\n' % (eSteps)
+ temp = getProfileSettingFloat('print_temperature')
+ if temp > 0 and not '{print_temperature}' in alterationContents:
+ prefix += 'M109 S%f\n' % (temp)
+ elif filename == 'replace.csv':
+ #Always remove the extruder on/off M codes. These are no longer needed in 5D printing.
+ prefix = 'M101\nM103\n'
+
+ return unicode(prefix + re.sub("\{[^\}]*\}", replaceTagMatch, alterationContents).rstrip() + '\n').encode('utf-8')
diff --git a/Cura/util/sliceRun.py b/Cura/util/sliceRun.py
index 0bc157fa1e..4bc302a04f 100644
--- a/Cura/util/sliceRun.py
+++ b/Cura/util/sliceRun.py
@@ -5,6 +5,28 @@ import platform, os, subprocess, sys
from cura_sf.skeinforge_application.skeinforge_utilities import skeinforge_craft
from util import profile
+#How long does each step take compared to the others. This is used to make a better scaled progress bar, and guess time left.
+sliceStepTimeFactor = {
+ 'start': 3.3713991642,
+ 'slice': 15.4984838963,
+ 'preface': 5.17178297043,
+ 'inset': 116.362634182,
+ 'fill': 215.702672005,
+ 'multiply': 21.9536788464,
+ 'speed': 12.759510994,
+ 'raft': 31.4580039978,
+ 'skirt': 19.3436040878,
+ 'skin': 1.0,
+ 'joris': 1.0,
+ 'comb': 23.7805759907,
+ 'cool': 27.148763895,
+ 'dimension': 90.4914340973
+}
+
+totalRunTimeFactor = 0
+for v in sliceStepTimeFactor.itervalues():
+ totalRunTimeFactor += v
+
def getPyPyExe():
"Return the path to the pypy executable if we can find it. Else return False"
if platform.system() == "Windows":
@@ -61,7 +83,7 @@ def runSlice(fileNames):
subprocess.call([pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), '-p', profile.getGlobalProfileString(), fileName])
def getSliceCommand(filename):
- if profile.getPreference('slicer').startswith('Slic3r'):
+ if profile.getPreference('slicer').startswith('Slic3r') and getSlic3rExe() != False:
slic3rExe = getSlic3rExe()
if slic3rExe == False:
return False
@@ -116,5 +138,7 @@ def getSliceCommand(filename):
pypyExe = getPyPyExe()
if pypyExe == False:
pypyExe = sys.executable
- return [pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), '-p', profile.getGlobalProfileString(), filename]
+ cmd = [pypyExe, os.path.abspath(os.path.join(os.path.dirname(os.path.abspath(__file__)), "..", os.path.split(sys.argv[0])[1])), '-p', profile.getGlobalProfileString()]
+ cmd.append(filename)
+ return cmd
diff --git a/Cura/util/stl.py b/Cura/util/stl.py
index 05e759ea22..bf7558b497 100644
--- a/Cura/util/stl.py
+++ b/Cura/util/stl.py
@@ -9,11 +9,11 @@ import struct
from util import util3d
-class stlFace():
+class stlFace(object):
def __init__(self, v0, v1, v2):
self.v = [v0, v1, v2]
-class stlModel():
+class stlModel(object):
def __init__(self):
self.faces = []
self.vertexes = []
@@ -28,6 +28,8 @@ class stlModel():
else:
self._loadBinary(f)
f.close()
+
+ self._createOrigonalVertexCopy()
def _loadAscii(self, f):
cnt = 0
@@ -62,6 +64,12 @@ class stlModel():
self.vertexes.append(v1)
self.vertexes.append(v2)
+ def _createOrigonalVertexCopy(self):
+ self.origonalVertexes = list(self.vertexes)
+ for i in xrange(0, len(self.origonalVertexes)):
+ self.origonalVertexes[i] = self.origonalVertexes[i].copy()
+ self.getMinimumZ()
+
def getMinimumZ(self):
minv = self.vertexes[0].copy()
maxv = self.vertexes[0].copy()
@@ -74,12 +82,15 @@ class stlModel():
maxv.z = max(maxv.z, v.z)
self.min = minv
self.max = maxv
+ self.size = maxv - minv
return self.min.z
def getMaximum(self):
return self.max
def getMinimum(self):
return self.min
+ def getSize(self):
+ return self.size
if __name__ == '__main__':
for filename in sys.argv[1:]:
diff --git a/Cura/util/util3d.py b/Cura/util/util3d.py
index d9f53e5252..d5411fc9c4 100644
--- a/Cura/util/util3d.py
+++ b/Cura/util/util3d.py
@@ -1,7 +1,7 @@
import math
-class Vector3():
+class Vector3(object):
def __init__(self, x=0.0, y=0.0, z=0.0):
self.x = x
self.y = y
@@ -27,6 +27,7 @@ class Vector3():
def __div__(self, v):
return Vector3( self.x / v, self.y / v, self.z / v )
+ __truediv__ = __div__
def __neg__(self):
return Vector3( - self.x, - self.y, - self.z )
@@ -68,3 +69,9 @@ class Vector3():
self.y /= f
self.z /= f
+ def min(self, v):
+ return Vector3(min(self.x, v.x), min(self.y, v.y), min(self.z, v.z))
+
+ def max(self, v):
+ return Vector3(max(self.x, v.x), max(self.y, v.y), max(self.z, v.z))
+