int main(int argc, char **argv) { QApplication app(argc, argv); qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); GraphWidget widget; widget.show(); return app.exec(); }
void CheapestPathDialog::run() { Solution sol_dialog = c_path; GraphicNode *startn = nullptr; GraphicNode *endn = nullptr; MainWindow* mw = dynamic_cast<MainWindow*>(parent()); GraphWidget* graph = dynamic_cast<GraphWidget*>(mw->centralWidget()); QList<GraphicNode*> nodeList = graph->returnNodeList(); for (int i=0; i < nodeList.size(); i++) { if(nodeList.at(i)->returnName()==start) { startn = nodeList.at(i); } } for (int j=0; j < nodeList.size(); j++) { if(nodeList.at(j)->returnName()==end) { endn=nodeList.at(j); } } try { if (startn && endn) { mw->net->cheapest_path(startn->net_node,endn->net_node); } else { QString msg = tr("Error calculating cheapest tree\nThe nodes you gave do not exist."); QMessageBox::warning(this, tr("Error"), msg); return; } } catch (network_error &e) { QString msg = tr("Error calculating cheapest tree\n%1") .arg(e.what()); QMessageBox::warning(this, tr("Error"), msg); return; } SolutionDialog sd(sol_dialog, this); sd.show(); }
Resource* CreateGraphWidget( XMLIterator i, XMLCreatorEnv *env ) { XMLCreatorEnv ch_env; XMLAttributes attributes; XMLStyle branch_style; CascadeStyles( i, env, attributes, branch_style, ch_env ); std::string color = get_attribute( attributes, "color" ); NormalPixel ncolor( to_hex( color )); int dotted = 0; try_attribute_i( attributes, "dotted", &dotted ); GraphWidget *ptr = new GraphWidget( Dim2i( 100, 100 ), ncolor.c, ( dotted ? GraphWidget::GT_POINTS : GraphWidget::GT_LINES ) ); std::string bounds; if ( try_attribute( attributes, "bounds", &bounds )) { std::vector< int > b = to_integer_vector( bounds ); ptr->SetValueBounds( b[0], b[1], b[2], b[3] ); } Useless::GraphWidget::tpe_input_vector initData( 100 ); initData.resize(0); for ( double f=0.0; f <= 6.28; f += 3.14/100.0 ) { double y = sin( f ); initData.push_back( y ); } ptr->SetInputData( initData ); InsertChildWidget( ptr, attributes, env); return new AnyResource<GraphWidget*>( ptr ); }
void MainWindow::VizualizationFunc() { qsrand(QTime(0,0,0).secsTo(QTime::currentTime())); GraphWidget *widget = new GraphWidget; widget->show(); }
void ModelerUserInterface::checkboxWrapCallback(Fl_Check_Button* button, void* p) { GraphWidget* graph = ((ModelerUserInterface*)p)->graph; graph->currCurveWrap(button->value() ? true : false); graph->redraw(); }
void ModelerUserInterface::chooserCurveTypeCallback(Fl_Choice* chooser, void* p) { GraphWidget* graph = ((ModelerUserInterface*)p)->graph; graph->currCurveType(chooser->value()); graph->redraw(); }