diff --git a/ELECTRONAT.cbp b/ELECTRONAT.cbp new file mode 100644 index 0000000..c6469a5 --- /dev/null +++ b/ELECTRONAT.cbp @@ -0,0 +1,79 @@ + + + + + + diff --git a/ELECTRONAT.depend b/ELECTRONAT.depend new file mode 100644 index 0000000..a3f3bd1 --- /dev/null +++ b/ELECTRONAT.depend @@ -0,0 +1,791 @@ +# depslib dependency file v1.0 +1638483771 source:c:\mingw\bin\electronuaic\electron\electronat\main.cpp + + + + + "startup_page.h" + "workplace_page.h" + "menu_selection.h" + "stare_table.h" + "new_project_name_reading_window.h" + +1642197535 source:d:\electron\electronat\main.cpp + + + + + + + + + "startup_page.h" + "workplace_page.h" + "menu_selection.h" + "stare_table.h" + "new_project_name_reading_window.h" + "drawing_components.h" + "messages_panels_main_menu.h" + "open_save.h" + "change_color_panel.h" + "messages_log_panel.h" + "edit_component_value.h" + "zoom_rotate_fader_workplace.h" + "choose_from_two_options.h" + "functii_auxiliare.h" + +1637875934 d:\electron\electronat\workbench.h + +1637885026 d:\electron\electronat\frontpage\frontpage.h + +1637920586 c:\mingw\bin\electronuaic\electron\electronat\frontpage\frontpage.h + +1637922089 c:\mingw\bin\electronuaic\electron\electronat\resistor.h + +1637922469 c:\mingw\bin\electronuaic\electron\electronat\capacitor.h + +1637922674 c:\mingw\bin\electronuaic\electron\electronat\fuse.h + +1637923114 c:\mingw\bin\electronuaic\electron\electronat\dioda.h + +1637954017 c:\mingw\bin\electronuaic\electron\electronat\bulb.h + +1637954299 c:\mingw\bin\electronuaic\electron\electronat\ampermeter.h + +1638484982 c:\mingw\bin\electronuaic\electron\electronat\components.h + "workplace_page.h" + +1638033748 c:\mingw\bin\electronuaic\electron\electronat\startpage.h + + + +1638311561 c:\mingw\bin\electronuaic\electron\electronat\startup_page.h + +1638210614 c:\mingw\bin\electronuaic\electron\electronat\menubar.h + +1641654066 source:g:\electron\electronat\main.cpp + + + + + + + + + "startup_page.h" + "workplace_page.h" + "menu_selection.h" + "stare_table.h" + "new_project_name_reading_window.h" + "drawing_components.h" + "messages_panels_main_menu.h" + "open_save.h" + "change_color_panel.h" + "messages_log_panel.h" + "edit_component_value.h" + "zoom_rotate_fader_workplace.h" + +1640635416 g:\electron\electronat\components.h + "workplace_page.h" + +1638226333 g:\electron\electronat\menubar.h + +1640848827 g:\electron\electronat\startup_page.h + +1638261682 g:\electron\electronat\menu_bar.h + "components.h" + +1641653516 g:\electron\electronat\menu_selection.h + +1641654680 g:\electron\electronat\workplace_page.h + "drawing_components.h" + "stare_table.h" + "zoom_rotate_fader_workplace.h" + +1638311561 c:\mingw\bin\electronuaic\electron\electronat\workplace_page.h + "components.h" + +1638311561 c:\mingw\bin\electronuaic\electron\electronat\menu_selection.h + "change_color_panel.h" + +1638483474 c:\mingw\bin\electronuaic\electron\electronat\stare_table.h + + + + + + + + + + +1641651956 g:\electron\electronat\stare_table.h + + + + + + + + + + + "drawing_components.h" + +1641593021 g:\electron\electronat\change_color_panel.h + "startup_page.h" + "workplace_page.h" + +1638311561 c:\mingw\bin\electronuaic\electron\electronat\change_color_panel.h + "startup_page.h" + "workplace_page.h" + +1641651290 g:\electron\electronat\new_project_name_reading_window.h + + +1638483138 c:\mingw\bin\electronuaic\electron\electronat\new_project_name_reading_window.h + +1640795315 source:d:\electronuaic\electron\electronat\main.cpp + + + + + + + + + "startup_page.h" + "workplace_page.h" + "menu_selection.h" + "stare_table.h" + "new_project_name_reading_window.h" + "drawing_components.h" + "messages_panels_main_menu.h" + "open_save.h" + +1638907797 d:\electronuaic\electron\electronat\startup_page.h + +1640795062 d:\electronuaic\electron\electronat\workplace_page.h + "components.h" + "stare_table.h" + +1639340903 d:\electronuaic\electron\electronat\components.h + "workplace_page.h" + +1640640597 d:\electronuaic\electron\electronat\menu_selection.h + "change_color_panel.h" + +1638311561 d:\electronuaic\electron\electronat\change_color_panel.h + "startup_page.h" + "workplace_page.h" + +1640797610 d:\electronuaic\electron\electronat\stare_table.h + + + + + + + + + + + "drawing_components.h" + +1638920570 d:\electronuaic\electron\electronat\new_project_name_reading_window.h + + +1638545034 d:\electronuaic\electron\electronat\table_status.h + + + + + + + + + + +1639527949 d:\electronuaic\electron\electronat\drawing_components.h + +1638739266 g:\electron\electronat\table_status.h + + + + + + + + + + +1641593021 g:\electron\electronat\drawing_components.h + + + + + +1642197256 d:\electron\electronat\startup_page.h + "open_save.h" + "functii_auxiliare.h" + +1642198066 d:\electron\electronat\workplace_page.h + "drawing_components.h" + "stare_table.h" + "zoom_rotate_fader_workplace.h" + "functii_auxiliare.h" + +1638739266 d:\electron\electronat\components.h + "workplace_page.h" + +1642186267 d:\electron\electronat\menu_selection.h + +1642186306 d:\electron\electronat\change_color_panel.h + "startup_page.h" + "workplace_page.h" + +1638739266 d:\electron\electronat\table_status.h + + + + + + + + + + +1642186244 d:\electron\electronat\new_project_name_reading_window.h + + +1642186294 d:\electron\electronat\drawing_components.h + + + + + +1638913473 g:\electron\electronat\error_panels_main_menu.h + + +1641655289 g:\electron\electronat\messages_panels_main_menu.h + + +1638922837 d:\electronuaic\electron\electronat\messages_panels_main_menu.h + + +1640165519 d:\electronuaic\electron\electronat\open_save.h + + + + + + + + + + "drawing_components.h" + +1641419126 g:\electron\electronat\open_save.h + + + + + + + + + + "drawing_components.h" + +1641593333 g:\electron\electronat\messages_log_panel.h + +1641651232 g:\electron\electronat\edit_component_value.h + + +1641593021 g:\electron\electronat\zoom_rotate_fader_workplace.h + +1642197415 d:\electron\electronat\stare_table.h + + + + + + + + + + + "drawing_components.h" + "functii_auxiliare.h" + +1641659499 d:\electron\electronat\messages_log_panel.h + +1641721335 d:\electron\electronat\zoom_rotate_fader_workplace.h + +1642186249 d:\electron\electronat\messages_panels_main_menu.h + + +1642190639 d:\electron\electronat\open_save.h + + + + + + + + + + "drawing_components.h" + "stare_table.h" + +1642186279 d:\electron\electronat\edit_component_value.h + + +1642186299 d:\electron\electronat\choose_from_two_options.h + +1642188519 source:c:\users\user\downloads\electronat\main.cpp + + + + + + + + + "startup_page.h" + "workplace_page.h" + "menu_selection.h" + "stare_table.h" + "new_project_name_reading_window.h" + "drawing_components.h" + "messages_panels_main_menu.h" + "open_save.h" + "change_color_panel.h" + "messages_log_panel.h" + "edit_component_value.h" + "zoom_rotate_fader_workplace.h" + "choose_from_two_options.h" + +1642188654 c:\users\user\downloads\electronat\startup_page.h + "open_save.h" + +1642189610 c:\users\user\downloads\electronat\open_save.h + + + + + + + + + + "drawing_components.h" + "stare_table.h" + +1642186294 c:\users\user\downloads\electronat\drawing_components.h + + + + + +1642189959 c:\users\user\downloads\electronat\stare_table.h + + + + + + + + + + + "drawing_components.h" + +1642188698 c:\users\user\downloads\electronat\workplace_page.h + "drawing_components.h" + "stare_table.h" + "zoom_rotate_fader_workplace.h" + +1641721335 c:\users\user\downloads\electronat\zoom_rotate_fader_workplace.h + +1642186267 c:\users\user\downloads\electronat\menu_selection.h + +1642186244 c:\users\user\downloads\electronat\new_project_name_reading_window.h + + +1642186249 c:\users\user\downloads\electronat\messages_panels_main_menu.h + + +1642186306 c:\users\user\downloads\electronat\change_color_panel.h + "startup_page.h" + "workplace_page.h" + +1641659499 c:\users\user\downloads\electronat\messages_log_panel.h + +1642186279 c:\users\user\downloads\electronat\edit_component_value.h + + +1642186299 c:\users\user\downloads\electronat\choose_from_two_options.h + +1642191142 source:c:\users\user\desktop\electronat\main.cpp + + + + + + + + + "startup_page.h" + "workplace_page.h" + "menu_selection.h" + "stare_table.h" + "new_project_name_reading_window.h" + "drawing_components.h" + "messages_panels_main_menu.h" + "open_save.h" + "change_color_panel.h" + "messages_log_panel.h" + "edit_component_value.h" + "zoom_rotate_fader_workplace.h" + "choose_from_two_options.h" + "functii_auxiliare.h" + +1642191154 c:\users\user\desktop\electronat\startup_page.h + "open_save.h" + "functii_auxiliare.h" + +1642190639 c:\users\user\desktop\electronat\open_save.h + + + + + + + + + + "drawing_components.h" + "stare_table.h" + +1642186294 c:\users\user\desktop\electronat\drawing_components.h + + + + + +1642191150 c:\users\user\desktop\electronat\stare_table.h + + + + + + + + + + + "drawing_components.h" + "functii_auxiliare.h" + +1642191162 c:\users\user\desktop\electronat\workplace_page.h + "drawing_components.h" + "stare_table.h" + "zoom_rotate_fader_workplace.h" + "functii_auxiliare.h" + +1641721335 c:\users\user\desktop\electronat\zoom_rotate_fader_workplace.h + +1642186267 c:\users\user\desktop\electronat\menu_selection.h + +1642186244 c:\users\user\desktop\electronat\new_project_name_reading_window.h + + +1642186249 c:\users\user\desktop\electronat\messages_panels_main_menu.h + + +1642186306 c:\users\user\desktop\electronat\change_color_panel.h + "startup_page.h" + "workplace_page.h" + +1641659499 c:\users\user\desktop\electronat\messages_log_panel.h + +1642186279 c:\users\user\desktop\electronat\edit_component_value.h + + +1642186299 c:\users\user\desktop\electronat\choose_from_two_options.h + +1642191187 c:\users\user\desktop\electronat\functii_auxiliare.h + +1642197535 source:c:\users\andre\desktop\electronat\main.cpp + + + + + + + + + "startup_page.h" + "workplace_page.h" + "menu_selection.h" + "stare_table.h" + "new_project_name_reading_window.h" + "drawing_components.h" + "messages_panels_main_menu.h" + "open_save.h" + "change_color_panel.h" + "messages_log_panel.h" + "edit_component_value.h" + "zoom_rotate_fader_workplace.h" + "choose_from_two_options.h" + "functii_auxiliare.h" + +1642197256 c:\users\andre\desktop\electronat\startup_page.h + "open_save.h" + "functii_auxiliare.h" + +1642190639 c:\users\andre\desktop\electronat\open_save.h + + + + + + + + + + "drawing_components.h" + "stare_table.h" + +1642186294 c:\users\andre\desktop\electronat\drawing_components.h + + + + + +1642197415 c:\users\andre\desktop\electronat\stare_table.h + + + + + + + + + + + "drawing_components.h" + "functii_auxiliare.h" + +1642197769 c:\users\andre\desktop\electronat\functii_auxiliare.h + +1642198066 c:\users\andre\desktop\electronat\workplace_page.h + "drawing_components.h" + "stare_table.h" + "zoom_rotate_fader_workplace.h" + "functii_auxiliare.h" + +1641721335 c:\users\andre\desktop\electronat\zoom_rotate_fader_workplace.h + +1642186267 c:\users\andre\desktop\electronat\menu_selection.h + +1642186244 c:\users\andre\desktop\electronat\new_project_name_reading_window.h + + +1642186249 c:\users\andre\desktop\electronat\messages_panels_main_menu.h + + +1642186306 c:\users\andre\desktop\electronat\change_color_panel.h + "startup_page.h" + "workplace_page.h" + +1641659499 c:\users\andre\desktop\electronat\messages_log_panel.h + +1642186279 c:\users\andre\desktop\electronat\edit_component_value.h + + +1642186299 c:\users\andre\desktop\electronat\choose_from_two_options.h + +1642197535 source:c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\main.cpp + + + + + + + + + "startup_page.h" + "workplace_page.h" + "menu_selection.h" + "stare_table.h" + "new_project_name_reading_window.h" + "drawing_components.h" + "messages_panels_main_menu.h" + "open_save.h" + "change_color_panel.h" + "messages_log_panel.h" + "edit_component_value.h" + "zoom_rotate_fader_workplace.h" + "choose_from_two_options.h" + "functii_auxiliare.h" + +1642197256 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\startup_page.h + "open_save.h" + "functii_auxiliare.h" + +1642190639 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\open_save.h + + + + + + + + + + "drawing_components.h" + "stare_table.h" + +1642186294 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\drawing_components.h + + + + + +1642197415 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\stare_table.h + + + + + + + + + + + "drawing_components.h" + "functii_auxiliare.h" + +1642197769 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\functii_auxiliare.h + +1642197028 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\workplace_page.h + "drawing_components.h" + "stare_table.h" + "zoom_rotate_fader_workplace.h" + "functii_auxiliare.h" + +1641721335 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\zoom_rotate_fader_workplace.h + +1642186267 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\menu_selection.h + +1642186244 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\new_project_name_reading_window.h + + +1642186249 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\messages_panels_main_menu.h + + +1642186306 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\change_color_panel.h + "startup_page.h" + "workplace_page.h" + +1641659499 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\messages_log_panel.h + +1642186279 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\edit_component_value.h + + +1642186299 c:\users\user\downloads\1e2_tudorilade_cerbuandreimihnea (1)\electronat\choose_from_two_options.h + +1642197769 d:\electron\electronat\functii_auxiliare.h + +1642201135 source:c:\users\andrei - mihnea\desktop\electronat\main.cpp + + + + + + + + + "startup_page.h" + "workplace_page.h" + "menu_selection.h" + "stare_table.h" + "new_project_name_reading_window.h" + "drawing_components.h" + "messages_panels_main_menu.h" + "open_save.h" + "change_color_panel.h" + "messages_log_panel.h" + "edit_component_value.h" + "zoom_rotate_fader_workplace.h" + "choose_from_two_options.h" + "functii_auxiliare.h" + +1642200856 c:\users\andrei - mihnea\desktop\electronat\startup_page.h + "open_save.h" + "functii_auxiliare.h" + +1642194239 c:\users\andrei - mihnea\desktop\electronat\open_save.h + + + + + + + + + + "drawing_components.h" + "stare_table.h" + +1642189894 c:\users\andrei - mihnea\desktop\electronat\drawing_components.h + + + + + +1642201015 c:\users\andrei - mihnea\desktop\electronat\stare_table.h + + + + + + + + + + + "drawing_components.h" + "functii_auxiliare.h" + +1642201369 c:\users\andrei - mihnea\desktop\electronat\functii_auxiliare.h + +1642201666 c:\users\andrei - mihnea\desktop\electronat\workplace_page.h + "drawing_components.h" + "stare_table.h" + "zoom_rotate_fader_workplace.h" + "functii_auxiliare.h" + +1641724935 c:\users\andrei - mihnea\desktop\electronat\zoom_rotate_fader_workplace.h + +1642189867 c:\users\andrei - mihnea\desktop\electronat\menu_selection.h + +1642189844 c:\users\andrei - mihnea\desktop\electronat\new_project_name_reading_window.h + + +1642189849 c:\users\andrei - mihnea\desktop\electronat\messages_panels_main_menu.h + + +1642189906 c:\users\andrei - mihnea\desktop\electronat\change_color_panel.h + "startup_page.h" + "workplace_page.h" + +1641663099 c:\users\andrei - mihnea\desktop\electronat\messages_log_panel.h + +1642189879 c:\users\andrei - mihnea\desktop\electronat\edit_component_value.h + + +1642189899 c:\users\andrei - mihnea\desktop\electronat\choose_from_two_options.h + diff --git a/ELECTRONAT.layout b/ELECTRONAT.layout new file mode 100644 index 0000000..5641854 --- /dev/null +++ b/ELECTRONAT.layout @@ -0,0 +1,75 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Proiect electron.docx b/Proiect electron.docx new file mode 100644 index 0000000..25c5461 Binary files /dev/null and b/Proiect electron.docx differ diff --git a/bec_aprins.jpg b/bec_aprins.jpg new file mode 100644 index 0000000..5122bc7 Binary files /dev/null and b/bec_aprins.jpg differ diff --git a/becstins.jpg b/becstins.jpg new file mode 100644 index 0000000..0a533c7 Binary files /dev/null and b/becstins.jpg differ diff --git a/bg_main_menu.jpg b/bg_main_menu.jpg new file mode 100644 index 0000000..caea102 Binary files /dev/null and b/bg_main_menu.jpg differ diff --git a/change_color_panel.h b/change_color_panel.h new file mode 100644 index 0000000..2b6d7b2 --- /dev/null +++ b/change_color_panel.h @@ -0,0 +1,251 @@ +#ifndef CHANGE_COLOR_PANEL_H_INCLUDED +#define CHANGE_COLOR_PANEL_H_INCLUDED + +#include "startup_page.h" +#include "workplace_page.h" + + +//Andrei CERBU pana jos + +void change_color_icon_startup_page(int var, int W, int H, int R) +{ + switch(var) + { + case 1: + setlinestyle(SOLID_LINE,0,7); + setcolor(RED); + rectangle(W/6,H/4,W/6+R*H/6,H/4+R*H/6); + break; + case 2: + setlinestyle(SOLID_LINE,0,7); + setcolor(RED); + rectangle(W/3,H/4,W/3+R*H/6,H/4+R*H/6); + break; + case 3: + setlinestyle(SOLID_LINE,0,7); + setcolor(RED); + rectangle(W/6,3*H/4-R*H/6,W/6+R*H/6,3*H/4); + break; + case 4: + setlinestyle(SOLID_LINE,0,7); + setcolor(RED); + rectangle(W/3,3*H/4-R*H/6,W/3+R*H/6,3*H/4); + break; + case 0: + setcolor(WHITE); + create_panels_startup_page(W,H,R); + break; + } +} + +void change_color_icon_top_menu_workplace_page(int W, int H, int R, int val){ + int width_rectangle = W/12; + int height_rectangle = H/24; + + switch(val){ + case 1: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle(3*width_rectangle*R,0,4*width_rectangle*R, height_rectangle*R); + break; + case 2: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle(4*width_rectangle*R,0,5*width_rectangle*R, height_rectangle*R); + break; + case 3: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle(5*width_rectangle*R,0,6*width_rectangle*R, height_rectangle*R); + break; + case 4: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle(6*width_rectangle*R,0,7*width_rectangle*R, height_rectangle*R); + break; + case 5: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle(7*width_rectangle*R,0,8*width_rectangle*R, height_rectangle*R); + break; + case 6: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle(8*width_rectangle*R,0,9*width_rectangle*R, height_rectangle*R); + break; + case 0: + setlinestyle(SOLID_LINE,0,3); + setcolor(WHITE); + create_top_menu_workplace(W,H,R,W/12,H/24); + break; + } +} + +void change_color_icon_left_menu_workplace_page(int W, int H, int R, int val){ + int width_rectangle = W/9; + int height_rectangle = H/16; + + switch(val){ + case 1: + setlinestyle(SOLID_LINE,0,2); + setcolor(RED); + rectangle(0,(height_rectangle*3)*R,width_rectangle*R,(height_rectangle*4)*R); + break; + case 2: + setlinestyle(SOLID_LINE,0,2); + setcolor(RED); + rectangle(0,(height_rectangle*4)*R,width_rectangle*R,(height_rectangle*5)*R); + break; + case 3: + setlinestyle(SOLID_LINE,0,2); + setcolor(RED); + rectangle(0,(height_rectangle*5)*R,width_rectangle*R,(height_rectangle*6)*R); + break; + case 4: + setlinestyle(SOLID_LINE,0,2); + setcolor(RED); + rectangle(0,(height_rectangle*6)*R,width_rectangle*R,(height_rectangle*7)*R); + break; + case 5: + setlinestyle(SOLID_LINE,0,2); + setcolor(RED); + rectangle(0,(height_rectangle*7)*R,width_rectangle*R,(height_rectangle*8)*R); + break; + case 6: + setlinestyle(SOLID_LINE,0,2); + setcolor(RED); + rectangle(0,(height_rectangle*8)*R,width_rectangle*R,(height_rectangle*9)*R); + break; + case 7: + setlinestyle(SOLID_LINE,0,2); + setcolor(RED); + rectangle(0,(height_rectangle*9)*R,width_rectangle*R,(height_rectangle*10)*R); + break; + case 8: + setlinestyle(SOLID_LINE,0,2); + setcolor(RED); + rectangle(0,(height_rectangle*10)*R,width_rectangle*R,(height_rectangle*11)*R); + break; + case 9: + setlinestyle(SOLID_LINE,0,2); + setcolor(RED); + rectangle(0,(height_rectangle*11)*R,width_rectangle*R,(height_rectangle*12)*R); + break; + case 0: + setlinestyle(SOLID_LINE,0,3); + setcolor(WHITE); + create_left_menu_workplace(W,H,R,W/9,H/16); + break; + } +} + +void change_color_icon_right_menu_workplace_page(int W, int H, int R, int val){ + int width_rectangle = W/9; + int height_rectangle = H/16; + + switch(val){ + case 1: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle((W-width_rectangle)*R,2*height_rectangle*R,W,3*height_rectangle*R); + break; + case 2: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle((W-width_rectangle)*R,3*height_rectangle*R,W,4*height_rectangle*R); + break; + case 3: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle((W-width_rectangle)*R,4*height_rectangle*R,W,5*height_rectangle*R); + break; + case 4: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle((W-width_rectangle)*R,5*height_rectangle*R,W,6*height_rectangle*R); + break; + case 5: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle((W-width_rectangle)*R,6*height_rectangle*R,W,7*height_rectangle*R); + break; + case 6: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle((W-width_rectangle)*R,7*height_rectangle*R,W,8*height_rectangle*R); + break; + case 0: + setlinestyle(SOLID_LINE,0,3); + setcolor(WHITE); + create_right_menu_workplace(W,H,R,W/9,H/16); + break; + } +} + +void change_color_icon_undo_redu_menu_workplace_page(int W, int H, int R, int val){ + int width_rectangle = W/18; + int height_rectangle = H/16; + + switch(val){ + case 1: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle(2*width_rectangle/9,14.2*height_rectangle*R,width_rectangle,15*height_rectangle*R); + break; + case 2: + setlinestyle(SOLID_LINE,0,3); + setcolor(RED); + rectangle(width_rectangle,14.2*height_rectangle*R,16*width_rectangle/9,15*height_rectangle*R); + break; + case 0: + setlinestyle(SOLID_LINE,0,3); + setcolor(WHITE); + create_undo_redo_menu_workplace(W,H,R,W/18,H/16); + break; + } +} + +void change_color_icon_drawing_line_type_menu_workplace(int W, int H, int R, int val, int condition){ + int width_rectangle = W/10; + int height_rectangle = H/22; + + switch(val){ + case 1: + setlinestyle(SOLID_LINE,0,1); + setcolor(RED); + rectangle((W-width_rectangle)*R,(height_rectangle*11.1)*R,W-width_rectangle/9,(height_rectangle*12.1)*R); + break; + case 4: + setlinestyle(SOLID_LINE,0,1); + setcolor(RED); + rectangle((W-width_rectangle)*R,(height_rectangle*12.1)*R,W-width_rectangle/9,(height_rectangle*13.1)*R); + break; + case 2: + setlinestyle(SOLID_LINE,0,1); + setcolor(RED); + rectangle((W-width_rectangle)*R,(height_rectangle*13.1)*R,W-width_rectangle/9,(height_rectangle*14.1)*R); + break; + case 3: + setlinestyle(SOLID_LINE,0,1); + setcolor(RED); + rectangle((W-width_rectangle)*R,(height_rectangle*14.1)*R,W-width_rectangle/9,(height_rectangle*15.1)*R); + break; + case 0: + if(!condition){ + setlinestyle(SOLID_LINE,0,1); + setcolor(WHITE); + create_drawing_line_type_menu_workplace(W,H,R,W/10,H/22,WHITE); + } + break; + } +} + +void change_color_icon_zoom_rotate_menu_workplace_page(int W, int H, int R, int width_rectangle, int height_rectangle, int color){ + setcolor(color); + setlinestyle(SOLID_LINE,0,2); + + rectangle((W-width_rectangle)*R,(height_rectangle*16.1)*R,(W-width_rectangle)*R+4*W/225*2,(height_rectangle*20.1)*R); + rectangle((W-width_rectangle)*R+4*W/225*3,(height_rectangle*16.1)*R,(W-width_rectangle)*R+4*W/225*5,(height_rectangle*20.1)*R); +} + +#endif // CHANGE_COLOR_PANEL_H_INCLUDED diff --git a/choose_from_two_options.h b/choose_from_two_options.h new file mode 100644 index 0000000..d3bf278 --- /dev/null +++ b/choose_from_two_options.h @@ -0,0 +1,158 @@ +#ifndef CHOOSE_FROM_TWO_OPTIONS_H_INCLUDED +#define CHOOSE_FROM_TWO_OPTIONS_H_INCLUDED + + +//Andrei CERBU pana jos + +void print_text_on_choose_from_two_options_page(int W, int H, int R, int width_rectangle, int height_rectangle, int rect_w, int rect_h, char* str){ + int text_w=textwidth(str); + int text_h=textheight(str); + + float x=(width_rectangle+(rect_w-text_w)/2); + float y=(height_rectangle+(rect_h-text_h)/2); + + outtextxy(x,y,str); +} + +void draw_pannels_choose_from_two_options_menu(int W, int H, int R){ + setlinestyle(SOLID_LINE,0,1); + setcolor(WHITE); + + int width_rectangle; + int height_rectangle; + + width_rectangle=W/4; + height_rectangle=H/2; + + rectangle(width_rectangle-W/5,height_rectangle-H/8,width_rectangle+W/5,height_rectangle+H/8);//latest project + + width_rectangle=3*W/4; + height_rectangle=H/2; + + rectangle(width_rectangle-W/5,height_rectangle-H/8,width_rectangle+W/5,height_rectangle+H/8);//new project + + width_rectangle=W-3*W/32; + height_rectangle=H/10; + + rectangle(width_rectangle-3*W/40,height_rectangle-2*H/30,width_rectangle+3*W/40,height_rectangle+2*H/30);//back +} + +void put_text_on_choose_from_two_options_menu(int W, int H, int R){ + int font; + int width_rectangle; + int height_rectangle; + + if(W*4<=1920) + font=1; + else font=2; + + settextstyle(COMPLEX_FONT,0,font); + + width_rectangle=W/4; + height_rectangle=H/2; + + print_text_on_choose_from_two_options_page(W,H,R,width_rectangle-W/5,height_rectangle-H/8,2*W/5,H/4,"Last Project"); + + width_rectangle=3*W/4; + height_rectangle=H/2; + + print_text_on_choose_from_two_options_page(W,H,R,width_rectangle-W/5,height_rectangle-H/8,2*W/5,H/4,"New Project"); + + width_rectangle=W-3*W/32; + height_rectangle=H/10; + + print_text_on_choose_from_two_options_page(W,H,R,width_rectangle-3*W/40,height_rectangle-2*H/30,3*W/20,2*H/15,"Back"); +} + +void change_color_to_choose_from_two_options_menu(int W, int H, int R, int val){ + int width_rectangle; + int height_rectangle; + + switch(val){ + case 1: + setlinestyle(SOLID_LINE,0,1); + setcolor(RED); + + width_rectangle=W/4; + height_rectangle=H/2; + + rectangle(width_rectangle-W/5,height_rectangle-H/8,width_rectangle+W/5,height_rectangle+H/8);//latest project + + break; + case 2: + setlinestyle(SOLID_LINE,0,1); + setcolor(RED); + + width_rectangle=3*W/4; + height_rectangle=H/2; + + rectangle(width_rectangle-W/5,height_rectangle-H/8,width_rectangle+W/5,height_rectangle+H/8);//new project + + break; + case 3: + setlinestyle(SOLID_LINE,0,1); + setcolor(RED); + + width_rectangle=W-3*W/32; + height_rectangle=H/10; + + rectangle(width_rectangle-3*W/40,height_rectangle-2*H/30,width_rectangle+3*W/40,height_rectangle+2*H/30);//back + + break; + case 0: + draw_pannels_choose_from_two_options_menu(W,H,R); + break; + } +} + +int menu_selection_choose_from_two_options(int W, int H, int R, int x, int y){ + int width_rectangle; + int height_rectangle; + + width_rectangle=W/4; + height_rectangle=H/2; + + if(x>width_rectangle-W/5&&xheight_rectangle-H/8&&ywidth_rectangle-W/5&&xheight_rectangle-H/8&&ywidth_rectangle-3*W/40&&xheight_rectangle-2*H/30&&y +#include +#include +#include + +using namespace std; + +//Andrei CERBU pana jos + +struct coordonate +{ + float x, y; +}; + +typedef struct dreptunghi +{ + coordonate TL, TR, BR, BL; +} drepunghi; + +typedef struct componenta +{ + int line_width=0; + int branch; + float points[8]; +}; + +struct dreptunghi create_struct_rectangle(float w1, float w2, float h1, float h2) +{ + dreptunghi D; + D.TL.x=w1,D.TL.y=h1; + D.TR.x=w2,D.TR.y=h1; + D.BL.x=w1,D.BL.y=h2; + D.BR.x=w2,D.BR.y=h2; + return D; +} + +struct dreptunghi translate_rectangle(drepunghi D, coordonate C) +{ + D.TL.x-=C.x,D.TL.y-=C.y; + D.TR.x-=C.x,D.TR.y-=C.y; + D.BR.x-=C.x,D.BR.y-=C.y; + D.BL.x-=C.x,D.BL.y-=C.y; + return D; +} + +struct coordonate determine_points(float pointX, float pointY, float beta) +{ + coordonate C; + C.x=cos(beta)*pointX-sin(beta)*pointY; + C.y=sin(beta)*pointX+cos(beta)*pointY; + return C; +} + +struct componenta RotateRectangle(coordonate C, drepunghi D, int angle, int branch) +{ + componenta CMP; + + if(branch<=2) //componenta care trebuie sa se invarta + { + double beta=-(double)(angle%360)*M_PI/180.0; + D.TL=determine_points(D.TL.x,D.TL.y,beta); + D.TR=determine_points(D.TR.x,D.TR.y,beta); + D.BR=determine_points(D.BR.x,D.BR.y,beta); + D.BL=determine_points(D.BL.x,D.BL.y,beta); + if(branch==1) + { + float point[8]= + { + (D.TL.x+C.x),(D.TL.y+C.y), + (D.TR.x+C.x),(D.TR.y+C.y), + (D.BR.x+C.x),(D.BR.y+C.y), + (D.BL.x+C.x),(D.BL.y+C.y) + }; + for(int i=0; i<8; i++) + CMP.points[i]=point[i]; + } + else if(branch==2) + { + CMP.points[0]=D.TL.x+C.x; + CMP.points[1]=D.TL.y+C.y; + CMP.points[2]=D.BR.x+C.x; + CMP.points[3]=D.BR.y+C.y; + } + } + if(branch==3) /*componenta care nu trebuie sa se invarta*/ + { + CMP.points[0]=D.TL.x; + CMP.points[1]=D.TL.y; + CMP.points[2]=D.BR.x; + CMP.points[3]=D.BR.y; + } + if(branch==4) /*cerc*/ + { + CMP.points[0]=D.TL.x; + CMP.points[1]=D.TL.y; + CMP.points[2]=D.TR.x; + } + + CMP.branch=branch; + return CMP; +} + + +void construct_resistor(int W, int H, float R, int X, int Y, int angle, float zoom, struct componenta CMP[]) +{ + int width = W/8, height = H/4; + float w1, w2, h1, h2, w, h; + + dreptunghi D; + coordonate C; + C.x=X, C.y=Y; + + //chenar + w1=-(width*4-width/1.7)*R*zoom+X, w2=(width*4-width/1.7)*R*zoom+X, + h1=-(height*2-height/2.7)*R*zoom+Y, h2=(height*2-height/2.7)*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[1]=RotateRectangle(C,D,angle,1); + + //conector stanga + w1=-3.3*width*R*zoom+X, w2=-3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[2]=RotateRectangle(C,D,angle,1); + + //conector drept + w1=3*width*R*zoom+X, w2=3.3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[3]=RotateRectangle(C,D,angle,1); + + //corp + w1=-3*width/2*R*zoom+X, w2=3*width/2*R*zoom+X, + h1=-height*R*zoom+Y, h2=height*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[4]=RotateRectangle(C,D,angle,1); + + //linie stanga + w1=-3*width*R*zoom+X, w2=-3*width/2*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[5]=RotateRectangle(C,D,angle,1); + + //linie dreapta + w1=3*width/2*R*zoom+X, w2=3*width*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[6]=RotateRectangle(C,D,angle,1); +} + +void construct_fuse(int W, int H, float R, int X, int Y, int angle, float zoom, struct componenta CMP[]) +{ + int width = W/8, height = H/4; + float w1, w2, h1, h2, w, h; + + dreptunghi D; + coordonate C; + C.x=X, C.y=Y; + + //chenar + w1=-(width*4-width/1.7)*R*zoom+X, w2=(width*4-width/1.7)*R*zoom+X, + h1=-(height*2-height/2.7)*R*zoom+Y, h2=(height*2-height/2.7)*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[1]=RotateRectangle(C,D,angle,1); + + //conector stanga + w1=-3.3*width*R*zoom+X, w2=-3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[2]=RotateRectangle(C,D,angle,1); + + //conector drept + w1=3*width*R*zoom+X, w2=3.3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[3]=RotateRectangle(C,D,angle,1); + + //corp + w1=-3*width/2*R*zoom+X, w2=3*width/2*R*zoom+X, + h1=-height*R*zoom+Y, h2=height*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[4]=RotateRectangle(C,D,angle,1); + + //linie + w1=-3*width*R*zoom+X, w2=3*width*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[5]=RotateRectangle(C,D,angle,1); +} + +void construct_electrical_cell(int W, int H, float R, int X, int Y, int angle, float zoom, struct componenta CMP[]) +{ + int width = W/8, height = H/4; + float w1, w2, h1, h2, w, h; + + dreptunghi D; + coordonate C; + C.x=X, C.y=Y; + + //chenar + w1=-(width*4-width/1.7)*R*zoom+X, w2=(width*4-width/1.7)*R*zoom+X, + h1=-(height*2-height/2.7)*R*zoom+Y, h2=(height*2-height/2.7)*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[1]=RotateRectangle(C,D,angle,1); + + //conector stanga + w1=-3.3*width*R*zoom+X, w2=-3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[2]=RotateRectangle(C,D,angle,1); + + //conector drept + w1=3*width*R*zoom+X, w2=3.3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[3]=RotateRectangle(C,D,angle,1); + + //borna minus + w1=-width/4*R*zoom+X, w2=-width/4*R*zoom+X, + h1=-4*height/3*R*zoom+Y, h2=4*height/3*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[4]=RotateRectangle(C,D,angle,1); + + //borna plus + w1=width/4*R*zoom+X, w2=width/4*R*zoom+X, + h1=-15*height/8*R*zoom+Y, h2=15*height/8*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[5]=RotateRectangle(C,D,angle,1); + + //linie stanga + w1=-3*width*R*zoom+X, w2=-width/4*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[6]=RotateRectangle(C,D,angle,1); + + //linie dreapta + w1=width/4*R*zoom+X, w2=3*width*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[7]=RotateRectangle(C,D,angle,1); +} + +void construct_dioda(int W, int H, float R, int X, int Y, int angle, float zoom, struct componenta CMP[]) +{ + int width = W/8, height = H/4; + float w1, w2, h1, h2, w, h; + + dreptunghi D; + coordonate C; + C.x=X, C.y=Y; + + //chenar + w1=-(width*4-width/1.7)*R*zoom+X, w2=(width*4-width/1.7)*R*zoom+X, + h1=-(height*2-height/2.7)*R*zoom+Y, h2=(height*2-height/2.7)*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[1]=RotateRectangle(C,D,angle,1); + + //conector stanga + w1=-3.3*width*R*zoom+X, w2=-3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[2]=RotateRectangle(C,D,angle,1); + + //conector drept + w1=3*width*R*zoom+X, w2=3.3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[3]=RotateRectangle(C,D,angle,1); + + //linie blocaj + w1=width*R*zoom+X, w2=width*R*zoom+X, + h1=-height*R*zoom+Y, h2=height*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[4]=RotateRectangle(C,D,angle,1); + + //linie stanga + w1=-3*width*R*zoom+X, w2=-width*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[5]=RotateRectangle(C,D,angle,1); + + //linie dreapta + w1=width*R*zoom+X, w2=3*width*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[6]=RotateRectangle(C,D,angle,1); + + ///TRIUNGHI + //baza + w1=-width*R*zoom+X, w2=-width*R*zoom+X, + h1=-height*R*zoom+Y, h2=height*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[7]=RotateRectangle(C,D,angle,1); + + //latura sus->jos + w1=-width*R*zoom+X, w2=width*R*zoom+X, + h1=-height*R*zoom+Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[8]=RotateRectangle(C,D,angle,2); + + //latura jos->sus + w1=-width*R*zoom+X, w2=width*R*zoom+X, + h1=height*R*zoom+Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[9]=RotateRectangle(C,D,angle,2); +} + +void construct_ampermeter(int W, int H, float R, int X, int Y, int angle, float zoom, struct componenta CMP[]) +{ + int width = W/8, height = H/4; + float w1, w2, h1, h2, w, h; + + dreptunghi D; + coordonate C; + C.x=X, C.y=Y; + + //chenar + w1=-(width*4-width/1.7)*R*zoom+X, w2=(width*4-width/1.7)*R*zoom+X, + h1=-(height*2-height/2.7)*R*zoom+Y, h2=(height*2-height/2.7)*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[1]=RotateRectangle(C,D,angle,1); + + //conector stanga + w1=-3.3*width*R*zoom+X, w2=-3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[2]=RotateRectangle(C,D,angle,1); + + //conector dreapta + w1=3*width*R*zoom+X, w2=3.3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[3]=RotateRectangle(C,D,angle,1); + + //linie stanga + w1=-3*width*R*zoom+X, w2=-width*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[4]=RotateRectangle(C,D,angle,1); + + //linie dreapta + w1=width*R*zoom+X, w2=3*width*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[5]=RotateRectangle(C,D,angle,1); + + ///litera A + //talpa dreapta + w1=width/3*R*zoom+X, w2=39*width/84*R*zoom+X, + h1=height/3*R*zoom+Y, h2=height/3*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[6]=RotateRectangle(C,D,angle,3); + CMP[6].line_width=3; + + //picior drept + w1=width/10*R*zoom+X, w2=2*width/5*R*zoom+X, + h1=-height/2*R*zoom+Y, h2=height/3*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[7]=RotateRectangle(C,D,angle,3); + CMP[7].line_width=3; + + //tapla stanga + w1=-39*width/84*R*zoom+X, w2=-width/3*R*zoom+X, + h1=height/3*R*zoom+Y, h2=height/3*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[8]=RotateRectangle(C,D,angle,3); + CMP[8].line_width=3; + + //picior stang + w1=-width/10*R*zoom+X, w2=-2*width/5*R*zoom+X, + h1=-height/2*R*zoom+Y, h2=height/3*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[9]=RotateRectangle(C,D,angle,3); + CMP[9].line_width=3; + + //palarie + w1=-width/10*R*zoom+X, w2=width/5*R*zoom+X, + h1=-height/2*R*zoom+Y, h2=-height/2*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[10]=RotateRectangle(C,D,angle,3); + CMP[10].line_width=3; + + //linie mijloc + w1=-width/4*R*zoom+X, w2=width/4*R*zoom+X, + h1=-height/12*R*zoom+Y, h2=-height/12*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[11]=RotateRectangle(C,D,angle,3); + CMP[11].line_width=3; + + //centru + w1=X*R*zoom, w2=width*R*zoom, + h1=Y*R*zoom, h2=Y*R*zoom; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[12]=RotateRectangle(C,D,angle,4); +} + +void construct_voltmeter(int W, int H, float R, int X, int Y, int angle, float zoom, struct componenta CMP[]) +{ + int width = W/8, height = H/4; + float w1, w2, h1, h2, w, h; + + dreptunghi D; + coordonate C; + C.x=X, C.y=Y; + + //chenar + w1=-(width*4-width/1.7)*R*zoom+X, w2=(width*4-width/1.7)*R*zoom+X, + h1=-(height*2-height/2.7)*R*zoom+Y, h2=(height*2-height/2.7)*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[1]=RotateRectangle(C,D,angle,1); + + //conector stanga + w1=-3.3*width*R*zoom+X, w2=-3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[2]=RotateRectangle(C,D,angle,1); + + //conector dreapta + w1=3*width*R*zoom+X, w2=3.3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[3]=RotateRectangle(C,D,angle,1); + + //linie stanga + w1=-3*width*R*zoom+X, w2=-width*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[4]=RotateRectangle(C,D,angle,1); + + //linie dreapta + w1=width*R*zoom+X, w2=3*width*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[5]=RotateRectangle(C,D,angle,1); + + ///litera V + //talpa dreapta + w1=width/3*R*zoom+X, w2=39*width/84*R*zoom+X, + h1=-height/3*R*zoom+Y, h2=-height/3*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[6]=RotateRectangle(C,D,angle,3); + CMP[6].line_width=3; + + //picior drept + w1=X*R*zoom, w2=2*width/5*R*zoom+X, + h1=height/2*R*zoom+Y, h2=-height/3*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[7]=RotateRectangle(C,D,angle,3); + CMP[7].line_width=3; + + //tapla stanga + w1=-39*width/84*R*zoom+X, w2=-width/3*R*zoom+X, + h1=-height/3*R*zoom+Y, h2=-height/3*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[8]=RotateRectangle(C,D,angle,3); + CMP[8].line_width=3; + + //picior stang + w1=X*R*zoom, w2=-2*width/5*R*zoom+X, + h1=height/2*R*zoom+Y, h2=-height/3*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[9]=RotateRectangle(C,D,angle,3); + CMP[9].line_width=3; + + //centru + w1=X*R*zoom, w2=width*R*zoom, + h1=Y*R*zoom, h2=Y*R*zoom; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[10]=RotateRectangle(C,D,angle,4); +} + +void construct_capacitor(int W, int H, float R, int X, int Y, int angle, float zoom, struct componenta CMP[]) +{ + int width = W/8, height = H/4; + float w1, w2, h1, h2, w, h; + + dreptunghi D; + coordonate C; + C.x=X, C.y=Y; + + //chenar + w1=-(width*4-width/1.7)*R*zoom+X, w2=(width*4-width/1.7)*R*zoom+X, + h1=-(height*2-height/2.7)*R*zoom+Y, h2=(height*2-height/2.7)*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[1]=RotateRectangle(C,D,angle,1); + + //conector stanga + w1=-3.3*width*R*zoom+X, w2=-3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[2]=RotateRectangle(C,D,angle,1); + + //conector drept + w1=3*width*R*zoom+X, w2=3.3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[3]=RotateRectangle(C,D,angle,1); + + //borna minus + w1=-width/4*R*zoom+X, w2=-width/4*R*zoom+X, + h1=-4*height/3*R*zoom+Y, h2=4*height/3*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[4]=RotateRectangle(C,D,angle,1); + + //borna plus + w1=width/4*R*zoom+X, w2=width/4*R*zoom+X, + h1=-4*height/3*R*zoom+Y, h2=4*height/3*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[5]=RotateRectangle(C,D,angle,1); + + //linie stanga + w1=-3*width*R*zoom+X, w2=-width/4*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[6]=RotateRectangle(C,D,angle,1); + + //linie dreapta + w1=width/4*R*zoom+X, w2=3*width*R*zoom+X, + h1=Y, h2=Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[7]=RotateRectangle(C,D,angle,1); +} + +void construct_bulb(int W, int H, float R, int X, int Y, int angle, float zoom, struct componenta CMP[]) +{ + int width = W/8, height = H/4; + float w1, w2, h1, h2, w, h; + + dreptunghi D; + coordonate C; + C.x=X, C.y=Y; + + //chenar + w1=-(width*4-width/1.7)*R*zoom+X, w2=(width*4-width/1.7)*R*zoom+X, + h1=-(height*2-height/2.7)*R*zoom+Y, h2=(height*2-height/2.7)*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[1]=RotateRectangle(C,D,angle,1); + + //conector stanga + w1=-3.3*width*R*zoom+X, w2=-3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[2]=RotateRectangle(C,D,angle,1); + + //conector dreapta + w1=3*width*R*zoom+X, w2=3.3*width*R*zoom+X, + h1=-height/3*R*R*zoom+Y, h2=height/3*R*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[3]=RotateRectangle(C,D,angle,1); + + //linie stanga + w1=-3*width*R*zoom+X, w2=-width*R*zoom+X, + h1=Y*R*zoom, h2=Y*R*zoom; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[4]=RotateRectangle(C,D,angle,1); + + //linie dreapta + w1=width*R*zoom+X, w2=3*width*R*zoom+X, + h1=Y*R*zoom, h2=Y*R*zoom; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[5]=RotateRectangle(C,D,angle,1); + + //bec linie stanga + w1=-2*width/5*R*zoom+X, w2=2*width/5*R*zoom+X, + h1=-height*R*zoom+Y, h2=height*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[6]=RotateRectangle(C,D,angle,3); + + //bec linie dreapta + w1=2*width/5*R*zoom+X, w2=-2*width/5*R*zoom+X, + h1=-height*R*zoom+Y, h2=height*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[7]=RotateRectangle(C,D,angle,3); + + //cerc + w1=X*R*zoom, w2=width*R*zoom, + h1=Y*R*zoom, h2=Y*R*zoom; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[8]=RotateRectangle(C,D,angle,4); +} + +void construct_transistor(int W, int H, float R, int X, int Y, int angle, float zoom, struct componenta CMP[]) +{ + int width = W/8, height = H/4; + float w1, w2, h1, h2, w, h; + + dreptunghi D; + coordonate C; + C.x=X, C.y=Y; + + //chenar + w1=-2*width*R*zoom+X, w2=width*R*zoom+X, + h1=-(height*2-height/2.7)*R*zoom+Y, h2=(height*2-height/2.7)*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[1]=RotateRectangle(C,D,angle,1); + + //conector stanga + w1=-1.8*width*R*zoom+X, w2=-1.5*width*R*zoom+X, + h1=-0.3*height*R*zoom+Y, h2=0.3*height*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[2]=RotateRectangle(C,D,angle,1); + + //conector top + w1=0.65*width*R*zoom+X, w2=0.95*width*R*zoom+X, + h1=-1.5*height*R*zoom+Y, h2=-height*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[3]=RotateRectangle(C,D,angle,1); + + //conector bot + w1=0.65*width*R*zoom+X, w2=0.95*width*R*zoom+X, + h1=height*R*zoom+Y, h2=1.5*height*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[4]=RotateRectangle(C,D,angle,1); + + //linie centru + w1=-0.1*width*R*zoom+X, w2=-0.1*width*R*zoom+X, + h1=-height/2*R*zoom+Y, h2=height/2*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[5]=RotateRectangle(C,D,angle,1); + + //linie centru bot + w1=-0.1*width*R*zoom+X, w2=0.8*width*R*zoom+X, + h1=(height-height/1.2)*R*zoom+Y, h2=3*height/5.5*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[6]=RotateRectangle(C,D,angle,2); + + //linie centru top + w1=-0.1*width*R*zoom+X, w2=0.8*width*R*zoom+X, + h1=(-(height-height/1.2))*R*zoom+Y, h2=-3*height/5.5*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[7]=RotateRectangle(C,D,angle,2); + + //linie conector stanga + w1=-1.5*width*R*zoom+X, w2=-0.1*width*R*zoom+X, + h1=Y*R*zoom, h2=Y*R*zoom; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[8]=RotateRectangle(C,D,angle,1); + + //linie conector top + w1=0.8*width*R*zoom+X, w2=0.8*width*R*zoom+X, + h1=-height/2*R*zoom+Y, h2=-height*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[9]=RotateRectangle(C,D,angle,1); + + //linie conector bot + w1=0.8*width*R*zoom+X, w2=0.8*width*R*zoom+X, + h1=height/2*R*zoom+Y, h2=height*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP[10]=RotateRectangle(C,D,angle,1); + + //centru + w1=X*R*zoom, w2=0.6*width*R*zoom, + h1=Y*R*zoom, h2=Y*R*zoom; + D=create_struct_rectangle(w1,w2,h1,h2); + CMP[11]=RotateRectangle(C,D,angle,4); +} + +void draw_component(struct componenta CMP[], int n, int color) +{ + setcolor(color); + for(int i=2; i<=n; i++) + { + setlinestyle(SOLID_LINE,0,CMP[i].line_width); + + switch(CMP[i].branch) + { + case 1: + for(int j=0; j<8; j+=2) + line(CMP[i].points[j],CMP[i].points[j+1],CMP[i].points[(j+2)%8],CMP[i].points[(j+3)%8]); + break; + case 2: + line(CMP[i].points[0],CMP[i].points[1],CMP[i].points[2],CMP[i].points[3]); + break; + case 3: + line(CMP[i].points[0],CMP[i].points[1],CMP[i].points[2],CMP[i].points[3]); + break; + case 4: + circle(CMP[i].points[0],CMP[i].points[1],CMP[i].points[2]); + break; + } + } +} + +void draw_components_on_working_table(int type, int W, int H, int X, int Y, float R, int angle, float zoom, int color, struct componenta CMP[]) +{ + + switch(type) + { + case 1: + construct_resistor(W/10,H/16,R,X,Y,angle,zoom,CMP); + draw_component(CMP,6,color); + break; + case 2: + construct_fuse(W/10,H/16,R,X,Y,angle,zoom,CMP); + draw_component(CMP,5,color); + break; + case 3: + construct_electrical_cell(W/10,H/16,R,X,Y,angle,zoom,CMP); + draw_component(CMP,7,color); + break; + case 4: + construct_dioda(W/10,H/16,R,X,Y,angle,zoom,CMP); + draw_component(CMP,9,color); + break; + case 5: + construct_ampermeter(W/10,H/16,R,X,Y,angle,zoom,CMP); + draw_component(CMP,12,color); + break; + case 6: + construct_voltmeter(W/10,H/16,R,X,Y,angle,zoom,CMP); + draw_component(CMP,10,color); + break; + case 7: + construct_capacitor(W/10,H/16,R,X,Y,angle,zoom,CMP); + draw_component(CMP,7,color); + break; + case 8: + construct_bulb(W/10,H/16,R,X,Y,angle,zoom,CMP); + draw_component(CMP,8,color); + break; + case 9: + construct_transistor(W/10,H/16,R,X,Y,angle,zoom,CMP); + draw_component(CMP,11,color); + break; + } +} + +#endif // DRAWING_COMPONENTS_H_INCLUDED diff --git a/edit_component_value.h b/edit_component_value.h new file mode 100644 index 0000000..37c85a7 --- /dev/null +++ b/edit_component_value.h @@ -0,0 +1,319 @@ +#ifndef EDIT_COMPONENT_VALUE_H_INCLUDED +#define EDIT_COMPONENT_VALUE_H_INCLUDED + +#include + + +using namespace std; + +#define KEY_LEFT 75 +#define KEY_RIGHT 77 + + +//Andrei CEREBU pana jos + +void creare_nume_componenta(int indx, char nume_componenta[], char unitate_masura[]) +{ + switch(indx) + { + case 1: + strcpy(nume_componenta,"Rezistor"); + strcpy(unitate_masura,"Ohm"); + break; + case 2: + strcpy(nume_componenta,"Fuse"); + strcpy(unitate_masura,"Ohm"); + break; + case 3: + strcpy(nume_componenta,"Battery"); + strcpy(unitate_masura,"Volts"); + break; + case 4: + strcpy(nume_componenta,"Dioda"); + strcpy(unitate_masura,"Ohm"); + break; + case 5: + strcpy(nume_componenta,"Ampermeter"); + strcpy(unitate_masura,"Ohm"); + break; + case 6: + strcpy(nume_componenta,"Voltmeter"); + strcpy(unitate_masura,"Ohm"); + break; + case 7: + strcpy(nume_componenta,"Capacitor"); + strcpy(unitate_masura,"Farad"); + break; + case 8: + strcpy(nume_componenta,"Transistor"); + strcpy(unitate_masura,"Ohm"); + break; + case 9: + strcpy(nume_componenta,"Light bulb"); + strcpy(unitate_masura,"Ohm"); + break; + } +} + +int menu_selection_edit_value_window(int W, int H, int x, int y) +{ + //enter button + if((x>W/2-W/10&&xH/2+3*H/12-H/12&&yW-3*W/32-3*W/40&&xH/10-2*H/30&&y14) nr_elem-=14; + else nr_elem=0; + strcpy(aux,aux+nr_elem); + + settextstyle(COMPLEX_FONT,0,1); + outtextxy(W/2-W/5-W/60,H/3+H/9+H/30,aux); +} + +int det_numar_elemente(char number_initial[]) +{ + int nr_elem=0, i=0; + while(number_initial[i]!=0) + { + ++nr_elem; + ++i; + } + return nr_elem; +} + + +void convert_value_to_string(char number[], int nr) +{ + int lenght=0; + + do + { + number[lenght]=nr%10+'0'; + nr/=10; + lenght+=1; + } + while(nr); + + + for(int i=0; i'9') + return -1; + nr=nr*10+(number[i]-'0'); + } + return nr; +} + + + +int edit_value_window(int W, int H, float R, int indx, int value) +{ + + char number[10000]; + convert_value_to_string(number, value); + + + int project_window1=initwindow(W/4,H/4,"Edit component",W/3,H/3,0,0); + + POINT cursorPos; + char aux[10000], c, ex, number_initial[100000], unitate_masura[10], + nume_componenta[20]; + + int nr_elem=0, poz=0, cursor=0, xMouse, yMouse, + nr_elem_number_initial=det_numar_elemente(number_initial); + + bool modif=false, afisare_numar_initial=false; + + strcpy(number_initial,number);//se copiaza numarul initial + + creare_nume_componenta(indx,nume_componenta,unitate_masura); + + draw_edit_value_window(W/4,H/4,R,poz,nume_componenta,unitate_masura); + + while(true) + { + GetCursorPos(&cursorPos); + ScreenToClient(GetForegroundWindow(), &cursorPos); + + if(kbhit()) + { + c=getch(); + if(c&&c!=224) + { + if(c==8&&nr_elem&&poz) + { + strcpy(number+poz-1,number+poz); + nr_elem--; + --poz; + } + else if(c==13) + { + closegraph(project_window1); + return 0; + } + else if(nr_elem<10000&&c>=' '&&c<='~') + { + for(int i=nr_elem; i>poz; i--) + number[i]=number[i-1]; + number[poz]=c; + ++poz; + ++nr_elem; + number[nr_elem]=0; + } + } + else + { + switch(ex=getch()) + { + case KEY_LEFT: + if(poz>0) + --poz; + break; + case KEY_RIGHT: + if(poz14) + cursor=14; + else cursor=poz; + + //create new frame + cleardevice(); + draw_edit_value_window(W/4,H/4,cursor,poz,nume_componenta,unitate_masura); + strcpy(aux,number); + print_number_on_edit_value_screen(W/4,H/4,aux,nr_elem); + if(nr_elem==0) + afisare_numar_initial=false; + } + if(afisare_numar_initial==false) + { + afisare_numar_initial=true; + + cleardevice(); + draw_edit_value_window(W/4,H/4,cursor,poz,nume_componenta,unitate_masura); + strcpy(aux,number_initial); + print_number_on_edit_value_screen(W/4,H/4,aux,nr_elem_number_initial); + } + if(ismouseclick(WM_LBUTTONDOWN)) + { + getmouseclick(WM_LBUTTONDOWN,xMouse,yMouse); + switch(menu_selection_edit_value_window(W/4,H/4,xMouse,yMouse)) + { + case 1://Enter was pressed + { + int val = convert_string_to_value(number); + if(val==-1) + { + //mesaj eroare + } + else + { + closegraph(project_window1); + memset(number, 0, 10000); + memset(number_initial, 0, 10000); + memset(aux, 0, 10000); + return val; + } + break; + } + case 2://back was pressed + strcpy(number,number_initial); + closegraph(project_window1); + memset(number, 0, 10000); + memset(number_initial, 0, 10000); + memset(aux, 0, 10000); + return value; + break; + case 0: + clearmouseclick(WM_LBUTTONDOWN); + break; + } + } + } +} + +#endif // EDIT_COMPONENT_VALUE_H_INCLUDED diff --git a/filename b/filename new file mode 100644 index 0000000..1619e4a --- /dev/null +++ b/filename @@ -0,0 +1 @@ +AT \ No newline at end of file diff --git a/functii_auxiliare.h b/functii_auxiliare.h new file mode 100644 index 0000000..e6faa6b --- /dev/null +++ b/functii_auxiliare.h @@ -0,0 +1,26 @@ +#ifndef FUNCTII_AUXILIARE_H_INCLUDED +#define FUNCTII_AUXILIARE_H_INCLUDED + +//Tudor Ilade +///Functie responsabila pentru a gasi calea absoluta a imaginilor folosite in proiect, indiferent de locatia proiectului pe dispozitiv +char* path_for_images(char* filename, char *path) +{ + char *path_for_file=new char[strlen(path)+strlen(filename)+4]; + *path_for_file='\0'; + strcat(path_for_file,path); + strcat(path_for_file,"\\"); + strcat(path_for_file,filename); + + return path_for_file; +} + +char* create_fixed_path(){ + char cwd[256]; + getcwd(cwd,256); + char* path = new char[strlen(cwd)+4]; + *path = '\0'; + strcat(path,cwd); + return path; +} + +#endif // FUNCTII_AUXILIARE_H_INCLUDED diff --git a/icon.jpg b/icon.jpg new file mode 100644 index 0000000..6b62d52 Binary files /dev/null and b/icon.jpg differ diff --git a/lib_finder.script b/lib_finder.script new file mode 100644 index 0000000..636d79b --- /dev/null +++ b/lib_finder.script @@ -0,0 +1,7 @@ +function SetBuildOptions(base) +{ + if ( "LibFinder" in getroottable() ) + { + LibFinder.SetupTarget(base); + } +} diff --git a/main.cpp b/main.cpp new file mode 100644 index 0000000..730753b --- /dev/null +++ b/main.cpp @@ -0,0 +1,862 @@ +///LIBRARIES +#include +#include +#include +#include +#include +#include +#include +#include + +///HEADERS +#include "startup_page.h" +#include "workplace_page.h" +#include "menu_selection.h" +#include "stare_table.h" +#include "new_project_name_reading_window.h" +#include "drawing_components.h" +#include "messages_panels_main_menu.h" +#include "open_save.h" +#include "change_color_panel.h" +#include "messages_log_panel.h" +#include "edit_component_value.h" +#include "zoom_rotate_fader_workplace.h" +#include "choose_from_two_options.h" +#include "functii_auxiliare.h" + +using namespace std; + + + +//Tudor ILADE && Andrei CERBU + +int main() +{ + + //Tudor Ilade + DWORD W = GetSystemMetrics(SM_CXSCREEN); + DWORD H = GetSystemMetrics(SM_CYSCREEN); + POINT cursorPos; + + RECTANGLE RECT[5]; + RECTANGLE_FULL RECT_FULL[5]; + RECTANGLE MAXIMUM_ROTATION_RECT; + + SWITCHSTATE switcher; + SITUATIA_TABLEI project; + HISTORY stackk; + + float R = (float)(W/H), zoom; + + bool panel=false, click_l=false, aprinde=false, turnOn; + + char filename[1024], *current_directory=create_fixed_path(); + + int x, y, ans, xMouse, yMouse, component_selected, + linking, right_menu, left_menu, top_menu, bulb=1, + undoRedo, type=1, type_line, ndxCmp, cmp, legNdx, + menu_select,center_fader=36.2*H/32*R, color=WHITE, + top_fader=19.7*H/22*R, angle, slider, indx; + + int main_window=initwindow(W,H,"Electron"); + draw_main_menu(W,H,R,current_directory); + + while(true) + { + //TudorIlade + //Main Menu + if(panel==0) + { + GetCursorPos(&cursorPos); + ScreenToClient(GetForegroundWindow(), &cursorPos); + + change_color_icon_startup_page(menu_selection_startup_page(W,H,R,cursorPos.x,cursorPos.y),W,H,R); + + if(ismouseclick(WM_LBUTTONDOWN)) + { + getmouseclick(WM_LBUTTONDOWN, x, y); + menu_select=menu_selection_startup_page(W,H,R,x,y); + + switch(menu_select) + { + case 0: + clearmouseclick(WM_LBUTTONDOWN); + break; + case 1: + if(project.open) + { + //Andrei CERBU + int value=choose_from_two_options(W/4,H/4,R); + setcurrentwindow(main_window); + switch(value) + { + case 1: + draw_working_table(W,H,R,current_directory); + + drawAllComponents(project,W,H,R,WHITE); + panel=1; + break; + case 2: + if(new_project_name_reading_window(W/4,H/4,R,filename)==1) + { + panel=1; + setcurrentwindow(main_window); + project=create_project(project,filename); + project.open = true; + draw_working_table(W,H,R,current_directory); + } + else + { + panel=0; + setcurrentwindow(main_window); + } + break; + } + } + //Tudor Ilade + else + { + if(new_project_name_reading_window(W/4,H/4,R,filename)==1) + { + + panel=1; + setcurrentwindow(main_window); + project=create_project(project,filename); + project.open = true; + draw_working_table(W,H,R,current_directory); + + } + else + { + panel=0; + setcurrentwindow(main_window); + } + } + break; + case 2: + //Tudor ILADE + project=open_dialog(1,project); + if(project.ans==-2||project.ans==-1||project.ans==-3) + { + if(project.ans!=-3) + error_code_main_menu(W,H,project.ans); + setcurrentwindow(main_window); + panel=0; + } + else + { + succes_panel_main_menu(W,H); + panel=1; + setcurrentwindow(main_window); + project.open = true; + draw_working_table(W,H,R,current_directory); + + delay(10); + draw_components_from_file(project,W,H); + } + break; + case 3: + openHtml(current_directory); + break; + case 4: + closegraph(); + return 0; + break; + } + } + } + //Workbench + else if(panel==1) + { + GetCursorPos(&cursorPos); + ScreenToClient(GetForegroundWindow(), &cursorPos); + + change_color_icon_top_menu_workplace_page(W,H,R,top_menu_workplace_page(W,H,R,cursorPos.x,cursorPos.y)); + change_color_icon_left_menu_workplace_page(W,H,R,left_menu_workplace_page(W,H,R,cursorPos.x,cursorPos.y)); + change_color_icon_right_menu_workplace_page(W,H,R,right_menu_workplace_page(W,H,R,cursorPos.x,cursorPos.y)); +//Tudor ILADE + if(ismouseclick(WM_LBUTTONDOWN)) + { + getmouseclick(WM_LBUTTONDOWN,x,y); + + top_menu=top_menu_workplace_page(W,H,R,x,y); + left_menu=left_menu_workplace_page(W,H,R,x,y); + right_menu=right_menu_workplace_page(W,H,R,x,y); + undoRedo=undo_redo_menu_workplace_page(W,H,R,x,y); + component_selected=isComponentselected(project,x,y,R); + linking=isLinking(project, W,H,x,y,R,CMP); + switcher=turnLight(W,H,R,x,y,switcher); + + turnOn = turnBulbOn(project); + if(turnBulbOn(project)&&aprinde) + color=YELLOW; + else //apelez functia aici de stingere + { + readimagefile(path_for_images("becstins.jpg",current_directory),W-W/9+W/34,0.2*H/16,W-W/6.5+W/34,1.6*H/16); + color=WHITE; + } + + if(!turnBulbOn(project) && color==YELLOW) + { + color = WHITE; + readimagefile(path_for_images("becstins.jpg",current_directory),W-W/9+W/34,0.2*H/16,W-W/6.5+W/34,1.6*H/16); + } +//Tudor ILADE + if(left_menu) + { + messages_log_panel(" ",W,H,R,W/9,H/16); + do + { + if(ismouseclick(WM_LBUTTONDOWN)) + { + getmouseclick(WM_LBUTTONDOWN,xMouse,yMouse); + if(!top_menu_workplace_page(W,H,R,xMouse,yMouse) && !left_menu_workplace_page(W,H,R,xMouse,yMouse) && + !right_menu_workplace_page(W,H,R,xMouse,yMouse) && !undo_redo_menu_workplace_page(W,H,R,xMouse,yMouse)&&left_menu) + { + draw_components_on_working_table(left_menu,W,H,xMouse,yMouse,R,0,1.0,BLACK,CMP); + drawAllComponents(project, W, H, R, color); + generate_rectangle_struct(RECT, CMP, left_menu); + generate_rectangle_full_struct(RECT_FULL,CMP, left_menu); + MAXIMUM_ROTATION_RECT=generate_maximum_rotation(W/10,H/16,R,xMouse, yMouse,1.0,left_menu); + if(!isColision(MAXIMUM_ROTATION_RECT,H,W,project,R,left_menu)) + { + draw_components_on_working_table(left_menu,W,H,xMouse,yMouse,R,0,1.0,WHITE,CMP); + generate_rectangle_struct(RECT, CMP,left_menu); + generate_rectangle_full_struct(RECT_FULL,CMP, left_menu); + project=creare_obiect(project,left_menu,xMouse,yMouse,W,H,R, RECT, RECT_FULL, MAXIMUM_ROTATION_RECT); + stackk=actualizareStiva(stackk,project); + messages_log_panel(" ",W,H,R,W/9,H/16); + messages_log_panel("Done!",W,H,R,W/9,H/16); + } + else{ + messages_log_panel(" ",W,H,R,W/9,H/16); + messages_log_panel("Colision!",W,H,R,W/9,H/16); + } + } + else if(left_menu_workplace_page(W,H,R,xMouse,yMouse)!=left_menu) + left_menu=left_menu_workplace_page(W,H,R,xMouse,yMouse), + change_color_icon_left_menu_workplace_page(W,H,R,0), + change_color_icon_left_menu_workplace_page(W,H,R,left_menu_workplace_page(W,H,R,xMouse,yMouse)); + else if(left_menu_workplace_page(W,H,R,xMouse,yMouse)==left_menu) + break; + else if(top_menu_workplace_page(W,H,R,xMouse,yMouse)) + break; + else if(right_menu_workplace_page(W,H,R,xMouse,yMouse)) + break; + else if(undo_redo_menu_workplace_page(W,H,R,xMouse,yMouse)) + break; + } + } + while(true); + } +//Tudor ILADE + else if(top_menu) + { + messages_log_panel(" ",W,H,R,W/9,H/16); + switch(top_menu) + { + case 1: + panel=0; + + delay(50); + succes_panel_main_menu(W,H); + delay(50); + setcurrentwindow(main_window); + cleardevice(); + draw_main_menu(W,H,R,current_directory); + break; + case 2: + project=open_dialog(1,project); + if(project.ans==-2||project.ans==-1||project.ans==-3) + { + if(project.ans!=-3) + error_code_main_menu(W,H,project.ans); + setcurrentwindow(main_window); + } + else + { + succes_panel_main_menu(W,H); + setcurrentwindow(main_window); + + delay(10); + draw_working_table(W,H,R,current_directory); + + + delay(10); + + draw_components_from_file(project,W,H); + stackk=emptyStack(stackk); + } + break; + case 3: + ans = save_project(project, project.path_file); + if(ans==-1) + { + error_code_main_menu(W,H,ans); + setcurrentwindow(main_window); + } + else + { + succes_panel_main_menu(W,H); + setcurrentwindow(main_window); + delay(10); + } + break; + case 4: + project=open_dialog(2,project); + if(project.ans==-1||project.ans==-3) + { + if(project.ans!=-3) + error_code_main_menu(W,H,project.ans); + setcurrentwindow(main_window); + } + else + { + succes_panel_main_menu(W,H); + setcurrentwindow(main_window); + + delay(10); + draw_working_table(W,H,R,current_directory); + + + delay(10); + + draw_components_from_file(project,W,H); + } + break; + case 5: + openHtml(current_directory); + break; + case 6: + project=stergere_tabla(project); + actualizareStiva(stackk,project); + + cleardevice(); + draw_working_table(W,H,R,current_directory); + + + break; + } + } + else if(right_menu) + { +//Andrei CERBU + switch(right_menu) + { + case 1://check integrity + if(checkIntegrity(project)){ + messages_log_panel(" ",W,H,R,W/9,H/16); + messages_log_panel("Connected!",W,H,R,W/9,H/16); + } + else{ + messages_log_panel(" ",W,H,R,W/9,H/16); + messages_log_panel("Disconnected!",W,H,R,W/9,H/16); + } + break; + case 2: + messages_log_panel("Choose a component!",W,H,R,W/9,H/16); + clearmouseclick(WM_LBUTTONDOWN); + int last_y; + do + { + if(ismouseclick(WM_LBUTTONDOWN)) + { + getmouseclick(WM_LBUTTONDOWN,x,y); + if(isComponentselected(project,x,y,R)) + { + int ndxCmp=getIndexOfComponent(project, x,y,R); + change_color_icon_zoom_rotate_menu_workplace_page(W,H,R,W/10,H/22,RED); + clearmouseclick(WM_LBUTTONDOWN); + //create_zoom_rotate_panel_workplace(W,H,R,W/10,H/22,BLACK); + //create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,convert_angle_to_y(project.v[ndxCmp].angle, top_fader),1,WHITE); + //create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,convert_zoom_to_y(project.v[ndxCmp].zoom, center_fader),2,WHITE); + do + { + + if(ismouseclick(WM_LBUTTONDOWN)) + { + getmouseclick(WM_LBUTTONDOWN, x, y); + clearmouseclick(WM_LBUTTONDOWN); + slider = determine_angle_fader_position(W,H,R,W/10,H/22,x,y); + + if(slider) + { + + + draw_black_zoom_rotate_panel(W,H,R,W/10,H/22, slider); + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,R,project.v[ndxCmp].angle,project.v[ndxCmp].zoom,BLACK,CMP); + do + { + yMouse=mousey(); + xMouse=mousex(); + if(betweenBars(W,H, R, W/10, H/22, xMouse, yMouse, slider)) + { + if(slider==1) + { + angle=convert_y_to_angle(yMouse,top_fader); + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,R,angle,project.v[ndxCmp].zoom,WHITE,CMP); + generate_rectangle_struct(RECT, CMP, project.v[ndxCmp].type); + generate_rectangle_full_struct(RECT_FULL,CMP, project.v[ndxCmp].type); + draw_moving_line(project,ndxCmp,color,W,H,R,RECT); + + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,last_y,slider,BLACK); + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,yMouse,slider,WHITE); + + delay(50); + + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,R,angle,project.v[ndxCmp].zoom,BLACK,CMP); + generate_rectangle_struct(RECT, CMP, project.v[ndxCmp].type); + generate_rectangle_full_struct(RECT_FULL,CMP,project.v[ndxCmp].type); + draw_moving_line(project,ndxCmp,BLACK,W,H,R,RECT); + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,yMouse,slider,BLACK); + } + else + { + zoom=convert_y_to_zoom(yMouse,center_fader); + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,R,project.v[ndxCmp].angle,zoom,WHITE,CMP); + generate_rectangle_struct(RECT, CMP, type); + generate_rectangle_full_struct(RECT_FULL,CMP, type); + draw_moving_line(project,ndxCmp,color,W,H,R,RECT); + + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,last_y,slider,BLACK); + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,yMouse,slider,WHITE); + + delay(50); + + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,R,project.v[ndxCmp].angle,zoom,BLACK,CMP); + draw_moving_line(project,ndxCmp,BLACK,W,H,R,RECT); + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,yMouse,slider,BLACK); + } + last_y = yMouse; + } + else + { + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,last_y,slider,WHITE); + if(slider==1) + { + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,R,angle,project.v[ndxCmp].zoom,WHITE,CMP); + generate_rectangle_struct(RECT, CMP, project.v[ndxCmp].type); + generate_rectangle_full_struct(RECT_FULL,CMP, project.v[ndxCmp].type); + draw_moving_line(project,ndxCmp,color,W,H,R,RECT); + + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,last_y,slider,BLACK); + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,last_y,slider,WHITE); + + delay(50); + + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,R,angle,project.v[ndxCmp].zoom,BLACK,CMP); + generate_rectangle_struct(RECT, CMP, project.v[ndxCmp].type); + generate_rectangle_full_struct(RECT_FULL,CMP,project.v[ndxCmp].type); + draw_moving_line(project,ndxCmp,BLACK,W,H,R,RECT); + } + else + { + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,R,project.v[ndxCmp].angle,zoom,WHITE,CMP); + generate_rectangle_struct(RECT, CMP, type); + generate_rectangle_full_struct(RECT_FULL,CMP, type); + draw_moving_line(project,ndxCmp,color,W,H,R,RECT); + + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,last_y,slider,BLACK); + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,last_y,slider,WHITE); + + delay(50); + + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,R,project.v[ndxCmp].angle,zoom,BLACK,CMP); + draw_moving_line(project,ndxCmp,BLACK,W,H,R,RECT); + } + } + + if(ismouseclick(WM_LBUTTONDOWN)) + break; + } + while(true); + clearmouseclick(WM_LBUTTONDOWN); + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,yMouse,slider,WHITE); + if(slider==1) + { + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,R,angle,project.v[ndxCmp].zoom,WHITE,CMP); + generate_rectangle_struct(RECT, CMP, type); + generate_rectangle_full_struct(RECT_FULL,CMP, type); + + draw_moving_line(project,ndxCmp,WHITE,W,H,R,RECT); + project = actualizareTabla(project, ndxCmp,project.v[ndxCmp].x1,project.v[ndxCmp].y1,W,H,R,angle,project.v[ndxCmp].zoom, RECT, RECT_FULL, project.v[ndxCmp].outsideRect); + stackk=actualizareStiva(stackk,project); + drawAllComponents(project, W,H,R,color); + + } + else + { + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,R,project.v[ndxCmp].angle,zoom,BLACK,CMP); + generate_rectangle_full_struct(RECT_FULL, CMP, type); + generate_rectangle_struct(RECT, CMP, type); + MAXIMUM_ROTATION_RECT = generate_maximum_rotation(W/10,H/16,R,project.v[ndxCmp].x1, project.v[ndxCmp].y1,zoom, R); + draw_moving_line(project,ndxCmp,color,W,H,R,RECT); + + project = actualizareTabla(project, ndxCmp,project.v[ndxCmp].x1,project.v[ndxCmp].y1,W,H,R,project.v[ndxCmp].angle,zoom, RECT, RECT_FULL, MAXIMUM_ROTATION_RECT); + stackk=actualizareStiva(stackk,project); + drawAllComponents(project, W,H,R,color); + + } + } + } + if(right_menu_workplace_page(W,H,R,x,y)==2) + break; + + } + while(true); + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,convert_angle_to_y(angle, top_fader),1,BLACK); + create_zoom_rotate_fader_workplace(W,H,R,W/10,H/22,convert_zoom_to_y(zoom, center_fader),2,BLACK); + create_zoom_rotate_panel_workplace(W,H,R,W/10,H/22,WHITE); + } + if(right_menu_workplace_page(W,H,R,x,y)==2) + break; + } + } + while(true); + change_color_icon_zoom_rotate_menu_workplace_page(W,H,R,W/10,H/22,WHITE); + + messages_log_panel(" ",W,H,R,W/9,H/16); + messages_log_panel("Done!",W,H,R,W/9,H/16); + + break; + case 3://delete component +//Tudor ILADE + messages_log_panel("Choose a component!",W,H,R,W/9,H/16); + do + { + click_l=ismouseclick(WM_LBUTTONDOWN); + getmouseclick(WM_LBUTTONDOWN,xMouse,yMouse); + + if(click_l) + { + cmp=getIndexOfComponent(project,xMouse,yMouse,R); + if(right_menu_workplace_page(W,H,R,xMouse,yMouse)==3) + break; + if(cmp!=-1) + { + draw_components_on_working_table(project.v[cmp].type,W,H,project.v[cmp].x1, project.v[cmp].y1,project.v[cmp].R,project.v[cmp].angle,project.v[cmp].zoom,BLACK,CMP); + drawAllLinesBack(project,cmp,W,H,R); + project=deleteComponent(project,cmp); + stackk=actualizareStiva(stackk,project); + drawAllComponents(project,W,H,R,color); + } + } + } + while(true); + + messages_log_panel(" ",W,H,R,W/9,H/16); + messages_log_panel("Done!",W,H,R,W/9,H/16); + + break; + case 4://Delete linking +//Tudor Ilade + messages_log_panel("Choose a linking!",W,H,R,W/9,H/16); + do + { + if(ismouseclick(WM_LBUTTONDOWN)) + { + getmouseclick(WM_LBUTTONDOWN,xMouse,yMouse); + legNdx=isLinkSelected(project,xMouse,yMouse); + + if(legNdx!=-1) + { + project=stergeLegatura(project,legNdx); + stackk=actualizareStiva(stackk,project); + + drawAllComponents(project,W,H,R,color); + } + else if(right_menu_workplace_page(W,H,R,xMouse,yMouse)||!right_menu_workplace_page(W,H,R,xMouse,yMouse)) + break; + } + } + while(true); + + messages_log_panel(" ",W,H,R,W/9,H/16); + messages_log_panel("Done!",W,H,R,W/9,H/16); + + break; + case 5: + messages_log_panel("Choose a component!",W,H,R,W/9,H/16); + do + { + if(ismouseclick(WM_LBUTTONDOWN)) + { + + getmouseclick(WM_LBUTTONDOWN,xMouse,yMouse); + if(isComponentselected(project,xMouse,yMouse,R)) + { + cmp=getIndexOfComponent(project,xMouse,yMouse,R); + indx=project.v[cmp].type; + int value_cmp=edit_value_window(W,H,R,indx, project.v[cmp].value); + project.v[cmp].value=value_cmp; + + + setcurrentwindow(main_window); + break; + } + else break; + } + } + while(true); + setcurrentwindow(main_window); + + messages_log_panel(" ",W,H,R,W/9,H/16); + messages_log_panel("Done!",W,H,R,W/9,H/16); + + break; +//Tudor Ilade + case 6://Select linking type + messages_log_panel("Choose a linking type!",W,H,R,W/9,H/16); + + delay(40); + + create_drawing_line_type_menu_workplace(W,H,R,W/10,H/22,WHITE); + drawing_line_type(W,H,R,W/10,H/22,WHITE); + + do + { + xMouse=mousex(); + yMouse=mousey(); + if(type) + change_color_icon_drawing_line_type_menu_workplace(W,H,R,type,type); + change_color_icon_drawing_line_type_menu_workplace(W,H,R,line_type_menu_workplace(W,H,R,xMouse,yMouse),type); + + + if(ismouseclick(WM_LBUTTONDOWN)) + { + getmouseclick(WM_LBUTTONDOWN,xMouse,yMouse); + if(line_type_menu_workplace(W,H,R,xMouse,yMouse)==0) + break; + else if(type==0||line_type_menu_workplace(W,H,R,xMouse,yMouse)&&line_type_menu_workplace(W,H,R,xMouse,yMouse)!=type) + type=line_type_menu_workplace(W,H,R,xMouse,yMouse); + else if(line_type_menu_workplace(W,H,R,xMouse,yMouse)==type) + type=0; + } + } + while(true); + + delay(50); + + create_drawing_line_type_menu_workplace(W,H,R,W/10,H/22,BLACK); + drawing_line_type(W,H,R,W/10,H/22,BLACK); + + messages_log_panel(" ",W,H,R,W/9,H/16); + messages_log_panel("Done!",W,H,R,W/9,H/16); + + break; + } + } +//Tudor Ilade + else if(undoRedo) + { + messages_log_panel(" ",W,H,R,W/9,H/16); + switch(undoRedo) + { + case 1://Undo + do + { + getmouseclick(WM_LBUTTONDBLCLK,xMouse,yMouse); + drawAllComponents(project,W,H,R,BLACK); + project=URfnc(stackk,undoRedo,project); + drawAllComponents(project,W,H,R,color); + } + while(undo_redo_menu_workplace_page(W,H,R,xMouse,yMouse)==1); + break; + case 2://Redo + do + { + getmouseclick(WM_LBUTTONDBLCLK,xMouse,yMouse); + drawAllComponents(project,W,H,R,BLACK); + project=URfnc(stackk,undoRedo,project); + drawAllComponents(project,W,H,R,color); + } + while(undo_redo_menu_workplace_page(W,H,R,xMouse,yMouse)==2); + break; + } + } +//Tudor Ilade + else if(component_selected && !linking) + { + messages_log_panel(" ",W,H,R,W/9,H/16); + ndxCmp=getIndexOfComponent(project,x,y,R); + getmouseclick(WM_LBUTTONDBLCLK,xMouse,yMouse); + clearmouseclick(WM_LBUTTONDBLCLK); + + draw_components_on_working_table(project.v[ndxCmp].type,W,H,project.v[ndxCmp].x1,project.v[ndxCmp].y1,project.v[ndxCmp].R,project.v[ndxCmp].angle,project.v[ndxCmp].zoom,BLACK,CMP); + generate_rectangle_struct(RECT, CMP, project.v[ndxCmp].type); + generate_rectangle_full_struct(RECT_FULL,CMP, project.v[ndxCmp].type); + draw_moving_line(project, ndxCmp, BLACK, W,H,R,RECT); + do + { + click_l=ismouseclick(WM_LBUTTONDOWN); + x=mousex(); + y=mousey(); + MAXIMUM_ROTATION_RECT = generate_maximum_rotation(W/10,H/16,R,x,y,project.v[ndxCmp].zoom, project.v[ndxCmp].type); + if(click_l) + { + getmouseclick(WM_LBUTTONDOWN,x,y); + break; + } + if(outSideTable(x,y,H,W,R,MAXIMUM_ROTATION_RECT, project.v[ndxCmp].type)) + { + + messages_log_panel("A depasit limitele tablei!",W,H,R,W/9,H/16); + delay(50); + break; + } + if(xMouse!=x||yMouse!=y) + { + draw_components_on_working_table(project.v[ndxCmp].type,W,H,x,y,R,project.v[ndxCmp].angle,project.v[ndxCmp].zoom,WHITE,CMP); + generate_rectangle_struct(RECT, CMP, project.v[ndxCmp].type); + generate_rectangle_full_struct(RECT_FULL,CMP, project.v[ndxCmp].type); + draw_moving_line(project, ndxCmp,color,W,H,R, RECT); + + delay(40); + + draw_components_on_working_table(project.v[ndxCmp].type,W,H,x,y,R,project.v[ndxCmp].angle,project.v[ndxCmp].zoom,BLACK,CMP); + generate_rectangle_struct(RECT, CMP, project.v[ndxCmp].type); + generate_rectangle_full_struct(RECT_FULL,CMP, project.v[ndxCmp].type); + draw_moving_line(project,ndxCmp,BLACK,W,H,R, RECT); + drawComponentsXSelected(project, ndxCmp, W, H, R, color); + } + } + while(true); + MAXIMUM_ROTATION_RECT = generate_maximum_rotation(W/10,H/16,R,x,y,1.0, project.v[ndxCmp].type); + if(!isColision(MAXIMUM_ROTATION_RECT,H,W,project,R,project.v[ndxCmp].type,ndxCmp)) + { + drawAllLinesBack(project,ndxCmp,W,H,R); + draw_components_on_working_table(project.v[ndxCmp].type,W,H,x,y,R,project.v[ndxCmp].angle,project.v[ndxCmp].zoom,BLACK,CMP); + generate_rectangle_struct(RECT, CMP,project.v[ndxCmp].type); + generate_rectangle_full_struct(RECT_FULL, CMP, project.v[ndxCmp].type); + project=actualizareTabla(project,ndxCmp,x,y,W,H,project.v[ndxCmp].R,project.v[ndxCmp].angle,project.v[ndxCmp].zoom, RECT, RECT_FULL, MAXIMUM_ROTATION_RECT); + stackk=actualizareStiva(stackk, project); + drawAllComponents(project,W, H, R, color); + messages_log_panel(" ",W,H,R,W/9,H/16); + messages_log_panel("Done!",W,H,R,W/9,H/16); + } + else + { + messages_log_panel(" ",W,H,R,W/9,H/16); + messages_log_panel("Coliziune",W,H,R,W/9,H/16); + drawAllComponents(project, W, H, R, color); + } + + } +//Tudor Ilade + else if(linking) + { + messages_log_panel(" ",W,H,R,W/9,H/16); + punctLegatura leg1, leg2; + int ndx = getIndexOfComponent(project,x,y,R); + COMPONENTE cmp = project.v[ndx]; + leg1.x = x; + leg1.y = y; + leg1.sd = linking; + leg1.type = type; + xMouse = mousex(); + yMouse = mousey(); + click_l=0; + do + { + drawLine(leg1.x,leg1.y, xMouse,yMouse, WHITE,leg1.type); + delay(50); + drawLine(leg1.x,leg1.y, xMouse,yMouse, BLACK,leg1.type); + drawAllComponents(project, W,H,R, WHITE); + + xMouse=mousex(); + yMouse=mousey(); + if(outSideTable(xMouse,yMouse,H,W,R,MAXIMUM_ROTATION_RECT)) + { + delay(50); + break; + } + click_l = ismouseclick(WM_LBUTTONDOWN); + if(click_l) + break; + + + } + while(true); + click_l=0; + clearmouseclick(WM_LBUTTONDOWN); + clearmouseclick(click_l); + xMouse = mousex(); + yMouse = mousey(); + int leg = isLinking(project,W,H,xMouse,yMouse,R,CMP,ndx); + if(leg) + { + int ndx2 = getIndexOfComponent(project,xMouse,yMouse,R); + drawLine(leg1.x,leg1.y, xMouse,yMouse, WHITE,leg1.type); + leg1.xConnection = xMouse; + leg1.yConnection = yMouse; + leg1.ndxParent = ndx; + leg2.sd = leg; + leg2.x = xMouse; + leg2.y = yMouse; + leg2.ndxParent = ndx2; + leg2.xConnection = leg1.x; + leg2.yConnection = leg1.y; + leg2.type = leg1.type; + pairPAIR; + PAIR.first = leg1; + PAIR.second = leg2; + project.p.push_back(PAIR); + project.v[ndx].legatura.push_back(PAIR); + project.v[ndx2].legatura.push_back(PAIR); + drawAllComponents(project, W,H,R, color); + stackk = actualizareStiva(stackk, project); + } + else + { + drawLine(leg1.x,leg1.y, xMouse,yMouse, BLACK,leg1.type); + drawAllComponents(project, W,H,R, color); + } + messages_log_panel("Done!",W,H,R,W/9,H/16); + } +//Tudor Ilade + else if(switcher.inOut) + { + messages_log_panel(" ",W,H,R,W/9,H/16); + if(switcher.bulb==1)//aprinde becu + { + if(turnOn) + { + readimagefile(path_for_images("bec_aprins.jpg",current_directory),W-W/9+W/34,0.2*H/16,W-W/6.5+W/34,1.6*H/16); + color=YELLOW; + aprinde=true; + messages_log_panel("Happy Circuit!",W,H,R,W/9,H/16); + drawAllComponents(project, W,H,R,color); + delay(100); + } + else + { + color=WHITE; + messages_log_panel("Not working!",W,H,R,W/9,H/16); + + } + } + else if(switcher.bulb==2)//stinge becu + { + if(turnOn) + { + readimagefile(path_for_images("becstins.jpg",current_directory),W-W/9+W/34,0.2*H/16,W-W/6.5+W/34,1.6*H/16); + aprinde=false; + color=WHITE; + drawAllComponents(project,W,H,R,color); + delay(100); + + messages_log_panel("Light off!",W,H,R,W/9,H/16); + } + else + { + color=WHITE; + messages_log_panel("Not working!",W,H,R,W/9,H/16); + + } + } + } + } + } + } +} + diff --git a/main.o b/main.o new file mode 100644 index 0000000..c177180 Binary files /dev/null and b/main.o differ diff --git a/menu_selection.h b/menu_selection.h new file mode 100644 index 0000000..9b4fe40 --- /dev/null +++ b/menu_selection.h @@ -0,0 +1,138 @@ +#ifndef MENU_SELECTION_H_INCLUDED +#define MENU_SELECTION_H_INCLUDED + + +//Andrei CERBU +int menu_selection_startup_page(int W, int H, int R, int x, int y) +{ + if((x>W/6&&xH/4&&yW/3&&xH/4&&yW/6&&x3*H/4-R*H/6&&y<3*H/4)) + return 3; + if((x>W/3&&x3*H/4-R*H/6&&y<3*H/4)) + return 4; + return 0; +} + +int top_menu_workplace_page(int W, int H, int R, int x, int y) +{ + int width_rectangle = W/12; + int height_rectangle = H/24; + + if((x>width_rectangle*3*R&&x<(width_rectangle*4)*R)&&(y>0&&ywidth_rectangle*4*R&&x0&&ywidth_rectangle*5*R&&x0&&ywidth_rectangle*6*R&&x0&&ywidth_rectangle*7*R&&x0&&ywidth_rectangle*8*R&&x0&&y0&&x<(width_rectangle-width_rectangle/9)*R)&&(y>(height_rectangle*3)*R&&y<(height_rectangle*4)*R)) + return 1; + if((x>0&&x<(width_rectangle-width_rectangle/9)*R)&&(y>(height_rectangle*4)*R&&y<(height_rectangle*5)*R)) + return 2; + if((x>0&&x<(width_rectangle-width_rectangle/9)*R)&&(y>(height_rectangle*5)*R&&y<(height_rectangle*6)*R)) + return 3; + if((x>0&&x<(width_rectangle-width_rectangle/9)*R)&&(y>(height_rectangle*6)*R&&y<(height_rectangle*7)*R)) + return 4; + if((x>0&&x<(width_rectangle-width_rectangle/9)*R)&&(y>(height_rectangle*7)*R&&y<(height_rectangle*8)*R)) + return 5; + if((x>0&&x<(width_rectangle-width_rectangle/9)*R)&&(y>(height_rectangle*8)*R&&y<(height_rectangle*9)*R)) + return 6; + if((x>0&&x<(width_rectangle-width_rectangle/9)*R)&&(y>(height_rectangle*9)*R&&y<(height_rectangle*10)*R)) + return 7; + if((x>0&&x<(width_rectangle-width_rectangle/9)*R)&&(y>(height_rectangle*10)*R&&y<(height_rectangle*11)*R)) + return 8; + if((x>0&&x<(width_rectangle-width_rectangle/9)*R)&&(y>(height_rectangle*11)*R&&y<(height_rectangle*12)*R)) + return 9; + return 0; +} + +int right_menu_workplace_page(int W, int H, float R, int x, int y) +{ + int width_rectangle = W/9; + int height_rectangle = H/16; + + if(x>(W-width_rectangle)*R&&x(height_rectangle*2)*R&&y<(height_rectangle*3)*R)) + return 1; + if(x>(W-width_rectangle)*R&&x(height_rectangle*3)*R&&y<(height_rectangle*4)*R)) + return 2; + if(x>(W-width_rectangle)*R&&x(height_rectangle*4)*R&&y<(height_rectangle*5)*R)) + return 3; + if(x>(W-width_rectangle)*R&&x(height_rectangle*5)*R&&y<(height_rectangle*6)*R)) + return 4; + if(x>(W-width_rectangle)*R&&x(height_rectangle*6)*R&&y<(height_rectangle*7)*R)) + return 5; + if(x>(W-width_rectangle)*R&&x(height_rectangle*7)*R&&y<(height_rectangle*8)*R)) + return 6; + return 0; + +} + + +//Tudor ILADE +int undo_redo_menu_workplace_page(int W, int H, float R, int x, int y) +{ + int width_rectangle = W/18; + int height_rectangle = H/16; + + if(x>=2*width_rectangle/9&&x<=width_rectangle&&y>=14.2*height_rectangle*R&&y<=15*height_rectangle*R) + return 1; + if(x>=width_rectangle&&x<=16*width_rectangle/9&&y>=14.2*height_rectangle*R&&y<=15*height_rectangle*R) + return 2; + return 0; +} + +//Tudor Ilade +int line_type_menu_workplace(int W, int H, float R, int x, int y) +{ + int width_rectangle = W/10; + int height_rectangle = H/22; + + if((x>(W-width_rectangle)*R&&x(height_rectangle*11.1)*R&&y<(height_rectangle*12.1)*R)) + return 1; + if((x>(W-width_rectangle)*R&&x(height_rectangle*12.1)*R&&y<(height_rectangle*13.1)*R)) + return 4; + if((x>(W-width_rectangle)*R&&x(height_rectangle*13.1)*R&&y<(height_rectangle*14.1)*R)) + return 2; + if((x>(W-width_rectangle)*R&&x(height_rectangle*14.1)*R&&y<(height_rectangle*15.1)*R)) + return 3; + return 0; +} + +//Tudor Ilade + +SWITCHSTATE turnLight(int W, int H, float R, int x, int y, SWITCHSTATE switcher) +{ + if((x>W-W/6.5+W/15)*R&&x<(W-W/9+W/12.5)*R&&(y>0.2*H/16&&y<1.6*H/16*R)) + { + switcher.inOut = true; + if(switcher.bulb==2) + switcher.bulb = 1; + else if(switcher.bulb==1) + switcher.bulb = 2; + return switcher; + } + + switcher.inOut = false; + switcher.bulb = 2; + return switcher; +} + + + +#endif // MENU_SELECTION_H_INCLUDED diff --git a/messages_log_panel.h b/messages_log_panel.h new file mode 100644 index 0000000..95b321c --- /dev/null +++ b/messages_log_panel.h @@ -0,0 +1,5 @@ +#ifndef MESSAGES_LOG_PANEL_H_INCLUDED +#define MESSAGES_LOG_PANEL_H_INCLUDED + + +#endif // MESSAGES_LOG_PANEL_H_INCLUDED diff --git a/messages_panels_main_menu.h b/messages_panels_main_menu.h new file mode 100644 index 0000000..5fe6ba1 --- /dev/null +++ b/messages_panels_main_menu.h @@ -0,0 +1,78 @@ +#ifndef ERROR_PANELS_MAIN_MENU_H_INCLUDED +#define ERROR_PANELS_MAIN_MENU_H_INCLUDED + +#include + +//Andrei CERBU pana jos + +void succes_panel_main_menu(int W, int H){ + int width=W/4,height=H/4; + POINT cursorPos; + bool click; + char text[]="Loading\0"; + int k=4, poz=8, timp=0; + + int panel=initwindow(width,height,"Loading panel",W/3,H/3,0,0); + + + while(k){ + settextstyle(COMPLEX_FONT,0,width/123); + outtextxy(width/2-width/5,height/3+height/20,text); + strcat(text,"."); + --k; + delay(1500-timp); + timp+=500; + } + closegraph(panel); + +} + + +void error_code_main_menu(int W, int H, int error){ + int width=W/4,height=H/4; + POINT cursorPos; + bool click; char c; + + int panel=initwindow(width,height,"Error",W/3,H/3,0,0); + + //first message + if(error==-1){ + settextstyle(COMPLEX_FONT,0,width/160); + outtextxy(width/6,height/3+height/20,"Error opening project"); + } + else if(error==-2){ + settextstyle(COMPLEX_FONT,0,width/160); + outtextxy(width/6+width/35,height/3+height/20,"Incorrect file type"); + } + + //second message + settextstyle(COMPLEX_FONT,0,width/213); + outtextxy(width/4+width/15,height/2,"Please try again"); + + //button for exit + rectangle(width/2-width/10,height/2+height/8,width/2+width/10,height/2+height/4); + settextstyle(COMPLEX_FONT,0,width/213); + outtextxy(width/2-width/20,height/2+height/7,"Back"); + + while(true){ + GetCursorPos(&cursorPos); + ScreenToClient(GetForegroundWindow(), &cursorPos); + click=ismouseclick(WM_LBUTTONDOWN); + bool menu=0; + if((cursorPos.x>width/2-width/10&&cursorPos.xheight/2+height/8&&cursorPos.y + +#define KEY_LEFT 75 +#define KEY_RIGHT 77 + + +//Andrei CERBU pana jos + +int menu_selection_reading_window(int W, int H, int x, int y){ + //enter button + if((x>W/2-W/10&&xH/2+3*H/12-H/12&&yW-3*W/32-3*W/40&&xH/10-2*H/30&&y14) nr_elem-=14; + else nr_elem=0; + strcpy(aux, aux+nr_elem); + outtextxy(W/2-W/5-W/60,H/3+H/9+H/50,aux); +} + +int new_project_name_reading_window(int W, int H, float R, char filename[]){ + + int project_window1=initwindow(W,H,"New Project panel",W/3,H/3,0,0); + + POINT cursorPos; + char aux[10000],c, ex; + filename[0]=0; + int nr_elem=0, poz=0, cursor=0, xMouse, yMouse; + bool modif=0; + + draw_new_project_name_reading_window(W,H,R,poz); + + while(true){ + GetCursorPos(&cursorPos); + ScreenToClient(GetForegroundWindow(), &cursorPos); + + if(kbhit()){ + c=getch(); + if(c&&c!=224){ + if(c==8&&nr_elem&&poz){ + strcpy(filename+poz-1,filename+poz); + nr_elem--; + --poz; + } + else if(c==13){ + closegraph(project_window1); + return 1; + } + else if(nr_elem<10000&&c>=' '&&c<='~'){ + for(int i=nr_elem; i>poz; i--) + filename[i]=filename[i-1]; + filename[poz]=c; + ++poz; + ++nr_elem; + filename[nr_elem]=0; + } + } + else{ + switch(ex=getch()){ + case KEY_LEFT: + if(poz>0) + --poz; + break; + case KEY_RIGHT: + if(poz14) + cursor=14; + else cursor=poz; + + //create new frame + cleardevice(); + + draw_new_project_name_reading_window(W,H,R,poz); + strcpy(aux,filename); + print_text_on_new_project_screen(W,H,aux,nr_elem); + } + else if(ismouseclick(WM_LBUTTONDOWN)){ + getmouseclick(WM_LBUTTONDOWN,xMouse,yMouse); + switch(menu_selection_reading_window(W,H,xMouse,yMouse)){ + case 1://Enter was pressed + closegraph(project_window1); + return 1; + break; + case 2://back was pressed + closegraph(project_window1); + return 2; + break; + case 0: + clearmouseclick(WM_LBUTTONDOWN); + break; + } + } + } +} + +#endif // NEW_PROJECT_NAME_READING_WINDOW_H_INCLUDED diff --git a/open_save.h b/open_save.h new file mode 100644 index 0000000..5e9b1c5 --- /dev/null +++ b/open_save.h @@ -0,0 +1,266 @@ +#ifndef OPEN_SAVE_H_INCLUDED +#define OPEN_SAVE_H_INCLUDED +///LIBRARIES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "drawing_components.h" +#include "stare_table.h" + + + +//Tudor ILADE toate functiile + + +///Functie responsabila de crearea fisierului de proiect in directorul Projects +char* path_for_projects_directory(int type=0) +{ + //se creaza path-ul catre directorul unde vor fi salvate proiectele + char cwd[256]; + getcwd(cwd, 256); + char* dir = new char[40]; + char* path = new char[strlen(cwd)+12+strlen(dir)]; + *path = '\0'; + *dir = '\0'; + strcat(dir, "Projects"); + strcat(path, cwd); + if(type==1) + return path; + strcat(path,"\\"); + strcat(path,dir); + + //Se verifica existenta directorului pentru proiecte + bool isDir = false; + struct stat info; + if(stat(path,&info)!=0) + isDir = false; + else if(info.st_mode & S_IFDIR) + isDir = true; + if(isDir==0) + { + //Directorul nu exista, deci + int check = mkdir(path); + if(!check) + { + return path; + } + } + else + { + //Directorul exista, deci returnam path-ul + return path; + } +} + + +///Functie responsabila de crearea unui proiect care returneaza path-ul catre fisier ul unde se va salva proiectul +SITUATIA_TABLEI create_project(SITUATIA_TABLEI tabla,char* file_name) +{ + char* path_to_file = new char[strlen(path_for_projects_directory())+strlen(file_name)+5]; + path_to_file = path_for_projects_directory(); + strcpy(tabla.path_to_dir,path_to_file); + strcat(path_to_file, "\\"); + strcat(path_to_file, file_name); + strcat(path_to_file, "\.AT"); + strcpy(tabla.path_file,path_to_file); + FILE* project; + project = fopen(path_to_file, "wb+"); + if(project==NULL) + { + exit(1); + tabla.ans=-1; + return tabla; + } + char header[2] = {'A', 'T'}; + fwrite(&header, sizeof(header),1,project); + fclose(project); + return tabla; +} + + +///Functie responsabila de salvarea tablei actuale in proiectul deschis. (se va folosi si pentru save as) +int save_project(SITUATIA_TABLEI &table, char* path) +{ + FILE* project; + project = fopen(path, "wb+"); + if(project == NULL) + { + return -1; + } + char header[2] = {'A', 'T'}; + fwrite(&header, sizeof(header),1,project); + + if(table.v.size()!=0) + { + for(int i=0; iPAIR; + PAIR.first = cmp.legatura[2*i]; + PAIR.second = cmp.legatura[2*i+1]; + cmp_table.legatura.push_back(PAIR); + } + tabla.v.push_back(cmp_table); + + } + for(int i =0; i + +
+
+ ElectronAT +
+
+

