void MeshExtruder::modify() { std::unique_ptr<MooseMesh> source_mesh = _mesh_ptr->safeClone(); if (source_mesh->getMesh().mesh_dimension() == 3) mooseError("You cannot extrude a 3D mesh!"); _mesh_ptr->getMesh().clear(); std::unique_ptr<QueryElemSubdomainID> elem_subdomain_id; if (_existing_subdomains.size() > 0) elem_subdomain_id = libmesh_make_unique<QueryElemSubdomainID>( _existing_subdomains, _layers, _new_ids, _num_layers); // The first argument to build_extrusion() is required to be UnstructuredMesh&, a common // base class of both ReplicatedMesh and DistributedMesh, hence the dynamic_cast... MeshTools::Generation::build_extrusion( dynamic_cast<libMesh::UnstructuredMesh &>(_mesh_ptr->getMesh()), source_mesh->getMesh(), _num_layers, _extrusion_vector, elem_subdomain_id.get()); // See if the user has requested specific sides for the top and bottom std::set<boundary_id_type> side_ids = _mesh_ptr->getMesh().get_boundary_info().get_side_boundary_ids(); // Handle distributed meshes: processors may not know all side ids _communicator.set_union(side_ids); std::set<boundary_id_type>::reverse_iterator last_side_it = side_ids.rbegin(); const boundary_id_type old_top = *last_side_it; mooseAssert(last_side_it != side_ids.rend(), "Error in generating sidesets for extruded mesh"); const boundary_id_type old_bottom = *++last_side_it; // Update the IDs if (isParamValid("bottom_sideset")) changeID(getParam<std::vector<BoundaryName>>("bottom_sideset"), old_bottom); if (isParamValid("top_sideset")) changeID(getParam<std::vector<BoundaryName>>("top_sideset"), old_top); // Update the dimension _mesh_ptr->getMesh().set_mesh_dimension(source_mesh->getMesh().mesh_dimension() + 1); // Redetect the mesh extents _mesh_ptr->prepared(false); }
void MeshExtruder::modify() { // When we clone, we're responsible to clean up after ourselves! // TODO: traditionally clone() methods return pointers... MooseMesh * source_mesh = &(_mesh_ptr->clone()); if (source_mesh->getMesh().mesh_dimension() == 3) mooseError("You cannot extrude a 3D mesh!"); _mesh_ptr->getMesh().clear(); QueryElemSubdomainID elem_subdomain_id(getParam<std::vector<SubdomainID> >("existing_subdomains"), getParam<std::vector<unsigned int> >("layers"), getParam<std::vector<unsigned int> >("new_ids"), _num_layers); // The first argument to build_extrusion() is required to be UnstructuredMesh&, a common // base class of both ReplicatedMesh and DistributedMesh, hence the dynamic_cast... MeshTools::Generation::build_extrusion(dynamic_cast<libMesh::UnstructuredMesh&>(_mesh_ptr->getMesh()), source_mesh->getMesh(), _num_layers, _extrusion_vector, _map_custom_ids ? &elem_subdomain_id : NULL); // See if the user has requested specific sides for the top and bottom const std::set<boundary_id_type> & side_ids = _mesh_ptr->getMesh().get_boundary_info().get_side_boundary_ids(); std::set<boundary_id_type>::reverse_iterator last_side_it = side_ids.rbegin(); const boundary_id_type old_top = *last_side_it; mooseAssert(last_side_it != side_ids.rend(), "Error in generating sidesets for extruded mesh"); const boundary_id_type old_bottom = *++last_side_it; // Update the IDs if (isParamValid("bottom_sideset")) changeID(getParam<std::vector<BoundaryName> >("bottom_sideset"), old_bottom); if (isParamValid("top_sideset")) changeID(getParam<std::vector<BoundaryName> >("top_sideset"), old_top); // Update the dimension _mesh_ptr->getMesh().set_mesh_dimension(source_mesh->getMesh().mesh_dimension() + 1); // Clean up the source mesh we allocated delete source_mesh; }
std::unique_ptr<MeshBase> MeshExtruderGenerator::generate() { std::unique_ptr<MeshBase> source_mesh = std::move(_input); std::unique_ptr<ReplicatedMesh> mesh = libmesh_make_unique<ReplicatedMesh>(comm()); if (source_mesh->mesh_dimension() == 3) mooseError("You cannot extrude a 3D mesh !"); std::unique_ptr<QueryElemSubdomainID> elem_subdomain_id; if (_existing_subdomains.size() > 0) elem_subdomain_id = libmesh_make_unique<QueryElemSubdomainID>( _existing_subdomains, _layers, _new_ids, _num_layers); MeshTools::Generation::build_extrusion( *mesh, *source_mesh, _num_layers, _extrusion_vector, elem_subdomain_id.get()); // See if the user has requested specific sides for the top and bottom std::set<boundary_id_type> side_ids = mesh->get_boundary_info().get_side_boundary_ids(); // Handle distributed meshes: processors may not know all side ids _communicator.set_union(side_ids); std::set<boundary_id_type>::reverse_iterator last_side_it = side_ids.rbegin(); const boundary_id_type old_top = *last_side_it; mooseAssert(last_side_it != side_ids.rend(), "Error in generating sidesets for extruded mesh"); const boundary_id_type old_bottom = *++last_side_it; // Update the IDs if (isParamValid("bottom_sideset")) changeID(*mesh, getParam<std::vector<BoundaryName>>("bottom_sideset"), old_bottom); if (isParamValid("top_sideset")) changeID(*mesh, getParam<std::vector<BoundaryName>>("top_sideset"), old_top); // Update the dimension mesh->set_mesh_dimension(mesh->mesh_dimension() + 1); return dynamic_pointer_cast<MeshBase>(mesh); }
void FlowViewWindow::updatedFrames(int numFrames) { CANFrame thisFrame; if (numFrames == -1) //all frames deleted. Kill the display { ui->listFrameID->clear(); foundID.clear(); currentPosition = 0; refreshIDList(); updateFrameLabel(); removeAllGraphs(); memset(refBytes, 0, 8); memset(currBytes, 0, 8); updateDataView(); } else if (numFrames == -2) //all new set of frames. Reset { ui->listFrameID->clear(); foundID.clear(); currentPosition = 0; refreshIDList(); if (ui->listFrameID->count() > 0) { changeID(ui->listFrameID->item(0)->text()); ui->listFrameID->setCurrentRow(0); } updateFrameLabel(); } else //just got some new frames. See if they are relevant. { int refID = frameCache[0].ID; bool needRefresh = false; for (int i = modelFrames->count() - numFrames; i < modelFrames->count(); i++) { thisFrame = modelFrames->at(i); if (thisFrame.ID == refID) { frameCache.append(thisFrame); if (ui->cbLiveMode->checkState() == Qt::Checked) { currentPosition = frameCache.count() - 1; needRefresh = true; } } } if (needRefresh) { updateDataView(); if (ui->cbSync->checkState() == Qt::Checked) emit sendCenterTimeID(frameCache[currentPosition].ID, frameCache[currentPosition].timestamp / 1000000.0); } } }
void FlowViewWindow::showEvent(QShowEvent* event) { QDialog::showEvent(event); installEventFilter(this); readSettings(); refreshIDList(); if (ui->listFrameID->count() > 0) { changeID(ui->listFrameID->item(0)->text()); ui->listFrameID->setCurrentRow(0); } updateFrameLabel(); qDebug() << "FlowView show event was processed"; }
void FlowViewWindow::gotCenterTimeID(int32_t ID, double timestamp) { uint64_t t_stamp; t_stamp = timestamp * 1000000l; qDebug() << "timestamp: " << t_stamp; changeID(QString::number(ID)); //to be sure we're focused on the proper ID for (int j = 0; j < ui->listFrameID->count(); j++) { int thisNum = Utility::ParseStringToNum(ui->listFrameID->item(j)->text()); if (thisNum == ID) { ui->listFrameID->setCurrentRow(j); break; } } int bestIdx = -1; for (int i = 0; i < frameCache.count(); i++) { if (frameCache[i].timestamp > t_stamp) { bestIdx = i - 1; break; } } qDebug() << "Best index " << bestIdx; if (bestIdx > -1) { currentPosition = bestIdx; if (ui->cbAutoRef->isChecked()) { memcpy(refBytes, currBytes, 8); } memcpy(currBytes, frameCache.at(currentPosition).data, 8); updateDataView(); } }
void JournallingObject::restoreState( const QDomElement & _this ) { SerializingObject::restoreState( _this ); saveJournallingState( false ); // search for journal-node QDomNode node = _this.firstChild(); while( !node.isNull() ) { if( node.isElement() && node.nodeName() == "journal" ) { const jo_id_t new_id = node.toElement().attribute( "id" ).toInt(); if( new_id ) { changeID( new_id ); } } node = node.nextSibling(); } restoreJournallingState(); }
void AutomatableModel::loadSettings( const QDomElement& element, const QString& name ) { // read scale type and overwrite default scale type if( element.hasAttribute("scale_type") ) // wrong in most cases { if( element.attribute("scale_type") == "log" ) setScaleType( Logarithmic ); } else { setScaleType( Linear ); } // compat code QDomNode node = element.namedItem( AutomationPattern::classNodeName() ); if( node.isElement() ) { node = node.namedItem( name ); if( node.isElement() ) { AutomationPattern * p = AutomationPattern::globalAutomationPattern( this ); p->loadSettings( node.toElement() ); setValue( p->valueAt( 0 ) ); // in older projects we sometimes have odd automations // with just one value in - eliminate if necessary if( !p->hasAutomation() ) { delete p; } return; } // logscales were not existing at this point of time // so they can be ignored } QDomNode connectionNode = element.namedItem( "connection" ); // reads controller connection if( connectionNode.isElement() ) { QDomNode thisConnection = connectionNode.toElement().namedItem( name ); if( thisConnection.isElement() ) { setControllerConnection( new ControllerConnection( (Controller*)NULL ) ); m_controllerConnection->loadSettings( thisConnection.toElement() ); //m_controllerConnection->setTargetName( displayName() ); } } // models can be stored as elements (port00) or attributes (port10): // <ladspacontrols port10="4.41"> // <port00 value="4.41" id="4249278"/> // </ladspacontrols> // element => there is automation data node = element.namedItem( name ); if( node.isElement() ) { changeID( node.toElement().attribute( "id" ).toInt() ); setValue( node.toElement().attribute( "value" ).toFloat() ); } else if( element.hasAttribute( name ) ) // attribute => read the element's value from the attribute list { setInitValue( element.attribute( name ).toFloat() ); } else { reset(); } }
int changeREFID(ProvObjectPtr p_prov, REFID id, const char* new_id) { return(changeID(((ProvPtr)p_prov)->p_record, (IDREF)id, new_id)); }
FlowViewWindow::FlowViewWindow(const QVector<CANFrame> *frames, QWidget *parent) : QDialog(parent), ui(new Ui::FlowViewWindow) { ui->setupUi(this); readSettings(); modelFrames = frames; playbackTimer = new QTimer(); currentPosition = 0; playbackActive = false; playbackForward = true; memset(refBytes, 0, 8); memset(currBytes, 0, 8); memset(triggerValues, -1, sizeof(int) * 8); //ui->graphView->setInteractions(); ui->graphView->xAxis->setRange(0, 8); ui->graphView->yAxis->setRange(-10, 265); //run range a bit outside possible number so they aren't plotted in a hard to see place ui->graphView->axisRect()->setupFullAxesBox(); QCPItemText *textLabel = new QCPItemText(ui->graphView); ui->graphView->addItem(textLabel); textLabel->setPositionAlignment(Qt::AlignTop|Qt::AlignHCenter); textLabel->position->setType(QCPItemPosition::ptAxisRectRatio); textLabel->position->setCoords(0.5, .5); textLabel->setText("+"); textLabel->setFont(QFont(font().family(), 16)); // make font a bit larger textLabel->setPen(QPen(Qt::black)); // show black border around text ui->graphView->xAxis->setLabel("Time Axis"); ui->graphView->yAxis->setLabel("Value Axis"); QFont legendFont = font(); legendFont.setPointSize(10); QFont legendSelectedFont = font(); legendSelectedFont.setPointSize(12); legendSelectedFont.setBold(true); ui->graphView->legend->setFont(legendFont); ui->graphView->legend->setSelectedFont(legendSelectedFont); ui->graphView->legend->setSelectableParts(QCPLegend::spItems); // legend box shall not be selectable, only legend items //ui->graphView->xAxis->setAutoSubTicks(false); //ui->graphView->xAxis->setAutoTicks(false); ui->graphView->xAxis->setAutoTickStep(false); ui->graphView->xAxis->setAutoSubTicks(false); ui->graphView->xAxis->setNumberFormat("gb"); ui->graphView->xAxis->setTickStep(5.0); ui->graphView->xAxis->setSubTickCount(0); connect(ui->btnBackOne, SIGNAL(clicked(bool)), this, SLOT(btnBackOneClick())); connect(ui->btnPause, SIGNAL(clicked(bool)), this, SLOT(btnPauseClick())); connect(ui->btnReverse, SIGNAL(clicked(bool)), this, SLOT(btnReverseClick())); connect(ui->btnStop, SIGNAL(clicked(bool)), this, SLOT(btnStopClick())); connect(ui->btnPlay, SIGNAL(clicked(bool)), this, SLOT(btnPlayClick())); connect(ui->btnForwardOne, SIGNAL(clicked(bool)), this, SLOT(btnFwdOneClick())); connect(ui->spinPlayback, SIGNAL(valueChanged(int)), this, SLOT(changePlaybackSpeed(int))); connect(ui->cbLoopPlayback, SIGNAL(clicked(bool)), this, SLOT(changeLooping(bool))); connect(ui->listFrameID, SIGNAL(currentTextChanged(QString)), this, SLOT(changeID(QString))); connect(playbackTimer, SIGNAL(timeout()), this, SLOT(timerTriggered())); connect(ui->graphView, SIGNAL(plottableDoubleClick(QCPAbstractPlottable*,QMouseEvent*)), this, SLOT(plottableDoubleClick(QCPAbstractPlottable*,QMouseEvent*))); connect(ui->txtTrigger0, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); connect(ui->txtTrigger1, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); connect(ui->txtTrigger2, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); connect(ui->txtTrigger3, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); connect(ui->txtTrigger4, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); connect(ui->txtTrigger5, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); connect(ui->txtTrigger6, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); connect(ui->txtTrigger7, SIGNAL(textEdited(QString)), this, SLOT(updateTriggerValues())); connect(MainWindow::getReference(), SIGNAL(framesUpdated(int)), this, SLOT(updatedFrames(int))); ui->graphView->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->graphView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequestGraph(QPoint))); ui->flowView->setContextMenuPolicy(Qt::CustomContextMenu); connect(ui->flowView, SIGNAL(customContextMenuRequested(QPoint)), this, SLOT(contextMenuRequestFlow(QPoint))); playbackTimer->setInterval(ui->spinPlayback->value()); //set the timer to the default value of the control }
int fastPy::go(int argc, char **argv) { int c; app_name = argv[0]; while ((c = getopt (argc, argv, "dhvc:s:")) != -1) { switch (c) { case 'd': detach = true; break; case 'v': if (verbose) debug = true; verbose = true; break; case 'c': config_f = optarg; break; case 's': sock_f = optarg; break; case 'h': default: usage(); return 255; } } if (config_f == NULL || sock_f == NULL) { ts_cout("Config and socket is required"); usage(); return 254; } if (readConf(config_f) < 0) { return 253; } if (changeID() < 0) { logError("master", LOG_ERROR, "Unable start with user: %s and group: %s", conf.user.c_str(), conf.group.c_str()); return 252; } if (chdir(wsgi.base_dir.c_str()) < 0) { logError("master", LOG_ERROR, "Unable to change working directory to <%s>, check ownership", wsgi.base_dir.c_str()); return 251; } fcgi = new fastcgi; // opening socket if (fcgi->openSock(sock_f) < 0) { logError("master", LOG_ERROR, "Unable to open socket"); return 250; } if (detach) { int d_rc = detachProc(); if (d_rc > 0) { // write pid file here return 0; } else if (d_rc < 0) { return 249; } } for (int i=0; i < conf.workers_cnt; i++) { startChild(); } if (masterLoop() < 0) { return 248; } return 0; }