├── .gitignore
├── .idea
├── .gitignore
├── misc.xml
├── modules.xml
└── vcs.xml
├── Cargo.toml
├── GladiusGUI.iml
├── LICENSE
├── README.md
├── assets
└── Screenshot.png
├── langs
└── en_US.json
├── logo
└── logo.svg
├── slicer
├── gladius_slicer
└── gladius_slicer.exe
└── src
├── main.rs
├── model.rs
├── object.rs
└── shaders.rs
/.gitignore:
--------------------------------------------------------------------------------
1 | # Generated by Cargo
2 | # will have compiled files and executables
3 | /target/
4 |
5 | # Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
6 | # More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
7 | Cargo.lock
8 |
9 | # These are backup files generated by rustfmt
10 | **/*.rs.bk
11 |
12 |
13 | # Added by cargo
14 |
15 | /target
16 |
--------------------------------------------------------------------------------
/.idea/.gitignore:
--------------------------------------------------------------------------------
1 | # Default ignored files
2 | /shelf/
3 | /workspace.xml
4 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/modules.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "GladiusGUI"
3 | version = "0.1.0"
4 | edition = "2021"
5 |
6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
7 |
8 | [dependencies]
9 | egui = "0.17"
10 |
11 | # Backend-agnostic interface for writing apps using egui
12 | epi = "0.17.0"
13 | # Winit integration with egui
14 | egui_winit_platform = "0.13.0"
15 | # logging
16 | env_logger = { version = "0.9", default-features = false, features = ["termcolor", "atty"] }
17 | # Linear algebra library
18 | glam = "0.20.0"
19 |
20 | # Windowing
21 | winit = "0.26"
22 |
23 | native-dialog = "0.5.5"
24 |
25 | egui_glium = "0.17.0"
26 | glium = "0.31.0"
27 |
28 | nom_stl = "0.2.2"
29 |
30 | gladius_shared = { git = "https://github.com/GladiusSlicer/GladiusSlicer", branch = "Dev" }
31 |
32 | serde_json = "1.0.74"
33 | bincode = "1.3.3"
34 | serde = { version = "1.0", features = ["derive"] }
35 | num_cpus = "1.13.1"
36 |
37 | itertools = "0.10.3"
38 | geo = { version = "0.18.0", features = ["use-serde"] }
39 |
40 | json-gettext = "4.0.0"
--------------------------------------------------------------------------------
/GladiusGUI.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU LESSER GENERAL PUBLIC LICENSE
2 | Version 2.1, February 1999
3 |
4 | Copyright (C) 1991, 1999 Free Software Foundation, Inc.
5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
6 | Everyone is permitted to copy and distribute verbatim copies
7 | of this license document, but changing it is not allowed.
8 |
9 | [This is the first released version of the Lesser GPL. It also counts
10 | as the successor of the GNU Library Public License, version 2, hence
11 | the version number 2.1.]
12 |
13 | Preamble
14 |
15 | The licenses for most software are designed to take away your
16 | freedom to share and change it. By contrast, the GNU General Public
17 | Licenses are intended to guarantee your freedom to share and change
18 | free software--to make sure the software is free for all its users.
19 |
20 | This license, the Lesser General Public License, applies to some
21 | specially designated software packages--typically libraries--of the
22 | Free Software Foundation and other authors who decide to use it. You
23 | can use it too, but we suggest you first think carefully about whether
24 | this license or the ordinary General Public License is the better
25 | strategy to use in any particular case, based on the explanations below.
26 |
27 | When we speak of free software, we are referring to freedom of use,
28 | not price. Our General Public Licenses are designed to make sure that
29 | you have the freedom to distribute copies of free software (and charge
30 | for this service if you wish); that you receive source code or can get
31 | it if you want it; that you can change the software and use pieces of
32 | it in new free programs; and that you are informed that you can do
33 | these things.
34 |
35 | To protect your rights, we need to make restrictions that forbid
36 | distributors to deny you these rights or to ask you to surrender these
37 | rights. These restrictions translate to certain responsibilities for
38 | you if you distribute copies of the library or if you modify it.
39 |
40 | For example, if you distribute copies of the library, whether gratis
41 | or for a fee, you must give the recipients all the rights that we gave
42 | you. You must make sure that they, too, receive or can get the source
43 | code. If you link other code with the library, you must provide
44 | complete object files to the recipients, so that they can relink them
45 | with the library after making changes to the library and recompiling
46 | it. And you must show them these terms so they know their rights.
47 |
48 | We protect your rights with a two-step method: (1) we copyright the
49 | library, and (2) we offer you this license, which gives you legal
50 | permission to copy, distribute and/or modify the library.
51 |
52 | To protect each distributor, we want to make it very clear that
53 | there is no warranty for the free library. Also, if the library is
54 | modified by someone else and passed on, the recipients should know
55 | that what they have is not the original version, so that the original
56 | author's reputation will not be affected by problems that might be
57 | introduced by others.
58 |
59 | Finally, software patents pose a constant threat to the existence of
60 | any free program. We wish to make sure that a company cannot
61 | effectively restrict the users of a free program by obtaining a
62 | restrictive license from a patent holder. Therefore, we insist that
63 | any patent license obtained for a version of the library must be
64 | consistent with the full freedom of use specified in this license.
65 |
66 | Most GNU software, including some libraries, is covered by the
67 | ordinary GNU General Public License. This license, the GNU Lesser
68 | General Public License, applies to certain designated libraries, and
69 | is quite different from the ordinary General Public License. We use
70 | this license for certain libraries in order to permit linking those
71 | libraries into non-free programs.
72 |
73 | When a program is linked with a library, whether statically or using
74 | a shared library, the combination of the two is legally speaking a
75 | combined work, a derivative of the original library. The ordinary
76 | General Public License therefore permits such linking only if the
77 | entire combination fits its criteria of freedom. The Lesser General
78 | Public License permits more lax criteria for linking other code with
79 | the library.
80 |
81 | We call this license the "Lesser" General Public License because it
82 | does Less to protect the user's freedom than the ordinary General
83 | Public License. It also provides other free software developers Less
84 | of an advantage over competing non-free programs. These disadvantages
85 | are the reason we use the ordinary General Public License for many
86 | libraries. However, the Lesser license provides advantages in certain
87 | special circumstances.
88 |
89 | For example, on rare occasions, there may be a special need to
90 | encourage the widest possible use of a certain library, so that it becomes
91 | a de-facto standard. To achieve this, non-free programs must be
92 | allowed to use the library. A more frequent case is that a free
93 | library does the same job as widely used non-free libraries. In this
94 | case, there is little to gain by limiting the free library to free
95 | software only, so we use the Lesser General Public License.
96 |
97 | In other cases, permission to use a particular library in non-free
98 | programs enables a greater number of people to use a large body of
99 | free software. For example, permission to use the GNU C Library in
100 | non-free programs enables many more people to use the whole GNU
101 | operating system, as well as its variant, the GNU/Linux operating
102 | system.
103 |
104 | Although the Lesser General Public License is Less protective of the
105 | users' freedom, it does ensure that the user of a program that is
106 | linked with the Library has the freedom and the wherewithal to run
107 | that program using a modified version of the Library.
108 |
109 | The precise terms and conditions for copying, distribution and
110 | modification follow. Pay close attention to the difference between a
111 | "work based on the library" and a "work that uses the library". The
112 | former contains code derived from the library, whereas the latter must
113 | be combined with the library in order to run.
114 |
115 | GNU LESSER GENERAL PUBLIC LICENSE
116 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
117 |
118 | 0. This License Agreement applies to any software library or other
119 | program which contains a notice placed by the copyright holder or
120 | other authorized party saying it may be distributed under the terms of
121 | this Lesser General Public License (also called "this License").
122 | Each licensee is addressed as "you".
123 |
124 | A "library" means a collection of software functions and/or data
125 | prepared so as to be conveniently linked with application programs
126 | (which use some of those functions and data) to form executables.
127 |
128 | The "Library", below, refers to any such software library or work
129 | which has been distributed under these terms. A "work based on the
130 | Library" means either the Library or any derivative work under
131 | copyright law: that is to say, a work containing the Library or a
132 | portion of it, either verbatim or with modifications and/or translated
133 | straightforwardly into another language. (Hereinafter, translation is
134 | included without limitation in the term "modification".)
135 |
136 | "Source code" for a work means the preferred form of the work for
137 | making modifications to it. For a library, complete source code means
138 | all the source code for all modules it contains, plus any associated
139 | interface definition files, plus the scripts used to control compilation
140 | and installation of the library.
141 |
142 | Activities other than copying, distribution and modification are not
143 | covered by this License; they are outside its scope. The act of
144 | running a program using the Library is not restricted, and output from
145 | such a program is covered only if its contents constitute a work based
146 | on the Library (independent of the use of the Library in a tool for
147 | writing it). Whether that is true depends on what the Library does
148 | and what the program that uses the Library does.
149 |
150 | 1. You may copy and distribute verbatim copies of the Library's
151 | complete source code as you receive it, in any medium, provided that
152 | you conspicuously and appropriately publish on each copy an
153 | appropriate copyright notice and disclaimer of warranty; keep intact
154 | all the notices that refer to this License and to the absence of any
155 | warranty; and distribute a copy of this License along with the
156 | Library.
157 |
158 | You may charge a fee for the physical act of transferring a copy,
159 | and you may at your option offer warranty protection in exchange for a
160 | fee.
161 |
162 | 2. You may modify your copy or copies of the Library or any portion
163 | of it, thus forming a work based on the Library, and copy and
164 | distribute such modifications or work under the terms of Section 1
165 | above, provided that you also meet all of these conditions:
166 |
167 | a) The modified work must itself be a software library.
168 |
169 | b) You must cause the files modified to carry prominent notices
170 | stating that you changed the files and the date of any change.
171 |
172 | c) You must cause the whole of the work to be licensed at no
173 | charge to all third parties under the terms of this License.
174 |
175 | d) If a facility in the modified Library refers to a function or a
176 | table of data to be supplied by an application program that uses
177 | the facility, other than as an argument passed when the facility
178 | is invoked, then you must make a good faith effort to ensure that,
179 | in the event an application does not supply such function or
180 | table, the facility still operates, and performs whatever part of
181 | its purpose remains meaningful.
182 |
183 | (For example, a function in a library to compute square roots has
184 | a purpose that is entirely well-defined independent of the
185 | application. Therefore, Subsection 2d requires that any
186 | application-supplied function or table used by this function must
187 | be optional: if the application does not supply it, the square
188 | root function must still compute square roots.)
189 |
190 | These requirements apply to the modified work as a whole. If
191 | identifiable sections of that work are not derived from the Library,
192 | and can be reasonably considered independent and separate works in
193 | themselves, then this License, and its terms, do not apply to those
194 | sections when you distribute them as separate works. But when you
195 | distribute the same sections as part of a whole which is a work based
196 | on the Library, the distribution of the whole must be on the terms of
197 | this License, whose permissions for other licensees extend to the
198 | entire whole, and thus to each and every part regardless of who wrote
199 | it.
200 |
201 | Thus, it is not the intent of this section to claim rights or contest
202 | your rights to work written entirely by you; rather, the intent is to
203 | exercise the right to control the distribution of derivative or
204 | collective works based on the Library.
205 |
206 | In addition, mere aggregation of another work not based on the Library
207 | with the Library (or with a work based on the Library) on a volume of
208 | a storage or distribution medium does not bring the other work under
209 | the scope of this License.
210 |
211 | 3. You may opt to apply the terms of the ordinary GNU General Public
212 | License instead of this License to a given copy of the Library. To do
213 | this, you must alter all the notices that refer to this License, so
214 | that they refer to the ordinary GNU General Public License, version 2,
215 | instead of to this License. (If a newer version than version 2 of the
216 | ordinary GNU General Public License has appeared, then you can specify
217 | that version instead if you wish.) Do not make any other change in
218 | these notices.
219 |
220 | Once this change is made in a given copy, it is irreversible for
221 | that copy, so the ordinary GNU General Public License applies to all
222 | subsequent copies and derivative works made from that copy.
223 |
224 | This option is useful when you wish to copy part of the code of
225 | the Library into a program that is not a library.
226 |
227 | 4. You may copy and distribute the Library (or a portion or
228 | derivative of it, under Section 2) in object code or executable form
229 | under the terms of Sections 1 and 2 above provided that you accompany
230 | it with the complete corresponding machine-readable source code, which
231 | must be distributed under the terms of Sections 1 and 2 above on a
232 | medium customarily used for software interchange.
233 |
234 | If distribution of object code is made by offering access to copy
235 | from a designated place, then offering equivalent access to copy the
236 | source code from the same place satisfies the requirement to
237 | distribute the source code, even though third parties are not
238 | compelled to copy the source along with the object code.
239 |
240 | 5. A program that contains no derivative of any portion of the
241 | Library, but is designed to work with the Library by being compiled or
242 | linked with it, is called a "work that uses the Library". Such a
243 | work, in isolation, is not a derivative work of the Library, and
244 | therefore falls outside the scope of this License.
245 |
246 | However, linking a "work that uses the Library" with the Library
247 | creates an executable that is a derivative of the Library (because it
248 | contains portions of the Library), rather than a "work that uses the
249 | library". The executable is therefore covered by this License.
250 | Section 6 states terms for distribution of such executables.
251 |
252 | When a "work that uses the Library" uses material from a header file
253 | that is part of the Library, the object code for the work may be a
254 | derivative work of the Library even though the source code is not.
255 | Whether this is true is especially significant if the work can be
256 | linked without the Library, or if the work is itself a library. The
257 | threshold for this to be true is not precisely defined by law.
258 |
259 | If such an object file uses only numerical parameters, data
260 | structure layouts and accessors, and small macros and small inline
261 | functions (ten lines or less in length), then the use of the object
262 | file is unrestricted, regardless of whether it is legally a derivative
263 | work. (Executables containing this object code plus portions of the
264 | Library will still fall under Section 6.)
265 |
266 | Otherwise, if the work is a derivative of the Library, you may
267 | distribute the object code for the work under the terms of Section 6.
268 | Any executables containing that work also fall under Section 6,
269 | whether or not they are linked directly with the Library itself.
270 |
271 | 6. As an exception to the Sections above, you may also combine or
272 | link a "work that uses the Library" with the Library to produce a
273 | work containing portions of the Library, and distribute that work
274 | under terms of your choice, provided that the terms permit
275 | modification of the work for the customer's own use and reverse
276 | engineering for debugging such modifications.
277 |
278 | You must give prominent notice with each copy of the work that the
279 | Library is used in it and that the Library and its use are covered by
280 | this License. You must supply a copy of this License. If the work
281 | during execution displays copyright notices, you must include the
282 | copyright notice for the Library among them, as well as a reference
283 | directing the user to the copy of this License. Also, you must do one
284 | of these things:
285 |
286 | a) Accompany the work with the complete corresponding
287 | machine-readable source code for the Library including whatever
288 | changes were used in the work (which must be distributed under
289 | Sections 1 and 2 above); and, if the work is an executable linked
290 | with the Library, with the complete machine-readable "work that
291 | uses the Library", as object code and/or source code, so that the
292 | user can modify the Library and then relink to produce a modified
293 | executable containing the modified Library. (It is understood
294 | that the user who changes the contents of definitions files in the
295 | Library will not necessarily be able to recompile the application
296 | to use the modified definitions.)
297 |
298 | b) Use a suitable shared library mechanism for linking with the
299 | Library. A suitable mechanism is one that (1) uses at run time a
300 | copy of the library already present on the user's computer system,
301 | rather than copying library functions into the executable, and (2)
302 | will operate properly with a modified version of the library, if
303 | the user installs one, as long as the modified version is
304 | interface-compatible with the version that the work was made with.
305 |
306 | c) Accompany the work with a written offer, valid for at
307 | least three years, to give the same user the materials
308 | specified in Subsection 6a, above, for a charge no more
309 | than the cost of performing this distribution.
310 |
311 | d) If distribution of the work is made by offering access to copy
312 | from a designated place, offer equivalent access to copy the above
313 | specified materials from the same place.
314 |
315 | e) Verify that the user has already received a copy of these
316 | materials or that you have already sent this user a copy.
317 |
318 | For an executable, the required form of the "work that uses the
319 | Library" must include any data and utility programs needed for
320 | reproducing the executable from it. However, as a special exception,
321 | the materials to be distributed need not include anything that is
322 | normally distributed (in either source or binary form) with the major
323 | components (compiler, kernel, and so on) of the operating system on
324 | which the executable runs, unless that component itself accompanies
325 | the executable.
326 |
327 | It may happen that this requirement contradicts the license
328 | restrictions of other proprietary libraries that do not normally
329 | accompany the operating system. Such a contradiction means you cannot
330 | use both them and the Library together in an executable that you
331 | distribute.
332 |
333 | 7. You may place library facilities that are a work based on the
334 | Library side-by-side in a single library together with other library
335 | facilities not covered by this License, and distribute such a combined
336 | library, provided that the separate distribution of the work based on
337 | the Library and of the other library facilities is otherwise
338 | permitted, and provided that you do these two things:
339 |
340 | a) Accompany the combined library with a copy of the same work
341 | based on the Library, uncombined with any other library
342 | facilities. This must be distributed under the terms of the
343 | Sections above.
344 |
345 | b) Give prominent notice with the combined library of the fact
346 | that part of it is a work based on the Library, and explaining
347 | where to find the accompanying uncombined form of the same work.
348 |
349 | 8. You may not copy, modify, sublicense, link with, or distribute
350 | the Library except as expressly provided under this License. Any
351 | attempt otherwise to copy, modify, sublicense, link with, or
352 | distribute the Library is void, and will automatically terminate your
353 | rights under this License. However, parties who have received copies,
354 | or rights, from you under this License will not have their licenses
355 | terminated so long as such parties remain in full compliance.
356 |
357 | 9. You are not required to accept this License, since you have not
358 | signed it. However, nothing else grants you permission to modify or
359 | distribute the Library or its derivative works. These actions are
360 | prohibited by law if you do not accept this License. Therefore, by
361 | modifying or distributing the Library (or any work based on the
362 | Library), you indicate your acceptance of this License to do so, and
363 | all its terms and conditions for copying, distributing or modifying
364 | the Library or works based on it.
365 |
366 | 10. Each time you redistribute the Library (or any work based on the
367 | Library), the recipient automatically receives a license from the
368 | original licensor to copy, distribute, link with or modify the Library
369 | subject to these terms and conditions. You may not impose any further
370 | restrictions on the recipients' exercise of the rights granted herein.
371 | You are not responsible for enforcing compliance by third parties with
372 | this License.
373 |
374 | 11. If, as a consequence of a court judgment or allegation of patent
375 | infringement or for any other reason (not limited to patent issues),
376 | conditions are imposed on you (whether by court order, agreement or
377 | otherwise) that contradict the conditions of this License, they do not
378 | excuse you from the conditions of this License. If you cannot
379 | distribute so as to satisfy simultaneously your obligations under this
380 | License and any other pertinent obligations, then as a consequence you
381 | may not distribute the Library at all. For example, if a patent
382 | license would not permit royalty-free redistribution of the Library by
383 | all those who receive copies directly or indirectly through you, then
384 | the only way you could satisfy both it and this License would be to
385 | refrain entirely from distribution of the Library.
386 |
387 | If any portion of this section is held invalid or unenforceable under any
388 | particular circumstance, the balance of the section is intended to apply,
389 | and the section as a whole is intended to apply in other circumstances.
390 |
391 | It is not the purpose of this section to induce you to infringe any
392 | patents or other property right claims or to contest validity of any
393 | such claims; this section has the sole purpose of protecting the
394 | integrity of the free software distribution system which is
395 | implemented by public license practices. Many people have made
396 | generous contributions to the wide range of software distributed
397 | through that system in reliance on consistent application of that
398 | system; it is up to the author/donor to decide if he or she is willing
399 | to distribute software through any other system and a licensee cannot
400 | impose that choice.
401 |
402 | This section is intended to make thoroughly clear what is believed to
403 | be a consequence of the rest of this License.
404 |
405 | 12. If the distribution and/or use of the Library is restricted in
406 | certain countries either by patents or by copyrighted interfaces, the
407 | original copyright holder who places the Library under this License may add
408 | an explicit geographical distribution limitation excluding those countries,
409 | so that distribution is permitted only in or among countries not thus
410 | excluded. In such case, this License incorporates the limitation as if
411 | written in the body of this License.
412 |
413 | 13. The Free Software Foundation may publish revised and/or new
414 | versions of the Lesser General Public License from time to time.
415 | Such new versions will be similar in spirit to the present version,
416 | but may differ in detail to address new problems or concerns.
417 |
418 | Each version is given a distinguishing version number. If the Library
419 | specifies a version number of this License which applies to it and
420 | "any later version", you have the option of following the terms and
421 | conditions either of that version or of any later version published by
422 | the Free Software Foundation. If the Library does not specify a
423 | license version number, you may choose any version ever published by
424 | the Free Software Foundation.
425 |
426 | 14. If you wish to incorporate parts of the Library into other free
427 | programs whose distribution conditions are incompatible with these,
428 | write to the author to ask for permission. For software which is
429 | copyrighted by the Free Software Foundation, write to the Free
430 | Software Foundation; we sometimes make exceptions for this. Our
431 | decision will be guided by the two goals of preserving the free status
432 | of all derivatives of our free software and of promoting the sharing
433 | and reuse of software generally.
434 |
435 | NO WARRANTY
436 |
437 | 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
438 | WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
439 | EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
440 | OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
441 | KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
442 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
443 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
444 | LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
445 | THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
446 |
447 | 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
448 | WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
449 | AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
450 | FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
451 | CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
452 | LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
453 | RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
454 | FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
455 | SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
456 | DAMAGES.
457 |
458 | END OF TERMS AND CONDITIONS
459 |
460 | How to Apply These Terms to Your New Libraries
461 |
462 | If you develop a new library, and you want it to be of the greatest
463 | possible use to the public, we recommend making it free software that
464 | everyone can redistribute and change. You can do so by permitting
465 | redistribution under these terms (or, alternatively, under the terms of the
466 | ordinary General Public License).
467 |
468 | To apply these terms, attach the following notices to the library. It is
469 | safest to attach them to the start of each source file to most effectively
470 | convey the exclusion of warranty; and each file should have at least the
471 | "copyright" line and a pointer to where the full notice is found.
472 |
473 |
474 | Copyright (C)
475 |
476 | This library is free software; you can redistribute it and/or
477 | modify it under the terms of the GNU Lesser General Public
478 | License as published by the Free Software Foundation; either
479 | version 2.1 of the License, or (at your option) any later version.
480 |
481 | This library is distributed in the hope that it will be useful,
482 | but WITHOUT ANY WARRANTY; without even the implied warranty of
483 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
484 | Lesser General Public License for more details.
485 |
486 | You should have received a copy of the GNU Lesser General Public
487 | License along with this library; if not, write to the Free Software
488 | Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
489 | USA
490 |
491 | Also add information on how to contact you by electronic and paper mail.
492 |
493 | You should also get your employer (if you work as a programmer) or your
494 | school, if any, to sign a "copyright disclaimer" for the library, if
495 | necessary. Here is a sample; alter the names:
496 |
497 | Yoyodyne, Inc., hereby disclaims all copyright interest in the
498 | library `Frob' (a library for tweaking knobs) written by James Random
499 | Hacker.
500 |
501 | , 1 April 1990
502 | Ty Coon, President of Vice
503 |
504 | That's all there is to it!
505 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # GladiusGUI
2 | A Graphical Interface for the Gladius Slicer. The Core Engine can be found [here](https://github.com/GladiusSlicer/GladiusSlicer).
3 | 
4 |
5 | Rust, LGPL. Copyright 2022 Lucas Ince/mrhatman
6 |
7 | **Questions?** Please use the github discussion page.
8 |
9 | **Want to contribute?** Open a PR. See contributing document for more information.
10 |
11 | Gladius GUI is currently in an alpha state and very little is stable so assume any new release will cause breaking bugs.
12 |
--------------------------------------------------------------------------------
/assets/Screenshot.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GladiusSlicer/GladiusGUI/c67a65fdbb126978c32409d78ffd3a919cbb6276/assets/Screenshot.png
--------------------------------------------------------------------------------
/langs/en_US.json:
--------------------------------------------------------------------------------
1 | {
2 | "viewer": "2D Viewer",
3 | "setup_bar_heading" : "Setup Print",
4 | "choose_model_button": "Choose Model",
5 | "model_path": "Model Path: ",
6 | "border": "Border",
7 | "slice": "Slice",
8 | "remove": "Remove",
9 | "copy": "Copy",
10 | "center": "Center",
11 | "plastic_volume_msg": "This print will use {} cm^3 of plastic",
12 | "plastic_weight_msg": "This print will use {} grams of plastic",
13 | "print_time_msg": "This print will take {0} hours and {1} minutes",
14 | "settings_path": "Settings Path: "
15 |
16 | }
--------------------------------------------------------------------------------
/logo/logo.svg:
--------------------------------------------------------------------------------
1 |
2 |
28 |
--------------------------------------------------------------------------------
/slicer/gladius_slicer:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GladiusSlicer/GladiusGUI/c67a65fdbb126978c32409d78ffd3a919cbb6276/slicer/gladius_slicer
--------------------------------------------------------------------------------
/slicer/gladius_slicer.exe:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/GladiusSlicer/GladiusGUI/c67a65fdbb126978c32409d78ffd3a919cbb6276/slicer/gladius_slicer.exe
--------------------------------------------------------------------------------
/src/main.rs:
--------------------------------------------------------------------------------
1 | #![cfg_attr(not(debug_assertions), windows_subsystem = "windows")] // hide console window on Windows in release
2 | mod object;
3 | mod shaders;
4 | mod model;
5 |
6 | use crate::object::{load, DisplayVertex, Object};
7 | use crate::shaders::*;
8 | use crate::model::*;
9 |
10 | use native_dialog::FileDialog;
11 |
12 | use egui::plot::{Corner, Legend, Line, Plot, Value, Values};
13 | use egui::{
14 | Color32, FontDefinitions, FontFamily, InnerResponse, Pos2, Sense, Stroke, TextStyle,
15 | };
16 | use gladius_shared::error::SlicerErrors;
17 | use gladius_shared::messages::Message;
18 | use glam::{Vec2, Vec3};
19 | use glium::{glutin, Surface, uniform};
20 | use itertools::Itertools;
21 | use std::fs::File;
22 | use std::io::{BufRead, BufReader, Write};
23 | use std::process::{Command, Stdio};
24 | use std::sync::{Arc, RwLock};
25 | use json_gettext::JSONGetText;
26 | use winit::event::{DeviceEvent, ElementState, MouseScrollDelta, WindowEvent};
27 | #[macro_use] extern crate json_gettext;
28 | fn vertex(pos: [f32; 3]) -> DisplayVertex {
29 | DisplayVertex {
30 | position: (pos[0], pos[1], pos[2]),
31 | }
32 | }
33 |
34 | #[derive(Clone, Debug)]
35 | enum Errors {
36 | SlicerCommunicationIssue,
37 | SlicerApplicationIssue,
38 | SlicerError(SlicerErrors),
39 | }
40 |
41 | impl Errors {
42 | ///Return the error code and pretty error message
43 | pub fn get_code_and_message(&self) -> (u32, String) {
44 | match self {
45 | Errors::SlicerApplicationIssue => {
46 | (0x8000, format!("Slicing Application could not be found."))
47 | }
48 | Errors::SlicerCommunicationIssue => (
49 | 0x8001,
50 | format!("Error found in communication between GUI and slicer application."),
51 | ),
52 | Errors::SlicerError(e) => e.get_code_and_message(),
53 | }
54 | }
55 | }
56 |
57 |
58 | fn create_build_area(
59 | display: &glium::Display,
60 | build_x: f32,
61 | build_y: f32,
62 | build_z: f32,
63 | ) -> (glium::VertexBuffer, glium::IndexBuffer) {
64 | let mut vertex_positions: Vec = vec![
65 | // far side (0.0, 0.0, 1.0)
66 | vertex([0.0, 0.0, 0.0]),
67 | vertex([0.0, build_y, 0.0]),
68 | vertex([build_x, 0.0, 0.0]),
69 | vertex([build_x, build_y, 0.0]),
70 | vertex([0.0, 0.0, build_z]),
71 | vertex([0.0, build_y, build_z]),
72 | vertex([build_x, 0.0, build_z]),
73 | vertex([build_x, build_y, build_z]),
74 | ];
75 |
76 | let mut index_data: Vec = vec![
77 | 0, 1, 0, 2, 1, 3, 2, 3, 4, 5, 4, 6, 5, 7, 6, 7, 0, 4, 1, 5, 2, 6, 3, 7,
78 | ];
79 |
80 | let step_size = 10.0;
81 | (0..(build_x / step_size) as u32)
82 | .into_iter()
83 | .map(|index| index as f32 * step_size)
84 | .for_each(|x| {
85 | let index_pos = vertex_positions.len() as u32;
86 | vertex_positions.push(vertex([x, 0.0, 0.0]));
87 | vertex_positions.push(vertex([x, build_y, 0.0]));
88 | index_data.push(index_pos);
89 | index_data.push(index_pos + 1);
90 | });
91 |
92 | (0..(build_y / step_size) as u32)
93 | .into_iter()
94 | .map(|index| index as f32 * step_size)
95 | .for_each(|y| {
96 | let index_pos = vertex_positions.len() as u32;
97 | vertex_positions.push(vertex([0.0, y, 0.0]));
98 | vertex_positions.push(vertex([build_x, y, 0.0]));
99 | index_data.push(index_pos);
100 | index_data.push(index_pos + 1);
101 | });
102 |
103 | let positions = glium::VertexBuffer::new(display, &vertex_positions).unwrap();
104 | let indices =
105 | glium::IndexBuffer::new(display, glium::index::PrimitiveType::LinesList, &index_data)
106 | .unwrap();
107 | (positions, indices)
108 | }
109 |
110 | fn create_display(event_loop: &glutin::event_loop::EventLoop<()>) -> glium::Display {
111 | let window_builder = glutin::window::WindowBuilder::new()
112 | .with_resizable(true)
113 | .with_maximized(true)
114 | .with_title("Gladius");
115 |
116 | let context_builder = glutin::ContextBuilder::new()
117 | .with_depth_buffer(24)
118 | .with_multisampling(16)
119 | .with_srgb(true)
120 | .with_vsync(true);
121 |
122 | glium::Display::new(window_builder, context_builder, event_loop).unwrap()
123 | }
124 |
125 | fn main() {
126 |
127 | let ctx = static_json_gettext_build!(
128 | "en_US";
129 | "en_US" => "langs/en_US.json",
130 | ).unwrap();
131 |
132 | let lang = "en_US";
133 |
134 | let event_loop = glutin::event_loop::EventLoop::with_user_event();
135 | let display = create_display(&event_loop);
136 |
137 | let mut egui_glium = egui_glium::EguiGlium::new(&display);
138 |
139 |
140 | let mut left_mouse_button_state = ElementState::Released;
141 | let mut on_render_screen = false;
142 | let mut in_window = false;
143 | let mut index = 0;
144 | let mut layers = 0;
145 |
146 |
147 | let mut viewer_open = false;
148 |
149 | let build_x = 250.0;
150 | let build_y = 210.0;
151 | let build_z = 210.0;
152 |
153 | let model_program =
154 | glium::Program::from_source(&display, VERTEX_SHADER_SRC, FRAGMENT_SHADER_SRC, None)
155 | .unwrap();
156 | let line_program = glium::Program::from_source(
157 | &display,
158 | LINE_VERTEX_SHADER_SRC,
159 | LINE_FRAGMENT_SHADER_SRC,
160 | None,
161 | )
162 | .unwrap();
163 |
164 | let mut gui_data = GUIData::new(Vec2::new(400.0, 400.0),Vec3::new(build_x,build_y,build_z));
165 |
166 |
167 |
168 | let mut plot_window_resp = None;
169 | let mut window_rec = None;
170 | let mut window_clicked = false;
171 |
172 | let r = gui_data.check_refresh_and_clear();
173 |
174 | let (line_positions, line_indices) = create_build_area(&display, build_x, build_y, build_z);
175 | event_loop.run(move |event, _, control_flow| {
176 | let mut redraw = || {
177 | let mut quit = false;
178 |
179 |
180 | let needs_repaint = egui_glium.run(&display, |egui_ctx| {
181 |
182 | gui_data.update_colors();
183 |
184 | plot_window_resp = None;
185 | window_clicked = false;
186 | let resp = egui::SidePanel::left("my_side_panel").show(&egui_ctx, |ui| {
187 | ui.heading(&get_translated_string(&ctx, lang, "setup_bar_heading"));
188 | ui.horizontal(|ui| {
189 | ui.label(&get_translated_string(&ctx, lang, "model_path"));
190 | if ui.button(&get_translated_string(&ctx, lang, "choose_model_button")).clicked() {
191 | gui_data.load_model( &display);
192 | }
193 | });
194 | ui.horizontal(|ui| {
195 | ui.label(&get_translated_string(&ctx, lang, "settings_path"));
196 | let mut short = gui_data.get_settings_path().clone();
197 | if short.len() > 13{
198 | short.truncate(10);
199 | short += "...";
200 | }
201 | ui.label(short);
202 | });
203 | ui.horizontal(|ui| {
204 | if ui.button("Choose settings").clicked() {
205 | gui_data.load_settings_file();
206 | }
207 | });
208 | ui.group(|ui| {
209 |
210 | gui_data.get_objects().iter().enumerate()
211 | .for_each(|(i,mut obj)| {
212 | ui.horizontal(|ui| {
213 | ui.label(obj.name.to_string());
214 | });
215 |
216 | let mut changed = false;
217 |
218 | /*ui.horizontal(|ui| {
219 | changed |= ui.add(egui::DragValue::new(&mut obj.get_mut_location().x)
220 | .speed(1.0)
221 | .clamp_range(f64::NEG_INFINITY..=f64::INFINITY)
222 | .prefix("x: "))
223 | .changed();
224 | changed |= ui.add(egui::DragValue::new(&mut obj.get_mut_location().y)
225 | .speed(1.0)
226 | .clamp_range(f64::NEG_INFINITY..=f64::INFINITY)
227 | .prefix("y: "))
228 | .changed();
229 | changed |= ui.add(egui::DragValue::new(&mut obj.get_mut_scale().x)
230 | .speed(0.01)
231 | .clamp_range(0.0..=f64::INFINITY)
232 | .prefix("scale: "))
233 | .changed();
234 |
235 | obj.get_mut_scale().y = obj.get_scale().x;
236 | obj.get_mut_scale().z = obj.get_scale().x;
237 | });
238 |
239 | ui.horizontal(|ui| {
240 | if ui.button(&get_translated_string(&ctx, lang,"remove")).clicked() {
241 | remove = Some(i);
242 | };
243 | if ui.button(&get_translated_string(&ctx, lang, "copy")).clicked(){
244 | copy = Some(i)
245 | }
246 | if ui.button(&get_translated_string(&ctx, lang, "center")).clicked(){
247 | obj.get_mut_location().x = build_x /2.0;
248 | obj.get_mut_location().y = build_y /2.0;
249 | changed = true;
250 | }
251 |
252 | });*/
253 |
254 | if changed{
255 | //obj.revalidate_cache();
256 | //*gcode.write().unwrap() = None;
257 | //*calc_vals.write().unwrap() = None;
258 | }
259 | });
260 | });
261 |
262 | ui.horizontal(|ui| {
263 |
264 |
265 | ui.style_mut().spacing.button_padding = egui::Vec2::new(50., 20.);
266 | ui.style_mut().override_text_style = Some(TextStyle::Heading);
267 |
268 |
269 | ui.centered_and_justified(|ui| {
270 | let mut fonts = FontDefinitions::default();
271 |
272 | // Large button text:
273 |
274 | //ui.ctx().set_fonts(fonts);
275 |
276 |
277 | if ui.add_enabled( gui_data.can_slice(), egui::Button::new(&get_translated_string(&ctx, lang, "slice"))).clicked() {
278 | index = 0;
279 | layers = 0;
280 | viewer_open = true;
281 |
282 | gui_data.start_slice();
283 | }
284 | });
285 | });
286 |
287 | if let Some(cv) = gui_data.get_calculated_values(){
288 | ui.horizontal(|ui| {
289 | ui.label(get_translated_string_argument(&ctx,lang,"plastic_volume_msg",format!("{:.0}",cv.plastic_volume)));
290 | });
291 | ui.horizontal(|ui| {
292 | ui.label(get_translated_string_argument(&ctx,lang,"plastic_weight_msg",format!("{:.0}",cv.plastic_weight)));
293 |
294 | });
295 | ui.horizontal(|ui| {
296 | let (hour,min,_,_) = cv.get_hours_minutes_seconds_fract_time();
297 | ui.label(get_translated_string_arguments(&ctx,lang,"print_time_msg",&[hour.to_string(), min.to_string()]));
298 | });
299 | };
300 |
301 | for err in gui_data.get_errors(){
302 |
303 | let (code, message) = err.get_code_and_message();
304 | ui.horizontal(|ui| {
305 | ui.label(format!("Error {:#X}",code));
306 | });
307 | ui.horizontal(|ui| {
308 | ui.label(message.to_string());
309 | });
310 | };
311 |
312 | if gui_data.is_command_running(){
313 | ui.horizontal(|ui| {
314 | ui.heading("Running");
315 | });
316 | ui.horizontal(|ui| {
317 | ui.label(format!("Status {}",gui_data.get_command_state()));
318 | });
319 | }
320 |
321 | if let Some(str) = gui_data.get_gcode() {
322 | ui.horizontal(|ui| {
323 | ui.style_mut().spacing.button_padding = egui::Vec2::new(50., 20.);
324 | //ui.style_mut().body_text_style = TextStyle::Heading;
325 | ui.style_mut().override_text_style = Some(TextStyle::Heading);
326 |
327 |
328 | ui.centered_and_justified(|ui| {
329 | if ui.button("Save").clicked() {
330 | let path = FileDialog::new()
331 | .add_filter("gcode", &["gcode"])
332 | .show_save_single_file()
333 | .unwrap();
334 |
335 | let path = match path {
336 | Some(path) => path,
337 | None => return,
338 | };
339 |
340 | let mut file = File::create(path).unwrap();
341 | file.write_all(str.as_bytes()).unwrap();
342 | }
343 | });
344 | });
345 | }
346 | if let Some(cmds) = gui_data.get_commands() {
347 | plot_window_resp = egui::Window::new(&get_translated_string(&ctx, lang, "viewer"))
348 | .open(&mut viewer_open)
349 | .default_size(egui::Vec2::new(400.0, 400.0))
350 | .show(&egui_ctx, |ui| {
351 |
352 |
353 | let line = Line::new(Values::from_values(vec![Value{x:0.0,y: 0.0},Value{x:0.0,y: build_y as f64 },Value{x:build_x as f64 ,y: build_y as f64 },Value{x:build_x as f64,y: 0.0 },Value{x:0.0,y: 0.0},Value{x:0.0,y: build_y as f64 }])).width(5.0);
354 |
355 |
356 | let mut layer_height = 0.0;
357 |
358 | ui.style_mut().spacing.slider_width = ui.available_width() - 100.0;
359 | let drag_resp = ui.add(egui::Slider::new(&mut index, 1..=layers-1)
360 | .prefix("x: "));
361 |
362 |
363 | let plot = Plot::new("items_demo")
364 | .legend(Legend::default().position(Corner::RightBottom))
365 | .show_x(false)
366 | .show_y(false)
367 | .data_aspect(1.0);
368 |
369 |
370 | let resp = plot.show(ui, |plot_ui| {
371 | plot_ui.line(line.name(&get_translated_string(&ctx, lang, "Border")));
372 |
373 | let p1 = plot_ui.screen_from_plot(Value{x:0.0,y:0.0});
374 | let p2 = plot_ui.screen_from_plot(Value{x:0.0,y:1.0});
375 |
376 |
377 | let pixels_per_plot_unit = (p2-p1).length();
378 |
379 |
380 | let mut moves : Vec<_>= (&cmds
381 | .iter()
382 | .group_by(|cmd|{
383 | if let gladius_shared::types::Command::LayerChange { z, index: _index } = cmd{
384 | let r = *z == layer_height;
385 | layer_height = *z;
386 | r
387 | }else{
388 | true
389 | }
390 | }))
391 | .into_iter()
392 | .filter_map(|(change,layer)|{
393 | if !change{
394 | None
395 | }else{
396 | let lines :Vec<_> = layer.into_iter().filter_map(|cmd|{
397 |
398 | if let gladius_shared::types::Command::MoveAndExtrude{start,end,width,..} = cmd{
399 | Some(Line::new(Values::from_values(vec![Value{x:start.x,y:start.y},Value{x:end.x,y: end.y }]))
400 | .stroke(Stroke{width: *width as f32 * pixels_per_plot_unit* 0.95,color: Color32::BLUE}))
401 |
402 | }else{
403 | None
404 | }
405 | }).collect();
406 |
407 | Some(lines)
408 | }
409 | })
410 | .collect();
411 |
412 | layers = moves.len();
413 |
414 | for move_line in moves.remove(index){
415 | plot_ui.line(move_line.name("Move"));
416 | }
417 | });
418 |
419 | drag_resp.union(resp.response)
420 | });
421 | }
422 |
423 |
424 |
425 | });
426 |
427 | window_rec = plot_window_resp.as_ref().map(|r| r.response.rect);
428 |
429 | let full_resp = match plot_window_resp.take(){
430 | Some(mut window_resp) => {
431 |
432 | resp.response.union(window_resp.response.interact(Sense::click_and_drag()).union(window_resp.inner.take().unwrap()))
433 | },
434 | None => {
435 | resp.response
436 | }
437 | };
438 |
439 | on_render_screen = !egui_ctx.wants_pointer_input();
440 | });
441 |
442 | *control_flow = if quit {
443 | glutin::event_loop::ControlFlow::Exit
444 | } else if needs_repaint {
445 |
446 | gui_data.check_refresh_and_clear();
447 | display.gl_window().window().request_redraw();
448 |
449 | glutin::event_loop::ControlFlow::Poll
450 | } else if gui_data.is_command_running(){
451 | //If command is running keep refreshing
452 | glutin::event_loop::ControlFlow::Poll
453 | }else{
454 | glutin::event_loop::ControlFlow::Wait
455 | };
456 |
457 |
458 | {
459 | use glium::Surface as _;
460 | let mut target = display.draw();
461 |
462 | let color = egui::Rgba::from_rgb(0.0, 0.0, 0.0);
463 | target.clear_color_and_depth((color[0], color[1], color[2], color[3]),1.0);
464 |
465 | // draw things behind egui here
466 |
467 | let (view ,perspective ) = gui_data.get_camera_view_and_proj_matrix();
468 |
469 | let line_model = glam::Mat4::from_translation(Vec3::new(0.0,0.0,0.0)).to_cols_array_2d();
470 |
471 | let params = glium::DrawParameters {
472 | depth: glium::Depth {
473 | test: glium::draw_parameters::DepthTest::IfLess,
474 | write: true,
475 | .. Default::default()
476 | },
477 | //backface_culling: glium::draw_parameters::BackfaceCullingMode::CullClockwise,
478 | .. Default::default()
479 | };
480 |
481 | gui_data.update_colors();
482 | gui_data.update_screen_dimensions(Vec2::new(target.get_dimensions().0 as f32,target.get_dimensions().1 as f32 ));
483 |
484 | for obj in gui_data.get_objects(){
485 | let model = obj.get_model_matrix().to_cols_array_2d();
486 | let color = obj.color.to_array();
487 | let (positions, indices) = (&obj.vert_buff,&obj.index_buff);//create_mesh(&display);
488 | target.draw(positions, indices, &model_program, &uniform! {color: color, model: model, view: view, perspective: perspective }, ¶ms).unwrap();
489 | }
490 |
491 |
492 | target.draw(&line_positions, &line_indices, &line_program, &uniform! { model: line_model, view: view, perspective: perspective }, ¶ms).unwrap();
493 |
494 | egui_glium.paint(&display, &mut target);
495 |
496 | // draw things on top of egui here
497 |
498 | target.finish().unwrap();
499 | }
500 | };
501 |
502 |
503 |
504 |
505 | if r {
506 | redraw();
507 | }
508 |
509 | match event {
510 | // Platform-dependent event handlers to workaround a winit bug
511 | // See: https://github.com/rust-windowing/winit/issues/987
512 | // See: https://github.com/rust-windowing/winit/issues/1619
513 | glutin::event::Event::RedrawEventsCleared if cfg!(windows) => redraw(),
514 | glutin::event::Event::RedrawRequested(_) if !cfg!(windows) => redraw(),
515 |
516 | glutin::event::Event::WindowEvent { event, .. } => {
517 |
518 | match event{
519 | WindowEvent::CloseRequested | WindowEvent::Destroyed => {
520 | *control_flow = glutin::event_loop::ControlFlow::Exit;
521 | }
522 | WindowEvent::CursorMoved {position, ..} => {
523 | on_render_screen = on_render_screen && if let Some(rect ) = window_rec {
524 | //println!("{:?} {:?}",rect,position);
525 | !rect.contains(Pos2{x: position.x as f32,y: position.y as f32 })
526 | }
527 | else{
528 | true
529 | };
530 |
531 | if on_render_screen {
532 | gui_data.mouse_move(Vec2::new(position.x as f32, position.y as f32));
533 | }
534 |
535 | in_window = true;
536 | }
537 | WindowEvent::CursorLeft {..} =>{
538 | in_window = false;
539 | }
540 | _ => {}
541 | }
542 |
543 | egui_glium.on_event(&event);
544 |
545 | display.gl_window().window().request_redraw(); // TODO: ask egui if the events warrants a repaint instead
546 | }
547 | glutin::event::Event::DeviceEvent {event, ..} =>
548 | {
549 | match event {
550 | DeviceEvent::Button {button, state} => {
551 | if button == 1{
552 | if left_mouse_button_state == ElementState::Released && state == ElementState::Pressed {
553 | gui_data.select_button_pressed()
554 | }
555 | if state == ElementState::Released {
556 |
557 | gui_data.select_button_released()
558 | }
559 | left_mouse_button_state = state;
560 | }
561 | }
562 |
563 | DeviceEvent::MouseMotion {delta: (dx,dy)} =>{
564 | if left_mouse_button_state == ElementState::Pressed && on_render_screen && in_window{
565 | gui_data.mouse_move_delta(Vec2::new(dx as f32,dy as f32))
566 | }
567 | }
568 | DeviceEvent::MouseWheel {delta} =>{
569 | if on_render_screen && in_window {
570 | if let MouseScrollDelta::LineDelta(_x, y) = delta {
571 | gui_data.mouse_wheel(y)
572 | }
573 | }
574 | }
575 |
576 | _ => {
577 | //println!("{:?}",event);
578 | }
579 | }
580 | }
581 |
582 | _ => {
583 | //println!("{:?}",event)
584 | },
585 | }
586 | });
587 | }
588 |
589 |
590 | fn get_translated_string(ctx:& JSONGetText, lang: &str,index_str: &str) -> String{
591 | get_text!(ctx,lang, index_str).map_or(String::from("Not Translated"),|s| s.to_string())
592 | }
593 | fn get_translated_string_argument(ctx:& JSONGetText, lang: &str,index_str: &str, argument: String) -> String{
594 | get_text!(ctx,lang, index_str).map_or(String::from("Not Translated {}"),|s| s.to_string()).replace("{}", &argument)
595 | }
596 |
597 | fn get_translated_string_arguments(ctx:& JSONGetText, lang: &str,index_str: &str, arguments: &[String]) -> String{
598 | let mut ret_string = get_text!(ctx,lang, index_str).map_or(String::from("Not Translated {}"),|s| s.to_string());
599 | for (count,arg) in arguments.iter().enumerate(){
600 | ret_string = ret_string.replace(&format!("{{{}}}",count), &arg);
601 | }
602 |
603 | ret_string
604 | }
--------------------------------------------------------------------------------
/src/model.rs:
--------------------------------------------------------------------------------
1 | use std::io::{BufRead, BufReader};
2 | use std::process::{Command, Stdio};
3 | use std::sync::{Arc, RwLock};
4 | use gladius_shared::messages::Message;
5 | use gladius_shared::types::{CalculatedValues};
6 | use glam::{Mat4, Vec2, Vec3};
7 | use itertools::Itertools;
8 | use crate::Errors;
9 | use crate::object::{load, DisplayVertex, Object};
10 |
11 | use native_dialog::FileDialog;
12 |
13 | pub struct GUIData{
14 | objects: Vec