+ Acest proiect isi propune sa permita utilizatorului sa deseneze scheme electronice practice, conform indicatiilor oferite la seminar. Realizarea proiectului + a fost una plina de provocari, logica programului devenind foarte interesant de implementat. Scopul nostru a fost sa gandim un program + scalabil, care poate fi usor de intretinut si intuitiv de utilizat pentru user! +

+

+ In cele ce urmeaza, ne propunem sa prezentam functionalitatie principale ale programului si in ce mod poate fi folosit. +

+
+ +

+
+
+

Panoul principal

+ O data ce programul este lansat, panoul principal va fi primul care va aparea, ce va face posibila selectia urmatoarelor actiuni: +
    +
  1. Creaza nou proiect
  2. +
  3. Deschide un proiect existent
  4. +
  5. Info
  6. +
  7. Inchidere
  8. +
+

1) Creaza nou proiect

+

+ Utilizatorul poate opta pentru a crea un nou proiect, prin apasarea menu ului din partea stanga sus. In momentul in care acesta va fi selectat, + o casuta de dialog va fi aruncata care va cere drept input numele fisierului. Acest nume va fi preluat de catre program si se va crea un fisier binar + de tipul .AT cu numele dat. +

+

2) Deschide un proiect

+

+ Utilizatorul poate deschide un fisier de tip .AT deja existent. In momentul citirii, se va face o scurta verificare a integritatii fisierului + inainte de a se putea procesa informatia. +

