NEW:add fan control
Change-Id: I3b5c7cf638306aaac81459c2f25e37008a5a8a2f
4
resources/images/fan_control_add.svg
Normal file
|
@ -0,0 +1,4 @@
|
|||
<svg width="14" height="14" viewBox="0 0 14 14" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.329102 7.14591C0.329102 6.7317 0.664888 6.39591 1.0791 6.39591H12.2525C12.6667 6.39591 13.0025 6.7317 13.0025 7.14591C13.0025 7.56013 12.6667 7.89591 12.2525 7.89591H1.0791C0.664888 7.89591 0.329102 7.56013 0.329102 7.14591Z" fill="#828280"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M6.66504 0.809425C7.07925 0.809425 7.41504 1.14521 7.41504 1.55943L7.41504 12.7329C7.41504 13.1471 7.07925 13.4829 6.66504 13.4829C6.25082 13.4829 5.91504 13.1471 5.91504 12.7329L5.91504 1.55943C5.91504 1.14521 6.25083 0.809425 6.66504 0.809425Z" fill="#828280"/>
|
||||
</svg>
|
After Width: | Height: | Size: 711 B |
3
resources/images/fan_control_decrease.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="13" height="13" viewBox="0 0 13 13" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M0.160156 6.5C0.160156 6.08579 0.495943 5.75 0.910156 5.75H12.0836C12.4978 5.75 12.8336 6.08579 12.8336 6.5C12.8336 6.91421 12.4978 7.25 12.0836 7.25H0.910156C0.495943 7.25 0.160156 6.91421 0.160156 6.5Z" fill="#828280"/>
|
||||
</svg>
|
After Width: | Height: | Size: 374 B |
11
resources/images/fan_dash_bk.svg
Normal file
|
@ -0,0 +1,11 @@
|
|||
<svg width="100" height="100" viewBox="0 0 100 100" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<g clip-path="url(#clip0_44_12301)">
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M32.2533 15.2624C37.018 12.8234 42.3505 11.3358 48 11.0504V13.0531C42.7143 13.3347 37.7231 14.7256 33.2549 16.9972L32.2533 15.2624ZM28.791 17.2656C24.1876 20.2544 20.2542 24.1879 17.2655 28.7913L19.0002 29.7929C21.81 25.4912 25.4909 21.8102 29.7926 19.0004L28.791 17.2656ZM11.0504 48C11.3358 42.3506 12.8233 37.0183 15.2623 32.2536L16.997 33.2552C14.7255 37.7233 13.3347 42.7145 13.0532 48H11.0504ZM70.2069 81C74.5088 78.1901 78.1899 74.509 80.9998 70.2072L82.7345 71.2087C79.7457 75.8124 75.8121 79.7459 71.2084 82.7347L70.2069 81ZM88.9496 52C88.6643 57.6494 87.1767 62.9818 84.7377 67.7465L83.003 66.7449C85.2745 62.2768 86.6654 57.2856 86.9469 52H88.9496ZM52 11.0504V13.0531C57.2855 13.3347 62.2765 14.7254 66.7446 16.9969L67.7462 15.2621C62.9816 12.8232 57.6493 11.3358 52 11.0504ZM71.2085 17.2653L70.2069 19C74.5088 21.8099 78.1899 25.491 80.9998 29.7929L82.7346 28.7913C79.7458 24.1877 75.8121 20.2541 71.2085 17.2653ZM29.7926 80.9996C25.491 78.1898 21.81 74.5089 19.0002 70.2072L17.2655 71.2087C20.2542 75.8122 24.1876 79.7456 28.7911 82.7344L29.7926 80.9996ZM13.0532 52C13.3347 57.2856 14.7255 62.2767 16.9971 66.7449L15.2623 67.7465C12.8233 62.9818 11.3358 57.6494 11.0504 52H13.0532ZM84.7378 32.2536L83.003 33.2552C85.2745 37.7233 86.6654 42.7144 86.9469 48H88.9496C88.6643 42.3506 87.1767 37.0182 84.7378 32.2536Z" fill="#00AE42"/>
|
||||
<path fill-rule="evenodd" clip-rule="evenodd" d="M4.46154 50C4.46154 24.8498 24.8498 4.46154 50 4.46154C75.1502 4.46154 95.5385 24.8498 95.5385 50C95.5385 66.1387 87.1432 80.3165 74.4817 88.4047L75.7138 90.5387C89.1106 82.0233 98 67.0498 98 50C98 23.4903 76.5097 2 50 2C23.4903 2 2 23.4903 2 50C2 67.0493 10.8889 82.0225 24.2851 90.538L25.5172 88.404C12.8563 80.3157 4.46154 66.1382 4.46154 50Z" fill="#6B6B6B"/>
|
||||
</g>
|
||||
<defs>
|
||||
<clipPath id="clip0_44_12301">
|
||||
<rect width="100" height="100" fill="white"/>
|
||||
</clipPath>
|
||||
</defs>
|
||||
</svg>
|
After Width: | Height: | Size: 2 KiB |
6
resources/images/fan_icon.svg
Normal file
|
@ -0,0 +1,6 @@
|
|||
<svg width="19" height="19" viewBox="0 0 19 19" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M8.74075 11.2603C8.73545 10.9437 8.33311 10.5663 7.82345 10.0884C7.26132 9.56146 6.56204 8.90549 6.07884 8.00648C5.30352 6.5646 3.59261 5.55827 2.45248 5.45239C2.39039 5.44661 2.33024 5.44373 2.27345 5.44373C1.99239 5.44373 1.78063 5.51495 1.67619 5.64393C1.07653 6.38846 0.664082 7.56083 0.600554 8.70384C0.528845 9.99171 0.899422 11.0423 1.64298 11.6622C2.42986 12.3182 3.79185 12.6912 5.28812 12.6594C6.70594 12.6295 7.94473 12.2532 8.52129 11.6766C8.67096 11.527 8.74267 11.3908 8.74075 11.2603ZM7.70361 11.3975C7.15544 11.7123 6.22419 11.9206 5.2732 11.9409C5.22122 11.9418 5.16876 11.9423 5.11727 11.9423C3.85586 11.9423 2.72921 11.6309 2.10404 11.1097C1.53903 10.639 1.26037 9.79873 1.31909 8.74378C1.36866 7.84574 1.67523 6.89619 2.11896 6.26621L2.195 6.15793L2.32735 6.16467C2.5959 6.17814 2.9607 6.2821 3.32743 6.45006C4.23943 6.8678 5.03112 7.57671 5.44549 8.34722C5.74436 8.90309 6.13371 9.419 6.66984 9.97102C6.84214 10.1486 7.24015 10.5269 7.50292 10.7771C7.62901 10.8975 7.70794 10.9721 7.73297 10.9971L7.97216 11.243L7.70361 11.3975Z" fill="#828280"/>
|
||||
<path d="M10.627 10.8205C10.1 11.3826 9.44404 12.0819 8.54502 12.5651C7.10314 13.3404 6.09681 15.0508 5.99093 16.1914C5.95676 16.5591 6.02654 16.8421 6.18247 16.9677C6.927 17.5679 8.09937 17.9803 9.24238 18.0439C10.5303 18.1156 11.5809 17.745 12.2007 17.0014C12.8567 16.2145 13.2297 14.8521 13.1979 13.3563C13.1681 11.9385 12.7917 10.6997 12.2152 10.1231C12.0674 9.97537 11.9332 9.90367 11.8042 9.90367L11.797 9.80741L11.7984 9.90367C11.4822 9.90848 11.1049 10.3113 10.627 10.8205ZM11.936 10.9403C12.2513 11.4885 12.4592 12.4197 12.4794 13.3707C12.5068 14.6783 12.1882 15.8926 11.6487 16.5404C11.2228 17.0515 10.4792 17.333 9.55521 17.333C9.46569 17.333 9.37425 17.3306 9.28233 17.3253C8.3838 17.2753 7.43473 16.9687 6.80475 16.5254L6.69647 16.4494L6.70321 16.3171C6.71668 16.0485 6.82063 15.6837 6.9886 15.317C7.40634 14.405 8.11525 13.6133 8.88576 13.1989C9.44115 12.9 9.95755 12.5112 10.5096 11.9746C10.6872 11.8018 11.0659 11.4043 11.3162 11.141L11.3292 11.1275C11.4384 11.0125 11.5106 10.9369 11.5356 10.9119C11.5443 10.9033 11.5534 10.8941 11.5626 10.8859L11.7844 10.6761L11.936 10.9403Z" fill="#828280"/>
|
||||
<path d="M12.9997 1.13739C12.2547 0.537251 11.0823 0.124803 9.9398 0.0612752C9.83536 0.0554999 9.73092 0.0526123 9.62986 0.0526123C8.48684 0.0526123 7.54645 0.426077 6.98144 1.1037C6.32547 1.89058 5.95296 3.25353 5.98425 4.74884C6.01409 6.16666 6.39044 7.40545 6.967 7.98201C7.11619 8.1312 7.25191 8.20195 7.38426 8.20147C7.70045 8.19617 8.07777 7.79383 8.55567 7.28417C9.08266 6.72252 9.73862 6.02324 10.6376 5.53956C12.0795 4.76424 13.0858 3.05381 13.1917 1.9132C13.2254 1.54599 13.1556 1.263 12.9997 1.13739ZM12.4795 1.78807C12.466 2.05662 12.362 2.42142 12.1941 2.78815C11.7763 3.70015 11.0674 4.49184 10.2969 4.90621C9.74103 5.20508 9.22511 5.59443 8.6731 6.13056C8.49647 6.30189 8.11819 6.69942 7.86841 6.9622C7.80056 7.03391 7.74713 7.08973 7.70863 7.12968L7.7096 7.13064L7.6581 7.18214L7.63837 7.22112H7.61815L7.39821 7.42758L7.24661 7.16385C6.93138 6.61568 6.72348 5.68443 6.70326 4.73344C6.67583 3.42631 6.99443 2.21159 7.53393 1.5638C8.00509 0.998307 8.84539 0.719652 9.89985 0.778848C10.7979 0.828419 11.7474 1.13499 12.3774 1.57872L12.4857 1.65524L12.4795 1.78807Z" fill="#828280"/>
|
||||
<path d="M17.5412 6.44297C16.7601 5.79181 15.3875 5.4145 13.896 5.44578C12.4782 5.47562 11.2394 5.85197 10.6629 6.42853C10.5132 6.57821 10.4415 6.71441 10.4434 6.84531C10.4487 7.16199 10.851 7.53931 11.3607 8.01721C11.9228 8.5442 12.6221 9.20017 13.1053 10.0992C13.8806 11.5411 15.5911 12.5474 16.7317 12.6533C17.0993 12.6874 17.3823 12.6177 17.5079 12.4617C18.1081 11.7172 18.5205 10.5448 18.5841 9.40182C18.6553 8.11346 18.2852 7.06285 17.5412 6.44297ZM17.866 9.36139C17.8164 10.2599 17.5099 11.209 17.0661 11.839L16.9901 11.9473L16.8578 11.941C16.5892 11.928 16.2244 11.824 15.8577 11.6556C14.9457 11.2379 14.154 10.5285 13.7396 9.75844C13.4407 9.20257 13.0514 8.68665 12.5153 8.13464C12.3434 7.95753 11.9459 7.57925 11.6827 7.32851L11.7486 7.25824L11.6822 7.32803C11.5556 7.20771 11.4772 7.13263 11.4526 7.10809C11.4415 7.09702 11.4338 7.08932 11.4266 7.08162L11.2178 6.85975L11.482 6.70767C12.0301 6.39244 12.9614 6.18453 13.9124 6.16432C15.22 6.13737 16.4347 6.45597 17.082 6.99499C17.6456 7.46615 17.9247 8.30645 17.866 9.36139Z" fill="#828280"/>
|
||||
</svg>
|
After Width: | Height: | Size: 4.3 KiB |
3
resources/images/fan_scale_0.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M32.6757 31.6386L19.3114 49.7398C18.957 50.2199 18.2112 49.7875 18.4515 49.2414L27.5142 28.6531C27.5577 28.5543 27.6321 28.4722 27.7261 28.4191L31.9128 26.0568C32.2415 25.8713 32.6494 26.103 32.6583 26.4804L32.7733 31.3297C32.776 31.4407 32.7416 31.5493 32.6757 31.6386Z" fill="#FF6F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 401 B |
3
resources/images/fan_scale_1.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M31.5152 32.6674L10.8908 41.6614C10.3439 41.8999 9.91409 41.1525 10.3953 40.7998L28.538 27.5012C28.6251 27.4373 28.7305 27.4034 28.8385 27.4044L33.6454 27.4519C34.0229 27.4556 34.2602 27.8603 34.0793 28.1916L31.7542 32.4487C31.701 32.5461 31.6169 32.623 31.5152 32.6674Z" fill="#FF6F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 401 B |
3
resources/images/fan_scale_10.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M32.8413 28.657L41.8353 49.2814C42.0738 49.8284 41.3264 50.2581 40.9737 49.7769L27.6751 31.6342C27.6112 31.5471 27.5773 31.4417 27.5783 31.3337L27.6258 26.5268C27.6295 26.1493 28.0342 25.912 28.3655 26.0929L32.6226 28.418C32.72 28.4712 32.7969 28.5553 32.8413 28.657Z" fill="#FF6F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 398 B |
3
resources/images/fan_scale_2.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M30.0024 32.9817L7.64413 30.4585C7.05119 30.3916 7.05268 29.5295 7.64583 29.4646L30.0071 27.019C30.1145 27.0072 30.2227 27.0306 30.3157 27.0855L34.4549 29.53C34.7799 29.722 34.7832 30.1911 34.4608 30.3875L30.3187 32.9118C30.2239 32.9695 30.1127 32.9941 30.0024 32.9817Z" fill="#FF6F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 400 B |
3
resources/images/fan_scale_3.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M28.5379 32.4973L10.4367 19.133C9.95666 18.7786 10.389 18.0327 10.9351 18.2731L31.5234 27.3358C31.6222 27.3793 31.7043 27.4536 31.7574 27.5477L34.1197 31.7343C34.3052 32.0631 34.0735 32.4709 33.6961 32.4799L28.8468 32.5949C28.7358 32.5975 28.6272 32.5632 28.5379 32.4973Z" fill="#FF6F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 402 B |
3
resources/images/fan_scale_4.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M27.5093 31.344L18.5153 10.7195C18.2768 10.1726 19.0241 9.74283 19.3769 10.2241L32.6755 28.3667C32.7394 28.4538 32.7733 28.5592 32.7722 28.6672L32.7248 33.4741C32.721 33.8516 32.3164 34.089 31.9851 33.908L27.728 31.5829C27.6306 31.5297 27.5537 31.4457 27.5093 31.344Z" fill="#FF6F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 398 B |
3
resources/images/fan_scale_5.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M27.1946 29.8308L29.7178 7.47251C29.7847 6.87958 30.6468 6.88106 30.7116 7.47422L33.1573 29.8355C33.169 29.9429 33.1457 30.0511 33.0908 30.1441L30.6462 34.2833C30.4542 34.6083 29.9851 34.6116 29.7887 34.2892L27.2644 30.1471C27.2067 30.0523 27.1821 29.941 27.1946 29.8308Z" fill="#FF6F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 402 B |
3
resources/images/fan_scale_6.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M27.6866 28.3631L41.0509 10.2618C41.4053 9.78179 42.1512 10.2141 41.9108 10.7603L32.8481 31.3485C32.8046 31.4474 32.7302 31.5295 32.6362 31.5825L28.4495 33.9449C28.1208 34.1304 27.7129 33.8986 27.704 33.5213L27.589 28.6719C27.5863 28.561 27.6207 28.4523 27.6866 28.3631Z" fill="#FF6F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 401 B |
3
resources/images/fan_scale_7.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M28.8392 27.3343L49.4637 18.3403C50.0106 18.1018 50.4404 18.8491 49.9591 19.2019L31.8165 32.5005C31.7294 32.5643 31.624 32.5983 31.516 32.5972L26.7091 32.5497C26.3316 32.546 26.0943 32.1414 26.2752 31.8101L28.6003 27.5529C28.6535 27.4555 28.7375 27.3786 28.8392 27.3343Z" fill="#FF6F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 401 B |
3
resources/images/fan_scale_8.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M30.3521 27.02L52.7104 29.5432C53.3033 29.6101 53.3018 30.4722 52.7087 30.537L30.3474 32.9827C30.24 32.9944 30.1317 32.9711 30.0387 32.9162L25.8996 30.4716C25.5746 30.2796 25.5713 29.8105 25.8936 29.6141L30.0358 27.0898C30.1306 27.0321 30.2418 27.0075 30.3521 27.02Z" fill="#FF6F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 397 B |
3
resources/images/fan_scale_9.svg
Normal file
|
@ -0,0 +1,3 @@
|
|||
<svg width="60" height="60" viewBox="0 0 60 60" fill="none" xmlns="http://www.w3.org/2000/svg">
|
||||
<path d="M31.8459 27.504L49.9471 40.8683C50.4271 41.2227 49.9948 41.9686 49.4487 41.7282L28.8604 32.6655C28.7616 32.622 28.6795 32.5477 28.6264 32.4536L26.2641 28.267C26.0786 27.9382 26.3103 27.5304 26.6877 27.5214L31.537 27.4064C31.6479 27.4038 31.7566 27.4381 31.8459 27.504Z" fill="#FF6F00"/>
|
||||
</svg>
|
After Width: | Height: | Size: 399 B |
|
@ -56,6 +56,8 @@ set(SLIC3R_GUI_SOURCES
|
|||
GUI/Widgets/TempInput.hpp
|
||||
GUI/Widgets/AMSControl.cpp
|
||||
GUI/Widgets/AMSControl.hpp
|
||||
GUI/Widgets/FanControl.cpp
|
||||
GUI/Widgets/FanControl.hpp
|
||||
GUI/Widgets/Scrollbar.cpp
|
||||
GUI/Widgets/Scrollbar.hpp
|
||||
GUI/Widgets/ScrolledWindow.cpp
|
||||
|
|
|
@ -364,6 +364,7 @@ MachineObject::MachineObject(NetworkAgent* agent, std::string name, std::string
|
|||
cooling_fan_speed = 0;
|
||||
big_fan1_speed = 0;
|
||||
big_fan2_speed = 0;
|
||||
fan_gear = 0;
|
||||
|
||||
/* printing */
|
||||
mc_print_stage = 0;
|
||||
|
@ -1379,6 +1380,13 @@ int MachineObject::command_control_fan(FanType fan_type, bool on_off)
|
|||
return this->publish_gcode(gcode);
|
||||
}
|
||||
|
||||
int MachineObject::command_control_fan_val(FanType fan_type, int val)
|
||||
{
|
||||
std::string gcode = (boost::format("M106 P%1% S%2% \n") % (int)fan_type % (val)).str();
|
||||
return this->publish_gcode(gcode);
|
||||
}
|
||||
|
||||
|
||||
int MachineObject::command_task_abort()
|
||||
{
|
||||
json j;
|
||||
|
@ -2322,7 +2330,13 @@ int MachineObject::parse_json(std::string payload)
|
|||
wifi_signal = jj["wifi_signal"].get<std::string>();
|
||||
|
||||
/* cooling */
|
||||
if (jj.contains("cooling_fan_speed")) {
|
||||
if (jj.contains("fan_gear")) {
|
||||
fan_gear = jj["fan_gear"].get<std::uint32_t>();
|
||||
big_fan2_speed = (int)((fan_gear & 0x00FF0000) >> 16);
|
||||
big_fan1_speed = (int)((fan_gear & 0x0000FF00) >> 8);
|
||||
cooling_fan_speed= (int)((fan_gear & 0x000000FF) >> 0);
|
||||
}
|
||||
/* if (jj.contains("cooling_fan_speed")) {
|
||||
cooling_fan_speed = stoi(jj["cooling_fan_speed"].get<std::string>());
|
||||
}
|
||||
if (jj.contains("big_fan1_speed")) {
|
||||
|
@ -2330,7 +2344,7 @@ int MachineObject::parse_json(std::string payload)
|
|||
}
|
||||
if (jj.contains("big_fan2_speed")) {
|
||||
big_fan2_speed = stoi(jj["big_fan2_speed"].get<std::string>());
|
||||
}
|
||||
}*/
|
||||
if (jj.contains("heatbreak_fan_speed")) {
|
||||
heatbreak_fan_speed = stoi(jj["heatbreak_fan_speed"].get<std::string>());
|
||||
}
|
||||
|
|
|
@ -476,6 +476,7 @@ public:
|
|||
int cooling_fan_speed = 0;
|
||||
int big_fan1_speed = 0;
|
||||
int big_fan2_speed = 0;
|
||||
uint32_t fan_gear = 0;
|
||||
|
||||
/* signals */
|
||||
std::string wifi_signal;
|
||||
|
@ -637,6 +638,7 @@ public:
|
|||
int command_auto_leveling();
|
||||
int command_go_home();
|
||||
int command_control_fan(FanType fan_type, bool on_off);
|
||||
int command_control_fan_val(FanType fan_type, int val);
|
||||
int command_task_abort();
|
||||
int command_task_pause();
|
||||
int command_task_resume();
|
||||
|
|
|
@ -72,6 +72,7 @@ static wxColour TEXT_LIGHT_FONT_COL = wxColour(107, 107, 107);
|
|||
#define TASK_BUTTON_SIZE2 (wxSize(-1, FromDIP(24)))
|
||||
#define Z_BUTTON_SIZE (wxSize(FromDIP(52), FromDIP(52)))
|
||||
#define MISC_BUTTON_SIZE (wxSize(FromDIP(68), FromDIP(55)))
|
||||
#define MISC_BUTTON_3FAN_SIZE (wxSize(FromDIP(45), FromDIP(55)))
|
||||
#define TEMP_CTRL_MIN_SIZE (wxSize(FromDIP(122), FromDIP(52)))
|
||||
#define AXIS_MIN_SIZE (wxSize(FromDIP(220), FromDIP(220)))
|
||||
#define EXTRUDER_IMAGE_SIZE (wxSize(FromDIP(48), FromDIP(76)))
|
||||
|
@ -728,7 +729,7 @@ wxBoxSizer *StatusBasePanel::create_temp_control(wxWindow *parent)
|
|||
line->SetLineColour(STATIC_BOX_LINE_COL);
|
||||
sizer->Add(line, 0, wxEXPAND | wxLEFT | wxRIGHT, 12);
|
||||
|
||||
wxBoxSizer *m_misc_ctrl_sizer = create_misc_control(parent);
|
||||
m_misc_ctrl_sizer = create_misc_control(parent);
|
||||
|
||||
sizer->Add(m_misc_ctrl_sizer, 0, wxEXPAND, 0);
|
||||
return sizer;
|
||||
|
@ -772,31 +773,47 @@ wxBoxSizer *StatusBasePanel::create_misc_control(wxWindow *parent)
|
|||
sizer->Add(line, 0, wxEXPAND | wxLEFT | wxRIGHT, 12);
|
||||
|
||||
line_sizer = new wxBoxSizer(wxHORIZONTAL);
|
||||
m_switch_nozzle_fan = new ImageSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off);
|
||||
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_SIZE);
|
||||
m_switch_nozzle_fan = new FanSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off);
|
||||
m_switch_nozzle_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
|
||||
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
|
||||
m_switch_nozzle_fan->SetValue(false);
|
||||
m_switch_nozzle_fan->SetLabels(_L("Part Cooling"), _L("Part Cooling"));
|
||||
m_switch_nozzle_fan->SetLabels(_L("Part"), _L("Part"));
|
||||
m_switch_nozzle_fan->SetPadding(FromDIP(3));
|
||||
m_switch_nozzle_fan->SetBorderWidth(FromDIP(2));
|
||||
m_switch_nozzle_fan->SetFont(::Label::Body_10);
|
||||
m_switch_nozzle_fan->SetTextColor(StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_FAN_TEXT_COL, (int) StateColor::Normal)));
|
||||
|
||||
line_sizer->Add(m_switch_nozzle_fan, 1, wxALIGN_CENTER | wxALL, 0);
|
||||
|
||||
line = new StaticLine(parent, true);
|
||||
line->SetLineColour(STATIC_BOX_LINE_COL);
|
||||
line_sizer->Add(line, 0, wxEXPAND | wxTOP | wxBOTTOM, 4);
|
||||
|
||||
|
||||
m_switch_printing_fan = new ImageSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off);
|
||||
m_switch_printing_fan = new FanSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off);
|
||||
m_switch_printing_fan->SetValue(false);
|
||||
m_switch_printing_fan->SetMinSize(MISC_BUTTON_SIZE);
|
||||
m_switch_printing_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
|
||||
m_switch_printing_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
|
||||
m_switch_printing_fan->SetPadding(FromDIP(3));
|
||||
m_switch_printing_fan->SetBorderWidth(FromDIP(2));
|
||||
m_switch_printing_fan->SetFont(::Label::Body_10);
|
||||
m_switch_printing_fan->SetLabels(_L("Aux Cooling"), _L("Aux Cooling"));
|
||||
m_switch_printing_fan->SetLabels(_L("Aux"), _L("Aux"));
|
||||
m_switch_printing_fan->SetTextColor(
|
||||
StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int) StateColor::Disabled), std::make_pair(NORMAL_FAN_TEXT_COL, (int) StateColor::Normal)));
|
||||
|
||||
m_switch_cham_fan = new FanSwitchButton(parent, m_bitmap_fan_on, m_bitmap_fan_off);
|
||||
m_switch_cham_fan->SetValue(false);
|
||||
m_switch_cham_fan->SetMinSize(MISC_BUTTON_3FAN_SIZE);
|
||||
m_switch_cham_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
|
||||
m_switch_cham_fan->SetPadding(FromDIP(3));
|
||||
m_switch_cham_fan->SetBorderWidth(FromDIP(2));
|
||||
m_switch_cham_fan->SetFont(::Label::Body_10);
|
||||
m_switch_cham_fan->SetLabels(_L("Cham"), _L("Cham"));
|
||||
m_switch_cham_fan->SetTextColor(
|
||||
StateColor(std::make_pair(DISCONNECT_TEXT_COL, (int)StateColor::Disabled), std::make_pair(NORMAL_FAN_TEXT_COL, (int)StateColor::Normal)));
|
||||
|
||||
line_sizer->Add(m_switch_nozzle_fan, 1, wxALIGN_CENTER | wxALL, 0);
|
||||
//line_sizer->Add(line, 0, wxEXPAND | wxTOP | wxBOTTOM, 4);
|
||||
line_sizer->Add(m_switch_printing_fan, 1, wxALIGN_CENTER | wxALL, 0);
|
||||
line_sizer->Add(m_switch_cham_fan, 1, wxALIGN_CENTER | wxALL, 0);
|
||||
|
||||
sizer->Add(line_sizer, 0, wxEXPAND, FromDIP(5));
|
||||
|
||||
|
@ -825,6 +842,7 @@ void StatusBasePanel::reset_temp_misc_control()
|
|||
m_switch_lamp->SetValue(false);
|
||||
m_switch_nozzle_fan->SetValue(false);
|
||||
m_switch_printing_fan->SetValue(false);
|
||||
m_switch_cham_fan->SetValue(false);
|
||||
}
|
||||
|
||||
wxBoxSizer *StatusBasePanel::create_axis_control(wxWindow *parent)
|
||||
|
@ -1125,6 +1143,7 @@ void StatusPanel::update_camera_state(MachineObject* obj)
|
|||
|
||||
StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size, long style, const wxString &name)
|
||||
: StatusBasePanel(parent, id, pos, size, style)
|
||||
, m_fan_control_popup(FanControlPopup(this))
|
||||
{
|
||||
create_tasklist_info();
|
||||
update_tasklist_info();
|
||||
|
@ -1148,6 +1167,7 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
|
|||
m_switch_lamp->SetValue(false);
|
||||
m_switch_printing_fan->SetValue(false);
|
||||
m_switch_nozzle_fan->SetValue(false);
|
||||
m_switch_cham_fan->SetValue(false);
|
||||
|
||||
/* set default enable state */
|
||||
m_button_pause_resume->Enable(false);
|
||||
|
@ -1183,7 +1203,8 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
|
|||
m_tempCtrl_nozzle->Connect(wxEVT_SET_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_set_focus), NULL, this);
|
||||
m_switch_lamp->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_lamp_switch), NULL, this);
|
||||
m_switch_nozzle_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this); // TODO
|
||||
m_switch_printing_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_printing_fan_switch), NULL, this);
|
||||
m_switch_printing_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
|
||||
m_switch_cham_fan->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
|
||||
m_bpButton_xy->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_xy), NULL, this); // TODO
|
||||
m_bpButton_z_10->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_up_10), NULL, this);
|
||||
m_bpButton_z_1->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_up_1), NULL, this);
|
||||
|
@ -1200,6 +1221,8 @@ StatusPanel::StatusPanel(wxWindow *parent, wxWindowID id, const wxPoint &pos, co
|
|||
Bind(EVT_AMS_ON_FILAMENT_EDIT, &StatusPanel::on_filament_edit, this);
|
||||
Bind(EVT_AMS_GUIDE_WIKI, &StatusPanel::on_ams_guide, this);
|
||||
Bind(EVT_AMS_RETRY, &StatusPanel::on_ams_retry, this);
|
||||
Bind(EVT_FAN_CHANGED, &StatusPanel::on_fan_changed, this);
|
||||
|
||||
|
||||
m_switch_speed->Connect(wxEVT_LEFT_DOWN, wxCommandEventHandler(StatusPanel::on_switch_speed), NULL, this);
|
||||
m_calibration_btn->Connect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_start_calibration), NULL, this);
|
||||
|
@ -1222,7 +1245,8 @@ StatusPanel::~StatusPanel()
|
|||
m_tempCtrl_nozzle->Disconnect(wxEVT_SET_FOCUS, wxFocusEventHandler(StatusPanel::on_nozzle_temp_set_focus), NULL, this);
|
||||
m_switch_lamp->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_lamp_switch), NULL, this);
|
||||
m_switch_nozzle_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
|
||||
m_switch_printing_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_printing_fan_switch), NULL, this);
|
||||
m_switch_printing_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
|
||||
m_switch_cham_fan->Disconnect(wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_nozzle_fan_switch), NULL, this);
|
||||
m_bpButton_xy->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_xy), NULL, this);
|
||||
m_bpButton_z_10->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_up_10), NULL, this);
|
||||
m_bpButton_z_1->Disconnect(wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler(StatusPanel::on_axis_ctrl_z_up_1), NULL, this);
|
||||
|
@ -1421,7 +1445,6 @@ void StatusPanel::update(MachineObject *obj)
|
|||
else
|
||||
show_printing_status();
|
||||
|
||||
|
||||
update_temp_ctrl(obj);
|
||||
update_misc_ctrl(obj);
|
||||
|
||||
|
@ -1588,6 +1611,7 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area)
|
|||
m_switch_lamp->Enable();
|
||||
m_switch_nozzle_fan->Enable();
|
||||
m_switch_printing_fan->Enable();
|
||||
m_switch_cham_fan->Enable();
|
||||
m_bpButton_xy->Enable();
|
||||
m_text_tasklist_caption->SetForegroundColour(GROUP_TITLE_FONT_COL);
|
||||
m_bpButton_z_10->Enable();
|
||||
|
@ -1619,6 +1643,7 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area)
|
|||
m_switch_lamp->Enable(false);
|
||||
m_switch_nozzle_fan->Enable(false);
|
||||
m_switch_printing_fan->Enable(false);
|
||||
m_switch_cham_fan->Enable(false);
|
||||
} else {
|
||||
m_tempCtrl_nozzle->Enable();
|
||||
m_tempCtrl_bed->Enable();
|
||||
|
@ -1628,6 +1653,7 @@ void StatusPanel::show_printing_status(bool ctrl_area, bool temp_area)
|
|||
m_switch_lamp->Enable();
|
||||
m_switch_nozzle_fan->Enable();
|
||||
m_switch_printing_fan->Enable();
|
||||
m_switch_cham_fan->Enable();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1688,17 +1714,51 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj)
|
|||
// update extruder icon
|
||||
update_extruder_status(obj);
|
||||
|
||||
bool is_suppt_cham_fun = obj->is_function_supported(PrinterFunction::FUNC_CHAMBER_FAN);
|
||||
//update cham fan
|
||||
if (m_current_support_cham_fan != is_suppt_cham_fun) {
|
||||
if (is_suppt_cham_fun) {
|
||||
m_switch_cham_fan->Show();
|
||||
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
|
||||
m_switch_printing_fan->SetMaxSize(MISC_BUTTON_3FAN_SIZE);
|
||||
}
|
||||
else {
|
||||
m_switch_cham_fan->Hide();
|
||||
m_switch_nozzle_fan->SetMaxSize(MISC_BUTTON_SIZE);
|
||||
m_switch_printing_fan->SetMaxSize(MISC_BUTTON_SIZE);
|
||||
}
|
||||
m_misc_ctrl_sizer->Layout();
|
||||
}
|
||||
|
||||
// nozzle fan
|
||||
if (m_switch_nozzle_fan_timeout > 0)
|
||||
if (m_switch_nozzle_fan_timeout > 0) {
|
||||
m_switch_nozzle_fan_timeout--;
|
||||
else
|
||||
m_switch_nozzle_fan->SetValue(obj->cooling_fan_speed > 0);
|
||||
} else{
|
||||
int speed = floor(obj->cooling_fan_speed / float(25.5));
|
||||
m_switch_nozzle_fan->SetValue(speed > 0 ? true : false);
|
||||
m_switch_nozzle_fan->setFanValue(speed * 10);
|
||||
m_fan_control_popup.update_fan_data(MachineObject::FanType::COOLING_FAN, obj);
|
||||
}
|
||||
|
||||
// printing fan
|
||||
if (m_switch_printing_fan_timeout > 0)
|
||||
if (m_switch_printing_fan_timeout > 0) {
|
||||
m_switch_printing_fan_timeout--;
|
||||
else
|
||||
m_switch_printing_fan->SetValue(obj->big_fan1_speed > 0);
|
||||
}else{
|
||||
int speed = floor(obj->big_fan1_speed / float(25.5));
|
||||
m_switch_printing_fan->SetValue(speed > 0 ? true : false);
|
||||
m_switch_printing_fan->setFanValue(speed * 10);
|
||||
m_fan_control_popup.update_fan_data(MachineObject::FanType::BIG_COOLING_FAN, obj);
|
||||
}
|
||||
|
||||
// cham fan
|
||||
if (m_switch_cham_fan_timeout > 0) {
|
||||
m_switch_cham_fan_timeout--;
|
||||
}else{
|
||||
int speed = floor(obj->big_fan2_speed / float(25.5));
|
||||
m_switch_cham_fan->SetValue(speed > 0 ? true : false);
|
||||
m_switch_cham_fan->setFanValue(speed * 10);
|
||||
m_fan_control_popup.update_fan_data(MachineObject::FanType::CHAMBER_FAN, obj);
|
||||
}
|
||||
|
||||
bool light_on = obj->chamber_light != MachineObject::LIGHT_EFFECT::LIGHT_EFFECT_OFF;
|
||||
BOOST_LOG_TRIVIAL(trace) << "light: " << light_on ? "on" : "off";
|
||||
|
@ -1718,6 +1778,8 @@ void StatusPanel::update_misc_ctrl(MachineObject *obj)
|
|||
wxString text_speed = wxString::Format("%d%%", obj->printing_speed_mag);
|
||||
m_switch_speed->SetLabels(text_speed, text_speed);
|
||||
}
|
||||
|
||||
m_current_support_cham_fan = is_suppt_cham_fun?true:false;
|
||||
}
|
||||
|
||||
void StatusPanel::update_extruder_status(MachineObject* obj)
|
||||
|
@ -2510,6 +2572,28 @@ void StatusPanel::on_ams_retry(wxCommandEvent& event)
|
|||
}
|
||||
}
|
||||
|
||||
void StatusPanel::on_fan_changed(wxCommandEvent& event)
|
||||
{
|
||||
auto type = event.GetInt();
|
||||
auto speed = atoi(event.GetString().c_str());
|
||||
|
||||
if (type == MachineObject::FanType::COOLING_FAN) {
|
||||
set_hold_count(this->m_switch_nozzle_fan_timeout);
|
||||
m_switch_nozzle_fan->SetValue(speed > 0 ? true : false);
|
||||
m_switch_nozzle_fan->setFanValue(speed * 10);
|
||||
}
|
||||
else if (type == MachineObject::FanType::BIG_COOLING_FAN) {
|
||||
set_hold_count(this->m_switch_printing_fan_timeout);
|
||||
m_switch_printing_fan->SetValue(speed > 0 ? true : false);
|
||||
m_switch_printing_fan->setFanValue(speed * 10);
|
||||
}
|
||||
else if (type == MachineObject::FanType::CHAMBER_FAN) {
|
||||
set_hold_count(this->m_switch_cham_fan_timeout);
|
||||
m_switch_cham_fan->SetValue(speed > 0 ? true : false);
|
||||
m_switch_cham_fan->setFanValue(speed * 10);
|
||||
}
|
||||
}
|
||||
|
||||
void StatusPanel::on_bed_temp_kill_focus(wxFocusEvent &event)
|
||||
{
|
||||
event.Skip();
|
||||
|
@ -2595,7 +2679,7 @@ void StatusPanel::on_switch_speed(wxCommandEvent &event)
|
|||
|
||||
void StatusPanel::on_printing_fan_switch(wxCommandEvent &event)
|
||||
{
|
||||
if (!obj) return;
|
||||
/* if (!obj) return;
|
||||
|
||||
bool value = m_switch_printing_fan->GetValue();
|
||||
|
||||
|
@ -2607,12 +2691,19 @@ void StatusPanel::on_printing_fan_switch(wxCommandEvent &event)
|
|||
obj->command_control_fan(MachineObject::FanType::BIG_COOLING_FAN, false);
|
||||
m_switch_printing_fan->SetValue(false);
|
||||
set_hold_count(this->m_switch_printing_fan_timeout);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
|
||||
void StatusPanel::on_nozzle_fan_switch(wxCommandEvent &event)
|
||||
{
|
||||
if (!obj) return;
|
||||
auto pos = m_switch_nozzle_fan->GetScreenPosition();
|
||||
pos.y = pos.y + m_switch_nozzle_fan->GetSize().y;
|
||||
m_fan_control_popup.SetPosition(pos);
|
||||
m_fan_control_popup.Popup();
|
||||
|
||||
|
||||
|
||||
/*if (!obj) return;
|
||||
|
||||
bool value = m_switch_nozzle_fan->GetValue();
|
||||
|
||||
|
@ -2624,7 +2715,7 @@ void StatusPanel::on_nozzle_fan_switch(wxCommandEvent &event)
|
|||
obj->command_control_fan(MachineObject::FanType::COOLING_FAN, false);
|
||||
m_switch_nozzle_fan->SetValue(false);
|
||||
set_hold_count(this->m_switch_nozzle_fan_timeout);
|
||||
}
|
||||
}*/
|
||||
}
|
||||
void StatusPanel::on_lamp_switch(wxCommandEvent &event)
|
||||
{
|
||||
|
@ -2797,6 +2888,7 @@ void StatusPanel::set_default()
|
|||
m_temp_bed_timeout = 0;
|
||||
m_switch_nozzle_fan_timeout = 0;
|
||||
m_switch_printing_fan_timeout = 0;
|
||||
m_switch_cham_fan_timeout = 0;
|
||||
m_show_ams_group = false;
|
||||
reset_printing_values();
|
||||
|
||||
|
@ -2955,7 +3047,11 @@ void StatusPanel::msw_rescale()
|
|||
m_switch_nozzle_fan->Rescale();
|
||||
m_switch_printing_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
|
||||
m_switch_printing_fan->SetMinSize(MISC_BUTTON_SIZE);
|
||||
m_switch_printing_fan->Rescale();
|
||||
m_switch_printing_fan->Rescale();
|
||||
m_switch_cham_fan->SetImages(m_bitmap_fan_on, m_bitmap_fan_off);
|
||||
m_switch_cham_fan->SetMinSize(MISC_BUTTON_SIZE);
|
||||
m_switch_cham_fan->Rescale();
|
||||
|
||||
|
||||
m_ams_control->msw_rescale();
|
||||
// m_filament_step->Rescale();
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "Widgets/ProgressBar.hpp"
|
||||
#include "Widgets/ImageSwitchButton.hpp"
|
||||
#include "Widgets/AMSControl.hpp"
|
||||
#include "Widgets/FanControl.hpp"
|
||||
#include "HMS.hpp"
|
||||
#include "Widgets/ErrorMsgStaticText.hpp"
|
||||
class StepIndicator;
|
||||
|
@ -149,16 +150,20 @@ protected:
|
|||
ImageSwitchButton *m_switch_speed;
|
||||
|
||||
/* TempInput */
|
||||
wxBoxSizer * m_misc_ctrl_sizer;
|
||||
TempInput * m_tempCtrl_nozzle;
|
||||
int m_temp_nozzle_timeout {0};
|
||||
StaticLine * m_line_nozzle;
|
||||
TempInput * m_tempCtrl_bed;
|
||||
int m_temp_bed_timeout {0};
|
||||
TempInput * m_tempCtrl_frame;
|
||||
ImageSwitchButton *m_switch_nozzle_fan;
|
||||
bool m_current_support_cham_fan{true};
|
||||
FanSwitchButton *m_switch_nozzle_fan;
|
||||
int m_switch_nozzle_fan_timeout{0};
|
||||
ImageSwitchButton *m_switch_printing_fan;
|
||||
FanSwitchButton *m_switch_printing_fan;
|
||||
int m_switch_printing_fan_timeout{0};
|
||||
FanSwitchButton *m_switch_cham_fan;
|
||||
int m_switch_cham_fan_timeout{0};
|
||||
|
||||
float m_fixed_aspect_ratio{1.8};
|
||||
|
||||
|
@ -267,6 +272,7 @@ protected:
|
|||
SecondaryCheckDialog* abort_dlg = nullptr;
|
||||
SecondaryCheckDialog* ctrl_e_hint_dlg = nullptr;
|
||||
SecondaryCheckDialog* sdcard_hint_dlg = nullptr;
|
||||
FanControlPopup m_fan_control_popup{nullptr};
|
||||
|
||||
wxString m_request_url;
|
||||
bool m_start_loading_thumbnail = false;
|
||||
|
@ -333,7 +339,8 @@ protected:
|
|||
void on_ams_guide(wxCommandEvent &event);
|
||||
void on_ams_retry(wxCommandEvent &event);
|
||||
|
||||
void on_switch_speed(wxCommandEvent &event);
|
||||
void on_fan_changed(wxCommandEvent& event);
|
||||
void on_switch_speed(wxCommandEvent& event);
|
||||
void on_lamp_switch(wxCommandEvent &event);
|
||||
void on_printing_fan_switch(wxCommandEvent &event);
|
||||
void on_nozzle_fan_switch(wxCommandEvent &event);
|
||||
|
|
629
src/slic3r/GUI/Widgets/FanControl.cpp
Normal file
|
@ -0,0 +1,629 @@
|
|||
#include "FanControl.hpp"
|
||||
#include "Label.hpp"
|
||||
#include "../BitmapCache.hpp"
|
||||
#include "../I18N.hpp"
|
||||
|
||||
#include <wx/simplebook.h>
|
||||
#include <wx/dcgraph.h>
|
||||
|
||||
namespace Slic3r { namespace GUI {
|
||||
|
||||
wxDEFINE_EVENT(EVT_FAN_SWITCH_ON, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_FAN_SWITCH_OFF, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_FAN_ADD, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_FAN_DEC, wxCommandEvent);
|
||||
wxDEFINE_EVENT(EVT_FAN_CHANGED, wxCommandEvent);
|
||||
|
||||
/*************************************************
|
||||
Description:Fan
|
||||
**************************************************/
|
||||
Fan::Fan(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size)
|
||||
{
|
||||
create(parent, id, pos, size);
|
||||
}
|
||||
|
||||
void Fan::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size)
|
||||
{
|
||||
m_current_speeds = 0;
|
||||
|
||||
wxWindow::Create(parent, id, pos, size, wxBORDER_NONE);
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
|
||||
m_rotate_offsets.push_back(RotateOffSet{ 2.5, wxPoint(-FromDIP(16), FromDIP(11)) });
|
||||
m_rotate_offsets.push_back(RotateOffSet{ 2.2, wxPoint(-FromDIP(20), FromDIP(11)) });
|
||||
m_rotate_offsets.push_back(RotateOffSet{ 1.7, wxPoint(-FromDIP(24), FromDIP(12)) });
|
||||
m_rotate_offsets.push_back(RotateOffSet{ 1.2, wxPoint(-FromDIP(22), FromDIP(4)) });
|
||||
m_rotate_offsets.push_back(RotateOffSet{ 0.7, wxPoint(-FromDIP(17), -FromDIP(6)) });
|
||||
m_rotate_offsets.push_back(RotateOffSet{ 0.3, wxPoint(-FromDIP(8), -FromDIP(11)) });
|
||||
m_rotate_offsets.push_back(RotateOffSet{ 6.1, wxPoint(-FromDIP(0), -FromDIP(9)) });
|
||||
m_rotate_offsets.push_back(RotateOffSet{ 5.5, wxPoint(-FromDIP(4), -FromDIP(2)) });
|
||||
m_rotate_offsets.push_back(RotateOffSet{ 5.1, wxPoint(-FromDIP(3), FromDIP(5)) });
|
||||
m_rotate_offsets.push_back(RotateOffSet{ 4.6, wxPoint(-FromDIP(3), FromDIP(14)) });
|
||||
m_rotate_offsets.push_back(RotateOffSet{ 4.0, wxPoint(-FromDIP(2), FromDIP(11)) });
|
||||
|
||||
//auto m_bitmap_pointer = ScalableBitmap(this, "fan_pointer", FromDIP(25));
|
||||
//m_img_pointer = m_bitmap_pointer.bmp().ConvertToImage();
|
||||
|
||||
/*m_bitmap_scale_0 = ScalableBitmap(this, "fan_dash_board_level_0", FromDIP(13));
|
||||
m_bitmap_scale_1 = ScalableBitmap(this, "fan_dash_board_level_1", FromDIP(13));
|
||||
m_bitmap_scale_2 = ScalableBitmap(this, "fan_dash_board_level_2", FromDIP(13));
|
||||
m_bitmap_scale_3 = ScalableBitmap(this, "fan_dash_board_level_3", FromDIP(10));
|
||||
m_bitmap_scale_4 = ScalableBitmap(this, "fan_dash_board_level_4", FromDIP(5));
|
||||
m_bitmap_scale_5 = ScalableBitmap(this, "fan_dash_board_level_5", FromDIP(5));
|
||||
m_bitmap_scale_6 = ScalableBitmap(this, "fan_dash_board_level_6", FromDIP(10));
|
||||
m_bitmap_scale_7 = ScalableBitmap(this, "fan_dash_board_level_7", FromDIP(13));
|
||||
m_bitmap_scale_8 = ScalableBitmap(this, "fan_dash_board_level_8", FromDIP(13));
|
||||
m_bitmap_scale_9 = ScalableBitmap(this, "fan_dash_board_level_9", FromDIP(13));*/
|
||||
|
||||
m_bitmap_bk = ScalableBitmap(this, "fan_dash_bk", FromDIP(80));
|
||||
|
||||
for (auto i = 0; i <= 10; i++) {
|
||||
auto a = wxString::Format("fan_scale_%d", i);
|
||||
auto m_bitmap_scale = ScalableBitmap(this, wxString::Format("fan_scale_%d", i).ToStdString(), FromDIP(46));
|
||||
m_bitmap_scales.push_back(m_bitmap_scale);
|
||||
}
|
||||
|
||||
/* m_bitmap_scale_0 = ScalableBitmap(this, "fan_scale_0", FromDIP(60));
|
||||
m_bitmap_scale_1 = ScalableBitmap(this, "fan_scale_1", FromDIP(60));
|
||||
m_bitmap_scale_2 = ScalableBitmap(this, "fan_scale_2", FromDIP(60));
|
||||
m_bitmap_scale_3 = ScalableBitmap(this, "fan_scale_3", FromDIP(60));
|
||||
m_bitmap_scale_4 = ScalableBitmap(this, "fan_scale_4", FromDIP(60));
|
||||
m_bitmap_scale_5 = ScalableBitmap(this, "fan_scale_5", FromDIP(60));
|
||||
m_bitmap_scale_6 = ScalableBitmap(this, "fan_scale_6", FromDIP(60));
|
||||
m_bitmap_scale_7 = ScalableBitmap(this, "fan_scale_7", FromDIP(60));
|
||||
m_bitmap_scale_8 = ScalableBitmap(this, "fan_scale_8", FromDIP(60));
|
||||
m_bitmap_scale_9 = ScalableBitmap(this, "fan_scale_9", FromDIP(60));
|
||||
m_bitmap_scale_10 = ScalableBitmap(this, "fan_scale_10", FromDIP(60));*/
|
||||
|
||||
#ifdef __APPLE__
|
||||
SetMinSize(wxSize(FromDIP(94), FromDIP(81) + FromDIP(6)));
|
||||
SetMaxSize(wxSize(FromDIP(94), FromDIP(81) + FromDIP(6)));
|
||||
#else
|
||||
SetMinSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
|
||||
SetMaxSize(wxSize(m_bitmap_bk.GetBmpSize().x, m_bitmap_bk.GetBmpSize().y + FromDIP(6)));
|
||||
#endif // __APPLE__
|
||||
|
||||
Bind(wxEVT_PAINT, &Fan::paintEvent, this);
|
||||
}
|
||||
|
||||
void Fan::set_fan_speeds(int g)
|
||||
{
|
||||
m_current_speeds = g;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void Fan::post_event(wxCommandEvent &&event)
|
||||
{
|
||||
/*event.SetString(m_info.can_id);
|
||||
event.SetEventObject(m_parent);
|
||||
wxPostEvent(m_parent, event);
|
||||
event.Skip();*/
|
||||
}
|
||||
|
||||
void Fan::paintEvent(wxPaintEvent& evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
render(dc);
|
||||
}
|
||||
|
||||
void Fan::render(wxDC& dc)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
wxSize size = GetSize();
|
||||
wxMemoryDC memdc;
|
||||
wxBitmap bmp(size.x, size.y);
|
||||
memdc.SelectObject(bmp);
|
||||
memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
|
||||
|
||||
{
|
||||
wxGCDC dc2(memdc);
|
||||
doRender(dc2);
|
||||
}
|
||||
|
||||
memdc.SelectObject(wxNullBitmap);
|
||||
dc.DrawBitmap(bmp, 0, 0);
|
||||
#else
|
||||
doRender(dc);
|
||||
#endif
|
||||
}
|
||||
|
||||
void Fan::doRender(wxDC& dc)
|
||||
{
|
||||
auto rpm = wxT("rpm");
|
||||
|
||||
wxSize size = GetSize();
|
||||
dc.DrawBitmap(m_bitmap_bk.bmp(), wxPoint(0,0));
|
||||
|
||||
//fan scale
|
||||
/*auto central_point = wxPoint(size.x / 2, size.y / 2 + FromDIP(15));
|
||||
dc.DrawBitmap(m_bitmap_scale_0.bmp(), central_point.x - FromDIP(38), central_point.y);
|
||||
dc.DrawBitmap(m_bitmap_scale_1.bmp(), central_point.x - FromDIP(40), central_point.y - FromDIP(17));
|
||||
dc.DrawBitmap(m_bitmap_scale_2.bmp(), central_point.x - FromDIP(40), central_point.y - FromDIP(36));
|
||||
dc.DrawBitmap(m_bitmap_scale_3.bmp(), central_point.x - FromDIP(32), central_point.y - FromDIP(48));
|
||||
dc.DrawBitmap(m_bitmap_scale_4.bmp(), central_point.x - FromDIP(18), central_point.y - FromDIP(53));
|
||||
dc.DrawBitmap(m_bitmap_scale_5.bmp(), central_point.x - FromDIP(0), central_point.y - FromDIP(53));
|
||||
dc.DrawBitmap(m_bitmap_scale_6.bmp(), central_point.x + FromDIP(18), central_point.y - FromDIP(48));
|
||||
dc.DrawBitmap(m_bitmap_scale_7.bmp(), central_point.x + FromDIP(31), central_point.y - FromDIP(36));
|
||||
dc.DrawBitmap(m_bitmap_scale_8.bmp(), central_point.x + FromDIP(36), central_point.y - FromDIP(17));
|
||||
dc.DrawBitmap(m_bitmap_scale_9.bmp(), central_point.x + FromDIP(28), central_point.y);*/
|
||||
|
||||
//fan pointer
|
||||
//auto pointer_central_point = wxPoint((size.x - m_img_pointer.GetSize().x) / 2, (size.y - m_img_pointer.GetSize().y) / 2);
|
||||
//auto bmp = m_img_pointer.Rotate(m_rotate_offsets[m_current_speeds].rotate, wxPoint(size.x / 2,size.y / 2));
|
||||
auto central_point = wxPoint((size.x - m_bitmap_scales[m_current_speeds].GetBmpSize().x) / 2, (size.y - m_bitmap_scales[m_current_speeds].GetBmpSize().y) / 2 - FromDIP(4));
|
||||
dc.DrawBitmap(m_bitmap_scales[m_current_speeds].bmp(), central_point.x, central_point.y);
|
||||
|
||||
//fan val
|
||||
dc.SetTextForeground(DRAW_TEXT_COLOUR);
|
||||
dc.SetFont(::Label::Head_14);
|
||||
auto speeds = wxString::Format("%d%%", m_current_speeds * 10);
|
||||
dc.DrawText(speeds, (size.x - dc.GetTextExtent(speeds).x) / 2, size.y - dc.GetTextExtent(speeds).y - FromDIP(10));
|
||||
|
||||
//rpm
|
||||
dc.SetFont(::Label::Body_13);
|
||||
dc.DrawText(rpm, (size.x - dc.GetTextExtent(rpm).x) / 2, size.y - dc.GetTextExtent(rpm).y);
|
||||
}
|
||||
|
||||
void Fan::msw_rescale() {
|
||||
m_bitmap_bk.msw_rescale();
|
||||
}
|
||||
|
||||
void Fan::DoSetSize(int x, int y, int width, int height, int sizeFlags)
|
||||
{
|
||||
wxWindow::DoSetSize(x, y, width, height, sizeFlags);
|
||||
}
|
||||
|
||||
|
||||
/*************************************************
|
||||
Description:FanOperate
|
||||
**************************************************/
|
||||
FanOperate::FanOperate(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size)
|
||||
{
|
||||
m_current_speeds = 0;
|
||||
m_min_speeds = 1;
|
||||
m_max_speeds = 10;
|
||||
create(parent, id, pos, size);
|
||||
}
|
||||
|
||||
void FanOperate::create(wxWindow *parent, wxWindowID id, const wxPoint &pos, const wxSize &size)
|
||||
{
|
||||
|
||||
wxWindow::Create(parent, id, pos, size, wxBORDER_NONE);
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
|
||||
m_bitmap_add = ScalableBitmap(this, "fan_control_add", FromDIP(11));
|
||||
m_bitmap_decrease = ScalableBitmap(this, "fan_control_decrease", FromDIP(11));
|
||||
|
||||
SetMinSize(wxSize(FromDIP(SIZE_OF_FAN_OPERATE.x), FromDIP(SIZE_OF_FAN_OPERATE.y)));
|
||||
Bind(wxEVT_PAINT, &FanOperate::paintEvent, this);
|
||||
Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_HAND);});
|
||||
Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_ARROW);});
|
||||
Bind(wxEVT_LEFT_DOWN, &FanOperate::on_left_down, this);
|
||||
}
|
||||
|
||||
void FanOperate::on_left_down(wxMouseEvent& event)
|
||||
{
|
||||
auto mouse_pos = ClientToScreen(event.GetPosition());
|
||||
auto win_pos = ClientToScreen(wxPoint(0, 0));
|
||||
|
||||
auto decrease_fir = GetSize().x / 3 + win_pos.x;
|
||||
auto add_fir = GetSize().x / 3 * 2 + win_pos.x;
|
||||
|
||||
if (mouse_pos.x > win_pos.x && mouse_pos.x < decrease_fir && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) {
|
||||
decrease_fan_speeds();
|
||||
return;
|
||||
}
|
||||
|
||||
if (mouse_pos.x > add_fir && mouse_pos.x < (win_pos.x + GetSize().x) && mouse_pos.y > win_pos.y && mouse_pos.y < (win_pos.y + GetSize().y)) {
|
||||
add_fan_speeds();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void FanOperate::set_fan_speeds(int g)
|
||||
{
|
||||
m_current_speeds = g;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void FanOperate::add_fan_speeds()
|
||||
{
|
||||
if (m_current_speeds + 1 > m_max_speeds) return;
|
||||
set_fan_speeds(++m_current_speeds);
|
||||
post_event(wxCommandEvent(EVT_FAN_ADD));
|
||||
post_event(wxCommandEvent(EVT_FAN_SWITCH_ON));
|
||||
}
|
||||
|
||||
void FanOperate::decrease_fan_speeds()
|
||||
{
|
||||
//turn off
|
||||
if (m_current_speeds - 1 < m_min_speeds) {
|
||||
m_current_speeds = 0;
|
||||
set_fan_speeds(m_current_speeds);
|
||||
post_event(wxCommandEvent(EVT_FAN_SWITCH_OFF));
|
||||
}
|
||||
else {
|
||||
set_fan_speeds(--m_current_speeds);
|
||||
}
|
||||
post_event(wxCommandEvent(EVT_FAN_DEC));
|
||||
|
||||
}
|
||||
|
||||
void FanOperate::post_event(wxCommandEvent &&event)
|
||||
{
|
||||
event.SetInt(m_current_speeds);
|
||||
event.SetEventObject(this);
|
||||
wxPostEvent(this, event);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
void FanOperate::paintEvent(wxPaintEvent& evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
render(dc);
|
||||
}
|
||||
|
||||
void FanOperate::render(wxDC& dc)
|
||||
{
|
||||
#ifdef __WXMSW__
|
||||
wxSize size = GetSize();
|
||||
wxMemoryDC memdc;
|
||||
wxBitmap bmp(size.x, size.y);
|
||||
memdc.SelectObject(bmp);
|
||||
memdc.Blit({ 0, 0 }, size, &dc, { 0, 0 });
|
||||
|
||||
{
|
||||
wxGCDC dc2(memdc);
|
||||
doRender(dc2);
|
||||
}
|
||||
|
||||
memdc.SelectObject(wxNullBitmap);
|
||||
dc.DrawBitmap(bmp, 0, 0);
|
||||
#else
|
||||
doRender(dc);
|
||||
#endif
|
||||
}
|
||||
|
||||
void FanOperate::doRender(wxDC& dc)
|
||||
{
|
||||
wxSize size = GetSize();
|
||||
dc.SetPen(wxPen(DRAW_OPERATE_LINE_COLOUR));
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRoundedRectangle(0,0,size.x,size.y,5);
|
||||
|
||||
//splt
|
||||
auto left_fir = size.x / 3;
|
||||
|
||||
dc.DrawLine(left_fir, FromDIP(4), left_fir, size.y - FromDIP(4));
|
||||
dc.DrawLine(left_fir * 2, FromDIP(4), left_fir * 2, size.y - FromDIP(4));
|
||||
|
||||
dc.DrawBitmap(m_bitmap_decrease.bmp(), (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2, (size.y - m_bitmap_decrease.GetBmpSize().y) / 2);
|
||||
dc.DrawBitmap(m_bitmap_add.bmp(), (left_fir * 2 + (left_fir - m_bitmap_decrease.GetBmpSize().x) / 2), (size.y - m_bitmap_add.GetBmpSize().y) / 2);
|
||||
|
||||
//txt
|
||||
dc.SetFont(::Label::Body_12);
|
||||
dc.SetTextForeground(StateColor::darkModeColorFor(wxColour(0x898989)));
|
||||
wxString text = wxString::Format("%d%%", m_current_speeds * 10);
|
||||
wxSize text_size = dc.GetTextExtent(text);
|
||||
dc.DrawText(text, wxPoint(left_fir + (left_fir- text_size.x) / 2, (size.y- text_size.y) / 2 + 2));
|
||||
}
|
||||
|
||||
void FanOperate::msw_rescale() {
|
||||
}
|
||||
|
||||
/*************************************************
|
||||
Description:FanControl
|
||||
**************************************************/
|
||||
FanControl::FanControl(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size)
|
||||
:wxWindow(parent, id, pos, size)
|
||||
{
|
||||
auto m_bitmap_fan = new ScalableBitmap(this, "fan_icon", 18);
|
||||
m_bitmap_toggle_off = new ScalableBitmap(this, "toggle_off", 14);
|
||||
m_bitmap_toggle_on = new ScalableBitmap(this, "toggle_on", 14);
|
||||
|
||||
|
||||
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
|
||||
wxBoxSizer* m_sizer_main = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
m_fan = new Fan(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||
m_sizer_main->Add(m_fan, 1, wxEXPAND | wxALL, 0);
|
||||
|
||||
|
||||
m_sizer_main->Add(0, 0, 0, wxLEFT, FromDIP(18));
|
||||
|
||||
wxBoxSizer* sizer_control = new wxBoxSizer(wxVERTICAL);
|
||||
wxBoxSizer* sizer_control_top = new wxBoxSizer(wxHORIZONTAL);
|
||||
|
||||
|
||||
auto m_static_bitmap_fan = new wxStaticBitmap(this, wxID_ANY, m_bitmap_fan->bmp(), wxDefaultPosition, wxDefaultSize);
|
||||
|
||||
|
||||
m_static_name = new wxStaticText(this, wxID_ANY, wxEmptyString, wxDefaultPosition, wxDefaultSize, wxST_ELLIPSIZE_END|wxALIGN_CENTER_HORIZONTAL);
|
||||
m_static_name->SetForegroundColour(wxColour(DRAW_TEXT_COLOUR));
|
||||
m_static_name->SetBackgroundColour(*wxWHITE);
|
||||
m_static_name->SetMinSize(wxSize(FromDIP(50), -1));
|
||||
m_static_name->SetMaxSize(wxSize(FromDIP(50), -1));
|
||||
|
||||
|
||||
m_switch_button = new wxStaticBitmap(this, wxID_ANY, m_bitmap_toggle_off->bmp(), wxDefaultPosition, wxDefaultSize, 0);
|
||||
m_switch_button->Bind(wxEVT_ENTER_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_HAND); });
|
||||
m_switch_button->Bind(wxEVT_LEAVE_WINDOW, [this](auto& e) { SetCursor(wxCURSOR_RIGHT_ARROW); });
|
||||
m_switch_button->Bind(wxEVT_LEFT_DOWN, &FanControl::on_swith_fan, this);
|
||||
|
||||
|
||||
sizer_control_top->Add(m_static_bitmap_fan, 0, wxALIGN_CENTER, 5);
|
||||
sizer_control_top->Add(m_static_name, 0, wxALIGN_CENTER, 0);
|
||||
sizer_control_top->Add( 0, 0, 1, wxEXPAND, 0 );
|
||||
sizer_control_top->Add(m_switch_button, 0, wxALIGN_CENTER, 0);
|
||||
|
||||
|
||||
sizer_control->Add(sizer_control_top, 0, wxALIGN_CENTER, 0);
|
||||
sizer_control->Add(0, 0, 0, wxTOP, FromDIP(15));
|
||||
|
||||
m_fan_operate = new FanOperate(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||
sizer_control->Add(m_fan_operate, 0, wxALIGN_CENTER, 0);
|
||||
|
||||
|
||||
m_sizer_main->Add(sizer_control, 0, wxALIGN_CENTER, 0);
|
||||
|
||||
|
||||
this->SetSizer(m_sizer_main);
|
||||
this->Layout();
|
||||
m_sizer_main->Fit(this);
|
||||
|
||||
m_fan_operate->Bind(EVT_FAN_SWITCH_ON, [this](wxCommandEvent& e) {
|
||||
m_current_speed = e.GetInt();
|
||||
m_switch_button->SetBitmap(m_bitmap_toggle_on->bmp());
|
||||
m_switch_fan = true;
|
||||
m_fan->set_fan_speeds(m_current_speed);
|
||||
});
|
||||
m_fan_operate->Bind(EVT_FAN_SWITCH_OFF, [this](wxCommandEvent& e) {
|
||||
m_current_speed = e.GetInt();
|
||||
m_switch_button->SetBitmap(m_bitmap_toggle_off->bmp());
|
||||
m_switch_fan = false;
|
||||
m_fan->set_fan_speeds(m_current_speed);
|
||||
});
|
||||
|
||||
m_fan_operate->Bind(EVT_FAN_ADD, [this](wxCommandEvent& e) {
|
||||
m_current_speed = e.GetInt();
|
||||
m_fan->set_fan_speeds(m_current_speed);
|
||||
command_control_fan();
|
||||
});
|
||||
|
||||
m_fan_operate->Bind(EVT_FAN_DEC, [this](wxCommandEvent& e) {
|
||||
m_current_speed = e.GetInt();
|
||||
m_fan->set_fan_speeds(m_current_speed);
|
||||
command_control_fan();
|
||||
});
|
||||
}
|
||||
|
||||
void FanControl::on_left_down(wxMouseEvent& evt)
|
||||
{
|
||||
auto mouse_pos = ClientToScreen(evt.GetPosition());
|
||||
auto tag_pos = m_fan_operate->ScreenToClient(mouse_pos);
|
||||
evt.SetPosition(tag_pos);
|
||||
m_fan_operate->on_left_down(evt);
|
||||
}
|
||||
|
||||
void FanControl::command_control_fan()
|
||||
{
|
||||
if (m_current_speed < 0 || m_current_speed > 10) { return; }
|
||||
int speed = floor(m_current_speed * float(25.5));
|
||||
m_obj->command_control_fan_val(m_type, speed);
|
||||
post_event(wxCommandEvent(EVT_FAN_CHANGED));
|
||||
}
|
||||
|
||||
void FanControl::on_swith_fan(wxMouseEvent& evt)
|
||||
{
|
||||
int speed = 0;
|
||||
if (m_switch_fan) {
|
||||
speed = 0;
|
||||
m_switch_button->SetBitmap(m_bitmap_toggle_off->bmp());
|
||||
m_switch_fan = false;
|
||||
}
|
||||
else {
|
||||
speed = 255;
|
||||
m_switch_button->SetBitmap(m_bitmap_toggle_on->bmp());
|
||||
m_switch_fan = true;
|
||||
}
|
||||
|
||||
set_fan_speed(speed);
|
||||
command_control_fan();
|
||||
}
|
||||
|
||||
void FanControl::on_swith_fan(bool on)
|
||||
{
|
||||
m_switch_fan = on;
|
||||
if (m_switch_fan) {
|
||||
m_switch_button->SetBitmap(m_bitmap_toggle_on->bmp());
|
||||
}
|
||||
else {
|
||||
m_switch_button->SetBitmap(m_bitmap_toggle_off->bmp());
|
||||
}
|
||||
}
|
||||
|
||||
void FanControl::set_machine_obj(MachineObject* obj)
|
||||
{
|
||||
m_obj = obj;
|
||||
}
|
||||
|
||||
void FanControl::set_type(MachineObject::FanType type)
|
||||
{
|
||||
m_type = type;
|
||||
}
|
||||
|
||||
void FanControl::set_name(wxString name)
|
||||
{
|
||||
m_static_name->SetLabelText(name);
|
||||
}
|
||||
|
||||
void FanControl::set_fan_speed(int g)
|
||||
{
|
||||
if (g < 0 || g > 255) return;
|
||||
int speed = floor(float(g) / float(25.5));
|
||||
|
||||
if (m_current_speed != speed) {
|
||||
m_current_speed = speed;
|
||||
m_fan->set_fan_speeds(speed);
|
||||
m_fan_operate->set_fan_speeds(m_current_speed);
|
||||
|
||||
if (m_current_speed <= 0) {
|
||||
on_swith_fan(false);
|
||||
}
|
||||
else {
|
||||
on_swith_fan(true);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void FanControl::set_fan_switch(bool s)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FanControl::post_event(wxCommandEvent&& event)
|
||||
{
|
||||
event.SetInt(m_type);
|
||||
event.SetString(wxString::Format("%d", m_current_speed));
|
||||
event.SetEventObject(GetParent());
|
||||
wxPostEvent(GetParent(), event);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
|
||||
/*************************************************
|
||||
Description:FanControlPopup
|
||||
**************************************************/
|
||||
FanControlPopup::FanControlPopup(wxWindow* parent)
|
||||
:wxPopupTransientWindow(parent, wxBORDER_NONE)
|
||||
{
|
||||
this->SetSizeHints(wxDefaultSize, wxDefaultSize);
|
||||
|
||||
m_sizer_main = new wxBoxSizer(wxVERTICAL);
|
||||
m_part_fan = new FanControl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||
m_part_fan->set_type(MachineObject::FanType::COOLING_FAN);
|
||||
m_part_fan->set_name(_L("Part"));
|
||||
|
||||
m_aux_fan = new FanControl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||
m_aux_fan->set_type(MachineObject::FanType::BIG_COOLING_FAN);
|
||||
m_aux_fan->set_name(_L("Aux"));
|
||||
|
||||
m_cham_fan = new FanControl(this, wxID_ANY, wxDefaultPosition, wxDefaultSize);
|
||||
m_cham_fan->set_type(MachineObject::FanType::CHAMBER_FAN);
|
||||
m_cham_fan->set_name(_L("Cham"));
|
||||
|
||||
m_line_top = new wxWindow(this, wxID_ANY);
|
||||
m_line_top->SetSize(wxSize(-1, 1));
|
||||
m_line_top->SetBackgroundColour(0xF1F1F1);
|
||||
|
||||
m_line_bottom = new wxWindow(this, wxID_ANY);
|
||||
m_line_bottom->SetSize(wxSize(-1, 1));
|
||||
m_line_bottom->SetBackgroundColour(0xF1F1F1);
|
||||
|
||||
|
||||
m_sizer_main->Add(m_part_fan, 0, wxALL, FromDIP(14));
|
||||
m_sizer_main->Add(m_line_top, 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(8));
|
||||
m_sizer_main->Add(m_aux_fan, 0, wxALL, FromDIP(14));
|
||||
m_sizer_main->Add(m_line_bottom, 0, wxEXPAND|wxLEFT|wxRIGHT, FromDIP(8));
|
||||
m_sizer_main->Add(m_cham_fan, 0, wxALL, FromDIP(14));
|
||||
|
||||
|
||||
this->SetSizer(m_sizer_main);
|
||||
this->Layout();
|
||||
m_sizer_main->Fit(this);
|
||||
|
||||
this->Centre(wxBOTH);
|
||||
Bind(wxEVT_PAINT, &FanControlPopup::paintEvent, this);
|
||||
|
||||
#if __APPLE__
|
||||
Bind(wxEVT_LEFT_DOWN, &FanControlPopup::on_left_down, this);
|
||||
#endif
|
||||
|
||||
SetBackgroundColour(*wxWHITE);
|
||||
}
|
||||
|
||||
void FanControlPopup::update_fan_data(MachineObject::FanType type, MachineObject* obj)
|
||||
{
|
||||
bool is_suppt_cham_fun = obj->is_function_supported(PrinterFunction::FUNC_CHAMBER_FAN);
|
||||
if (is_suppt_cham_fun) {
|
||||
m_cham_fan->Show();
|
||||
m_line_bottom->Show();
|
||||
}
|
||||
else {
|
||||
m_cham_fan->Hide();
|
||||
m_line_bottom->Hide();
|
||||
}
|
||||
|
||||
if (type == MachineObject::FanType::COOLING_FAN && obj->cooling_fan_speed >= 0) {
|
||||
m_part_fan->set_fan_speed(obj->cooling_fan_speed);
|
||||
}
|
||||
|
||||
if (type == MachineObject::FanType::BIG_COOLING_FAN && obj->big_fan1_speed >= 0) {
|
||||
m_aux_fan->set_fan_speed(obj->big_fan1_speed);
|
||||
}
|
||||
|
||||
if (type == MachineObject::FanType::CHAMBER_FAN && obj->big_fan2_speed >= 0) {
|
||||
m_cham_fan->set_fan_speed(obj->big_fan2_speed);
|
||||
}
|
||||
|
||||
m_part_fan->set_machine_obj(obj);
|
||||
m_aux_fan->set_machine_obj(obj);
|
||||
m_cham_fan->set_machine_obj(obj);
|
||||
|
||||
Bind(EVT_FAN_CHANGED, [this](wxCommandEvent& e) {
|
||||
post_event(e.GetInt(), e.GetString());
|
||||
});
|
||||
|
||||
Layout();
|
||||
Fit();
|
||||
}
|
||||
|
||||
void FanControlPopup::on_left_down(wxMouseEvent& evt)
|
||||
{
|
||||
auto mouse_pos = ClientToScreen(evt.GetPosition());
|
||||
|
||||
auto part_tag_pos = m_part_fan->ScreenToClient(mouse_pos);
|
||||
evt.SetPosition(part_tag_pos);
|
||||
m_part_fan->on_left_down(evt);
|
||||
|
||||
auto aux_tag_pos = m_aux_fan->ScreenToClient(mouse_pos);
|
||||
evt.SetPosition(aux_tag_pos);
|
||||
m_aux_fan->on_left_down(evt);
|
||||
|
||||
auto cham_tag_pos = m_cham_fan->ScreenToClient(mouse_pos);
|
||||
evt.SetPosition(cham_tag_pos);
|
||||
m_cham_fan->on_left_down(evt);
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
void FanControlPopup::OnDismiss()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void FanControlPopup::post_event(int fan_type, wxString speed)
|
||||
{
|
||||
wxCommandEvent event(EVT_FAN_CHANGED);
|
||||
event.SetInt(fan_type);
|
||||
event.SetString(speed);
|
||||
event.SetEventObject(GetParent());
|
||||
wxPostEvent(GetParent(), event);
|
||||
event.Skip();
|
||||
}
|
||||
|
||||
bool FanControlPopup::ProcessLeftDown(wxMouseEvent& event)
|
||||
{
|
||||
return wxPopupTransientWindow::ProcessLeftDown(event);
|
||||
}
|
||||
|
||||
void FanControlPopup::paintEvent(wxPaintEvent& evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
dc.SetPen(wxColour(0xAC, 0xAC, 0xAC));
|
||||
dc.SetBrush(*wxTRANSPARENT_BRUSH);
|
||||
dc.DrawRoundedRectangle(0, 0, GetSize().x, GetSize().y, 0);
|
||||
}
|
||||
}} // namespace Slic3r::GUI
|
171
src/slic3r/GUI/Widgets/FanControl.hpp
Normal file
|
@ -0,0 +1,171 @@
|
|||
#ifndef slic3r_GUI_FANCONTROL_hpp_
|
||||
#define slic3r_GUI_FANCONTROL_hpp_
|
||||
|
||||
#include "../wxExtensions.hpp"
|
||||
#include "StaticBox.hpp"
|
||||
#include "StepCtrl.hpp"
|
||||
#include "Button.hpp"
|
||||
#include "../DeviceManager.hpp"
|
||||
#include "slic3r/GUI/Event.hpp"
|
||||
#include <wx/simplebook.h>
|
||||
#include <wx/hyperlink.h>
|
||||
#include <wx/animate.h>
|
||||
#include <wx/dynarray.h>
|
||||
|
||||
|
||||
namespace Slic3r {
|
||||
namespace GUI {
|
||||
|
||||
|
||||
/*************************************************
|
||||
Description:Fan
|
||||
**************************************************/
|
||||
#define SIZE_OF_FAN_OPERATE wxSize(100, 28)
|
||||
|
||||
#define DRAW_TEXT_COLOUR wxColour(0x898989)
|
||||
#define DRAW_OPERATE_LINE_COLOUR wxColour(0xDEDEDE)
|
||||
|
||||
struct RotateOffSet
|
||||
{
|
||||
float rotate;
|
||||
wxPoint offset;
|
||||
};
|
||||
|
||||
class Fan : public wxWindow
|
||||
{
|
||||
public:
|
||||
Fan(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
|
||||
~Fan() {};
|
||||
void post_event(wxCommandEvent&& event);
|
||||
void paintEvent(wxPaintEvent& evt);
|
||||
void render(wxDC& dc);
|
||||
void doRender(wxDC& dc);
|
||||
void msw_rescale();
|
||||
void create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size);
|
||||
void set_fan_speeds(int g);
|
||||
|
||||
private:
|
||||
int m_current_speeds;
|
||||
std::vector<RotateOffSet> m_rotate_offsets;
|
||||
|
||||
protected:
|
||||
std::vector<wxPoint> m_scale_pos_array;
|
||||
|
||||
ScalableBitmap m_bitmap_bk;
|
||||
ScalableBitmap m_bitmap_scale_0;
|
||||
ScalableBitmap m_bitmap_scale_1;
|
||||
ScalableBitmap m_bitmap_scale_2;
|
||||
ScalableBitmap m_bitmap_scale_3;
|
||||
ScalableBitmap m_bitmap_scale_4;
|
||||
ScalableBitmap m_bitmap_scale_5;
|
||||
ScalableBitmap m_bitmap_scale_6;
|
||||
ScalableBitmap m_bitmap_scale_7;
|
||||
ScalableBitmap m_bitmap_scale_8;
|
||||
ScalableBitmap m_bitmap_scale_9;
|
||||
ScalableBitmap m_bitmap_scale_10;
|
||||
|
||||
std::vector<ScalableBitmap> m_bitmap_scales;
|
||||
|
||||
wxImage m_img_pointer;
|
||||
|
||||
virtual void DoSetSize(int x, int y, int width, int height, int sizeFlags = wxSIZE_AUTO);
|
||||
};
|
||||
|
||||
/*************************************************
|
||||
Description:FanOperate
|
||||
**************************************************/
|
||||
class FanOperate : public wxWindow
|
||||
{
|
||||
public:
|
||||
FanOperate(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
|
||||
~FanOperate() {};
|
||||
void post_event(wxCommandEvent&& event);
|
||||
void paintEvent(wxPaintEvent& evt);
|
||||
void render(wxDC& dc);
|
||||
void doRender(wxDC& dc);
|
||||
void msw_rescale();
|
||||
void create(wxWindow* parent, wxWindowID id, const wxPoint& pos, const wxSize& size);
|
||||
void on_left_down(wxMouseEvent& event);
|
||||
|
||||
public:
|
||||
void set_fan_speeds(int g);
|
||||
void add_fan_speeds();
|
||||
void decrease_fan_speeds();
|
||||
private:
|
||||
int m_current_speeds;
|
||||
int m_min_speeds;
|
||||
int m_max_speeds;
|
||||
ScalableBitmap m_bitmap_add;
|
||||
ScalableBitmap m_bitmap_decrease;
|
||||
};
|
||||
|
||||
/*************************************************
|
||||
Description:FanControl
|
||||
**************************************************/
|
||||
class FanControl : public wxWindow
|
||||
{
|
||||
public:
|
||||
FanControl(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize);
|
||||
~FanControl() {};
|
||||
|
||||
protected:
|
||||
MachineObject::FanType m_type;
|
||||
MachineObject* m_obj;
|
||||
wxStaticText* m_static_name{ nullptr };
|
||||
wxStaticBitmap* m_switch_button{ nullptr };
|
||||
ScalableBitmap* m_bitmap_toggle_off{ nullptr };
|
||||
ScalableBitmap* m_bitmap_toggle_on{ nullptr };
|
||||
|
||||
Fan* m_fan{ nullptr };
|
||||
FanOperate* m_fan_operate{ nullptr };
|
||||
bool m_switch_fan{ false };
|
||||
int m_current_speed{0};
|
||||
public:
|
||||
void command_control_fan();
|
||||
void set_machine_obj(MachineObject* obj);
|
||||
void set_type(MachineObject::FanType type);
|
||||
void set_name(wxString name);
|
||||
void set_fan_speed(int g);
|
||||
void set_fan_switch(bool s);
|
||||
void post_event(wxCommandEvent&& event);
|
||||
void on_swith_fan(wxMouseEvent& evt);
|
||||
void on_swith_fan(bool on);
|
||||
void on_left_down(wxMouseEvent& event);
|
||||
};
|
||||
|
||||
|
||||
/*************************************************
|
||||
Description:FanControlPopup
|
||||
**************************************************/
|
||||
class FanControlPopup : public wxPopupTransientWindow
|
||||
{
|
||||
public:
|
||||
FanControlPopup(wxWindow* parent);
|
||||
~FanControlPopup() {};
|
||||
|
||||
private:
|
||||
wxBoxSizer* m_sizer_main;
|
||||
FanControl* m_part_fan;
|
||||
FanControl* m_aux_fan;
|
||||
FanControl* m_cham_fan;
|
||||
wxWindow* m_line_top;
|
||||
wxWindow* m_line_bottom;
|
||||
|
||||
public:
|
||||
void update_fan_data(MachineObject::FanType type, MachineObject* obj);
|
||||
void on_left_down(wxMouseEvent& evt);
|
||||
void paintEvent(wxPaintEvent& evt);
|
||||
void post_event(int fan_type, wxString speed);
|
||||
virtual void OnDismiss() wxOVERRIDE;
|
||||
virtual bool ProcessLeftDown(wxMouseEvent& event) wxOVERRIDE;
|
||||
};
|
||||
|
||||
wxDECLARE_EVENT(EVT_FAN_SWITCH_ON, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_FAN_SWITCH_OFF, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_FAN_ADD, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_FAN_DEC, wxCommandEvent);
|
||||
wxDECLARE_EVENT(EVT_FAN_CHANGED, wxCommandEvent);
|
||||
|
||||
}} // namespace Slic3r::GUI
|
||||
|
||||
#endif
|
|
@ -15,6 +15,16 @@ EVT_PAINT(ImageSwitchButton::paintEvent)
|
|||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
BEGIN_EVENT_TABLE(FanSwitchButton, StaticBox)
|
||||
|
||||
EVT_LEFT_DOWN(FanSwitchButton::mouseDown)
|
||||
EVT_ENTER_WINDOW(FanSwitchButton::mouseEnterWindow)
|
||||
EVT_LEAVE_WINDOW(FanSwitchButton::mouseLeaveWindow)
|
||||
EVT_LEFT_UP(FanSwitchButton::mouseReleased)
|
||||
EVT_PAINT(FanSwitchButton::paintEvent)
|
||||
|
||||
END_EVENT_TABLE()
|
||||
|
||||
static const wxColour DEFAULT_HOVER_COL = wxColour(0, 174, 66);
|
||||
static const wxColour DEFAULT_PRESS_COL = wxColour(238, 238, 238);
|
||||
|
||||
|
@ -171,6 +181,188 @@ void ImageSwitchButton::mouseLeaveWindow(wxMouseEvent &event)
|
|||
}
|
||||
|
||||
void ImageSwitchButton::sendButtonEvent()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
|
||||
event.SetEventObject(this);
|
||||
GetEventHandler()->ProcessEvent(event);
|
||||
}
|
||||
|
||||
FanSwitchButton::FanSwitchButton(wxWindow* parent, ScalableBitmap& img_on, ScalableBitmap& img_off, long style)
|
||||
: text_color(std::make_pair(0x6B6B6B, (int)StateColor::Disabled), std::make_pair(*wxBLACK, (int)StateColor::Normal))
|
||||
{
|
||||
radius = 0;
|
||||
m_padding = 0;
|
||||
m_speed = 0;
|
||||
m_on = img_on;
|
||||
m_off = img_off;
|
||||
background_color = StateColor(std::make_pair(*wxWHITE, (int)StateColor::Disabled), std::make_pair(DEFAULT_PRESS_COL, (int)StateColor::Pressed),
|
||||
std::make_pair(*wxWHITE, (int)StateColor::Normal));
|
||||
border_color = StateColor(std::make_pair(*wxWHITE, (int)StateColor::Disabled), std::make_pair(DEFAULT_HOVER_COL, (int)StateColor::Focused),
|
||||
std::make_pair(DEFAULT_HOVER_COL, (int)StateColor::Hovered), std::make_pair(*wxWHITE, (int)StateColor::Normal));
|
||||
|
||||
StaticBox::Create(parent, wxID_ANY, wxDefaultPosition, wxDefaultSize, style);
|
||||
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void FanSwitchButton::SetLabels(wxString const& lbl_on, wxString const& lbl_off)
|
||||
{
|
||||
labels[0] = lbl_on;
|
||||
labels[1] = lbl_off;
|
||||
auto fina_txt = GetValue() ? labels[0] : labels[1];
|
||||
SetToolTip(fina_txt);
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void FanSwitchButton::SetImages(ScalableBitmap& img_on, ScalableBitmap& img_off)
|
||||
{
|
||||
m_on = img_on;
|
||||
m_off = img_off;
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void FanSwitchButton::SetTextColor(StateColor const& color)
|
||||
{
|
||||
text_color = color;
|
||||
state_handler.update_binds();
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void FanSwitchButton::SetValue(bool value)
|
||||
{
|
||||
m_on_off = value;
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void FanSwitchButton::SetPadding(int padding)
|
||||
{
|
||||
m_padding = padding;
|
||||
messureSize();
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void FanSwitchButton::messureSize()
|
||||
{
|
||||
wxClientDC dc(this);
|
||||
dc.SetFont(GetFont());
|
||||
textSize = dc.GetTextExtent(GetValue() ? labels[0] : labels[1]);
|
||||
}
|
||||
|
||||
void FanSwitchButton::paintEvent(wxPaintEvent& evt)
|
||||
{
|
||||
wxPaintDC dc(this);
|
||||
render(dc);
|
||||
}
|
||||
|
||||
void FanSwitchButton::render(wxDC& dc)
|
||||
{
|
||||
StaticBox::render(dc);
|
||||
int states = state_handler.states();
|
||||
wxSize size = GetSize();
|
||||
|
||||
wxSize szIcon;
|
||||
wxSize szContent = textSize;
|
||||
ScalableBitmap& icon = GetValue() ? m_on : m_off;
|
||||
|
||||
//int content_height = icon.GetBmpHeight() + textSize.y + m_padding;
|
||||
int content_height = m_padding;
|
||||
|
||||
wxPoint pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, (size.y - content_height) / 2);
|
||||
|
||||
pt.x = (size.x - textSize.x) / 2;
|
||||
dc.SetFont(GetFont());
|
||||
if (!IsEnabled())
|
||||
dc.SetTextForeground(text_color.colorForStates(StateColor::Disabled));
|
||||
else
|
||||
dc.SetTextForeground(text_color.colorForStates(states));
|
||||
|
||||
auto fina_txt = GetValue() ? labels[0] : labels[1];
|
||||
if (dc.GetTextExtent(fina_txt).x > size.x) {
|
||||
wxString forment_txt = wxEmptyString;
|
||||
for (auto i = 0; i < fina_txt.length(); i++) {
|
||||
forment_txt = fina_txt.SubString(0, i) + "...";
|
||||
if (dc.GetTextExtent(forment_txt).x > size.x) {
|
||||
pt.x = (size.x - dc.GetTextExtent(forment_txt).x) / 2;
|
||||
dc.DrawText(forment_txt, wxPoint(pt.x, content_height));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
dc.DrawText(fina_txt, wxPoint(pt.x, content_height));
|
||||
}
|
||||
|
||||
pt = wxPoint((size.x - icon.GetBmpWidth()) / 2, content_height + textSize.y);
|
||||
if (icon.bmp().IsOk()) {
|
||||
dc.DrawBitmap(icon.bmp(), pt);
|
||||
pt.y += m_padding + icon.GetBmpHeight();
|
||||
}
|
||||
|
||||
auto speed = wxString::Format("%d%%", m_speed);
|
||||
|
||||
dc.SetFont(GetFont());
|
||||
if (!IsEnabled())
|
||||
dc.SetTextForeground(text_color.colorForStates(StateColor::Disabled));
|
||||
else
|
||||
dc.SetTextForeground(text_color.colorForStates(states));
|
||||
|
||||
pt.x = (size.x - dc.GetTextExtent(speed).x) / 2;
|
||||
dc.DrawText(speed, pt);
|
||||
}
|
||||
|
||||
void FanSwitchButton::Rescale()
|
||||
{
|
||||
messureSize();
|
||||
}
|
||||
|
||||
void FanSwitchButton::setFanValue(int val)
|
||||
{
|
||||
m_speed = val;
|
||||
Refresh();
|
||||
}
|
||||
|
||||
void FanSwitchButton::mouseDown(wxMouseEvent& event)
|
||||
{
|
||||
event.Skip();
|
||||
pressedDown = true;
|
||||
SetFocus();
|
||||
CaptureMouse();
|
||||
}
|
||||
|
||||
void FanSwitchButton::mouseReleased(wxMouseEvent& event)
|
||||
{
|
||||
event.Skip();
|
||||
if (pressedDown) {
|
||||
pressedDown = false;
|
||||
ReleaseMouse();
|
||||
//m_on_off = !m_on_off;
|
||||
Refresh();
|
||||
sendButtonEvent();
|
||||
}
|
||||
}
|
||||
|
||||
void FanSwitchButton::mouseEnterWindow(wxMouseEvent& event)
|
||||
{
|
||||
if (!hover) {
|
||||
hover = true;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void FanSwitchButton::mouseLeaveWindow(wxMouseEvent& event)
|
||||
{
|
||||
if (hover) {
|
||||
hover = false;
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
void FanSwitchButton::sendButtonEvent()
|
||||
{
|
||||
wxCommandEvent event(wxEVT_COMMAND_BUTTON_CLICKED, GetId());
|
||||
event.SetEventObject(this);
|
||||
|
|
|
@ -50,4 +50,46 @@ private:
|
|||
StateColor text_color;
|
||||
};
|
||||
|
||||
class FanSwitchButton : public StaticBox
|
||||
{
|
||||
public:
|
||||
FanSwitchButton(wxWindow* parent, ScalableBitmap& img_on, ScalableBitmap& img_off, long style = 0);
|
||||
void SetLabels(wxString const& lbl_on, wxString const& lbl_off);
|
||||
void SetImages(ScalableBitmap& img_on, ScalableBitmap& img_off);
|
||||
void SetTextColor(StateColor const& color);
|
||||
void SetValue(bool value);
|
||||
void SetPadding(int padding);
|
||||
|
||||
bool GetValue() { return m_on_off; }
|
||||
void Rescale();
|
||||
void setFanValue(int val);
|
||||
|
||||
private:
|
||||
void messureSize();
|
||||
void paintEvent(wxPaintEvent& evt);
|
||||
void render(wxDC& dc);
|
||||
void mouseDown(wxMouseEvent& event);
|
||||
void mouseReleased(wxMouseEvent& event);
|
||||
void mouseEnterWindow(wxMouseEvent& event);
|
||||
void mouseLeaveWindow(wxMouseEvent& event);
|
||||
void sendButtonEvent();
|
||||
|
||||
DECLARE_EVENT_TABLE()
|
||||
|
||||
private:
|
||||
ScalableBitmap m_on;
|
||||
ScalableBitmap m_off;
|
||||
bool m_on_off;
|
||||
int m_padding; // size between icon and text
|
||||
bool pressedDown = false;
|
||||
bool hover = false;
|
||||
|
||||
wxSize textSize;
|
||||
wxSize minSize;
|
||||
int m_speed;
|
||||
|
||||
wxString labels[2];
|
||||
StateColor text_color;
|
||||
};
|
||||
|
||||
#endif // !slic3r_GUI_SwitchButton_hpp_
|
||||
|
|