void MainWindow::on_btnDraw_clicked() { QString it = ui->iterations->text(); ui->iterations->setText(""); int n = it.toInt(); QString ang = ui->angle->text(); ui->angle->setText(""); double rangle = ang.toDouble(); if(n>100 || n < 0 || rangle > 180 || rangle < -180) { Dialog *about = new Dialog(this); //the parent is this about->show(); } else{ scene = new QGraphicsScene(ui->graphicsView); QLineF qline(0,0,300,0); scene->addLine(qline); ui->graphicsView->setScene(scene); int x2 = qline.x2(); int y2 = qline.y2(); int i = 0; drawLine(rangle,i,n,x2,y2,qline.length(), qline.angle(), scene); } }
bool textCommander::waitNextCommand(void) { char line[256]; is_waiting=true; fprintf(stderr,"Waiting for Command\n"); while(is_waiting && is_in_pipe_open) { int len; fgets(line,255,in_pipe); QString qline(line); fprintf(stderr,"%s \n",line); QStringList args = qline.split(" "); bool ok; if (args.length()>=4) { QString app=args.at(0); QString obj_name = args.at(1); QString slot_name = args.at(2); int argc = args.at(3).toInt(&ok,10); if (app==app_name) { fprintf(stderr,"Got Cmd: %s\n",line); if (argc==0) { QMetaObject::invokeMethod( objmap[obj_name], slot_name.toStdString().c_str(), Qt::AutoConnection); } else if (argc==1) { QString argtype = args.at(4); QString argval = args.at(5); if (argtype == "int") { bool ok; int ival =argval.toInt(&ok,10); QMetaObject::invokeMethod( objmap[obj_name], slot_name.toStdString().c_str(), Qt::AutoConnection, Q_ARG(int,ival) ); } if (argtype == "double") { bool ok; double dval =argval.toDouble(&ok); QMetaObject::invokeMethod( objmap[obj_name], slot_name.toStdString().c_str(), Qt::AutoConnection, Q_ARG(double,dval) ); }
bool ColorSchema::rereadSchemaFile() { QString fPath = fRelPath.isEmpty() ? "" : (fRelPath.startsWith("/") ? fRelPath : locate("data", "konsole/"+fRelPath)); if (fPath.isEmpty() || !QFile::exists(fPath)) return false; //KONSOLEDEBUG << "Rereading schema file " << fPath << endl; FILE *sysin = fopen(QFile::encodeName(fPath),"r"); if (!sysin) { int e = errno; kdWarning() << "Schema file " << fPath << " could not be opened (" << strerror(e) << ")" << endl; return false; } char line[100]; *lastRead = QDateTime::currentDateTime(); while (fscanf(sysin,"%80[^\n]\n",line) > 0) { if (strlen(line) > 5) { if (!strncmp(line,"title",5)) { m_title = i18n(line+6); } if (!strncmp(line,"image",5)) { char rend[100], path[100]; int attr = 1; if (sscanf(line,"image %s %s",rend,path) != 2) continue; if (!strcmp(rend,"tile" )) attr = 2; else if (!strcmp(rend,"center")) attr = 3; else if (!strcmp(rend,"full" )) attr = 4; else continue; QString qline(line); m_imagePath = locate("wallpaper", qline.mid( qline.find(" ",7)+1 ) ); m_alignment = attr; } if (!strncmp(line,"transparency",12)) { float rx; int rr, rg, rb; // Transparency needs 4 parameters: fade strength and the 3 // components of the fade color. if (sscanf(line,"transparency %g %d %d %d",&rx,&rr,&rg,&rb) != 4) continue; m_useTransparency=true; m_tr_x=rx; m_tr_r=rr; m_tr_g=rg; m_tr_b=rb; } if (!strncmp(line,"rcolor",6)) { int fi,ch,cs,cv,tr,bo; if(sscanf(line,"rcolor %d %d %d %d %d",&fi,&cs,&cv,&tr,&bo) != 5) continue; if (!(0 <= fi && fi <= TABLE_COLORS)) continue; if (random_hue == -1) random_hue = (KApplication::random()%32) * 11; ch = random_hue; if (!(0 <= cs && cs <= 255 )) continue; if (!(0 <= cv && cv <= 255 )) continue; if (!(0 <= tr && tr <= 1 )) continue; if (!(0 <= bo && bo <= 1 )) continue; m_table[fi].color = QColor(); m_table[fi].color.setHsv(ch,cs,cv); m_table[fi].transparent = tr; m_table[fi].bold = bo; } if (!strncmp(line,"color",5)) { int fi,cr,cg,cb,tr,bo; if(sscanf(line,"color %d %d %d %d %d %d",&fi,&cr,&cg,&cb,&tr,&bo) != 6) continue; if (!(0 <= fi && fi <= TABLE_COLORS)) continue; if (!(0 <= cr && cr <= 255 )) continue; if (!(0 <= cg && cg <= 255 )) continue; if (!(0 <= cb && cb <= 255 )) continue; if (!(0 <= tr && tr <= 1 )) continue; if (!(0 <= bo && bo <= 1 )) continue; m_table[fi].color = QColor(cr,cg,cb); m_table[fi].transparent = tr; m_table[fi].bold = bo; } if (!strncmp(line,"sysfg",5)) { int fi,tr,bo; if(sscanf(line,"sysfg %d %d %d",&fi,&tr,&bo) != 3) continue; if (!(0 <= fi && fi <= TABLE_COLORS)) continue; if (!(0 <= tr && tr <= 1 )) continue; if (!(0 <= bo && bo <= 1 )) continue; m_table[fi].color = kapp->palette().active().text(); m_table[fi].transparent = tr; m_table[fi].bold = bo; } if (!strncmp(line,"sysbg",5)) { int fi,tr,bo; if(sscanf(line,"sysbg %d %d %d",&fi,&tr,&bo) != 3) continue; if (!(0 <= fi && fi <= TABLE_COLORS)) continue; if (!(0 <= tr && tr <= 1 )) continue; if (!(0 <= bo && bo <= 1 )) continue; m_table[fi].color = kapp->palette().active().base(); m_table[fi].transparent = tr; m_table[fi].bold = bo; } } } fclose(sysin); m_fileRead=true; return true; }
/** \fn processYuv */ uint8_t flyContrast::processYuv(ADMImage* in, ADMImage *out) { buildContrastTable (param.coef, param.offset, tableluma, tablechroma); out->copyInfo(in); if(!previewActivated) { out->copyPlane(in,out,PLANAR_Y); out->copyPlane(in,out,PLANAR_U); out->copyPlane(in,out,PLANAR_V); } else { if(param.doLuma) doContrast(in,out,tableluma,PLANAR_Y); else out->copyPlane(in,out,PLANAR_Y); if(param.doChromaU) doContrast(in,out,tablechroma,PLANAR_U); else out->copyPlane(in,out,PLANAR_U); if(param.doChromaV) doContrast(in,out,tablechroma,PLANAR_V); else out->copyPlane(in,out,PLANAR_V); } if(!scene) return true; // Draw luma histogram uint8_t *luma=out->GetReadPtr(PLANAR_Y); int stride=out->GetPitch(PLANAR_Y); int decimate=4; double sumsum[256]; for(int i=0;i<256;i++) sumsum[i]=0; double totalSum=(double)(out->_width*out->_height)/decimate; // # of sampling points for(int y=0;y<in->_height;y+=decimate) { uint8_t *p=luma; for(int x=0;x<in->_width;x++) { sumsum[*p]++; p++; } luma+=stride*decimate; } // normalize for(int i=0;i<256;i++) { // zoom factor =10 sumsum[i]=(10*sumsum[i]*(127))/totalSum; if(sumsum[i]>127) sumsum[i]=127; } int toggle=0; scene->clear(); for(int i=0;i<256;i++) { QLineF qline(i,127,i,127-sumsum[i]); scene->addLine(qline); } // Draw 16 and 235 line QLineF qline(16,100,16,126); scene->addLine(qline); QLineF qline2(235,100,235,126); scene->addLine(qline2); return 1; }