+

3) Info

+

+ Pentru a citi mai multe despre modul de functionare a programului, se poate consulta pagina web aferenta prin selectarea panoului 3. +

+

4) Iesire

+

+ Ultimul panou, desenat cu un X, este utilizat pentru iesirea din program. +

+
+
+ main_menu +
+ +
+
+
+
+

Masa de lucru

+

Dupa crearea unui nou proiect sau deschiderea unuia existent, user-ul va fi trimis catre masa de lucru, unde poate efectua urmatoarele operatii:

+
    +
  1. Desenare componenta
  2. +
  3. Mutare componenta
  4. +
  5. Stergere componenta
  6. +
  7. Rotire si zoom in/out pe componenta
  8. +
  9. Deseneare legatura
  10. +
  11. Stergere legatura
  12. +
  13. Selectare tip de legatura
  14. +
  15. Verificare conectivitatea circuitului
  16. +
  17. Salvarea proiectului
  18. +
  19. Deschiderea unui alt proiect
  20. +
  21. Undo/Redo
  22. +
  23. Aprinde becul
  24. +
+ +
+
+ main_menu +
+ +
+
+
+

1) Desenare componenta

+

+ Pentru a putea amplasa o componenta pe tabla, utilizatorul trebuie sa selecteze o componenta din panoul din partea stanga. Odata selectata aceasta componenta, + utilizatorul poate amplasa piesa in chenarul verde, ce reprezinta masa de lucru. Daca se va face click in afara chenarului, va fi informat in casuta de log + ca acesta nu poate sa depaseasca limitele masei de lucru.
+ Daca se face click peste o componenta deja existenta, utilizatorul va fi instiintat despre faptul ca nu va putea amplasa o piesa peste + una deja existenta, tot prin casuta de log, iar piesa se va redesena la ultima pozitie existenta. +

