VGradientEx::VGradientEx( VGradientEx::Type type ) : m_type( type ) { // set up dummy gradient addStop( ScColor(255,0,0) , 0.0, 0.5, 1.0 ); addStop( ScColor(255,255,0) , 1.0, 0.5, 1.0 ); setOrigin( FPoint( 0, 0 ) ); setVector( FPoint( 0, 50 ) ); setRepeatMethod( VGradientEx::reflect ); }
// =========================================================================== // method definitions // =========================================================================== ROVehicle::ROVehicle(const SUMOVehicleParameter& pars, RORouteDef* route, const SUMOVTypeParameter* type, const RONet* net) : myParameter(pars), myType(type), myRoute(route) { myParameter.stops.clear(); if (route != 0) { for (std::vector<SUMOVehicleParameter::Stop>::const_iterator s = route->getFirstRoute()->getStops().begin(); s != route->getFirstRoute()->getStops().end(); ++s) { addStop(*s, net); } } for (std::vector<SUMOVehicleParameter::Stop>::const_iterator s = pars.stops.begin(); s != pars.stops.end(); ++s) { addStop(*s, net); } }
VGradient::VGradient( VGradientType type ) : m_type( type ) { // set up dummy gradient QColor color; color = QColor(255,0,0); addStop( color, 0.0, 0.5, 1.0 ); color = QColor(255,255,0); addStop( color, 1.0, 0.5, 1.0 ); setOrigin( FPoint( 0, 0 ) ); setVector( FPoint( 0, 50 ) ); setRepeatMethod( VGradient::pad ); }
Gradient::Gradient(QString filename) { QFile file(filename); if (file.open(QIODevice::ReadOnly | QIODevice::Text)) { QString line; while (!file.atEnd()) { line = file.readLine(); if (line.startsWith("stop:",Qt::CaseInsensitive)) { int colonPos, slashPos, fCommmaPos, sCommaPos; colonPos = line.indexOf(":"); slashPos = line.indexOf("/"); fCommmaPos = line.indexOf(","); sCommaPos = line.lastIndexOf(","); QString position, red, green, blue; position = line.mid(colonPos + 1, slashPos - colonPos - 1); red = line.mid(slashPos + 1, fCommmaPos - slashPos - 1); green = line.mid(fCommmaPos + 1, sCommaPos - fCommmaPos - 1); blue = line.mid(sCommaPos + 1, -1); addStop(new Stop(position.toInt(),QColor(red.toInt(),green.toInt(),blue.toInt()))); } } file.close(); } }
int GradientStopEditor::addStop( const QPointF &position ) { int newStopValue = 255 - int( ( qreal( position.y() ) / qreal( height() - 1 ) ) * 255.0 ); qreal newStopPosition = qreal( position.x() ) / qreal( width() - 1 ); return addStop( newStopValue, newStopPosition ); }
void MainWindow::addStopClicked() { ui->stopsView->setColumnWidth(0, 190); ui->stopsView->setColumnWidth(1, 30); ui->progressBar->setVisible(true); ui->progressBar->setValue(25); emit addStop(ui->stopLineEdit->text()); }
void SUMORouteHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) { switch (element) { case SUMO_TAG_VEHICLE: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_PERSON: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs, false, false, true); break; case SUMO_TAG_CONTAINER: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_FLOW: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseFlowAttributes(attrs, myBeginDefault, myEndDefault); break; case SUMO_TAG_VTYPE: myCurrentVType = SUMOVehicleParserHelper::beginVTypeParsing(attrs, getFileName()); break; case SUMO_TAG_VTYPE_DISTRIBUTION: openVehicleTypeDistribution(attrs); break; case SUMO_TAG_ROUTE: openRoute(attrs); break; case SUMO_TAG_ROUTE_DISTRIBUTION: openRouteDistribution(attrs); break; case SUMO_TAG_STOP: addStop(attrs); break; case SUMO_TAG_TRIP: { myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs, true); if (myVehicleParameter->id == "") { //@todo warn about deprecation of missing trip ids myVehicleParameter->id = myIdSupplier.getNext(); } myVehicleParameter->setParameter |= VEHPARS_FORCE_REROUTE; myActiveRouteID = "!" + myVehicleParameter->id; break; } case SUMO_TAG_INTERVAL: { bool ok; myBeginDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, 0, ok); myEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, 0, ok); break; } case SUMO_TAG_PARAM: addParam(attrs); break; default: break; } }
void DivePlannerPointsModel::createSimpleDive() { // initialize the start time in the plan diveplan.when = displayed_dive.when; // Use gas from the first cylinder int cylinderid = 0; // If we're in drop_stone_mode, don't add a first point. // It will be added implicit. if (!prefs.drop_stone_mode) addStop(M_OR_FT(15, 45), 1 * 60, cylinderid, 0, true); addStop(M_OR_FT(15, 45), 20 * 60, 0, 0, true); if (!isPlanner()) { addStop(M_OR_FT(5, 15), 42 * 60, 0, cylinderid, true); addStop(M_OR_FT(5, 15), 45 * 60, 0, cylinderid, true); } updateMaxDepth(); }
void MSBaseVehicle::addStops(const bool ignoreStopErrors) { for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = myParameter->stops.begin(); i != myParameter->stops.end(); ++i) { std::string errorMsg; if (!addStop(*i, errorMsg) && !ignoreStopErrors) { throw ProcessError(errorMsg); } if (errorMsg != "") { WRITE_WARNING(errorMsg); } } for (std::vector<SUMOVehicleParameter::Stop>::const_iterator i = myRoute->getStops().begin(); i != myRoute->getStops().end(); ++i) { std::string errorMsg; if (!addStop(*i, errorMsg) && !ignoreStopErrors) { throw ProcessError(errorMsg); } if (errorMsg != "") { WRITE_WARNING(errorMsg); } } }
void VGradient::setStop( const QColor &color, double rampPoint, double midPoint, double opa, QString name, int shade ) { for (int i = 0; i < m_colorStops.count(); ++i) { if (m_colorStops.at(i)->rampPoint == rampPoint) { delete m_colorStops.takeAt(i); break; } } addStop(color, rampPoint, midPoint, opa, name, shade); }
void DivePlannerPointsModel::createSimpleDive() { struct gasmix gas = { 0 }; // initialize the start time in the plan diveplan.when = displayed_dive.when; if (isPlanner()) // let's use the gas from the first cylinder gas = displayed_dive.cylinder[0].gasmix; // If we're in drop_stone_mode, don't add a first point. // It will be added implicit. if (!prefs.drop_stone_mode) addStop(M_OR_FT(15, 45), 1 * 60, &gas, 0, true); addStop(M_OR_FT(15, 45), 20 * 60, &gas, 0, true); if (!isPlanner()) { addStop(M_OR_FT(5, 15), 42 * 60, &gas, 0, true); addStop(M_OR_FT(5, 15), 45 * 60, &gas, 0, true); } }
// =========================================================================== // method definitions // =========================================================================== ROVehicle::ROVehicle(const SUMOVehicleParameter& pars, RORouteDef* route, const SUMOVTypeParameter* type, const RONet* net, MsgHandler* errorHandler) : RORoutable(pars, type), myRoute(route) { getParameter().stops.clear(); if (route != nullptr && route->getFirstRoute() != nullptr) { for (std::vector<SUMOVehicleParameter::Stop>::const_iterator s = route->getFirstRoute()->getStops().begin(); s != route->getFirstRoute()->getStops().end(); ++s) { addStop(*s, net, errorHandler); } } for (std::vector<SUMOVehicleParameter::Stop>::const_iterator s = pars.stops.begin(); s != pars.stops.end(); ++s) { addStop(*s, net, errorHandler); } if (pars.via.size() != 0) { // via takes precedence over stop edges // XXX check for inconsistencies #2275 myStopEdges.clear(); for (std::vector<std::string>::const_iterator it = pars.via.begin(); it != pars.via.end(); ++it) { assert(net->getEdge(*it) != 0); myStopEdges.push_back(net->getEdge(*it)); } } }
void DivePlannerPointsModel::loadFromDive(dive *d) { int depthsum = 0; int samplecount = 0; bool oldRec = recalc; recalc = false; CylindersModel::instance()->updateDive(); duration_t lasttime = {}; duration_t newtime = {}; struct gasmix gas; free_dps(&diveplan); diveplan.when = d->when; // is this a "new" dive where we marked manually entered samples? // if yes then the first sample should be marked // if it is we only add the manually entered samples as waypoints to the diveplan // otherwise we have to add all of them bool hasMarkedSamples = false; if (d->dc.samples) hasMarkedSamples = d->dc.sample[0].manually_entered; // if this dive has more than 100 samples (so it is probably a logged dive), // average samples so we end up with a total of 100 samples. int plansamples = d->dc.samples <= 100 ? d->dc.samples : 100; int j = 0; for (int i = 0; i < plansamples - 1; i++) { while (j * plansamples <= i * d->dc.samples) { const sample &s = d->dc.sample[j]; if (s.time.seconds != 0 && (!hasMarkedSamples || s.manually_entered)) { depthsum += s.depth.mm; ++samplecount; newtime = s.time; } j++; } if (samplecount) { get_gas_at_time(d, &d->dc, lasttime, &gas); addStop(depthsum / samplecount, newtime.seconds, &gas, 0, true); lasttime = newtime; depthsum = 0; samplecount = 0; } } recalc = oldRec; emitDataChanged(); }
int GradientStopEditor::moveStop( int stop, int newStopValue, qreal newStopPosition ) { if( ( stop < 0 ) || ( stop >= values.size() ) ) return -1; if( newStopValue < 0 ) newStopValue = 0; if( newStopValue > 255 ) newStopValue = 255; if( stop != 0 && stop != ( values.size() - 1 ) ) { if( newStopPosition < 0 ) newStopPosition = 0; if( newStopPosition > 1.0 ) newStopPosition = 1.0; } else newStopPosition = positions[ stop ]; if( ( stop == 0 ) || ( stop == ( values.size() - 1 ) ) ) { values[ stop ] = newStopValue; if( stopChannel == composite ) generateBackground( true ); update(); emit stopMoved( stop, newStopValue, newStopPosition, stop ); return stop; } values.remove( stop ); positions.remove( stop ); int newIndex = addStop( newStopValue, newStopPosition, false ); if( currentMovedStop == stop ) currentMovedStop = newIndex; emit stopMoved( stop, newStopValue, newStopPosition, newIndex ); if( stopChannel == composite ) generateBackground( true ); update(); return newIndex; }
void GradientStopEditor::mousePressEvent( QMouseEvent * event ) { switch( event->button() ) { case Qt::LeftButton: currentMovedStop = stopFromPoint( event->pos() ); if( currentMovedStop == -1 ) currentMovedStop = addStop( event->pos() ); break; case Qt::RightButton: deleteStop( stopFromPoint( event->pos() ) ); break; default: break; } }
void SUMORouteHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) { switch (element) { case SUMO_TAG_VEHICLE: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_PERSON: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_FLOW: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseFlowAttributes(attrs); break; case SUMO_TAG_VTYPE: myCurrentVType = SUMOVehicleParserHelper::beginVTypeParsing(attrs, getFileName()); break; case SUMO_TAG_VTYPE_DISTRIBUTION: openVehicleTypeDistribution(attrs); break; case SUMO_TAG_ROUTE: openRoute(attrs); break; case SUMO_TAG_ROUTE_DISTRIBUTION: openRouteDistribution(attrs); break; case SUMO_TAG_STOP: addStop(attrs); break; case SUMO_TAG_TRIP: { myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); myVehicleParameter->setParameter |= VEHPARS_FORCE_REROUTE; myActiveRouteID = "!" + myVehicleParameter->id; } break; default: break; } }
QgsVectorGradientColorRampV2Dialog::QgsVectorGradientColorRampV2Dialog( QgsVectorGradientColorRampV2* ramp, QWidget* parent ) : QDialog( parent ), mRamp( ramp ) { setupUi( this ); connect( btnColor1, SIGNAL( clicked() ), this, SLOT( setColor1() ) ); connect( btnColor2, SIGNAL( clicked() ), this, SLOT( setColor2() ) ); // handle stops QgsVectorGradientColorRampV2::StopsMap stops = ramp->stops(); groupStops->setChecked( !stops.isEmpty() ); QgsVectorGradientColorRampV2::StopsMap::iterator i; QList<QTreeWidgetItem *> items; for ( i = stops.begin(); i != stops.end(); ++i ) { QStringList lst; lst << "." << QString::number( i.key()*100, 'f', 0 ); QTreeWidgetItem* item = new QTreeWidgetItem( lst ); setStopColor( item, i.value() ); item->setData( 0, StopOffsetRole, i.key() ); items.append( item ); } treeStops->insertTopLevelItems( 0, items ); treeStops->resizeColumnToContents( 0 ); treeStops->sortByColumn( 1, Qt::AscendingOrder ); treeStops->setSortingEnabled( true ); connect( groupStops, SIGNAL( toggled( bool ) ), this, SLOT( toggledStops( bool ) ) ); connect( btnAddStop, SIGNAL( clicked() ), this, SLOT( addStop() ) ); connect( btnRemoveStop, SIGNAL( clicked() ), this, SLOT( removeStop() ) ); connect( treeStops, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( stopDoubleClicked( QTreeWidgetItem*, int ) ) ); updatePreview(); }
QgsVectorGradientColorRampV2Dialog::QgsVectorGradientColorRampV2Dialog( QgsVectorGradientColorRampV2* ramp, QWidget* parent ) : QDialog( parent ), mRamp( ramp ), mCurrentItem( 0 ) { setupUi( this ); #ifdef Q_WS_MAC setWindowModality( Qt::WindowModal ); #endif connect( btnColor1, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor1( const QColor& ) ) ); connect( btnColor2, SIGNAL( colorChanged( const QColor& ) ), this, SLOT( setColor2( const QColor& ) ) ); // handle stops updateStops(); connect( groupStops, SIGNAL( toggled( bool ) ), this, SLOT( toggledStops( bool ) ) ); connect( btnAddStop, SIGNAL( clicked() ), this, SLOT( addStop() ) ); connect( btnRemoveStop, SIGNAL( clicked() ), this, SLOT( removeStop() ) ); connect( treeStops, SIGNAL( itemDoubleClicked( QTreeWidgetItem*, int ) ), this, SLOT( stopDoubleClicked( QTreeWidgetItem*, int ) ) ); // fill type combobox cboType->blockSignals( true ); cboType->addItem( tr( "Discrete" ) ); cboType->addItem( tr( "Continous" ) ); if ( mRamp->isDiscrete() ) cboType->setCurrentIndex( 0 ); else cboType->setCurrentIndex( 1 ); cboType->blockSignals( false ); // information button if needed // QPushButton* button = buttonBox->addButton( tr( "Information" ), QDialogButtonBox::ActionRole ); if ( mRamp->info().isEmpty() ) btnInformation->setEnabled( false ); // else // connect( button, SIGNAL( pressed() ), this, SLOT( showInformation() ) ); updatePreview(); }
void GradientPreview::mouseReleaseEvent(QMouseEvent *m) { qApp->restoreOverrideCursor(); QRect insideRect = QRect(10, 43, width()-20, 13); if (isEditable) { QRect fpo; if (m->button() == Qt::LeftButton) { if ((Mpressed) && (ActStop > 0) && (ActStop != static_cast<int>(StopM.count()-1)) && (outside || !insideRect.contains(m->pos()))) { onlyselect = false; fill_gradient.removeStop(ActStop); ActStop = 0; repaint(); QList<VColorStop*> cstops = fill_gradient.colorStops(); emit selectedStop(cstops.at(ActStop)); } if ((m->y() < height()) && (m->y() > 43) && (m->x() > 0) && (m->x() < width()) && (ActStop == -1)) { QList<VColorStop*> cstops = fill_gradient.colorStops(); double newStop = static_cast<double>((m->x() - 10)) / (static_cast<double>(width())-20); QColor stopColor = (cstops.count() > 0) ? cstops.at(0)->color : QColor(255, 255, 255); QString stopName = (cstops.count() > 0) ? cstops.at(0)->name : QString("White"); int stopShade = (cstops.count() > 0) ? cstops.at(0)->shade : 100; fill_gradient.addStop(stopColor, newStop, 0.5, 1.0, stopName, stopShade); repaint(); onlyselect = false; cstops = fill_gradient.colorStops(); for (int yg = 0; yg < static_cast<int>(StopM.count()); ++yg) { fpo = QRect(static_cast<int>(StopM[yg])-4, 43, 8, 13); if (fpo.contains(m->pos())) { ActStop = yg; emit selectedStop(cstops.at(ActStop)); repaint(); break; } } } } else if (m->button() == Qt::RightButton) { Mpressed = false; QList<VColorStop*> cstops = fill_gradient.colorStops(); int stop = -1; for (int yg = 0; yg < static_cast<int>(StopM.count()); ++yg) { fpo = QRect(static_cast<int>(StopM[yg])-4, 43, 8, 13); if (fpo.contains(m->pos())) { stop = yg; break; } } contextStop = stop; mPos = m->pos(); QMenu *pmen = new QMenu(); setCursor(QCursor(Qt::ArrowCursor)); pmen->addAction( tr("Add Stop"), this, SLOT(addStop())); if (stop != -1) pmen->addAction( tr("Remove Stop"), this, SLOT(removeStop())); pmen->exec(QCursor::pos()); delete pmen; } } Mpressed = false; if ((!onlyselect) && (ActStop >= 0)){ emit gradientChanged(); QList<VColorStop*> cstops = fill_gradient.colorStops(); emit currStep(cstops.at(ActStop)->rampPoint); } }
void SUMORouteHandler::myStartElement(int element, const SUMOSAXAttributes& attrs) { switch (element) { case SUMO_TAG_VEHICLE: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_PERSON: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs, false, false, true); break; case SUMO_TAG_CONTAINER: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); break; case SUMO_TAG_FLOW: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseFlowAttributes(attrs, myBeginDefault, myEndDefault); break; case SUMO_TAG_VTYPE: // XXX: Where is this deleted? Delegated to subclasses?! MSRouteHandler takes care of this, in case of RORouteHandler this is not obvious. Consider introduction of a shared_ptr myCurrentVType = SUMOVehicleParserHelper::beginVTypeParsing(attrs, getFileName()); break; case SUMO_TAG_VTYPE_DISTRIBUTION: openVehicleTypeDistribution(attrs); break; case SUMO_TAG_ROUTE: openRoute(attrs); break; case SUMO_TAG_ROUTE_DISTRIBUTION: openRouteDistribution(attrs); break; case SUMO_TAG_STOP: addStop(attrs); break; case SUMO_TAG_TRIP: { myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs, true); if (myVehicleParameter->id == "") { WRITE_WARNING("Omitting trip ids is deprecated!"); myVehicleParameter->id = myIdSupplier.getNext(); } myVehicleParameter->parametersSet |= VEHPARS_FORCE_REROUTE; myActiveRouteID = "!" + myVehicleParameter->id; break; } case SUMO_TAG_PERSONTRIP: case SUMO_TAG_WALK: if (attrs.hasAttribute(SUMO_ATTR_EDGES) || attrs.hasAttribute(SUMO_ATTR_ROUTE)) { addWalk(attrs); } else { addPersonTrip(attrs); } break; case SUMO_TAG_INTERVAL: { bool ok; myBeginDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_BEGIN, 0, ok); myEndDefault = attrs.getSUMOTimeReporting(SUMO_ATTR_END, 0, ok); break; } case SUMO_TAG_PARAM: addParam(attrs); break; default: // parse embedded car following model information if (myCurrentVType != 0) { WRITE_WARNING("Defining car following parameters in a nested element is deprecated in vType '" + myCurrentVType->id + "', use attributes instead!"); SUMOVehicleParserHelper::parseVTypeEmbedded(*myCurrentVType, (SumoXMLTag)element, attrs); } break; } }
DivePlannerWidget::DivePlannerWidget(QWidget *parent, Qt::WindowFlags f) : QWidget(parent, f) { ui.setupUi(this); ui.dateEdit->setDisplayFormat(getDateFormat()); ui.tableWidget->setTitle(tr("Dive planner points")); ui.tableWidget->setModel(plannerModel); plannerModel->setRecalc(true); ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::GAS, new AirTypesDelegate(this)); ui.cylinderTableWidget->setTitle(tr("Available gases")); ui.cylinderTableWidget->setModel(CylindersModel::instance()); QTableView *view = ui.cylinderTableWidget->view(); view->setColumnHidden(CylindersModel::START, true); view->setColumnHidden(CylindersModel::END, true); view->setColumnHidden(CylindersModel::DEPTH, false); view->setItemDelegateForColumn(CylindersModel::TYPE, new TankInfoDelegate(this)); connect(ui.cylinderTableWidget, SIGNAL(addButtonClicked()), plannerModel, SLOT(addCylinder_clicked())); connect(ui.tableWidget, SIGNAL(addButtonClicked()), plannerModel, SLOT(addStop())); connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), GasSelectionModel::instance(), SLOT(repopulate())); connect(CylindersModel::instance(), SIGNAL(rowsInserted(QModelIndex, int, int)), GasSelectionModel::instance(), SLOT(repopulate())); connect(CylindersModel::instance(), SIGNAL(rowsRemoved(QModelIndex, int, int)), GasSelectionModel::instance(), SLOT(repopulate())); connect(CylindersModel::instance(), SIGNAL(dataChanged(QModelIndex, QModelIndex)), plannerModel, SIGNAL(cylinderModelEdited())); connect(CylindersModel::instance(), SIGNAL(rowsInserted(QModelIndex, int, int)), plannerModel, SIGNAL(cylinderModelEdited())); connect(CylindersModel::instance(), SIGNAL(rowsRemoved(QModelIndex, int, int)), plannerModel, SIGNAL(cylinderModelEdited())); connect(plannerModel, SIGNAL(calculatedPlanNotes()), MainWindow::instance(), SLOT(setPlanNotes())); ui.tableWidget->setBtnToolTip(tr("Add dive data point")); connect(ui.startTime, SIGNAL(timeChanged(QTime)), plannerModel, SLOT(setStartTime(QTime))); connect(ui.dateEdit, SIGNAL(dateChanged(QDate)), plannerModel, SLOT(setStartDate(QDate))); connect(ui.ATMPressure, SIGNAL(valueChanged(int)), this, SLOT(atmPressureChanged(int))); connect(ui.atmHeight, SIGNAL(valueChanged(int)), this, SLOT(heightChanged(int))); connect(ui.salinity, SIGNAL(valueChanged(double)), this, SLOT(salinityChanged(double))); connect(plannerModel, SIGNAL(startTimeChanged(QDateTime)), this, SLOT(setupStartTime(QDateTime))); // Creating (and canceling) the plan replanButton = ui.buttonBox->addButton(tr("Save new"), QDialogButtonBox::ActionRole); connect(replanButton, SIGNAL(clicked()), plannerModel, SLOT(saveDuplicatePlan())); connect(ui.buttonBox, SIGNAL(accepted()), plannerModel, SLOT(savePlan())); connect(ui.buttonBox, SIGNAL(rejected()), plannerModel, SLOT(cancelPlan())); QShortcut *closeKey = new QShortcut(QKeySequence(Qt::Key_Escape), this); connect(closeKey, SIGNAL(activated()), plannerModel, SLOT(cancelPlan())); // This makes shure the spinbox gets a setMinimum(0) on it so we can't have negative time or depth. ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DEPTH, new SpinBoxDelegate(0, INT_MAX, 1, this)); ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::RUNTIME, new SpinBoxDelegate(0, INT_MAX, 1, this)); ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::DURATION, new SpinBoxDelegate(0, INT_MAX, 1, this)); ui.tableWidget->view()->setItemDelegateForColumn(DivePlannerPointsModel::CCSETPOINT, new DoubleSpinBoxDelegate(0, 2, 0.1, this)); /* set defaults. */ ui.ATMPressure->setValue(1013); ui.atmHeight->setValue(0); setMinimumWidth(0); setMinimumHeight(0); }
void MSRouteHandler::myStartElement (int element, const SUMOSAXAttributes& attrs) { if(oc.getLoadVerbosity()>1) std::cout << "----> MSRouteHandler::myStartElement" << std::endl; switch (element) { case SUMO_TAG_VEHICLE: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); if(oc.getLoadVerbosity()>1) std::cout << "[110] MSRouteHandler::myStartElement\n myVehiclePar" "ameter->vtypeid=" << myVehicleParameter->vtypeid << "\n myVehicleParameter->id=" << myVehicleParameter ->id << std::endl; /*TASK * This could be the first place where we can process the * electric or nonelectric characteristics of the vehicles */ if((myVehicleParameter->id.substr(0, 4)=="elec") ||//DEPRECATED(MANTAIN) (myVehicleParameter->id.substr(0, 6)=="SHelec")||//DEPRECATED(MANTAIN) (myVehicleParameter->id.substr(0, 6)=="SHElec")|| (myVehicleParameter->id.substr(0, 9)=="SHItaElec")|| (myVehicleParameter->id.substr(0, 9)=="SHGerElec")|| (myVehicleParameter->id.substr(0, 3)=="fev")) { //TASK (uprego) This should be safe, but I'm not completely sure myVehicleParameter->vtypeid = DEFAULT_ELECVTYPE_ID; // Electric cars turn green myVehicleParameter->color = HIB_CAR_COLOR_GREEN; } else if((myVehicleParameter->id.substr(0, 4)=="norm")||//DEPRECATED(MANTAIN) (myVehicleParameter->id.substr(0, 6)=="SHnorm")||//DEPRECATED(MANTAIN) (myVehicleParameter->id.substr(0, 6)=="SHItaNorm")|| (myVehicleParameter->id.substr(0, 6)=="SHGerNorm")|| (myVehicleParameter->id.substr(0, 6)=="SHNorm")) { // Normal cars remain yellow myVehicleParameter->color = HIB_CAR_COLOR_YELLOW_TRY; } else { /* BUSCARLO EN LOS VEHICLES TO TRACK LIST !!! IF ESTA // CREARLE EL VTYPEID ELSE // Default yellow myVehicleParameter->color = HIB_CAR_COLOR_YELLOW_TRY; */ myVehicleParameter->color=HIB_CAR_COLOR_YELLOW_TRY; // TASK TODO FIXME ALERT DANGER DELETEME } break; case SUMO_TAG_PERSON: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); myActivePlan = new MSPerson::MSPersonPlan(); break; case SUMO_TAG_RIDE: { const std::string pid = myVehicleParameter->id; bool ok = true; MSEdge* from = 0; if (attrs.hasAttribute(SUMO_ATTR_FROM)) { const std::string fromID = attrs.getStringReporting(SUMO_ATTR_FROM, pid.c_str(), ok); from = MSEdge::dictionary(fromID); if (from == 0) { throw ProcessError("The from edge '" + fromID + "' within a ride of person '" + pid + "' is not known."); } if (!myActivePlan->empty() && &myActivePlan->back()->getDestination() != from) { throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + fromID + "!=" + myActivePlan->back()->getDestination().getID() + ")."); } if (myActivePlan->empty()) { myActivePlan->push_back(new MSPerson::MSPersonStage_Waiting(*from, -1, myVehicleParameter->depart)); } } const std::string toID = attrs.getStringReporting(SUMO_ATTR_TO, pid.c_str(), ok); MSEdge* to = MSEdge::dictionary(toID); if (to == 0) { throw ProcessError("The to edge '" + toID + "' within a ride of person '" + pid + "' is not known."); } const std::string desc = attrs.getStringReporting(SUMO_ATTR_LINES, pid.c_str(), ok); StringTokenizer st(desc); myActivePlan->push_back(new MSPerson::MSPersonStage_Driving(*to, st.getVector())); break; } case SUMO_TAG_WALK: { myActiveRoute.clear(); bool ok = true; MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_EDGES, myVehicleParameter->id.c_str(), ok), myActiveRoute, myActiveRouteID); if (myActiveRoute.empty()) { throw ProcessError("No edges to walk for person '" + myVehicleParameter->id + "'."); } if (!myActivePlan->empty() && &myActivePlan->back()->getDestination() != myActiveRoute.front()) { throw ProcessError("Disconnected plan for person '" + myVehicleParameter->id + "' (" + myActiveRoute.front()->getID() + "!=" + myActivePlan->back()->getDestination().getID() + ")."); } if (myActivePlan->empty()) { myActivePlan->push_back(new MSPerson::MSPersonStage_Waiting(*myActiveRoute.front(), -1, myVehicleParameter->depart)); } const SUMOTime duration = attrs.getOptSUMOTimeReporting(SUMO_ATTR_DURATION, 0, ok, -1); const SUMOReal speed = attrs.getOptSUMORealReporting(SUMO_ATTR_SPEED, 0, ok, -1); myActivePlan->push_back(new MSPerson::MSPersonStage_Walking(myActiveRoute, duration, speed)); myActiveRoute.clear(); break; } case SUMO_TAG_FLOW: delete myVehicleParameter; myVehicleParameter = SUMOVehicleParserHelper::parseFlowAttributes(attrs); if (attrs.hasAttribute(SUMO_ATTR_FROM) && attrs.hasAttribute(SUMO_ATTR_TO)) { myActiveRouteID = "!" + myVehicleParameter->id; bool ok = true; MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok), myActiveRoute, "for vehicle '" + myVehicleParameter->id + "'"); MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok), myActiveRoute, "for vehicle '" + myVehicleParameter->id + "'"); closeRoute(); } break; case SUMO_TAG_VTYPE__DEPRECATED: if (!myHaveWarnedAboutDeprecatedVType) { myHaveWarnedAboutDeprecatedVType = true; WRITE_WARNING("'" + toString(SUMO_TAG_VTYPE__DEPRECATED) + "' is deprecated; please use '" + toString(SUMO_TAG_VTYPE) + "'."); } case SUMO_TAG_VTYPE: myCurrentVType = SUMOVehicleParserHelper::beginVTypeParsing(attrs); break; case SUMO_TAG_VTYPE_DISTRIBUTION__DEPRECATED: if (!myHaveWarnedAboutDeprecatedVTypeDistribution) { myHaveWarnedAboutDeprecatedVTypeDistribution = true; WRITE_WARNING("'" + toString(SUMO_TAG_VTYPE_DISTRIBUTION__DEPRECATED) + "' is deprecated; please use '" + toString(SUMO_TAG_VTYPE_DISTRIBUTION) + "'."); } case SUMO_TAG_VTYPE_DISTRIBUTION: openVehicleTypeDistribution(attrs); break; case SUMO_TAG_ROUTE: openRoute(attrs); break; case SUMO_TAG_ROUTE_DISTRIBUTION: openRouteDistribution(attrs); break; case SUMO_TAG_STOP: addStop(attrs); break; case SUMO_TAG_TRIP__DEPRECATED: case SUMO_TAG_TRIP: { bool ok = true; myVehicleParameter = SUMOVehicleParserHelper::parseVehicleAttributes(attrs); myVehicleParameter->setParameter |= VEHPARS_FORCE_REROUTE; myActiveRouteID = "!" + myVehicleParameter->id; if (attrs.hasAttribute(SUMO_ATTR_FROM) || !myVehicleParameter->wasSet(VEHPARS_TAZ_SET)) { MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_FROM, myVehicleParameter->id.c_str(), ok), myActiveRoute, "for vehicle '" + myVehicleParameter->id + "'"); MSEdge::parseEdgesList(attrs.getStringReporting(SUMO_ATTR_TO, myVehicleParameter->id.c_str(), ok), myActiveRoute, "for vehicle '" + myVehicleParameter->id + "'"); } else { const MSEdge* fromTaz = MSEdge::dictionary(myVehicleParameter->fromTaz + "-source"); if (fromTaz == 0) { WRITE_ERROR("Source district '" + myVehicleParameter->fromTaz + "' not known for '" + myVehicleParameter->id + "'!"); } else if (fromTaz->getNoFollowing() == 0) { WRITE_ERROR("Source district '" + myVehicleParameter->fromTaz + "' has no outgoing edges for '" + myVehicleParameter->id + "'!"); } else { myActiveRoute.push_back(fromTaz->getFollower(0)); } } closeRoute(); closeVehicle(); } break; default: break; } // parse embedded vtype information if (myCurrentVType != 0 && element != SUMO_TAG_VTYPE && element != SUMO_TAG_VTYPE__DEPRECATED) { SUMOVehicleParserHelper::parseVTypeEmbedded(*myCurrentVType, element, attrs); return; } }
int GradientStopEditor::addStop( int newStopValue, qreal newStopPosition ) { return addStop( newStopValue, newStopPosition, true ); }
MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { // NOTE: these dataextractors are deleted by // routecontainer class instance. dataExtractor = new bacra::DataExtractor(); dataExtractor->initialize(); dataExtractor2 = new bacra::DataExtractor(); dataExtractor2->initialize(); routeContainer = new bacra::RouteContainer(dataExtractor, this); stopContainer = new bacra::RouteContainer(dataExtractor2, this); stopDelegate = new bacra::StopDelegate(this); routeDelegate = new bacra::StopDelegate(this); ui->setupUi(this); QRegExp rx("\\d{0,6}"); QValidator *validator = new QRegExpValidator(rx, this); ui->stopLineEdit->setValidator(validator); ui->routesView->setModel(routeContainer); ui->routesView->setItemDelegate(new bacra::StopDelegate()); ui->stopsView->setModel(stopContainer); ui->stopsView->setItemDelegate(new bacra::StopDelegate()); ui->tab_2->setDisabled(true); ui->progressBar->setVisible(false); //ui->stopsView->setStyleSheet("QTableView {background: url(:/bacra/images/bacra.png); background-attachment: fixed; background-position: bottom-center;}"); //ui->departuresView->setStyleSheet("QTableView {background: url(:/bacra/images/bacra.png); background-attachment: fixed; background-position: bottom-center;}"); //ui->routesView->setStyleSheet("QTableView {background: url(:/bacra/images/bacra.png); background-attachment: fixed; background-position: bottom-center;}"); ui->addStopButton->setIcon(QIcon(":/bacra/images/add.png")); ui->stopsView->setDragEnabled(true); ui->stopsView->setAcceptDrops(true); connect(stopContainer, SIGNAL(updatedDepartures()), ui->departuresView, SLOT(setFocus())); connect(dataExtractor, SIGNAL(infoResponseReady(int)), ui->progressBar, SLOT(setValue(int))); connect(dataExtractor2, SIGNAL(infoResponseReady(int)), ui->progressBar, SLOT(setValue(int))); connect(ui->tabWidget, SIGNAL(currentChanged(int)), this, SLOT(commercialAnnouncement(int))); connect(ui->fromLineEdit, SIGNAL(returnPressed()), ui->toLineEdit, SLOT(setFocus())); connect(ui->toLineEdit, SIGNAL(returnPressed()), ui->addRouteButton, SLOT(click())); connect(ui->addRouteButton, SIGNAL(clicked()), this, SLOT(addRouteClicked())); connect(this, SIGNAL(addRoute(QString, QString)), routeContainer, SLOT(addRouteItem(QString, QString))); connect(ui->stopLineEdit, SIGNAL(returnPressed()), ui->addStopButton, SLOT(click())); connect(ui->addStopButton, SIGNAL(clicked()), this, SLOT(addStopClicked())); connect(this, SIGNAL(addStop(QString)), stopContainer, SLOT(addStopItem(QString))); connect(ui->stopsView, SIGNAL(clicked(QModelIndex)), stopContainer, SLOT(indexSelected(QModelIndex))); connect(ui->routesView, SIGNAL(clicked(QModelIndex)), routeContainer, SLOT(indexSelected(QModelIndex))); connect(ui->updateButton, SIGNAL(clicked()), this, SLOT(updateDepartures())); connect(stopContainer, SIGNAL(dataChanged(QModelIndex,QModelIndex)), ui->stopsView, SLOT(dataChanged(QModelIndex,QModelIndex))); connect(routeContainer, SIGNAL(routeAdded()), this, SLOT(routeAdded())); connect(stopContainer, SIGNAL(stopAdded()), this, SLOT(stopAdded())); connect(stopContainer, SIGNAL(showDepartures(bacra::Route*)), this, SLOT(showDepartures(bacra::Route*))); connect(stopContainer, SIGNAL(invalidStop()), this, SLOT(invalidStop())); connect(routeContainer, SIGNAL(invalidRoute()), this, SLOT(invalidRoute())); //Loading routes from disk //setting ui so loaded stops display themselves //correctly // ui->stopsView->setColumnWidth(0, 170); // ui->stopsView->setColumnWidth(1, 40); ui->stopsView->setColumnWidth(0, 180); ui->stopsView->setColumnWidth(1, 30); stopContainer->loadRoutes("./savedata.txt"); }
void GUIVehicle::rerouteDRTStop(MSStoppingPlace* busStop) { SUMOTime intermediateDuration = TIME2STEPS(20); SUMOTime finalDuration = SUMOTime_MAX; if (myParameter->stops.size() >= 2) { // copy durations from the original stops intermediateDuration = myParameter->stops.front().duration; finalDuration = myParameter->stops.back().duration; } // if the stop is already in the list of stops, cancel all stops that come // after it and set the stop duration std::string line = ""; int destinations = 0; bool add = true; for (auto it = myStops.begin(); it != myStops.end(); it++) { if (!it->reached && destinations < 2 && it->busstop != nullptr) { line += it->busstop->getID(); destinations++; } if (it->busstop == busStop) { it->duration = finalDuration; myStops.erase(++it, myStops.end()); add = false; break; } else { it->duration = MIN2(it->duration, intermediateDuration); } } if (destinations < 2) { line += busStop->getID(); } if (add) { // create new stop SUMOVehicleParameter::Stop stopPar; stopPar.busstop = busStop->getID(); stopPar.lane = busStop->getLane().getID(); stopPar.startPos = busStop->getBeginLanePosition(); stopPar.endPos = busStop->getEndLanePosition(); stopPar.duration = finalDuration; stopPar.until = -1; stopPar.triggered = false; stopPar.containerTriggered = false; stopPar.parking = false; stopPar.index = STOP_INDEX_FIT; stopPar.parametersSet = STOP_START_SET | STOP_END_SET; // clean up prior route to improve visualisation, ensure that the stop can be added immediately ConstMSEdgeVector edges = myRoute->getEdges(); edges.erase(edges.begin(), edges.begin() + getRoutePosition()); edges.push_back(&busStop->getLane().getEdge()); replaceRouteEdges(edges, -1, 0, "DRT.tmp", false, false, false); std::string errorMsg; // add stop addStop(stopPar, errorMsg); } const bool hasReroutingDevice = getDevice(typeid(MSDevice_Routing)) != nullptr; SUMOAbstractRouter<MSEdge, SUMOVehicle>& router = hasReroutingDevice ? MSRoutingEngine::getRouterTT() : MSNet::getInstance()->getRouterTT(); // reroute to ensure the new stop is reached reroute(MSNet::getInstance()->getCurrentTimeStep(), "DRT", router); myParameter->line = line; assert(haveValidStopEdges()); }
void DivePlannerPointsModel::loadFromDive(dive *d) { int depthsum = 0; int samplecount = 0; o2pressure_t last_sp; bool oldRec = recalc; struct divecomputer *dc = &(d->dc); recalc = false; CylindersModel::instance()->updateDive(); duration_t lasttime = {}; duration_t lastrecordedtime = {}; duration_t newtime = {}; free_dps(&diveplan); if (mode != PLAN) clear(); diveplan.when = d->when; // is this a "new" dive where we marked manually entered samples? // if yes then the first sample should be marked // if it is we only add the manually entered samples as waypoints to the diveplan // otherwise we have to add all of them bool hasMarkedSamples = false; if (dc->samples) hasMarkedSamples = dc->sample[0].manually_entered; else dc = fake_dc(dc, true); // if this dive has more than 100 samples (so it is probably a logged dive), // average samples so we end up with a total of 100 samples. int plansamples = dc->samples <= 100 ? dc->samples : 100; int j = 0; int cylinderid = 0; last_sp.mbar = 0; for (int i = 0; i < plansamples - 1; i++) { while (j * plansamples <= i * dc->samples) { const sample &s = dc->sample[j]; if (s.time.seconds != 0 && (!hasMarkedSamples || s.manually_entered)) { depthsum += s.depth.mm; last_sp = s.setpoint; ++samplecount; newtime = s.time; } j++; } if (samplecount) { cylinderid = get_cylinderid_at_time(d, dc, lasttime); if (newtime.seconds - lastrecordedtime.seconds > 10) { addStop(depthsum / samplecount, newtime.seconds, cylinderid, last_sp.mbar, true); lastrecordedtime = newtime; } lasttime = newtime; depthsum = 0; samplecount = 0; } } // make sure we get the last point right so the duration is correct if (!hasMarkedSamples) addStop(0, d->dc.duration.seconds,cylinderid, last_sp.mbar, true); recalc = oldRec; emitDataChanged(); }