Changeset 67 in flair-src
- Timestamp:
- Aug 29, 2016, 4:58:23 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/lib/FlairCore/src/FrameworkManager_impl.cpp
r55 r67 181 181 status = UDT::close(com_sock); 182 182 if (status != 0) 183 printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());183 Printf("Error udt::close %s", UDT::getlasterror().getErrorMessage()); 184 184 185 185 status = UDT::close(file_sock); 186 186 if (status != 0) 187 printf("Error udt::close %s", UDT::getlasterror().getErrorMessage());187 Printf("Error udt::close %s", UDT::getlasterror().getErrorMessage()); 188 188 189 189 SleepMS(200); // a revoir, sinon UDT::cleanup bloque en RT … … 294 294 xmlDoc *doc; 295 295 rcv_buf[bytesRead] = 0; 296 296 //Printf("%s\n",rcv_buf); 297 297 doc = xmlReadMemory(rcv_buf, (int)bytesRead, "include.xml", 298 298 "ISO-8859-1", 0); -
trunk/lib/FlairCore/src/Map.cpp
r15 r67 21 21 #include "GeoCoordinate.h" 22 22 #include "FrameworkManager.h" 23 #include <cmath> 23 24 #include <string.h> 24 25 #include <sstream> … … 80 81 void Map::ExtraXmlEvent(void) { 81 82 82 // attention pas rt safe (creation checkpoint)83 // attention pas rt safe (creation/destruction checkpoint) 83 84 size_t i = 0; 84 85 while (1) { 85 // printf("test %i\n",i);86 86 double latitude, longitude; 87 87 double altitude = 0; … … 90 90 long_prop << "long" << i; 91 91 alt_prop << "alt" << i; 92 92 93 if (GetPersistentXmlProp(lat_prop.str(), latitude) && 93 94 GetPersistentXmlProp(long_prop.str(), longitude)) { 94 95 GetPersistentXmlProp(alt_prop.str(), altitude); 96 95 97 if (i >= checkpoints.size()) { 98 //add checkpoint 96 99 GeoCoordinate *checkpoint = new GeoCoordinate( 97 100 this, "checkpoint", latitude, longitude, altitude); 98 101 checkpoints.push_back(checkpoint); 99 // printf("add %i\n",i); 102 } else if(isnan(latitude) || isnan(longitude)) { 103 //delete checkpoint 104 removeCheckpoint(i); 105 break;//si delete, la station sol n'envoit que cette info 100 106 } else { 107 //move checkpoint 101 108 checkpoints.at(i)->SetCoordinates(latitude, longitude, altitude); 102 109 } … … 107 114 i++; 108 115 } 109 116 /* 110 117 for (size_t i = 0; i < checkpoints.size(); i++) { 111 118 double latitude, longitude, altitude; 112 119 checkpoints.at(i)->GetCoordinates(&latitude, &longitude, &altitude); 113 // printf("%i %f %f\n",i,latitude,longitude); 120 printf("%i %f %f\n",i,latitude,longitude); 121 }*/ 122 } 123 124 void Map::removeCheckpoint(size_t index) { 125 //left shift 126 for (size_t i = index; i < checkpoints.size()-1; i++) { 127 double latitude, longitude, altitude; 128 checkpoints.at(i+1)->GetCoordinates(&latitude, &longitude, &altitude); 129 checkpoints.at(i)->SetCoordinates(latitude,longitude,altitude); 114 130 } 131 132 //remove last one 133 delete checkpoints.back(); 134 checkpoints.pop_back(); 135 136 //remove last one in xml 137 ostringstream lat_prop, long_prop, alt_prop; 138 lat_prop << "lat" << checkpoints.size(); 139 long_prop << "long" << checkpoints.size(); 140 alt_prop << "alt" << checkpoints.size(); 141 UnsetPersistentXmlProp(lat_prop.str()); 142 UnsetPersistentXmlProp(long_prop.str()); 143 UnsetPersistentXmlProp(alt_prop.str()); 115 144 } 116 145 -
trunk/lib/FlairCore/src/Map.h
r15 r67 77 77 void ExtraXmlEvent(void); 78 78 79 void removeCheckpoint(size_t index); 80 79 81 std::vector<core::GeoCoordinate *> checkpoints; 80 82 std::vector<const core::GeoCoordinate *> to_draw; -
trunk/lib/FlairCore/src/Widget.cpp
r15 r67 82 82 if (GetPersistentXmlProp<double>(prop, tmp)) { 83 83 value = tmp; 84 return true; 85 } else { 86 return false; 87 } 88 } 89 90 template <> 91 bool Widget::GetPersistentXmlProp(std::string prop, std::string &value) { 92 xmlChar *result = NULL; 93 result = xmlGetProp(pimpl_->file_node, (xmlChar *)prop.c_str()); 94 if (result != NULL) { 95 value = std::string((char *)result); 96 xmlFree(result); 84 97 return true; 85 98 } else { … … 208 221 } 209 222 223 template <> void Widget::SetPersistentXmlProp(std::string prop, std::string value) { 224 SetVolatileXmlProp(prop, value); 225 SetVolatileXmlProp(prop, value, pimpl_->file_node); 226 } 227 228 void Widget::UnsetPersistentXmlProp(std::string prop) { 229 xmlUnsetProp(pimpl_->file_node, (xmlChar *)prop.c_str()); 230 } 231 210 232 void Widget::SendXml(void) { pimpl_->SendXml(); } 211 233 -
trunk/lib/FlairCore/src/Widget.h
r15 r67 143 143 virtual void XmlEvent(void){}; 144 144 145 /*! 146 * \brief Unset a persistent xml property 147 * 148 * Unset an existent property, so it won't be saved. 149 * 150 * \param prop property to set 151 */ 152 void UnsetPersistentXmlProp(std::string prop); 153 145 154 private: 146 155 class Widget_impl *pimpl_; -
trunk/lib/FlairSensorActuator/src/NmeaGps.cpp
r55 r67 195 195 if (result != 1) { 196 196 Warn("unrecognized nmea sentence: %s\n",frame); 197 return; 197 198 } 198 199 -
trunk/tools/FlairGCS/src/DataRemote.cpp
r15 r67 78 78 79 79 void DataRemote::SendPeriod(int period, bool auto_refresh) { 80 RemoveAllAttributes(); 81 80 82 SetAttribute("period", period); 81 83 SetAttribute("enabled", auto_refresh); -
trunk/tools/FlairGCS/src/Landmark.cpp
r15 r67 46 46 } 47 47 48 bool Landmark::IsUptodate(void) { 49 if(text->brush()==QBrush(Qt::white)) { 50 return true; 51 } else { 52 return false; 53 } 54 } 55 48 56 void Landmark::setCoordinate(const QGeoCoordinate &coordinate) { 49 57 pixmap->setCoordinate(coordinate); -
trunk/tools/FlairGCS/src/Landmark.h
r15 r67 29 29 void RemoveLandmark(void); 30 30 void AddLandmark(QtMobility::QGraphicsGeoMap *geoMap); 31 bool IsUptodate(void); 31 32 32 33 private: -
trunk/tools/FlairGCS/src/Map.cpp
r62 r67 95 95 for (int i = 0; i < points.count(); i++) delete points.at(i); 96 96 delete mapWidget; 97 98 if(geoMap!=0) delete geoMap;99 97 } 100 98 -
trunk/tools/FlairGCS/src/Map.h
r15 r67 25 25 class Map : public DataRemote { 26 26 Q_OBJECT 27 28 friend class MapWidget; 27 29 28 30 public: -
trunk/tools/FlairGCS/src/XmlWidget.cpp
r15 r67 291 291 } 292 292 293 void XmlWidget::RemoveAllAttributes() { 294 QString name = write_elem.attribute("name"); 295 296 QDomNamedNodeMap attributes=write_elem.attributes(); 297 while(attributes.count()!=0) { 298 printf("%i %s\n",attributes.count(),attributes.item(0).toAttr().name().toLocal8Bit().constData()); 299 write_elem.removeAttribute(attributes.item(0).toAttr().name()); 300 } 301 SetAttribute("name", name); 302 } 303 293 304 void XmlWidget::RenamedFrom(QString old_name) { 294 305 QString name = write_elem.attribute("name"); -
trunk/tools/FlairGCS/src/XmlWidget.h
r16 r67 68 68 void SetAttribute(const QString &name, float value); 69 69 void SetAttribute(const QString &name, double value); 70 void RemoveAllAttributes(); //except name 70 71 void RemoveAttribute(const QString &name); 71 72 }; -
trunk/tools/FlairGCS/src/mapwidget.cpp
r62 r67 54 54 #include "Landmark.h" 55 55 #include "Map.h" 56 #include "ConnectionLayout.h" 56 57 57 58 using namespace QtMobility; … … 66 67 pressed = false; 67 68 landmark_match = NULL; 68 is_uptodate = true;69 69 this->map = map; 70 70 … … 107 107 QList<QAction *> centered_actions; 108 108 109 //add centered for every point 109 110 QMenu *centered_menu = menu->addMenu("centered"); 110 111 for (int i = 0; i < points.count(); i++) { … … 122 123 123 124 b = menu->addAction("place checkpoint"); 125 126 //add go to for every landmark 124 127 QMenu *go_to_menu = menu->addMenu("go to"); 125 128 for (int i = 0; i < landmarks->count(); i++) { … … 134 137 z = map->execmenu(this, menu, event->globalPos()); 135 138 139 //center to the desired point 136 140 for (int i = 0; i < centered_actions.count(); i++) { 137 141 if (z == centered_actions.at(i)) { … … 146 150 } 147 151 152 //add a landmark 148 153 if (z == b) { 149 154 Landmark *landmark = new Landmark( … … 151 156 QString("%1").arg(landmarks->count() + 1)); 152 157 landmarks->append(landmark); 153 is_uptodate = false;154 158 } 155 159 for (int i = 0; i < go_to_actions.count(); i++) { … … 161 165 } 162 166 167 //delete landmark 163 168 } else { 164 169 QAction *a, *z; 165 170 a = menu->addAction("delete"); 166 z = menu->exec(event->globalPos()); 167 168 if (z == a) { 169 int i; 170 for (i = 0; i < landmarks->count(); i++) { 171 if (landmarks->at(i)->contains( 171 //get selected landmark id 172 int landmark_index; 173 for (landmark_index = 0; landmark_index < landmarks->count(); landmark_index++) { 174 if (landmarks->at(landmark_index)->contains( 172 175 geoMap->screenPositionToCoordinate(event->pos()))) { 173 delete landmarks->at(i); 174 landmarks->removeAt(i); 176 a->setEnabled(landmarks->at(landmark_index)->IsUptodate()); 175 177 break; 176 178 } 177 } 178 for (int j = i; j < landmarks->count(); j++) { 179 } 180 z = menu->exec(event->globalPos()); 181 182 if (z == a) { 183 //remove from landmarks_old 184 for (int i = 0; i < landmarks_old->count(); i++) { 185 if (landmarks_old->at(i)->contains( 186 geoMap->screenPositionToCoordinate(event->pos()))) { 187 landmarks_old->removeAt(i); 188 break; 189 } 190 } 191 192 //remove from landmarks 193 delete landmarks->at(landmark_index); 194 landmarks->removeAt(landmark_index); 195 196 //reorder the remaining ones 197 for (int j = landmark_index; j < landmarks->count(); j++) { 179 198 landmarks->at(j)->setText(QString("%1").arg(j + 1)); 180 199 } 200 201 //send delete 202 map->RemoveAllAttributes(); 203 map->SetAttribute("lat" + QString::number(landmark_index),"delete"); 204 map->SetAttribute("long" + QString::number(landmark_index),"delete"); 205 map->connectionLayout()->XmlToSend(map->XmlDoc()); 206 map->RemoveAttribute("lat" + QString::number(landmark_index)); 207 map->RemoveAttribute("long" + QString::number(landmark_index)); 181 208 } 182 209 } … … 219 246 landmark_match = landmarks->at(i); 220 247 landmark_match->setColor(Qt::red); 221 is_uptodate = false;222 248 } 223 249 new_cursor = Qt::PointingHandCursor; … … 290 316 } 291 317 292 bool MapWidget::IsUptodate(void) { return is_uptodate; } 318 bool MapWidget::IsUptodate(void) { 319 for (int i = 0; i < landmarks->count(); i++) { 320 if(!landmarks->at(i)->IsUptodate()) return false; 321 } 322 return true; 323 } 293 324 294 325 void MapWidget::SetUptodate(void) { … … 306 337 landmarks_old->at(i)->setVisible(false); 307 338 } 308 309 is_uptodate = true;310 339 } 311 340 … … 323 352 landmarks->at(i)->setColor(Qt::white); 324 353 } 325 326 is_uptodate = true;327 354 } 328 355 -
trunk/tools/FlairGCS/src/mapwidget.h
r62 r67 94 94 QPoint dragStartPosition; 95 95 bool pressed; 96 bool is_uptodate;97 96 98 97 QGraphicsScene *m_scene;
Note:
See TracChangeset
for help on using the changeset viewer.