+

2) Mutare componenta

+

+ Mutarea componentei pe masa de lucru se face prin selectarea componentei dorite de pe tabla prin click stanga, ce va permite mutarea oriunde in limitele chenarului + verde. Daca se va merge cu cursorul in afara chenarului verde, utilizatrul va fi informat ca a depasit limitele masei de lucru, iar componenta se va redesena + la ultima sa pozitie.(cea dinainte de click) +

+

3) Stergere componenta

+

+ Stergerea unei componente de pe masa de lucru se face prin selectarea actiunii specifice din panoul din dreapta (Delete component). Odata functionalitatea activata, + utilizatorul va trebui sa selecteze de pe tabla piesa ce se doreste a fi stearsa.
+ Daca aceasta componenta are si legaturi care ies sau intra, acestea vor fi sterse o data cu stergerea componentei.Daca se va face click intr-un loc unde nu este nicio componenta, + si nici un menu nu a fost selectat, nu se va intampla nimic. +

+

4) Rotire si zoom in/out pe componenta

+

+ Rotirea si zoom in/out pot fi activate prin selectarea casutei aferenta din panoul din dreapta. Odata ce se activeaza aceasta functionalitate, utilizatorul trebuie sa + aleaga de pe masa piesa care se doreste a fi rotita sau micsorata/marita. Daca nu se va selecta nimic, nimic nu se va intampla. Se va astepta urmatoarea comanda. +
+ O data ce componenta este selectata, in partea dreapta jos vor aparea doua glisatoare, unul responsabil pentru rotire la 360 G, iar celalalt pentru micsorare/marire. + In functie de preferinta, se selecteaza glisatorul si se gliseaza sus/jos. Pentru ca actiunile sa fie aplicate componentei, va fi nevoie sa se apese butonul "Aplica modificarile" + de sub glisator. +

