Changeset 1046:12bbf8604117 for src
- Timestamp:
- 04/06/22 18:15:57 (3 years ago)
- Branch:
- python3
- Phase:
- public
- Location:
- src/mlx
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/mlx/gui/flight.py
r1044 r1046 703 703 print("DPI", context.get_dpi_x(), context.get_dpi_y()) 704 704 705 logoSurface = cairo.ImageSurface.create_from_png( 706 os.path.join(wizard.gui.programDirectory, "mavalogo.png")) 707 705 708 scale = context.get_dpi_x() / 72.0 706 709 … … 709 712 cr.set_antialias(cairo.ANTIALIAS_GRAY) 710 713 711 cr.set_source_rgb(0.0, 0.0, 0.0)712 cr.set_line_width(2.0 * scale)713 cr.rectangle(0, 0, context.get_width(), context.get_height())714 cr.stroke()715 716 714 pcr = context.create_pango_context() 717 715 716 delimiter = "*" * 70 717 718 718 layout = Pango.Layout(pcr) 719 layout.set_text("Malév VA official briefing") 720 font = Pango.FontDescription(" sans")721 font.set_size(int( 32 * Pango.SCALE))722 font.set_weight(Pango.Weight. NORMAL)719 720 font = Pango.FontDescription("Courier") 721 font.set_size(int(12 * Pango.SCALE)) 722 font.set_weight(Pango.Weight.THIN) 723 723 layout.set_font_description(font) 724 724 725 fontBold = Pango.FontDescription("Courier") 726 fontBold.set_size(int(12 * Pango.SCALE)) 727 fontBold.set_weight(Pango.Weight.BOLD) 728 729 layout.set_text(delimiter) 725 730 (_ink, logical) = layout.get_extents() 726 731 width = logical.width / Pango.SCALE 727 732 733 x0 = (context.get_width() - width)/2.0 734 735 logoWidth = width / 3 736 logoScale = logoSurface.get_width() / logoWidth 737 728 738 y = 25 * scale 739 740 source = cr.get_source() 741 logoSurface.set_device_scale(logoScale, logoScale) 742 cr.set_source_surface(logoSurface, x0, y) 743 cr.rectangle(x0, y, logoSurface.get_width() / logoScale, 744 logoSurface.get_height() / logoScale) 745 cr.fill() 746 cr.set_source(source) 747 748 y += logoSurface.get_height() / logoScale 749 y += 12 * scale 750 751 cr.move_to(x0, y) 752 cr.set_line_width(0.1 * scale) 753 PangoCairo.layout_path(cr, layout) 754 cr.stroke_preserve() 755 cr.fill() 756 757 y += logical.height / Pango.SCALE 758 y += 4 * scale 759 760 layout.set_text("F L I G H T B R I E F I N G S H E E T") 761 (_ink, logical) = layout.get_extents() 762 width = logical.width / Pango.SCALE 729 763 730 764 cr.move_to((context.get_width() - width)/2.0, y) … … 735 769 736 770 y += logical.height / Pango.SCALE 737 y += 6 * scale 738 739 layout = Pango.Layout(pcr) 740 layout.set_text("%s (%s) részére" % 741 (loginResult.pilotName, loginResult.pilotID)) 742 font = Pango.FontDescription("sans") 743 font.set_size(int(16 * Pango.SCALE)) 744 font.set_weight(Pango.Weight.MEDIUM) 745 layout.set_font_description(font) 771 y += 4 * scale 772 773 layout.set_text(delimiter) 746 774 (_ink, logical) = layout.get_extents() 747 775 width = logical.width / Pango.SCALE 748 776 749 cr.move_to((context.get_width() - width)/2.0, y) 777 x2 = x0 + width * 0.4 778 779 cr.move_to(x0, y) 750 780 cr.set_line_width(0.1 * scale) 751 781 PangoCairo.layout_path(cr, layout) … … 754 784 755 785 y += logical.height / Pango.SCALE 786 y += 5 * scale 787 788 layout.set_text("AIRCRAFT: ") 789 layout.set_font_description(fontBold) 790 (_ink, logical) = layout.get_extents() 791 x1 = x0 + logical.width / Pango.SCALE 792 793 layout.set_text("FLIGHT:") 794 layout.set_font_description(fontBold) 795 796 cr.move_to(x0, y) 797 cr.set_line_width(0.1 * scale) 798 PangoCairo.layout_path(cr, layout) 799 cr.stroke_preserve() 800 cr.fill() 801 802 layout.set_text("%s %s-%s" % (flight.callsign, 803 flight.departureICAO, 804 flight.arrivalICAO)) 805 806 layout.set_font_description(font) 807 808 cr.move_to(x1, y) 809 cr.set_line_width(0.1 * scale) 810 PangoCairo.layout_path(cr, layout) 811 cr.stroke_preserve() 812 cr.fill() 813 814 layout.set_text("DATE:") 815 layout.set_font_description(fontBold) 816 (_ink, logical) = layout.get_extents() 817 x3 = x2 + logical.width / Pango.SCALE 818 819 cr.move_to(x2, y) 820 cr.set_line_width(0.1 * scale) 821 PangoCairo.layout_path(cr, layout) 822 cr.stroke_preserve() 823 cr.fill() 824 825 layout.set_text(" %s" % (flight.date,)) 826 layout.set_font_description(font) 827 828 cr.move_to(x3, y) 829 cr.set_line_width(0.1 * scale) 830 PangoCairo.layout_path(cr, layout) 831 cr.stroke_preserve() 832 cr.fill() 833 834 layout.set_text(" %02d:%02d" % (flight.departureTime.hour, 835 flight.departureTime.minute)) 836 (_ink, logical) = layout.get_extents() 837 x5 = x0 + width - logical.width / Pango.SCALE 838 cr.move_to(x5, y) 839 cr.set_line_width(0.1 * scale) 840 PangoCairo.layout_path(cr, layout) 841 cr.stroke_preserve() 842 cr.fill() 843 844 layout.set_text("ETD (UTC):") 845 layout.set_font_description(fontBold) 846 (_ink, logical) = layout.get_extents() 847 x4 = x5 - logical.width / Pango.SCALE 848 cr.move_to(x4, y) 849 cr.set_line_width(0.1 * scale) 850 PangoCairo.layout_path(cr, layout) 851 cr.stroke_preserve() 852 cr.fill() 853 854 y += logical.height / Pango.SCALE 756 855 y += 4 * scale 757 856 758 cr.move_to(0, y) 759 cr.line_to(context.get_width(), y) 760 cr.set_line_width(1.0 * scale) 761 cr.stroke() 762 763 y += 20 * scale 764 765 font = Pango.FontDescription("sans") 766 font.set_size(int(7 * Pango.SCALE)) 767 font.set_weight(Pango.Weight.ULTRALIGHT) 768 769 table = [] 770 table.append(("Flight", flight.callsign)) 771 table.append(("Date", flight.date)) 772 table.append(("Aircraft", 773 aircraftNames[flight.aircraftType] + ", Lajstrom: " + 774 flight.tailNumber)) 775 table.append(("DOW", 776 str(acft.getClass(flight.aircraftType).dow) + " kgs")) 777 table.append(("From", flight.departureICAO)) 778 table.append(("To", flight.arrivalICAO)) 779 table.append(("ETD (UTC)", flight.departureTime.strftime("%H:%M:%S"))) 780 table.append(("ETA (UTC)", flight.arrivalTime.strftime("%H:%M:%S"))) 781 table.append(("Crew", str(flight.numCrew))) 782 table.append(("Pass", str(flight.numPassengers))) 783 table.append(("Bag", str(flight.bagWeight))) 784 table.append(("Mail", str(flight.mailWeight))) 785 table.append(("Route", flight.route)) 786 787 tableY = y 788 tableX = 15 * scale 789 labelFill = 5 * scale 790 labelValueFill = 25 * scale 791 valueFill = 5 * scale 792 labelX = tableX + labelFill 793 tableWidth = context.get_width() * 55 / 100 - tableX 794 795 labelLayouts = [] 796 maxLabelWidth = 0 797 totalHeight = 0 798 for (label, value) in table: 799 labelLayout = Pango.Layout(pcr) 800 labelLayout.set_text(label) 801 labelLayout.set_font_description(font) 802 803 (_ink, logical) = labelLayout.get_extents() 804 maxLabelWidth = max(maxLabelWidth, logical.width) 805 labelHeight = logical.height 806 807 valueLayout = Pango.Layout(pcr) 808 valueLayout.set_text(value) 809 valueLayout.set_font_description(font) 810 811 labelLayouts.append((labelLayout, valueLayout, labelHeight)) 812 813 maxLabelWidth = maxLabelWidth / Pango.SCALE 814 815 valueX = labelX + labelValueFill + maxLabelWidth 816 817 layouts = [] 818 valueWidth = tableWidth - \ 819 (labelFill + maxLabelWidth + labelValueFill + valueFill) 820 for (labelLayout, valueLayout, labelHeight) in labelLayouts: 821 valueLayout.set_width(int(valueWidth * Pango.SCALE)) 822 823 (_ink, logical) = valueLayout.get_extents() 824 valueHeight = logical.height 825 826 height = float(max(labelHeight, valueHeight))/Pango.SCALE 827 layouts.append((labelLayout, valueLayout, height)) 828 829 rowIndex = 0 830 for (labelLayout, valueLayout, height) in layouts: 831 if (rowIndex%2)==0: 832 cr.set_source_rgb(0.85, 0.85, 0.85) 833 else: 834 cr.set_source_rgb(0.9, 0.9, 0.9) 835 836 cr.rectangle(tableX, y-2*scale, tableWidth, height + 4 * scale) 837 cr.fill() 838 839 cr.set_source_rgb(0.0, 0.0, 0.0) 840 841 cr.move_to(labelX, y) 842 cr.set_line_width(0.1) 843 PangoCairo.layout_path(cr, labelLayout) 857 layout.set_text("AIRCRAFT:") 858 layout.set_font_description(fontBold) 859 cr.move_to(x0, y) 860 cr.set_line_width(0.1 * scale) 861 PangoCairo.layout_path(cr, layout) 862 cr.stroke_preserve() 863 cr.fill() 864 865 layout.set_text(aircraftNames[flight.aircraftType].upper()) 866 layout.set_font_description(font) 867 cr.move_to(x1, y) 868 cr.set_line_width(0.1 * scale) 869 PangoCairo.layout_path(cr, layout) 870 cr.stroke_preserve() 871 cr.fill() 872 873 layout.set_text(" %02d:%02d" % (flight.arrivalTime.hour, 874 flight.arrivalTime.minute)) 875 cr.move_to(x5, y) 876 cr.set_line_width(0.1 * scale) 877 PangoCairo.layout_path(cr, layout) 878 cr.stroke_preserve() 879 cr.fill() 880 881 layout.set_text("ETA (UTC):") 882 layout.set_font_description(fontBold) 883 cr.move_to(x4, y) 884 cr.set_line_width(0.1 * scale) 885 PangoCairo.layout_path(cr, layout) 886 cr.stroke_preserve() 887 cr.fill() 888 889 y += logical.height / Pango.SCALE 890 y += 4 * scale 891 892 layout.set_text("CREW:") 893 layout.set_font_description(fontBold) 894 cr.move_to(x0, y) 895 cr.set_line_width(0.1 * scale) 896 PangoCairo.layout_path(cr, layout) 897 cr.stroke_preserve() 898 cr.fill() 899 900 layout.set_text("%d + %d" % (flight.numCockpitCrew, 901 flight.numCabinCrew)) 902 layout.set_font_description(font) 903 cr.move_to(x1, y) 904 cr.set_line_width(0.1 * scale) 905 PangoCairo.layout_path(cr, layout) 906 cr.stroke_preserve() 907 cr.fill() 908 909 layout.set_text("DOW:") 910 layout.set_font_description(fontBold) 911 cr.move_to(x4, y) 912 cr.set_line_width(0.1 * scale) 913 PangoCairo.layout_path(cr, layout) 914 cr.stroke_preserve() 915 cr.fill() 916 917 layout.set_text("%d KG" % (flight.dow,)) 918 layout.set_font_description(font) 919 (_ink, logical) = layout.get_extents() 920 x5 = x0 + width - logical.width / Pango.SCALE 921 cr.move_to(x5, y) 922 cr.set_line_width(0.1 * scale) 923 PangoCairo.layout_path(cr, layout) 924 cr.stroke_preserve() 925 cr.fill() 926 927 y += logical.height / Pango.SCALE 928 y += logical.height / Pango.SCALE 929 y += 4 * scale 930 931 layout.set_text("PASSENGERS") 932 layout.set_font_description(fontBold) 933 cr.move_to(x0, y) 934 cr.set_line_width(0.1 * scale) 935 PangoCairo.layout_path(cr, layout) 936 cr.stroke_preserve() 937 cr.fill() 938 939 layout.set_text("CARGO HOLDS") 940 layout.set_font_description(fontBold) 941 cr.move_to(x2, y) 942 cr.set_line_width(0.1 * scale) 943 PangoCairo.layout_path(cr, layout) 944 cr.stroke_preserve() 945 cr.fill() 946 947 layout.set_text("TOTAL") 948 layout.set_font_description(fontBold) 949 cr.move_to(x4, y) 950 cr.set_line_width(0.1 * scale) 951 PangoCairo.layout_path(cr, layout) 952 cr.stroke_preserve() 953 cr.fill() 954 955 y += logical.height / Pango.SCALE 956 y += 4 * scale 957 958 layout.set_text("CHILDREN:") 959 layout.set_font_description(font) 960 (_ink, logical) = layout.get_extents() 961 x1 = x0 + logical.width / Pango.SCALE 962 963 layout.set_text("CARGO:") 964 layout.set_font_description(font) 965 (_ink, logical) = layout.get_extents() 966 x3 = x2 + logical.width / Pango.SCALE 967 968 layout.set_text("ADULTS:") 969 layout.set_font_description(font) 970 cr.move_to(x0, y) 971 cr.set_line_width(0.1 * scale) 972 PangoCairo.layout_path(cr, layout) 973 cr.stroke_preserve() 974 cr.fill() 975 976 layout.set_text(" %3d" % (flight.numPassengers,)) 977 layout.set_font_description(font) 978 cr.move_to(x1, y) 979 cr.set_line_width(0.1 * scale) 980 PangoCairo.layout_path(cr, layout) 981 cr.stroke_preserve() 982 cr.fill() 983 984 layout.set_text("BAGS:") 985 layout.set_font_description(font) 986 cr.move_to(x2, y) 987 cr.set_line_width(0.1 * scale) 988 PangoCairo.layout_path(cr, layout) 989 cr.stroke_preserve() 990 cr.fill() 991 992 layout.set_text(" %5d KG" % (flight.bagWeight,)) 993 layout.set_font_description(font) 994 cr.move_to(x3, y) 995 cr.set_line_width(0.1 * scale) 996 PangoCairo.layout_path(cr, layout) 997 cr.stroke_preserve() 998 cr.fill() 999 1000 y += logical.height / Pango.SCALE 1001 y += 4 * scale 1002 1003 layout.set_text("CHILDREN:") 1004 layout.set_font_description(font) 1005 cr.move_to(x0, y) 1006 cr.set_line_width(0.1 * scale) 1007 PangoCairo.layout_path(cr, layout) 1008 cr.stroke_preserve() 1009 cr.fill() 1010 1011 layout.set_text(" %3d" % (flight.numChildren,)) 1012 layout.set_font_description(font) 1013 cr.move_to(x1, y) 1014 cr.set_line_width(0.1 * scale) 1015 PangoCairo.layout_path(cr, layout) 1016 cr.stroke_preserve() 1017 cr.fill() 1018 1019 layout.set_text("MAIL:") 1020 layout.set_font_description(font) 1021 cr.move_to(x2, y) 1022 cr.set_line_width(0.1 * scale) 1023 PangoCairo.layout_path(cr, layout) 1024 cr.stroke_preserve() 1025 cr.fill() 1026 1027 layout.set_text(" %5d KG" % (flight.mailWeight,)) 1028 layout.set_font_description(font) 1029 cr.move_to(x3, y) 1030 cr.set_line_width(0.1 * scale) 1031 PangoCairo.layout_path(cr, layout) 1032 cr.stroke_preserve() 1033 cr.fill() 1034 1035 layout.set_text("PAYLOAD:") 1036 layout.set_font_description(font) 1037 cr.move_to(x4, y) 1038 cr.set_line_width(0.1 * scale) 1039 PangoCairo.layout_path(cr, layout) 1040 cr.stroke_preserve() 1041 cr.fill() 1042 1043 layout.set_text("%5d KG" % (flight.payload,)) 1044 layout.set_font_description(font) 1045 (_ink, logical) = layout.get_extents() 1046 x5 = x0 + width - logical.width / Pango.SCALE 1047 cr.move_to(x5, y) 1048 cr.set_line_width(0.1 * scale) 1049 PangoCairo.layout_path(cr, layout) 1050 cr.stroke_preserve() 1051 cr.fill() 1052 1053 y += logical.height / Pango.SCALE 1054 y += 4 * scale 1055 1056 layout.set_text("INFANTS:") 1057 layout.set_font_description(font) 1058 cr.move_to(x0, y) 1059 cr.set_line_width(0.1 * scale) 1060 PangoCairo.layout_path(cr, layout) 1061 cr.stroke_preserve() 1062 cr.fill() 1063 1064 layout.set_text(" %3d" % (flight.numInfants,)) 1065 layout.set_font_description(font) 1066 cr.move_to(x1, y) 1067 cr.set_line_width(0.1 * scale) 1068 PangoCairo.layout_path(cr, layout) 1069 cr.stroke_preserve() 1070 cr.fill() 1071 1072 layout.set_text("CARGO:") 1073 layout.set_font_description(font) 1074 cr.move_to(x2, y) 1075 cr.set_line_width(0.1 * scale) 1076 PangoCairo.layout_path(cr, layout) 1077 cr.stroke_preserve() 1078 cr.fill() 1079 1080 layout.set_text(" %5d KG" % (flight.cargoWeight,)) 1081 layout.set_font_description(font) 1082 cr.move_to(x3, y) 1083 cr.set_line_width(0.1 * scale) 1084 PangoCairo.layout_path(cr, layout) 1085 cr.stroke_preserve() 1086 cr.fill() 1087 1088 layout.set_text("ZFW:") 1089 layout.set_font_description(font) 1090 cr.move_to(x4, y) 1091 cr.set_line_width(0.1 * scale) 1092 PangoCairo.layout_path(cr, layout) 1093 cr.stroke_preserve() 1094 cr.fill() 1095 1096 layout.set_text("%5d KG" % (flight.dow + flight.payload,)) 1097 layout.set_font_description(font) 1098 (_ink, logical) = layout.get_extents() 1099 x5 = x0 + width - logical.width / Pango.SCALE 1100 cr.move_to(x5, y) 1101 cr.set_line_width(0.1 * scale) 1102 PangoCairo.layout_path(cr, layout) 1103 cr.stroke_preserve() 1104 cr.fill() 1105 1106 y += logical.height / Pango.SCALE 1107 y += logical.height / Pango.SCALE 1108 y += 4 * scale 1109 1110 layout.set_text("ROUTE:") 1111 layout.set_font_description(fontBold) 1112 (_ink, logical) = layout.get_extents() 1113 x1 = x0 + logical.width / Pango.SCALE 1114 cr.move_to(x0, y) 1115 cr.set_line_width(0.1 * scale) 1116 PangoCairo.layout_path(cr, layout) 1117 cr.stroke_preserve() 1118 cr.fill() 1119 1120 routeWords = flight.route.split(" ") 1121 layout.set_font_description(font) 1122 1123 startWord = 0 1124 textWidth = width - (x1 - x0) 1125 while startWord<len(routeWords): 1126 endWord = startWord + 1 1127 while endWord<=len(routeWords): 1128 layout.set_text(" %s" % (" ".join(routeWords[startWord:endWord]),)) 1129 (_ink, logical) = layout.get_extents() 1130 if textWidth<logical.width / Pango.SCALE: 1131 endWord -= 1 1132 if endWord<=startWord: 1133 endWord = startWord + 1 1134 break 1135 endWord += 1 1136 1137 layout.set_text(" %s" % (" ".join(routeWords[startWord:endWord]),)) 1138 cr.move_to(x1, y) 1139 cr.set_line_width(0.1 * scale) 1140 PangoCairo.layout_path(cr, layout) 844 1141 cr.stroke_preserve() 845 1142 cr.fill() 846 1143 847 cr.move_to(valueX, y) 848 cr.set_line_width(0.1) 849 PangoCairo.layout_path(cr, valueLayout) 850 cr.stroke_preserve() 851 cr.fill() 852 853 y += height 1144 startWord = endWord 1145 1146 y += logical.height / Pango.SCALE 854 1147 y += 4 * scale 855 1148 856 rowIndex += 1 857 858 cr.set_source_rgb(0.0, 0.0, 0.0) 859 cr.set_line_width(1.0 * scale) 860 cr.rectangle(tableX, tableY - 2 * scale, tableWidth, y - tableY) 861 cr.stroke() 862 863 cr.move_to(valueX - 5 * scale, tableY - 2 * scale) 864 cr.line_to(valueX - 5 * scale, y - 2 * scale) 865 cr.stroke() 1149 y += logical.height / Pango.SCALE 1150 1151 layout.set_text(delimiter) 1152 layout.set_font_description(font) 1153 cr.move_to(x0, y) 1154 cr.set_line_width(0.1 * scale) 1155 PangoCairo.layout_path(cr, layout) 1156 cr.stroke_preserve() 1157 cr.fill() 866 1158 867 1159 def _deleteClicked(self, button): -
src/mlx/gui/gui.py
r1037 r1046 105 105 self.toRestart = False 106 106 107 @property 108 def programDirectory(self): 109 """Get the program directory.""" 110 return self._programDirectory 111 107 112 def build(self, iconDirectory): 108 113 """Build the GUI.""" -
src/mlx/rpc.py
r1044 r1046 369 369 self.arrivalTime += datetime.timedelta(days = 1) 370 370 371 @property 372 def payload(self): 373 """Get the default payload of the flight.""" 374 payload= (self.numCabinCrew - self.dowNumCabinCrew) * \ 375 const.WEIGHT_CABIN_CREW 376 payload += self.numPassengers * \ 377 (const.WEIGHT_PASSENGER_CHARTER 378 if self.flightType==const.FLIGHTTYPE_CHARTER 379 else const.WEIGHT_PASSENGER) 380 payload += self.numChildren * const.WEIGHT_CHILD 381 payload += self.numInfants * const.WEIGHT_INFANT 382 payload += self.bagWeight 383 payload += self.cargoWeight 384 payload += self.mailWeight 385 return payload 386 371 387 def readFromFile(self, f, fleet): 372 388 """Read the data of the flight from a file via the given file
Note:
See TracChangeset
for help on using the changeset viewer.