void end_frame() { #ifdef GRAPHICS draw_ui_scale(); //renderGraph(vg, 5, 5, &fps_graph); //renderGraph(vg, 5 + 200 + 5, 5, &cpu_graph); if (gpu_timer.supported) renderGraph(vg, 5 + 200 + 5 + 200 + 5, 5, &gpu_graph); draw_world_scale(); nvgEndFrame(vg); cpu_time = glfwGetTime() - render_start_time; updateGraph(&fps_graph, delta_time); updateGraph(&cpu_graph, cpu_time); float gpu_times[3]; int n = stopGPUTimer(&gpu_timer, gpu_times, 3); for (int i = 0; i < n; i++) updateGraph(&gpu_graph, gpu_times[i]); glfwSwapBuffers(window); glfwPollEvents(); #endif }
void ShiftModeControl::update(const sf::Time& dt) { if (!canActiveShift) { elapsed += dt; if (isShiftActive) { updateGraph(false); if (elapsed >= duration) { isShiftActive = false; elapsed = sf::Time::Zero; } } else { updateGraph(true); if (elapsed >= necessary) { canActiveShift = true; elapsed = sf::Time::Zero; } } } }
void DianVoteControl::ParseData(quint32 id, quint8 option) { RevData *rd = new RevData; rd->key = option; // 取出最后一个字节 rd->id = id; // 取出ID QString *time; // 接收时间 time = new QString(); *time = QTime::currentTime().toString("hh:mm:ss"); rd->revTime = time; // 容错性检查,如果收到已经发送过的数据手持端 // 果断丢弃数据,并且写入log中 #ifndef TEST_RECEIVE_DATA_CONTINUE for(int i = 0; i < log->length(); i++) { if((log->at(i)->id == id) && (log->at(i)->type == NORMAL)) { rd->type = DUPLICATE; log->append(rd); WriteRevDataLog(rd); return; } } #endif emit updateGraph((int)rd->key - MAP_VALUE); // 更新数据 rd->type = NORMAL; log->append(rd); WriteRevDataLog(rd); }
void SingleCluster::clusterMatrix(InMatrix * mat) { uint newId = numLeaves, maxVertices = numLeaves * 2 - 1; uint row, col; float value; Vertex *v1, *v2, *v; while (mat->getNext(row, col, value) && value < mat->threshold && newId < maxVertices) { // get the ancestor of two leaves extracted from the input matrix v1 = vertices[row]->ancestor; v2 = vertices[col]->ancestor; if (v1 == v2) continue; v = createVertex(newId); vertices.push_back(v); ++newId; // update the left and right attribute v->left = v1; v->right = v2; // update the ancestor atrribute v1->updateAncestor(v); v2->updateAncestor(v); // for visualization purpose updateGraph(v1->id, v2->id, value); } fprintf(stderr, "Finished! index = %u\n", mat->pos); }
void iDialogGraph::onReset(iWidget* source) { _graphs = _oldGraphs; _selectedValueIndex = 0; updateGraph(); updateSelection(); }
GLWidget::GLWidget(QWidget *parent) : QGLWidget(QGLFormat(QGL::SampleBuffers), parent) { parent = parent; scale = 1; logo = new QtLogo(this); src_mode = SRC_BADGE; backgroundColor = QColor(Qt::white); graph_update_timer.setSingleShot(false); connect(&graph_update_timer, SIGNAL(timeout()), this, SLOT(updateGraph())); fa2_timer.setSingleShot(false); connect(&fa2_timer, SIGNAL(timeout()), this, SLOT(mainLoop())); graph = NULL; default_reading_location = "../real-time-data/"; fa2 = new ForceAtlas2(width(), height()); ubi_radius = 1.5; setAutoFillBackground(false); }
void ClassDiagramView::displayAddClassDialog() { AddClassDialog dialog; ClassNode *node = gClassDiagramView->getNode(gStartPosInfo.x, gStartPosInfo.y); if(node && node->getType()) { OovString title = "Add Class "; title += node->getType()->getName(); dialog.setTitle(title); } // Fill the dialog with the default radio button and selected class info. GtkWidget *radio = Builder::getBuilder()->getWidget("AddClassStandardRadiobutton"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(radio), true); GtkWidget *relayout = Builder::getBuilder()->getWidget("AddClassRelayoutCheckbutton"); gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(relayout), false); // Even though the toggle was set above, it doesn't trigger unless it has changed. on_AddClassStandardRadiobutton_toggled(radio, nullptr); if(dialog.run(true)) { getDiagram().addRelatedNodesRecurse(getDiagram().getModelData(), dialog.getSelectedType(), dialog.getSelectedAddType()); updateGraph(gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(relayout))); } }
void WSpacePlot::selectRange(WRange r) { for (QArray<SpaceCell>::Iterator it=cellData.begin(); it!=cellData.end();++it) if (it->attr&normal && r.contains(it->data)) it->attr|=selected; else it->attr&=~selected; updateGraph(); emit selectionChanged(); }
/** Custom event handler. Checks if the event is a bandwidth update event. If it * is, it will add the data point to the history and updates the graph. */ void BandwidthGraph::customEvent(QEvent *event) { if (event->type() == CustomEventType::BandwidthEvent) { BandwidthEvent *bw = (BandwidthEvent *)event; updateGraph(bw->bytesRead(), bw->bytesWritten()); } }
void WSpacePlot::markSelected() { for (QArray<SpaceCell>::Iterator it=cellData.begin(); it!=cellData.end();++it) if (it->attr & selected) it->attr|=marked; else it->attr&=~marked; updateGraph(); }
void iDialogGraph::onGraphChanged(iWidget* source) { for (int i = 0; i < _graph->getGraphCount(); ++i) { _graphs[i] = _graph->getPoints(i); } updateGraph(); updateSelection(); }
void Viewer::doTestGraph() { // Add sample nodes addNode("TOP,type-TOP"); addNode("S,type-S"); addNode("NP,type-NP"); addNode("DT,type-DT"); addNode("This,type-TK"); addNode("VP,type-VP"); addNode("VBZ,type-VBZ"); addNode("is,type-TK"); addNode("NP,type-NP"); addNode("DT,type-DT"); addNode("an,type-TK"); addNode("NN,type-NN"); addNode("example,type-TK"); addNode(".,type-."); addNode("sentence,type-TK"); // Add sample edges addEdge("3,4"); addEdge("2,3"); addEdge("1,2"); addEdge("6,7"); addEdge("5,6"); addEdge("9,10"); addEdge("8,9"); addEdge("11,12"); addEdge("8,11"); addEdge("5,8"); addEdge("1,5"); addEdge("13,14"); addEdge("1,13"); addEdge("0,1"); // Test interaction with javascript connect(ui->doJavaScript, &QPushButton::released, [&]{ wv->page()->mainFrame()->evaluateJavaScript("g.setEdge(1,3);"); updateGraph(); }); updateGraph(); }
void Graph::modelChanged() { graphModel * gModel = castModel<graphModel>(); QObject::connect( gModel, SIGNAL( samplesChanged( int, int ) ), this, SLOT( updateGraph( int, int ) ) ); QObject::connect( gModel, SIGNAL( lengthChanged( ) ), this, SLOT( updateGraph( ) ) ); }
SceneGraphEditor::SceneGraphEditor(QQuickItem* parent) : QQuickPaintedItem(parent), m_scale(100), m_nodeWidth(80), m_nodeHeight(30) { SGState::pSge = this; setAcceptedMouseButtons(Qt::AllButtons); // for testing purposes I'm selecting the node from here. // later this will be done from the viewport or outliner feather::qml::command::select_node(0,0); updateGraph(); }
// FREE OPERATORS void NxNSceneGraph::preTick() { updateGraph(); for( int i=0; i<d_addColliders.getLastIndex(); i++ ) { addToGraph( d_addColliders[i] ); } d_addColliders = sgdc::DynamicArray<ICollider*>(); }
void ComparativeBarChart::update() { updateSizes(); osg::Vec3 scale(_width,1.0,_height); osg::Matrix scaleMat; scaleMat.makeScale(scale); _bgScaleMT->setMatrix(scaleMat); updateAxis(); updateGraph(); }
void WSpacePlot::mousePressEvent(QMouseEvent *e) { if (e->button()==LeftButton) { QPoint pos=frame()->mapFrom(this,e->pos())- frame()->contentsRect().topLeft(); currCursorPos=pos; float x,y; mapFromViewCoords(pos,x,y); QPoint cell=QPoint(clampi(int(rint(x)),0,viewSize.width()), clampi(int(rint(y)),0,viewSize.height())); int index=cell.x()+cell.y()*viewSize.width(); if (multiSelect) if (e->state() & ShiftButton) { clearTmpSelected(); selectRectTmp(QRect(startCell,cell),selecting); } else if (e->state() & ControlButton) { startCell=cell; acceptTmpSelected(); selecting=!(cellData[index].attr & selected); selectRectTmp(QRect(startCell,cell),selecting); } else { startCell=cell; if ((cellData[index].attr & selected) && (cellData[index].attr & normal)) dragEnabled=true; else { clearSelection(); selecting=true; selectRectTmp(QRect(startCell,cell),selecting); } e->ignore(); } else { clearSelection(); selectRectTmp(QRect(cell,cell),true); emit selectionChanged(); e->ignore(); } setCellLabel(pos,cell); updateGraph(); currCell=cell; } else e->ignore(); }
void BandwidthGraph::updategraphstatus( ) { if(RsAutoUpdatePage::eventsLocked()) return ; /* set users/friends/network */ float downKb = 0; float upKb = 0; rsicontrol -> ConfigGetDataRates(downKb, upKb); updateGraph(downKb,upKb); }
void iDialogGraph::onDelete(iWidget* source) { if (_graphs[0].size() > 1) { for (int i = 0; i < _graphs.size(); ++i) { _graphs[i].erase(_graphs[i].begin() + _selectedValueIndex); } _selectedValueIndex = 0; updateGraph(); updateSelection(); } }
void WSpacePlot::exchgMarkedSelected() { for (QArray<SpaceCell>::Iterator it=cellData.begin(); it!=cellData.end();++it) { if (it->attr & selected && !(it->attr & marked)) { it->attr&=~selected; it->attr|=marked; } else if (!(it->attr & selected) && (it->attr & marked)) { it->attr&=~marked; it->attr|=selected; } } updateGraph(); emit selectionChanged(); }
void WSpacePlot::mouseMoveEvent(QMouseEvent *e) { if (e->state() & LeftButton) { QPoint pos=frame()->mapFrom(this,e->pos())- frame()->contentsRect().topLeft(); currCursorPos=pos; float x,y; mapFromViewCoords(pos,x,y); QPoint cell=QPoint(clampi(int(rint(x)),0,viewSize.width()), clampi(int(rint(y)),0,viewSize.height())); if (dragEnabled) { dragEnabled=false; clearCellLabel(); emit wouldDrag(); } else { if (!QRect(QPoint(0,0),getFrameSize()).contains(pos)) { if (!autoPanTimer->isActive()) autoPanTimer->start(1); } else { autoPanTimer->stop(); if (cell!=currCell) { if (multiSelect) { clearTmpSelected(); selectRectTmp(QRect(startCell,cell),selecting); } else { clearSelection(); selectRectTmp(QRect(cell,cell),true); emit selectionChanged(); } } setCellLabel(pos,cell); } } currCell=cell; updateGraph(); } else e->ignore(); }
void WSpacePlot::keyPressEvent(QKeyEvent *e) { switch (e->key()) { case Key_Up: if (currCell.y()<viewSize.height()-1) currCell+=QPoint(0,1); break; case Key_Down: if (currCell.y()>0) currCell-=QPoint(0,1); break; case Key_Right: if (currCell.x()<viewSize.width()-1) currCell+=QPoint(1,0); break; case Key_Left: if (currCell.x()>0) currCell-=QPoint(1,0); break; case Key_End: currCell.setX(viewSize.width()-1); break; case Key_Home: currCell.setX(0); break; case Key_PageUp: currCell.setY(viewSize.height()-1); break; case Key_PageDown: currCell.setY(0); break; case Key_Space: if (multiSelect) { if (!(e->state() & ControlButton)) clearSelection(); if (!(e->state() & ShiftButton)) startCell=currCell; int index=currCell.x()+currCell.y()*viewSize.width(); selectRectTmp(QRect(startCell,currCell), !(cellData[index].attr & selected)); emit selectionChanged(); } break; default: e->ignore(); return; } e->accept(); if (!multiSelect) { clearSelection(); selectRectTmp(QRect(currCell,currCell),true); emit selectionChanged(); } updateGraph(); }
void Render::resizeGL(const int nWidth, const int nHeight) { int width = nWidth; int height = nHeight? nHeight: 1; glViewport(0, 0, width, height); glMatrixMode(GL_PROJECTION); glLoadIdentity(); float aspectRatio = (float)width/height; if (width <= height) { setBounds(-viewRadius, viewRadius, -viewRadius/aspectRatio, viewRadius/aspectRatio); } else { setBounds(-viewRadius*aspectRatio, viewRadius*aspectRatio, -viewRadius, viewRadius); } glOrtho(getLeftBound(), getRightBound(), getBottomBound(), getTopBound(), 1.0, -1.0); glMatrixMode(GL_MODELVIEW); glLoadIdentity(); updateGraph(); }
void ClassGraph::addNode(const ModelData &model, char const * const className, ClassGraph::eAddNodeTypes addType, int nodeDepth, bool reposition) { const ModelType *type = model.getTypeRef(className); const ModelClassifier *classifier = type->getClass(); if(classifier) { if(mNodes.size() == 0 && mGraphOptions.drawRelationKey) { addRelationKeyNode(); } size_t startSize = mNodes.size(); getRelatedNodesRecurse(model, classifier, addType, nodeDepth, mNodes); if(startSize != mNodes.size()) { mModified = true; } updateGraph(model, reposition); } }
void Render::drawGraph() { GeneticAlgorithm *algorithm = world->getAlgorithm(); int count = algorithm->getGenerationNum(); if (!count) return; if (genrationNum != count) { genrationNum = count; updateGraph(); } count++; glLineWidth(2); qglColor(Qt::black); glVertexPointer(2, GL_FLOAT, 0, avgScore); glEnableClientState(GL_VERTEX_ARRAY); glDrawArrays(GL_LINE_STRIP, 0, count); qglColor(Qt::red); glVertexPointer(2, GL_FLOAT, 0, maxScore); glDrawArrays(GL_LINE_STRIP, 0, count); glDisableClientState(GL_VERTEX_ARRAY); glLineWidth(1); }
graph::graph( QWidget * _parent, graphStyle _style ) : QWidget( _parent ), /* TODO: size, background? */ ModelView( new graphModel( -1.0, 1.0, 128, NULL, true ), this ), m_graphStyle( _style ) { m_mouseDown = false; m_graphColor = QColor( 0xFF, 0xAA, 0x00 ); resize( 132, 104 ); setAcceptDrops( true ); setCursor( Qt::CrossCursor ); graphModel * gModel = castModel<graphModel>(); QObject::connect( gModel, SIGNAL( samplesChanged( int, int ) ), this, SLOT( updateGraph( int, int ) ) ); QObject::connect( gModel, SIGNAL( lengthChanged( ) ), this, SLOT( updateGraph( ) ) ); }
void WSpacePlot::setCellLabel(QPoint pos, QPoint cell) { pos+=QPoint(1,1); cellLabelString.sprintf("%d:%d",cell.x(),cell.y()); QPainter p(this); cellLabelRect = p.boundingRect(pos.x()+2,pos.y()+2,80,20, AlignLeft,cellLabelString); cellLabelRect.setSize(cellLabelRect.size()+QSize(4,4)); int dx = (cellLabelRect.right() >= getFrameSize().width()) ? -(cellLabelRect.right()-getFrameSize().width()+1) : (cellLabelRect.left() < 0) ? -cellLabelRect.left() : 0; int dy = (cellLabelRect.bottom() >= getFrameSize().height()) ? -(cellLabelRect.bottom()-getFrameSize().height()+1) : (cellLabelRect.top() < 0) ? -cellLabelRect.top() : 0; cellLabelRect.moveBy(dx,dy); updateGraph(); }
void iDialogGraph::onValueChanged(iWidget* source) { if (_axisNumberChooser[0] == source) { for (int i = 0; i < _graphs.size(); ++i) { _graphs[i][_selectedValueIndex]._x = _axisNumberChooser[0]->getValue(); } } else if (_axisNumberChooser[1] == source) { _graphs[0][_selectedValueIndex]._y = _axisNumberChooser[1]->getValue(); } else if (_axisNumberChooser[2] == source) { _graphs[1][_selectedValueIndex]._y = _axisNumberChooser[2]->getValue(); } else if (_axisNumberChooser[3] == source) { _graphs[2][_selectedValueIndex]._y = _axisNumberChooser[3]->getValue(); } updateGraph(); }
void Graph::updateGraph() { updateGraph( 0, model()->length() - 1 ); }
int main() { GLFWwindow* window; struct DemoData data; struct NVGcontext* vg = NULL; struct PerfGraph fps; double prevt = 0; if (!glfwInit()) { printf("Failed to init GLFW."); return -1; } initGraph(&fps, GRAPH_RENDER_FPS, "Frame Time"); glfwSetErrorCallback(errorcb); glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 2); glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 0); #ifdef DEMO_MSAA glfwWindowHint(GLFW_SAMPLES, 4); #endif window = glfwCreateWindow(1000, 600, "NanoVG", NULL, NULL); // window = glfwCreateWindow(1000, 600, "NanoVG", glfwGetPrimaryMonitor(), NULL); if (!window) { glfwTerminate(); return -1; } glfwSetKeyCallback(window, key); glfwMakeContextCurrent(window); #ifdef NANOVG_GLEW if(glewInit() != GLEW_OK) { printf("Could not init glew.\n"); return -1; } #endif #ifdef DEMO_MSAA vg = nvgCreateGL2(512, 512, 0); #else vg = nvgCreateGL2(512, 512, NVG_ANTIALIAS); #endif if (vg == NULL) { printf("Could not init nanovg.\n"); return -1; } if (loadDemoData(vg, &data) == -1) return -1; glfwSwapInterval(0); glfwSetTime(0); prevt = glfwGetTime(); while (!glfwWindowShouldClose(window)) { double mx, my, t, dt; int winWidth, winHeight; int fbWidth, fbHeight; float pxRatio; t = glfwGetTime(); dt = t - prevt; prevt = t; updateGraph(&fps, dt); glfwGetCursorPos(window, &mx, &my); glfwGetWindowSize(window, &winWidth, &winHeight); glfwGetFramebufferSize(window, &fbWidth, &fbHeight); // Calculate pixel ration for hi-dpi devices. pxRatio = (float)fbWidth / (float)winWidth; // Update and render glViewport(0, 0, fbWidth, fbHeight); if (premult) glClearColor(0,0,0,0); else glClearColor(0.3f, 0.3f, 0.32f, 1.0f); glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT|GL_STENCIL_BUFFER_BIT); nvgBeginFrame(vg, winWidth, winHeight, pxRatio, premult ? NVG_PREMULTIPLIED_ALPHA : NVG_STRAIGHT_ALPHA); renderDemo(vg, mx,my, winWidth,winHeight, t, blowup, &data); renderGraph(vg, 5,5, &fps); nvgEndFrame(vg); if (screenshot) { screenshot = 0; saveScreenShot(fbWidth, fbHeight, premult, "dump.png"); } glfwSwapBuffers(window); glfwPollEvents(); } freeDemoData(vg, &data); nvgDeleteGL2(vg); glfwTerminate(); return 0; }