+
+ +
+
+
+

5) Desenarea legaturii

+

+ Desenarea legaturii se face prin selectarea unui nod al unei componente, care se doreste a fi legata de o alta componenta. O data facuta selectia, + legatura va incepe sa urmareasca cursorul. + Daca cursorul merge in afara tablei de lucru, legatura se va pierde, fiind nevoita reselectarea nodului. +

+ Pentru a se face conexiunea cu o alta componenta, este nevoie sa se faca click pe nodul celeilalte componente. Daca click-ul s-a facut cu succes pe nod, + cele doua componente vor fi conectate. +

+

+ Dintr-un nod pot pleca/intra o infinitate de legaturi. Nu exista restrictii. +

+

+

6) Mutare componenta

+

+ Mutarea componentei pe masa de lucru se face prin selectarea componentei dorite de pe tabla prin click stanga, ce va permite mutarea oriunde in limitele chenarului + verde. Daca se va merge cu cursorul in afara chenarului verde, utilizatrul va fi informat ca a depasit limitele masei de lucru, iar componenta se va redesena + la ultima sa pozitie.(cea dinainte de click) +

+

7) Stergere componenta

+

+ Stergerea unei componente de pe masa de lucru se face prin selectarea actiunii specifice din panoul din dreapta (Delete component). Odata functionalitatea activata, + utilizatorul va trebui sa selecteze de pe tabla piesa ce se doreste a fi stearsa.
+ Daca aceasta componenta are si legaturi care ies sau intra, acestea vor fi sterse o data cu stergerea componentei.Daca se va face click intr-un loc unde nu este nicio componenta, + si nici un menu nu a fost selectat, nu se va intampla nimic. +

