void Interface::setRotate( int r) { if (r < 360) { /* -360 - 360 */ rotazione = r; /////QPixmap base(origImageFilename); QImage base(origImageFilename); int massimo = QMAX(base.width(),base.height()); /* find max cube from image */ int fotox = (massimo / 2) - (base.width() / 2); int fotoy = (massimo / 2) - (base.height() / 2); QPixmap nuovo(massimo,massimo); QPainter painter; painter.begin(&nuovo); painter.setRenderHint(QPainter::Antialiasing); painter.translate((massimo / 2),(massimo / 2)); painter.rotate(r); painter.translate(-(massimo / 2),-(massimo / 2)); /////painter.drawPixmap(fotox,fotoy,base); painter.drawImage(fotox,fotoy,base,Qt::MonoOnly); painter.end(); int newlarge = (massimo/cento)*ratio; display = nuovo.scaledToWidth(newlarge,Qt::FastTransformation); original = nuovo; wrapper->paint(display); ////////SetZoom( ratio ); airotato = true; } }
void Interface::DisegnaRect( QPoint topLeft , QPoint bottomRight ) { Top_startX = QMIN(topLeft.x(), bottomRight.x()); Top_startY = QMIN(topLeft.y(), bottomRight.y()) ; int Bot_endX = QMAX(topLeft.x(), bottomRight.x()); int Bot_endY = QMAX(topLeft.y(), bottomRight.y()); QPoint topLefta( Top_startX , Top_startY ); QPoint bottomRighta( Bot_endX , Bot_endY ); QRect areaplace( topLefta, bottomRighta ); /* */ TagliaPoi = areaplace; /////////////////qDebug() << "####### TagliaPoi.width() " << TagliaPoi.height(); if (areaplace.width() > 9 ) { TagliaPoi = areaplace; QPen pen; pen.setStyle( Qt::SolidLine ); pen.setWidth( 2 ); if (ratio > 80 && ratio < 110) { pen.setWidth( 2 ); } if (ratio < 81) { pen.setWidth( 4 ); } if (ratio < 50) { pen.setWidth( 6 ); } if (ratio > 130) { pen.setWidth( 1 ); } pen.setColor( color1 ); QPixmap nuovo(original2.width(),original2.height()); QPainter painter; painter.begin(&nuovo); painter.setRenderHint(QPainter::Antialiasing); painter.drawPixmap(0,0,original2); painter.setPen( pen); /* penna */ painter.drawRect(areaplace); /* disegna */ painter.end(); display = nuovo; int newlarge = (original2.width()/cento)*ratio; wrapper->paint(QPixmap(display.scaledToWidth(newlarge,Qt::FastTransformation))); setCursor(Qt::CrossCursor); UpdateNow(); } }
void statistica (rbtree* p, int n, int k){ float a = 0, b = 0; int h; int per; printf( "prova %d %d\n", n, k ); for ( int i = 0; i < k; i++ ) { // printf( "prova\n" ); rbtree *m = nuovo(); costruisci(m,&n); h = get_ordine(m); per = get_perimetro(m); a += (h * h) / n; b += per / n; } printf(" a = %f b = %f \n", a / k, b / k); }
causali::causali(QWidget *parent) : QDialog(parent) { setupUi(this); setAttribute(Qt::WA_DeleteOnClose); //Pulsante chiusura finestra di dialogo: connect(esci,SIGNAL(clicked()),this,SLOT(close())); //Pulsante nuovo tipo di causale di trasporto: connect(nuovo_b,SIGNAL(clicked()),this,SLOT(nuovo())); //Cliccando sulla tabella si cerca automaticamente: connect(tableView,SIGNAL(clicked(QModelIndex)),this,SLOT(clickgrid())); //Salvataggio dati: connect(salva_b,SIGNAL(clicked()),this,SLOT(salva())); //Eliminazione dati: connect(elimina_b,SIGNAL(clicked()),this,SLOT(elimina())); //Disabilita qlineedit id: id->setEnabled(false); //Query mod_grid per riempire la tabella: mod_grid = new QSqlQueryModel; //Visualizza i dati nella tabella: lista(); }
int main(int argc, char *argv[]){ std::vector<double> default_pulses({1.596, 1.596, 0.358, 0.358, 1.954}); std::vector<double> default_volts({0, 0, 0.74039804, 0.74039804, 0.96216636}); std::vector<double> deltas, pulses, volts; double noise_rate; double noise_amplitude_squared; std::string limit_run; unsigned long limit; Limit_parameter limit_param; std::string o_file_name; try{ po::options_description desc("Options"); desc.add_options() ("help,h", "produce help message") ("deltas,d", po::value< std::vector<double> >(&deltas)->multitoken()->required(), "list of delta currents") ("rate,r", po::value< double >(&noise_rate)->required(), "Noise rate") ("amp,a", po::value< double >(&noise_amplitude_squared)->required(), "Square root of noise amplitude") ("limit,l", po::value< Limit_parameter >(&limit_param)->multitoken()->required(), "Limit simulation run.\nSample usages:" "\nresets 1026 or" "\ntime 120 or" "\nsaddles 143.") ("out,o", po::value< std::string>(&o_file_name), "output file name") ("pulses,p", po::value< std::vector<double> >()->multitoken(),"initial pulse timings") ("volts,v", po::value< std::vector<double> >()->multitoken(), "initial volts") ; po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); if (vm.count("help")){ std::cout << desc << std::endl; return 1; } if (!vm.count("pulses")) pulses = default_pulses; else pulses = vm["pulses"].as< std::vector<double> >(); if (!vm.count("volts")) volts = default_volts; else volts = vm["volts"].as< std::vector<double> >(); po::notify(vm); } catch(std::exception& e){ std::cerr << "Error: " << e.what() << "\n"; return false; } catch(...){ std::cerr << "Unknown error!" << "\n"; return false; } //GOOGLE_PROTOBUF_VERIFY_VERSION; LifNetSim nuovo(volts, pulses, deltas, noise_rate, noise_amplitude_squared); try{ std::ofstream ofs(o_file_name); nuovo.run(limit_param.limit_type, limit_param.limit_n); std::cout << nuovo.time << std::endl; nuovo.data_to_save.SerializeToOstream(&ofs); return 0; } catch(int e){ std::string err_file_name = o_file_name + "_partial_"; std::ofstream err_ofs(err_file_name); std::cerr << "Something bad happened.\n" << "Partial results saved in " << err_file_name << std::endl; nuovo.data_to_save.SerializeToOstream(&err_ofs); return -1; } }