1 #include "plottyfile.h" 15 this->function_type = function_type;
20 if(quadrant < 1 || quadrant > 4)
21 throw std::range_error(
"Ungueltiger Quadrant");
22 this->quadrant = quadrant;
37 this->para_first = para_first;
42 this->para_stepwidth = para_stepwidth;
47 this->unit_x = unit_x;
52 this->desc_x = desc_x;
57 this->unit_y = unit_y;
62 this->desc_y = desc_y;
67 this->unit_para = unit_para;
72 this->desc_para = desc_para;
102 return para_stepwidth;
135 void PlottyFile::prepStr(std::string& str, uint8_t len)
137 if(str.length() > len)
138 throw std::runtime_error(
"Zu grosser String.");
140 if(str.length() != len)
143 while(str.length() < len)
150 throw std::length_error(
"Es wurden keine Punkte gespeichert.");
152 prepStr(unit_x, STR_LEN_SHORT);
153 prepStr(desc_x, STR_LEN_LARGE);
154 prepStr(unit_y, STR_LEN_SHORT);
155 prepStr(desc_y, STR_LEN_LARGE);
156 prepStr(unit_para, STR_LEN_SHORT);
157 prepStr(desc_para, STR_LEN_LARGE);
159 std::ofstream file(filename);
162 file.write(reinterpret_cast<char*>(&command), 1);
163 file.write(head.c_str(), head.length());
164 file.write(filetype.c_str(), filetype.length());
165 file.write(reinterpret_cast<char*>(&version), 2);
166 file.write(reinterpret_cast<char*>(&subversion), 2);
167 file.put(static_cast<uint8_t>(function_type));
168 file.write(reinterpret_cast<char*>(&quadrant), 1);
169 file.write(reinterpret_cast<char*>(&ref_x), 2);
170 file.write(reinterpret_cast<char*>(&ref_y), 2);
171 file.write(reinterpret_cast<char*>(¶_first), 2);
172 file.write(reinterpret_cast<char*>(¶_stepwidth), 2);
173 file.write(unit_x.c_str(), unit_x.length());
174 file.write(desc_x.c_str(), desc_x.length());
175 file.write(unit_y.c_str(), unit_y.length());
176 file.write(desc_y.c_str(), desc_y.length());
177 file.write(unit_para.c_str(), unit_para.length());
178 file.write(desc_para.c_str(), desc_para.length());
179 file.write(reinterpret_cast<const char*>(&eof), 1);
182 while(file.tellp() < 256)
187 file.put((dot.getX() >> 8) | (static_cast<uint8_t>(dot.getCurve()) << 2));
188 file.put(dot.getX() & 0xFF);
189 file.put(dot.getY() >> 8);
190 file.put(dot.getY() & 0xFF);
198 int code = system((
"plotty --in " + filename).c_str());
200 throw std::runtime_error(
"Fehler beim Aufruf von plotty");