+

8) Rotire si zoom in/out pe componenta

+

+ Rotirea si zoom in/out pot fi activate prin selectarea casutei aferenta din panoul din dreapta. Odata ce se activeaza aceasta functionalitate, utilizatorul trebuie sa + aleaga de pe masa piesa care se doreste a fi rotita sau micsorata/marita. Daca nu se va selecta nimic, nimic nu se va intampla. Se va astepta urmatoarea comanda. +
+ O data ce componenta este selectata, in partea dreapta jos vor aparea doua glisatoare, unul responsabil pentru rotire la 360 G, iar celalalt pentru micsorare/marire. + In functie de preferinta, se selecteaza glisatorul si se gliseaza sus/jos. Pentru ca actiunile sa fie aplicate componentei, va fi nevoie sa se apese butonul "Aplica modificarile" + de sub glisator. +

+
+ + +
+
+

9) Salvarea proiectului

+

+ Functionalitatea "Save" de pe masa de lucru ofera posibilitatea user-ului sa poata + salva progresul realizat in crearea schemelor electrice dorite. Aceasta functionalitate a fost + implementata cu ajutorul fisierelor binare, care vor stoca informatiile fiecarei componente + de pe tabla. Fisierul va fi de tip .AT . + Fisierele vor fi salvate in directorul /Projects din root-ul proiectului. + Daca acest director nu exista, el va fi creat. +

+ Daca se doreste sa se salveze proiectul in alt folder decat cel predefinit, el poate opta pentru + functionalitatea "Save as" care ii a permite sa isi aleaga un director unde sa isi salveze progresul. +

+ +

+

10) Deschiderea unui alt proiect

+

+ Utilizatorul poate sa deschida un proiect la care a lucrat si sa isi continue dezvoltarea circuitului dorit. + Se poate deschide orice fisier de tip .AT care respecta cateva conditii de integritate. Alte fisiere, care nu sunt de tipul + .AT, nu vor fi deschise, o eroare fiind aruncata. + +

Fisierul se poate afla oriunde pe device, fiind permisa navigarea cate fisierul target pentru a putea fi deschis.

+

+

11) Undo/Redo

+

+ Undo/Redo reprezinta o functionalitate utilizata de orice user/programator, fiind implementata nativ + in majoritatea sistemelor de operare comercializate. O astfel de functionalitate este implementata + si in proiectul nostru. +

Undo/Redo permite revenire la o stare anterioara (sau succesoare dupa caz), daca se doreste acest lucru + prin actionarea butonului de UNDO. Daca userul doreste totusi sa revina la starea la care a fost inainte + de aplicarea UNDO-ului, acesta poate prin apasarea butonului de REDO, care revine pana la ultima stare, + dinainte de UNDO (sau la o stare intermediara, daca au fost aplicate mai multe UNDO uri succesive). + +

+

+

+
+ + + +
+
+
+
+

Aprinde becul !

+ bulb +
+
+
+

Aprinde becul este un mic joc implementat de catre noi de care utilizatorul se poate bucura!

+

+ Acest joc presupune crearea unui "Circuit Fericit" format dintr-un numar specific de componente si tipuri de componente, + conectate intre ele (nu conteaza ordinea) care va putea aprinde un bec! +

+

Acesta trebuie sa contina: +

+
    +
  • 2 surse
  • +
  • 2 rezistori
  • +
  • 1 voltmetru
  • +
  • 1 ampermetru
  • +
  • 1 dioda
  • +
  • 1 tranzistor
  • +
  • 1 siguranta
  • +
  • 1 capacitor
  • +
  • 1 bec
  • +
+ + + + main_menu + +
+

+ +
+ +
+ + + + + diff --git a/stare_table.h b/stare_table.h new file mode 100644 index 0000000..969458c --- /dev/null +++ b/stare_table.h @@ -0,0 +1,1584 @@ +#ifndef STARE_TABLE_H_INCLUDED +#define STARE_TABLE_H_INCLUDED + +///LIBRARIES +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "drawing_components.h" +#include "functii_auxiliare.h" + +using namespace std; + + +//Tudor Ilade - in afara de functiile facute de Andrei +struct punctLegatura +{ + int type; + int x,y; + int xConnection, yConnection; + int ndxParent; + int sd; +}; + +typedef struct RECTANGLE +{ + float left; + float top; + float right; + float bottom; + int xCenter; + int yCenter; +}; + + +struct SWITCHSTATE{ + int bulb=2; + bool inOut; +}; + +typedef struct RECTANGLE_FULL +{ + struct + { + float x, y; + } left_top, right_top, left_bottom, right_bottom; +} RECTANGLE_FULL; + +struct BinaryCMP +{ + int type; + char name[512]; + int x; + int y; + float R; + int angle; + float zoom; + int value=0; + bool conectat; + RECTANGLE outsideRect; + RECTANGLE rect; + RECTANGLE nodes[3]; + RECTANGLE_FULL coordinates[4]; + int size_of_linkings; + punctLegatura legatura[256]; +}; + +struct COMPONENTE +{ + int type; + char name[512]; + int x1; + int y1; + float R; + int nr_puncte_legatura; + bool connectat; + int angle=0; + float zoom=1.0; + int value=0; + RECTANGLE nodes[3]; + RECTANGLE_FULL coordinates[4]; + RECTANGLE rect; + RECTANGLE outsideRect; + vector>legatura; +}; + +struct SITUATIA_TABLEI +{ + int ans; + char path_file[1024]; + char path_to_dir[1024]; + bool open=false; + bool light = false; + vector v; + vector>p; +}; + +struct HISTORY +{ + stackUNDO; + stackREDO; + stackLOG; +}; + + +//Andrei Cerbu +struct RECTANGLE_FULL generate_coordinates_full(struct componenta CMP) +{ + struct RECTANGLE_FULL structt; + + structt.left_top.x=CMP.points[0]; + structt.left_top.y=CMP.points[1]; + structt.right_top.x=CMP.points[2]; + structt.right_top.y=CMP.points[3]; + structt.right_bottom.x=CMP.points[4]; + structt.right_bottom.y=CMP.points[5]; + structt.left_bottom.x=CMP.points[6]; + structt.left_bottom.y=CMP.points[7]; + + return structt; +} + +struct RECTANGLE generate_coordinates(struct componenta CMP) +{ + struct RECTANGLE RECT; + RECT.left=CMP.points[0]; + RECT.top=CMP.points[1]; + RECT.right=CMP.points[4]; + RECT.bottom=CMP.points[5]; + RECT.xCenter=(CMP.points[0]+CMP.points[4])/2; + RECT.yCenter=(CMP.points[1]+CMP.points[5])/2; + return RECT; +} + +struct RECTANGLE initialize_RECT() +{ + struct RECTANGLE RECT; + + RECT.left=1000000.0; + RECT.top=1000000.0; + RECT.bottom=0.0; + RECT.right=0.0; + + return RECT; +} + +RECTANGLE generate_maximum_rotation(int W, int H, float R, int X, int Y, float zoom, int type) +{ + RECTANGLE RECT; + componenta CMP; + + RECT = initialize_RECT(); + + if(type!=9) + { + for(int i=0; i>=-90; i--) + { + int width = W/8, height = H/4; + float w1, w2, h1, h2, w, h; + + dreptunghi D; + coordonate C; + C.x=X, C.y=Y; + + w1=-(width*4-width/1.7)*R*zoom+X, w2=(width*4-width/1.7)*R*zoom+X, + h1=-(height*2-height/2.7)*R*zoom+Y, h2=(height*2-height/2.7)*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP=RotateRectangle(C,D,i,1); + + RECT.left=min(RECT.left,CMP.points[6]); + RECT.top=min(RECT.top,CMP.points[1]); + RECT.right=max(RECT.right,CMP.points[2]); + RECT.bottom=max(RECT.bottom,CMP.points[5]); + } + } + else if(type==9) + { + for(int i=0; i>=-90; i--) + { + int width = W/8, height = H/4; + float w1, w2, h1, h2, w, h; + + dreptunghi D; + coordonate C; + C.x=X, C.y=Y; + + w1=-2*width*R*zoom+X, w2=width*R*zoom+X, + h1=-(height*2-height/2.7)*R*zoom+Y, h2=(height*2-height/2.7)*R*zoom+Y; + D=create_struct_rectangle(w1,w2,h1,h2); + D=translate_rectangle(D,C); + CMP=RotateRectangle(C,D,i,1); + + RECT.left=min(RECT.left,CMP.points[6]); + RECT.top=min(RECT.top,CMP.points[1]); + RECT.right=max(RECT.right,CMP.points[2]); + RECT.bottom=max(RECT.bottom,CMP.points[5]); + } + } + + return RECT; +} + +void generate_rectangle_full_struct(struct RECTANGLE_FULL RECT_FULL[], componenta CMP[], int type) +{ + if(type!=9) + { + RECT_FULL[1]=generate_coordinates_full(CMP[1]); + RECT_FULL[2]=generate_coordinates_full(CMP[2]); + RECT_FULL[3]=generate_coordinates_full(CMP[3]); + } + else if(type==9) + { + RECT_FULL[1]=generate_coordinates_full(CMP[1]); + RECT_FULL[2]=generate_coordinates_full(CMP[2]); + RECT_FULL[3]=generate_coordinates_full(CMP[3]); + RECT_FULL[4]=generate_coordinates_full(CMP[4]); + } +} + +void generate_rectangle_struct(RECTANGLE RECT[], componenta CMP[], int type) +{ + if(type!=9) + { + RECT[1]=generate_coordinates(CMP[1]); + RECT[2]=generate_coordinates(CMP[2]); + RECT[3]=generate_coordinates(CMP[3]); + } + else if(type==9) + { + RECT[1]=generate_coordinates(CMP[1]); + RECT[2]=generate_coordinates(CMP[2]); + RECT[3]=generate_coordinates(CMP[3]); + RECT[4]=generate_coordinates(CMP[4]); + } +} + +int convert_y_to_angle(int y, int top_fader) +{ + return (top_fader-y)*3; +} + +int convert_angle_to_y(int angle, int top_fader) +{ + //if(angle == 0) + return top_fader-angle/3; +} + +float convert_y_to_zoom(int y, int center_fader) +{ + float conversion; + y=-(y-center_fader); + conversion=1.0*y/260; + return conversion; +} + +int convert_zoom_to_y(float zoom, int center_fader) +{ + return center_fader-zoom*260; +} + + + + + +//Tudor ILADE pana jos + + +int getIndexOfComponent(SITUATIA_TABLEI project, int x, int y, float R) +{ + for(int i=0; i=project.v[i].outsideRect.left && x <= project.v[i].outsideRect.right && + (y>=project.v[i].outsideRect.top && y<=project.v[i].outsideRect.bottom)) + { + return i; + } + } + return -1; +} + +componenta CMP[30]; + + +///Verifica daca a fost dat click pe o legatura + +int isLinking(SITUATIA_TABLEI project, int w, int h, int x, int y, float R,componenta CMP[], int ndxCmp=-1) +{ + int ndx = getIndexOfComponent(project, x,y,R); + if(ndx == - 1) + return 0; + if(ndx == ndxCmp) + return 0; + COMPONENTE cmp = project.v[ndx]; + if(cmp.type != 9) + { + + if(x>=cmp.coordinates[1].left_top.x && x <= cmp.coordinates[1].right_bottom.x && + (y>=cmp.coordinates[1].right_top.y&&y<=cmp.coordinates[1].left_bottom.y)) + { + return 1; + } + + if(x>=cmp.coordinates[1].left_bottom.x && x <= cmp.coordinates[1].right_top.x && + (y>=cmp.coordinates[1].left_top.y && y<=cmp.coordinates[1].right_bottom.y)) + { + return 1; + } + if(x>=cmp.coordinates[1].right_bottom.x && x <= cmp.coordinates[1].left_top.x && + (y>=cmp.coordinates[1].left_bottom.y&&y<=cmp.coordinates[1].right_top.y)) + { + + return 1; + } + if(x>=cmp.coordinates[1].right_top.x && x <= cmp.coordinates[1].left_bottom.x && + (y>=cmp.coordinates[1].right_bottom.y&&y<=cmp.coordinates[1].left_top.y)) + { + return 1; + } + + + if(x>=cmp.coordinates[2].left_bottom.x && x <= cmp.coordinates[2].right_top.x && + (y>=cmp.coordinates[2].left_top.y && y<=cmp.coordinates[2].right_bottom.y)) + { + return 2; + } + if(x>=cmp.coordinates[2].right_bottom.x && x <= cmp.coordinates[2].left_top.x && + (y>=cmp.coordinates[2].left_bottom.y&&y<=cmp.coordinates[2].right_top.y)) + { + return 2; + + } + if(x>=cmp.coordinates[2].left_top.x && x <= cmp.coordinates[2].right_bottom.x && + (y>=cmp.coordinates[2].right_top.y&&y<=cmp.coordinates[2].left_bottom.y)) + { + return 2; + } + if(x>=cmp.coordinates[2].right_top.x && x <= cmp.coordinates[2].left_bottom.x && + (y>=cmp.coordinates[2].right_bottom.y&&y<=cmp.coordinates[2].left_top.y)) + { + return 2; + } + + + return 0; + } + + else + { + if(x>=cmp.coordinates[1].left_bottom.x && x <= cmp.coordinates[1].right_top.x && + (y>=cmp.coordinates[1].left_top.y && y<=cmp.coordinates[1].right_bottom.y)) + { + return 1; + } + if(x>=cmp.coordinates[1].right_bottom.x && x <= cmp.coordinates[1].left_top.x && + (y>=cmp.coordinates[1].left_bottom.y&&y<=cmp.coordinates[1].right_top.y)) + { + + return 1; + } + if(x>=cmp.coordinates[1].left_top.x && x <= cmp.coordinates[1].right_bottom.x && + (y>=cmp.coordinates[1].right_top.y&&y<=cmp.coordinates[1].left_bottom.y)) + { + return 1; + } + if(x>=cmp.coordinates[1].right_top.x && x <= cmp.coordinates[1].left_bottom.x && + (y>=cmp.coordinates[1].right_bottom.y&&y<=cmp.coordinates[1].left_top.y)) + { + return 1; + } + + + + if(x>=cmp.coordinates[2].left_bottom.x && x <= cmp.coordinates[2].right_top.x && + (y>=cmp.coordinates[2].left_top.y && y<=cmp.coordinates[2].right_bottom.y)) + { + return 2; + } + if(x>=cmp.coordinates[2].right_bottom.x && x <= cmp.coordinates[2].left_top.x && + (y>=cmp.coordinates[2].left_bottom.y&&y<=cmp.coordinates[2].right_top.y)) + { + + return 2; + } + if(x>=cmp.coordinates[2].left_top.x && x <= cmp.coordinates[2].right_bottom.x && + (y>=cmp.coordinates[2].right_top.y&&y<=cmp.coordinates[2].left_bottom.y)) + { + return 2; + } + if(x>=cmp.coordinates[2].right_top.x && x <= cmp.coordinates[2].left_bottom.x && + (y>=cmp.coordinates[2].right_bottom.y&&y<=cmp.coordinates[2].left_top.y)) + { + return 2; + } + + + if(x>=cmp.coordinates[3].left_bottom.x && x <= cmp.coordinates[3].right_top.x && + (y>=cmp.coordinates[3].left_top.y && y<=cmp.coordinates[3].right_bottom.y)) + { + return 3; + } + if(x>=cmp.coordinates[3].right_bottom.x && x <= cmp.coordinates[3].left_top.x && + (y>=cmp.coordinates[3].left_bottom.y&&y<=cmp.coordinates[3].right_top.y)) + { + + return 3; + } + if(x>=cmp.coordinates[3].left_top.x && x <= cmp.coordinates[3].right_bottom.x && + (y>=cmp.coordinates[3].right_top.y&&y<=cmp.coordinates[3].left_bottom.y)) + { + return 3; + } + if(x>=cmp.coordinates[3].right_top.x && x <= cmp.coordinates[3].left_bottom.x && + (y>=cmp.coordinates[3].right_bottom.y&&y<=cmp.coordinates[3].left_top.y)) + { + return 3; + } + + return 0; + } + return 0; +} + + + +///Deseneaza linia de legatura +void drawLine(int x1, int y1, int x2, int y2, int cul, int type) +{ + if(type==1) + { + setcolor(cul); + line(x1,y1,(x1+x2)/2,y1); + line((x1+x2)/2,y1,(x1+x2)/2,y2); + line((x1+x2)/2,y2,x2,y2); + } + else if(type==2) + { + setcolor(cul); + line(x1,y1,x1,y2); + line(x1,y2,x2,y2); + + } + else if(type==3) + { + setcolor(cul); + line(x1,y1,x2,y1); + line(x2,y1,x2,y2); + } + else if(type==4) + { + setcolor(cul); + line(x1,y1,x1,(y1+y2)/2); + line(x1,(y1+y2)/2,x2,(y1+y2)/2); + line(x2,(y1+y2)/2,x2,y2); + + } +} + + +///Functie care creaza un obiect pe tabla +SITUATIA_TABLEI creare_obiect(SITUATIA_TABLEI &tabla, int type, int x, int y, int w, int h, float R, RECTANGLE RECT[], RECTANGLE_FULL RECT_FULL[], RECTANGLE outSideRect) +{ + COMPONENTE cmp; + cmp.x1 = x; + cmp.y1 = y; + cmp.type = type; + cmp.R = R; + int W = w/10; + int H = h/16; + int width = W/8; + int height = H/4; + cmp.outsideRect = outSideRect; + cmp.rect.bottom=RECT[1].bottom; + cmp.rect.top=RECT[1].top; + cmp.rect.left=RECT[1].left; + cmp.rect.right=RECT[1].right; + cmp.nodes[0] = RECT[2]; + cmp.nodes[1] = RECT[3]; + cmp.nodes[2] = RECT[4]; + cmp.coordinates[0]=RECT_FULL[1]; + cmp.coordinates[1]=RECT_FULL[2]; + cmp.coordinates[2]=RECT_FULL[3]; + cmp.coordinates[3]=RECT_FULL[4]; + + cmp.zoom = 1.0; + tabla.v.push_back(cmp); + return tabla; +} +///Verifica coliziuni pe tabla +bool isColision(RECTANGLE outSideRectangle,int h,int w,SITUATIA_TABLEI tabla, int R, int type, int ndxCmp = -1) +{ + int H = h/16; + int W = w/10; + RECTANGLE t; + int width_rectangle = w/8; + int height_rectangle = h/12; + t.left = width_rectangle*R; + t.top = height_rectangle*R; + t.right = (w-width_rectangle-width_rectangle/8)*R; + t.bottom = (h-height_rectangle)*R; + if(outSideRectangle.leftt.right || outSideRectangle.top < t.top || outSideRectangle.bottom > t.bottom) + { + return true; + } + if(!tabla.v.empty()) + { + for(int i=0; i=tabla.v[i].outsideRect.bottom&&outSideRectangle.right>=tabla.v[i].outsideRect.right) + return true; + + if(outSideRectangle.top<=tabla.v[i].outsideRect.bottom && outSideRectangle.right>=tabla.v[i].outsideRect.left&& + outSideRectangle.bottom>tabla.v[i].outsideRect.bottom&&outSideRectangle.left=tabla.v[i].outsideRect.left && outSideRectangle.left<=tabla.v[i].outsideRect.left&& + outSideRectangle.top<=tabla.v[i].outsideRect.top && outSideRectangle.bottom>=tabla.v[i].outsideRect.top) + return true; + + if(outSideRectangle.left<=tabla.v[i].outsideRect.right && outSideRectangle.right>=tabla.v[i].outsideRect.right&& + outSideRectangle.bottom>=tabla.v[i].outsideRect.top && outSideRectangle.top<=tabla.v[i].outsideRect.top) + return true; + + if(outSideRectangle.left>=tabla.v[i].outsideRect.left&&outSideRectangle.right<=tabla.v[i].outsideRect.right&& + outSideRectangle.bottom>=tabla.v[i].outsideRect.top&&outSideRectangle.top<=tabla.v[i].outsideRect.top) + return true; + + if(outSideRectangle.left>=tabla.v[i].outsideRect.left&&outSideRectangle.right<=tabla.v[i].outsideRect.right&& + outSideRectangle.top<=tabla.v[i].outsideRect.bottom&&outSideRectangle.bottom>=tabla.v[i].outsideRect.bottom) + return true; + + if(outSideRectangle.right>=tabla.v[i].outsideRect.left&&outSideRectangle.left<=tabla.v[i].outsideRect.left&& + outSideRectangle.top>=tabla.v[i].outsideRect.top&&outSideRectangle.bottom<=tabla.v[i].outsideRect.bottom) + return true; + + if(outSideRectangle.left<=tabla.v[i].outsideRect.right&&outSideRectangle.right>=tabla.v[i].outsideRect.right&& + outSideRectangle.top>=tabla.v[i].outsideRect.top&&outSideRectangle.bottom<=tabla.v[i].outsideRect.bottom) + return true; + } + } + } + return false; +} + +///Sterge tabla si tot ce a fost desenat +SITUATIA_TABLEI stergere_tabla(SITUATIA_TABLEI tabla) +{ + tabla.v.clear(); + tabla.p.clear(); + return tabla; +} + +///Deseneaza componentele ce au fost luate prin citirea fisierului binar +void draw_components_from_file(SITUATIA_TABLEI tabla, int W, int H) +{ + struct componenta CMP[30]; + + for(int i=0; i0) + for(int i=0; i=project.v[i].outsideRect.left && x <= project.v[i].outsideRect.right&& + (y>=project.v[i].outsideRect.top&&y<=project.v[i].outsideRect.bottom)) + return project.v[i].type; + } + + return 0; +} + + +void drawComponentsXSelected(SITUATIA_TABLEI project, int ndx, int W, int H, int R, int color) +{ + componenta CMP[30]; + + for(int i=0; it.right || y < t.top || y > t.bottom) + return 1; + return 0; + } + RECTANGLE t; + int H = h/16; + int W = w/10; + int width_r = W/8*R; + int height_r = H/4*R; + int width_rectangle = w/8; + int height_rectangle = h/12; + + t.left = width_rectangle*R; + t.top = height_rectangle*R; + t.right = 7*width_rectangle*R; + t.bottom = 11*height_rectangle*R; + if(outSideRect.leftt.right+10|| outSideRect.top < t.top-34 || outSideRect.bottom > t.bottom + 34) + return 1; + return 0; +} + + +void draw_moving_line(SITUATIA_TABLEI project, int ndxCmp, int color, int W, int H, int R, RECTANGLE RECT[]) +{ + for(int i = 0; i ndx) + project.p[i].first.ndxParent-=1; + if(project.p[i].second.ndxParent > ndx) + project.p[i].second.ndxParent-=1; + } + + for(int i = 0; i < project.v.size(); i++) + for(int j=0; j ndx) + { + project.v[i].legatura[j].first.ndxParent--; + } + if(project.v[i].legatura[j].second.ndxParent > ndx) + { + project.v[i].legatura[j].second.ndxParent--; + } + } + + return project; +} + +int checkLineTypeLink(int type, int x, int y, int x1, int y1, int x2, int y2) +{ + if(type==1) + { + if(x>x1 && x <= (x1+x2)/2 && y y1-3) + return 1; + if(x (x1+x2)/2 && y y1-3) + return 1; + if(x>(x1+x2)/2-3 && x<(x1+x2)/2+3 && yy2) + return 1; + if(x>(x1+x2)/2-3 && x<(x1+x2)/2+3 && y>y1 && y(x1+x2)/2 && x < x2 && y y2-3) + return 1; + if(x < (x1+x2)/2 && x > x2 && y y2-3) + return 1; + return 0; + } + else if(type == 2) + { + if(x>x1-3 && x=y1 && y<=y2) + return 2; + if(x>x1-3 && x=y2) + return 2; + if(x>x1 && xy2-3 && y < y2 + 3) + return 2; + if(xx2 && y>y2-3 && y < y2 + 3) + return 2; + return 0; + } + else if(type == 3) + { + if(x>x1 && x < x2 && y>y1-3 && y x2 && y>y1-3 && yx2-3 && x < x2 + 3 && y>y1 && y < y2) + return 3; + if(x>x2-3 && x < x2 + 3 && y y2) + return 3; + return 0; + } + else if(type == 4) + { + if(x>x1-3 && xy1 && y<(y1+y2)/2) + return 4; + if(x>x1-3 && x(y1+y2)/2) + return 4; + if(x>x1 && x < x2 && y>(y1+y2)/2-3 && y < (y1+y2)/2+3) + return 4; + if(x x2 && y>(y1+y2)/2-3 && y < (y1+y2)/2+3) + return 4; + if(x>x2-3 && x < x2+3 && y > (y1+y2)/2 && y < y2) + return 4; + if(x>x2-3 && x < x2+3 && y < (y1+y2)/2 && y > y2) + return 4; + return 0; + } +} + + +int isLinkSelected(SITUATIA_TABLEI project, int x, int y) +{ + for(int i = 0; i < project.p.size(); i++) + if(checkLineTypeLink(project.p[i].first.type, x, y, project.p[i].first.x, project.p[i].first.y, project.p[i].first.xConnection, project.p[i].first.yConnection)) + return i; + return -1; +} + + +SITUATIA_TABLEI stergeLegatura(SITUATIA_TABLEI project, int ndxLink) +{ + pairP= project.p[ndxLink]; + drawLine(P.first.x, P.first.y,P.first.xConnection, P.first.yConnection, BLACK, P.first.type); + project.p.erase(project.p.begin()+ndxLink); + + for(int i = 0; i< project.v.size(); i++) + for(int j = 0; j0) + { + if(stiva.UNDO.size()==1) + { + stiva.REDO.push(stiva.UNDO.top()); + stiva.UNDO.pop(); + return project; + } + stiva.REDO.push(stiva.UNDO.top()); + stiva.UNDO.pop(); + project = stiva.UNDO.top(); + return project; + } + else + return proj; + } + else if(UndoRedo==2) + { + if(stiva.REDO.size()>0) + { + project = stiva.REDO.top(); + stiva.REDO.pop(); + stiva.UNDO.push(project); + return project; + } + else + return proj; + } +} + +///Functie care goleste stiva de memorie pt undo si redo +HISTORY emptyStack(HISTORY stackk) +{ + while(!stackk.UNDO.empty()) + { + stackk.UNDO.pop(); + } + while(!stackk.REDO.empty()) + { + stackk.REDO.pop(); + } + return stackk; +} + + +///Functie responsabila de a verifica daca circuitul este conectat +int checkIntegrity(SITUATIA_TABLEI project) +{ + //cmp != 9 + vectornodIntraStg(project.v.size()+project.p.size()); + vectornodIeseStg(project.v.size()+project.p.size()); + vectornodIntraDreapta(project.v.size()+project.p.size()); + vectornodIeseDr(project.v.size()+project.p.size()); + + + //cmp==9 + vectornodIntraStg9(project.v.size()+project.p.size()); + vectornodIeseStg9(project.v.size()+project.p.size()); + vectornodIeseJos(project.v.size()+project.p.size()); + vectornodIntraJos(project.v.size()+project.p.size()); + vectornodIntraSus(project.v.size()+project.p.size()); + vectornodIeseSus(project.v.size()+project.p.size()); + + + for(int j = 0; j=0 && nodIeseDr[i]>=0)//Toate intra din dreapta, restul 0 + return 0; + if(nodIntraStg[i]>=0 && nodIeseStg[i]>=0 && nodIntraDreapta[i]==0 && nodIeseDr[i]==0)//Toate intra din dreapta, restul 0 + return 0; + } + } + + for(int i=0; i=0 && nodIeseJos[i]>=0 && nodIntraSus[i]>=0 && nodIeseSus[i]>=0)//stanga este 0 + return 0; + if(nodIntraStg9[i]>=0 && nodIeseStg9[i]>=0 && nodIntraJos[i]==0 && nodIeseJos[i]==0 && nodIntraSus[i]>=0 && nodIeseSus[i]>=0)//jos este 0 + return 0; + if(nodIntraStg9[i]>=0 && nodIeseStg9[i]>=0 && nodIntraJos[i]>=0 && nodIeseJos[i]>=0 && nodIntraSus[i]==0 && nodIeseSus[i]==0)//sus este 0 + return 0; + } + } + return 1; +} + + + +///Functie responsabila de a deschide pagina html +void openHtml(char *current_path) +{ + + LPCTSTR helpFile = path_for_images("prezentare.html",current_path); + ShellExecute(NULL, "open", helpFile, NULL, NULL, SW_SHOWNORMAL); + + return; + +} + +///Functie care verifica proprietatile "Circuitului Fericit" +bool turnBulbOn(SITUATIA_TABLEI project) +{ + // 2 electrical power // 2 resitors// 1 bulb // 1 transistor // 1 voltmeter // 1 ampermeter// 1 diode // 1 fuse // 1 capacitor + if(project.light) + return true; + int circuit[12]; + for(int i=0; i<12; i++) + circuit[i]=0; + + if(project.v.empty()) + return false; + int connected = checkIntegrity(project); + if(connected) + { + for(int i=0; i(W-width_rectangle)*R && x<(W-width_rectangle)*R+4*W/225*2 && y>height_rectangle*16.1*R && y<(height_rectangle*20.1)*R && id == 1) + return 1; + if(x>(W-width_rectangle)*R+4*W/225*3 && xheight_rectangle*16.1*R && y<(height_rectangle*20.1)*R && id == 2) + return 2; + return 0; +} + +//Andrei CERBU pana jos +void print_text_on_workplace_page(int W, int H, int R, int width_rectangle, int height_rectangle, int rect_w, int rect_h, char* str){ + int text_w=textwidth(str); + int text_h=textheight(str); + + float x=(width_rectangle+(rect_w-text_w)/2); + float y=(height_rectangle+(rect_h-text_h)/2); + + outtextxy(x,y,str); +} + +void create_text_workplace(int W, int H, float R){ + int width_rectangle, height_rectangle, FONT; + + if(W<=1920) + FONT=1; + else FONT=3; + + settextstyle(EUROPEAN_FONT,HORIZ_DIR,FONT); + setcolor(WHITE); + + ///TOP TEXT + + width_rectangle=W/12; + height_rectangle=H/24; + + print_text_on_workplace_page(W,H,R,width_rectangle*3*R,0,width_rectangle,height_rectangle,"Start panel"); + print_text_on_workplace_page(W,H,R,width_rectangle*4*R,0,width_rectangle,height_rectangle,"Open"); + print_text_on_workplace_page(W,H,R,width_rectangle*5*R,0,width_rectangle,height_rectangle,"Save"); + print_text_on_workplace_page(W,H,R,width_rectangle*6*R,0,width_rectangle,height_rectangle,"Save as"); + print_text_on_workplace_page(W,H,R,width_rectangle*7*R,0,width_rectangle,height_rectangle,"Help"); + print_text_on_workplace_page(W,H,R,width_rectangle*8*R,0,width_rectangle,height_rectangle,"Reset"); + + ///RIGHT TEXT + + width_rectangle = W/9; + height_rectangle = H/16; + + print_text_on_workplace_page(W,H,R,(W-width_rectangle)*R,(height_rectangle*2),width_rectangle,height_rectangle,"Check integrity"); + print_text_on_workplace_page(W,H,R,(W-width_rectangle)*R,(height_rectangle*3),width_rectangle,height_rectangle,"Zoom/Rotate"); + print_text_on_workplace_page(W,H,R,(W-width_rectangle)*R,(height_rectangle*4),width_rectangle,height_rectangle,"Delete comp."); + print_text_on_workplace_page(W,H,R,(W-width_rectangle)*R,(height_rectangle*5),width_rectangle,height_rectangle,"Delete link"); + print_text_on_workplace_page(W,H,R,(W-width_rectangle)*R,(height_rectangle*6),width_rectangle,height_rectangle,"Update comp."); + print_text_on_workplace_page(W,H,R,(W-width_rectangle)*R,(height_rectangle*7),width_rectangle,height_rectangle,"Line type"); +} +void create_bulb(int W, int H, int R, int width_rectangle, int height_rectangle, int color){ + /*setfillstyle(SOLID_FILL,color); + circle(W-width_rectangle/2,height_rectangle,W/100); + floodfill(W-width_rectangle/2,height_rectangle,WHITE); + + line(W-width_rectangle/2-width_rectangle/20,height_rectangle+W/120,W-width_rectangle/2-width_rectangle/20,1.6*(height_rectangle)*R); + line(W-width_rectangle/2+width_rectangle/20,height_rectangle+W/120,W-width_rectangle/2+width_rectangle/20,1.6*(height_rectangle)*R); + + line((W-width_rectangle/2-width_rectangle/20)*R,1.6*(height_rectangle)*R,(W-width_rectangle/2+width_rectangle/20)*R,1.6*(height_rectangle)*R);*/ +} + + +void messages_log_panel(char* str, int W, int H, float R, int width_rectangle, int height_rectangle){ + + setlinestyle(SOLID_LINE,0,2); + setcolor(WHITE); + + rectangle(3.5*width_rectangle*R,15*height_rectangle*R,5.5*width_rectangle*R,15.7*height_rectangle*R); + + int text_w=textwidth(str); + int text_h=textheight(str); + + int rect_w=width_rectangle*R; + int rect_h=0.7*height_rectangle*R; + + float x=(4*width_rectangle+(rect_w-text_w)/2)*R; + float y=(15*height_rectangle+(rect_h-text_h)/2)*R; + + outtextxy(x,y,str); +} + +void draw_components_left_panel(int W, int H, float R){ + int X=W/8,Y=H/16; + + struct componenta CMP[30]; + + construct_resistor(W/10,H/16,R,7*X/16,7*Y/2,0,1.0,CMP); + draw_component(CMP,6,WHITE); + + construct_fuse(W/10,H/16,R,7*X/16,9*Y/2,0,1.0,CMP); + draw_component(CMP,5,WHITE); + + construct_electrical_cell(W/10,H/16,R,7*X/16,11*Y/2,0,1.0,CMP); + draw_component(CMP,7,WHITE); + + construct_dioda(W/10,H/16,R,7*X/16,13*Y/2,0,1.0,CMP); + draw_component(CMP,9,WHITE); + + construct_ampermeter(W/10,H/16,R,7*X/16,15*Y/2,0,1.0,CMP); + draw_component(CMP,12,WHITE); + + construct_voltmeter(W/10,H/16,R,7*X/16,17*Y/2,0,1.0,CMP); + draw_component(CMP,10,WHITE); + + construct_capacitor(W/10,H/16,R,7*X/16,19*Y/2,0,1.0,CMP); + draw_component(CMP,7,WHITE); + + construct_bulb(W/10,H/16,R,7*X/16,21*Y/2,0,1.0,CMP); + draw_component(CMP,8,WHITE); + + construct_transistor(W/10,H/16,R,7*X/16,23*Y/2,0,1.0,CMP); + draw_component(CMP,11,WHITE); +} + +void drawing_line_type(int W, int H, float R, int width_rectangle, int height_rectangle, int color){ + setcolor(color); + setlinestyle(SOLID_LINE,0,0); + + drawLine((W-width_rectangle)*R+width_rectangle/5,height_rectangle*11.1+height_rectangle/6,W-width_rectangle/5,height_rectangle*12.1-height_rectangle/6,color,1); + drawLine((W-width_rectangle)*R+width_rectangle/5,height_rectangle*12.1+height_rectangle/6,W-width_rectangle/5,height_rectangle*13.1-height_rectangle/6,color,4); + drawLine((W-width_rectangle)*R+width_rectangle/5,height_rectangle*13.1+height_rectangle/6,W-width_rectangle/5,height_rectangle*14.1-height_rectangle/6,color,3); + drawLine((W-width_rectangle)*R+width_rectangle/5,height_rectangle*14.1+height_rectangle/6,W-width_rectangle/5,height_rectangle*15.1-height_rectangle/6,color,2); +} + +void draw_images(int W, int H, float R, char *current_path) +{ + readimagefile(path_for_images("icon.jpg",current_path),W/70+W/70,W/70+W/70,W/15+W/70,W/15+W/70); + + readimagefile(path_for_images("becstins.jpg",current_path),W-W/9+W/34,0.2*H/16,W-W/6.5+W/34,1.6*H/16); +} + +void draw_working_table(int W, int H, float R, char *current_path){ + cleardevice(); + + draw_images(W,H,R,current_path); + + create_workbench_workplace(W,H,R); + create_top_menu_workplace(W,H,R,W/12,H/24); + create_left_menu_workplace(W,H,R,W/9,H/16); + create_right_menu_workplace(W,H,R,W/9,H/16); + create_undo_redo_menu_workplace(W,H,R,W/18,H/16); + create_zoom_rotate_panel_workplace(W,H,R,W/10,H/22,WHITE); + create_text_workplace(W,H,R); + create_bulb(W,H,R,W/9,H/16,WHITE); + + messages_log_panel("Logs",W,H,R,W/9,H/16); + + draw_components_left_panel(W,H,R); +} + +#endif // WORKPLACE_PAGE_H_INCLUDED diff --git a/zoom_rotate_fader_workplace.h b/zoom_rotate_fader_workplace.h new file mode 100644 index 0000000..6c29e64 --- /dev/null +++ b/zoom_rotate_fader_workplace.h @@ -0,0 +1,109 @@ +#ifndef ZOOM_ROTATE_FADER_WORKPLACE_H_INCLUDED +#define ZOOM_ROTATE_FADER_WORKPLACE_H_INCLUDED + + +//Andrei CERBU +struct point +{ + int x, y; +}; + +struct fader +{ + point Centru; + int angle; + float R_ZOOM; +}; + + +//Andrei CERBU && Tudor Ilade +void create_zoom_rotate_fader_workplace(int W, int H, int R, int width_rectangle, int height_rectangle, int y, int id, int color) +{ + + if(id==1) + { + fader rrotate; + rrotate.Centru.x=(W-width_rectangle)*R+4*W/225; + rrotate.Centru.y=((height_rectangle*16.95)+(height_rectangle*19.7))*R/2; + if(y>((height_rectangle*16.5)*R)&&y<(height_rectangle*19.7)*R) + { + setcolor(color); + setlinestyle(SOLID_LINE,0,0); + rectangle(rrotate.Centru.x-W/140,y-H/70,rrotate.Centru.x+W/140,y+H/70); + setlinestyle(SOLID_LINE,0,0); + line((W-width_rectangle)*R+4*W/225,(height_rectangle*16.5)*R,(W-width_rectangle)*R+4*W/225,(height_rectangle*19.7)*R); + + + } + else if(y<((height_rectangle*16.4)*R)) + { + setcolor(color); + setlinestyle(SOLID_LINE,0,0); + rectangle(rrotate.Centru.x-W/140,((height_rectangle*16.4)*R),rrotate.Centru.x+W/140,(height_rectangle*16.4)*R+2*H/70); + setlinestyle(SOLID_LINE,0,0); + line((W-width_rectangle)*R+4*W/225,(height_rectangle*16.5)*R,(W-width_rectangle)*R+4*W/225,(height_rectangle*19.7)*R); + } + else if(y>(height_rectangle*19.7)*R) + { + setcolor(color); + setlinestyle(SOLID_LINE,0,0); + rectangle(rrotate.Centru.x-W/140,(height_rectangle*19.7)*R-2*H/70,rrotate.Centru.x+W/140,(height_rectangle*19.7)*R); + setlinestyle(SOLID_LINE,0,0); + line((W-width_rectangle)*R+4*W/225,(height_rectangle*16.5)*R,(W-width_rectangle)*R+4*W/225,(height_rectangle*19.7)*R); + } + } + else if(id == 2) + { + + fader zzom; + zzom.Centru.x=(W-width_rectangle)*R+4*W/225*4; + zzom.Centru.y=((height_rectangle*16.95)+(height_rectangle*19.7))*R/2; + + if(y-H/70>((height_rectangle*16.5)*R)&&y+H/70<(height_rectangle*19.7)*R) + { + setcolor(color); + setlinestyle(SOLID_LINE,0,0); + rectangle(zzom.Centru.x-W/140,y-H/70,zzom.Centru.x+W/140,y+H/70); + setlinestyle(SOLID_LINE,0,0); + line((W-width_rectangle)*R+4*W/225*4,(height_rectangle*16.5)*R,(W-width_rectangle)*R+4*W/225*4,(height_rectangle*19.7)*R); + + } + else if(y-H/70<((height_rectangle*16.4)*R)) + { + setcolor(color); + setlinestyle(SOLID_LINE,0,0); + rectangle(zzom.Centru.x-W/140,((height_rectangle*16.4)*R),zzom.Centru.x+W/140,(height_rectangle*16.4)*R+2*H/70); + setlinestyle(SOLID_LINE,0,0); + line((W-width_rectangle)*R+4*W/225*4,(height_rectangle*16.5)*R,(W-width_rectangle)*R+4*W/225*4,(height_rectangle*19.7)*R); + } + else if(y+H/70>(height_rectangle*19.7)*R) + { + setcolor(color); + setlinestyle(SOLID_LINE,0,0); + rectangle(zzom.Centru.x-W/140,(height_rectangle*19.7)*R-2*H/70,zzom.Centru.x+W/140,(height_rectangle*19.7)*R); + setlinestyle(SOLID_LINE,0,0); + line((W-width_rectangle)*R+4*W/225*4,(height_rectangle*16.5)*R,(W-width_rectangle)*R+4*W/225*4,(height_rectangle*19.7)*R); + } + } +} + +//Andrei Cerbu +int determine_angle_fader_position(int W, int H, int R, int width_rectangle, int height_rectangle, int x, int y) +{ + + fader rrotate, zzom; + rrotate.Centru.x=(W-width_rectangle)*R+4*W/225; + rrotate.Centru.y=((height_rectangle*16.95)+(height_rectangle*19.7))*R/2; + + zzom.Centru.x=(W-width_rectangle)*R+4*W/225*4; + zzom.Centru.y=((height_rectangle*16.95)+(height_rectangle*19.7))*R/2; + + + if(x>rrotate.Centru.x-W/140&&xrrotate.Centru.y-H/70&&yzzom.Centru.x-W/140 && x< zzom.Centru.x+W/140 && y>zzom.Centru.y-H/70 && zzom.Centru.y+H/70) + return 2; + return 0; +} + +#endif // ZOOM_ROTATE_FADER_WORKPLACE_H_INCLUDED