Clock::Clock( QWidget * parent, const char *, WFlags f ) : ClockBase( parent, "clock", f ), swatch_splitms(99), init(FALSE) // No tr { alarmDlg = 0; swLayout = 0; alarmProc = 0; alarmCmd = 0; dayBtn = new QToolButton * [7]; Config config( "qpe" ); config.setGroup("Time"); ampm = config.readBoolEntry( "AMPM", TRUE ); onMonday = config.readBoolEntry( "MONDAY" ); connect( tabs, SIGNAL(currentChanged(QWidget*)), this, SLOT(tabChanged(QWidget*)) ); analogStopwatch = new AnalogClock( swFrame ); stopwatchLcd = new QLCDNumber( swFrame ); stopwatchLcd->setFrameStyle( QFrame::NoFrame ); stopwatchLcd->setSegmentStyle( QLCDNumber::Flat ); stopwatchLcd->setSizePolicy( QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred) ); analogClock->display( QTime::currentTime() ); clockLcd->setNumDigits( 5 ); clockLcd->setFixedWidth( clockLcd->sizeHint().width() ); date->setText( TimeString::dateString( QDate::currentDate(), TimeString::currentDateFormat() ) ); if ( qApp->desktop()->width() < 200 ) date->setFont( QFont(date->font().family(), 14, QFont::Bold) ); if ( qApp->desktop()->height() > 240 ) { clockLcd->setFixedHeight( 30 ); stopwatchLcd->setFixedHeight( 30 ); } connect( stopStart, SIGNAL(pressed()), SLOT(stopStartStopWatch()) ); connect( reset, SIGNAL(pressed()), SLOT(resetStopWatch()) ); t = new QTimer( this ); connect( t, SIGNAL(timeout()), SLOT(updateClock()) ); t->start( 1000 ); applyAlarmTimer = new QTimer( this ); connect( applyAlarmTimer, SIGNAL(timeout()), this, SLOT(applyDailyAlarm()) ); alarmt = new QTimer( this ); connect( alarmt, SIGNAL(timeout()), SLOT(alarmTimeout()) ); connect( qApp, SIGNAL(timeChanged()), SLOT(updateClock()) ); connect( qApp, SIGNAL(timeChanged()), SLOT(applyDailyAlarm()) ); swatch_running = FALSE; swatch_totalms = 0; swatch_currLap = 0; swatch_dispLap = 0; stopwatchLcd->setNumDigits( 8+1+sw_prec ); stopwatchLcd->display( "00:00:00.00" ); QVBoxLayout *lvb = new QVBoxLayout( lapFrame ); nextLapBtn = new QToolButton( UpArrow, lapFrame ); connect( nextLapBtn, SIGNAL(clicked()), this, SLOT(nextLap()) ); nextLapBtn->setAccel( Key_Up ); lvb->addWidget( nextLapBtn ); prevLapBtn = new QToolButton( DownArrow, lapFrame ); connect( prevLapBtn, SIGNAL(clicked()), this, SLOT(prevLap()) ); prevLapBtn->setAccel( Key_Down ); prevLapBtn->setMinimumWidth( 15 ); lvb->addWidget( prevLapBtn ); prevLapBtn->setEnabled( FALSE ); nextLapBtn->setEnabled( FALSE ); reset->setEnabled( FALSE ); lapLcd->setNumDigits( 8+1+sw_prec ); lapLcd->display( "00:00:00.00" ); splitLcd->setNumDigits( 8+1+sw_prec ); splitLcd->display( "00:00:00.00" ); lapNumLcd->display( 1 ); lapTimer = new QTimer( this ); connect( lapTimer, SIGNAL(timeout()), this, SLOT(lapTimeout()) ); for (uint s = 0; s < swatch_splitms.count(); s++ ) swatch_splitms[(int)s] = 0; connect( qApp, SIGNAL(clockChanged(bool)), this, SLOT(changeClock(bool)) ); cdGroup->hide(); // XXX implement countdown timer. connect( dailyHour, SIGNAL(valueChanged(int)), this, SLOT(scheduleApplyDailyAlarm()) ); connect( dailyMinute, SIGNAL(valueChanged(int)), this, SLOT(setDailyMinute(int)) ); connect( dailyAmPm, SIGNAL(activated(int)), this, SLOT(setDailyAmPm(int)) ); connect( dailyEnabled, SIGNAL(toggled(bool)), this, SLOT(enableDaily(bool)) ); cdLcd->display( "00:00" ); dailyMinute->setValidator(0); Config cConfig( "Clock" ); // No tr cConfig.setGroup( "Daily Alarm" ); QStringList days; days.append( tr("Mon", "Monday") ); days.append( tr("Tue", "Tuesday") ); days.append( tr("Wed", "Wednesday") ); days.append( tr("Thu", "Thursday") ); days.append( tr("Fri", "Friday") ); days.append( tr("Sat", "Saturday") ); days.append( tr("Sun", "Sunday") ); int i; QHBoxLayout *hb = new QHBoxLayout( daysFrame ); for ( i = 0; i < 7; i++ ) { dayBtn[i] = new QToolButton( daysFrame ); hb->addWidget( dayBtn[i] ); dayBtn[i]->setToggleButton( TRUE ); dayBtn[i]->setOn( TRUE ); dayBtn[i]->setFocusPolicy( StrongFocus ); connect( dayBtn[i], SIGNAL(toggled(bool)), this, SLOT(scheduleApplyDailyAlarm()) ); } for ( i = 0; i < 7; i++ ) dayBtn[dayBtnIdx(i+1)]->setText( days[i] ); QStringList exclDays = cConfig.readListEntry( "ExcludeDays", ',' ); QStringList::Iterator it; for ( it = exclDays.begin(); it != exclDays.end(); ++it ) { int d = (*it).toInt(); if ( d >= 1 && d <= 7 ) dayBtn[dayBtnIdx(d)]->setOn( FALSE ); } sbSnoozeTime->setValue( cConfig.readNumEntry( "SnoozeTime", DEFAULT_SNOOZE_TIME ) ); connect( sndOption, SIGNAL( activated(int) ), SLOT( slotSoundChange(int) ) ); sndOption->insertItem(tr("Default alarm")); sndOption->insertItem(tr("Play file in background")); sndOption->insertItem(tr("Play file with OpiePlayer")); sndOption->insertItem(tr("Play file with OpiePlayer 2")); bool alarm = cConfig.readBoolEntry("Enabled", FALSE); dailyEnabled->setChecked( alarm ); sndGroup->setEnabled( alarm ); // FIXME ODP migrate to own config class.. merge config options Config cfg_qpe( "qpe" ); cfg_qpe.setGroup( "Time" ); sndFileName->setText( cfg_qpe.readEntry( "mp3File" ) ); sndOption->setCurrentItem( cfg_qpe.readNumEntry( "mp3Player", DEFAULT_ALARMTYPE ) ); slotSoundChange(sndOption->currentItem()); int m = cConfig.readNumEntry( "Minute", 0 ); dailyMinute->setValue( m ); // dailyMinute->setPrefix( m <= 9 ? "0" : "" ); int h = cConfig.readNumEntry( "Hour", 7 ); if ( ampm ) { if (h > 12) { h -= 12; dailyAmPm->setCurrentItem( 1 ); } if (h == 0) h = 12; dailyHour->setMinValue( 1 ); dailyHour->setMaxValue( 12 ); } else { dailyAmPm->hide(); } dailyHour->setValue( h ); connect( ((MySpinBox*)dailyHour)->lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(dailyEdited()) ); connect( ((MySpinBox*)dailyMinute)->lineEdit(), SIGNAL(textChanged(const QString&)), this, SLOT(dailyEdited()) ); #if defined(Q_WS_QWS) && !defined(QT_NO_COP) connect( qApp, SIGNAL(appMessage(const QCString&,const QByteArray&)), this, SLOT(appMessage(const QCString&,const QByteArray&)) ); #endif QTimer::singleShot( 0, this, SLOT(updateClock()) ); swFrame->installEventFilter( this ); init = TRUE; }
// Returns the font of the text for a style. QFont QsciLexerCPP::defaultFont(int style) const { QFont f; switch (style) { case Comment: case InactiveComment: case CommentLine: case InactiveCommentLine: case CommentDoc: case InactiveCommentDoc: case CommentLineDoc: case InactiveCommentLineDoc: case CommentDocKeyword: case InactiveCommentDocKeyword: case CommentDocKeywordError: case InactiveCommentDocKeywordError: #if defined(Q_OS_WIN) f = QFont("Comic Sans MS",9); #elif defined(Q_OS_MAC) f = QFont("Comic Sans MS", 12); #else f = QFont("Bitstream Vera Serif",9); #endif break; case Keyword: case InactiveKeyword: case Operator: case InactiveOperator: f = QsciLexer::defaultFont(style); f.setBold(true); break; case DoubleQuotedString: case InactiveDoubleQuotedString: case SingleQuotedString: case InactiveSingleQuotedString: case UnclosedString: case InactiveUnclosedString: case VerbatimString: case InactiveVerbatimString: case Regex: case InactiveRegex: case TripleQuotedVerbatimString: case InactiveTripleQuotedVerbatimString: case HashQuotedString: case InactiveHashQuotedString: #if defined(Q_OS_WIN) f = QFont("Courier New",10); #elif defined(Q_OS_MAC) f = QFont("Courier", 12); #else f = QFont("Bitstream Vera Sans Mono",9); #endif break; default: f = QsciLexer::defaultFont(style); } return f; }
void Matrix::print(QPrinter *printer) { if (!printer) return; QPainter p; if ( !p.begin(printer)) return; // paint on printer int dpiy = printer->logicalDpiY(); const int margin = (int) ( (1/2.54)*dpiy ); // 1 cm margins if (d_view_type == ImageView){ p.drawImage (printer->pageRect(), d_matrix_model->renderImage()); return; } QHeaderView *vHeader = d_table_view->verticalHeader(); int rows = numRows(); int cols = numCols(); int height = margin; int i, vertHeaderWidth = vHeader->width(); int right = margin + vertHeaderWidth; // print header p.setFont(QFont()); QString header_label = d_matrix_model->headerData(0, Qt::Horizontal).toString(); QRect br = p.boundingRect(br, Qt::AlignCenter, header_label); p.drawLine(right, height, right, height+br.height()); QRect tr(br); for(i=0; i<cols; i++){ int w = d_table_view->columnWidth(i); tr.setTopLeft(QPoint(right,height)); tr.setWidth(w); tr.setHeight(br.height()); header_label = d_matrix_model->headerData(i, Qt::Horizontal).toString(); p.drawText(tr, Qt::AlignCenter, header_label,-1); right += w; p.drawLine(right, height, right, height+tr.height()); if (right >= printer->width()-2*margin ) break; } p.drawLine(margin + vertHeaderWidth, height, right-1, height);//first horizontal line height += tr.height(); p.drawLine(margin, height, right-1, height); // print table values for(i=0;i<rows;i++){ right = margin; QString cell_text = d_matrix_model->headerData(i, Qt::Horizontal).toString()+"\t"; tr = p.boundingRect(tr, Qt::AlignCenter, cell_text); p.drawLine(right, height, right, height+tr.height()); br.setTopLeft(QPoint(right,height)); br.setWidth(vertHeaderWidth); br.setHeight(tr.height()); p.drawText(br,Qt::AlignCenter,cell_text,-1); right += vertHeaderWidth; p.drawLine(right, height, right, height+tr.height()); for(int j=0; j<cols; j++){ int w = d_table_view->columnWidth (j); cell_text = text(i,j)+"\t"; tr = p.boundingRect(tr,Qt::AlignCenter,cell_text); br.setTopLeft(QPoint(right,height)); br.setWidth(w); br.setHeight(tr.height()); p.drawText(br, Qt::AlignCenter, cell_text, -1); right += w; p.drawLine(right, height, right, height+tr.height()); if (right >= printer->width()-2*margin ) break; } height += br.height(); p.drawLine(margin, height, right-1, height); if (height >= printer->height()-margin ){ printer->newPage(); height = margin; p.drawLine(margin, height, right, height); } } p.end(); }
LogLineBox::LogLineBox(RDAirPlayConf *conf,QWidget *parent,const char *name) : QWidget(parent,name) { line_status=RDLogLine::Scheduled; line_type=RDLogLine::UnknownType; line_mode=LogLineBox::Full; line_time_mode=RDAirPlayConf::TwentyFourHour; line_logline=NULL; log_id=-1; log_line=-1; line_move_count=-1; line_allow_drags=false; // // Templates // line_title_template=conf->titleTemplate(); line_artist_template=conf->artistTemplate(); line_outcue_template=conf->outcueTemplate(); line_description_template=conf->descriptionTemplate(); // // Create Font // line_bold_font=QFont("Helvetica",12,QFont::Bold); line_bold_font.setPixelSize(12); line_font=QFont("Helvetica",12,QFont::Normal); line_font.setPixelSize(12); talk_font=QFont("Helvetica",12,QFont::Bold); talk_font.setPixelSize(12); QFont outcue_font=QFont("Helvetica",12,QFont::Normal); outcue_font.setPixelSize(12); outcue_font.setItalic(true); // // Create Icons // line_playout_map=new QPixmap(play_xpm); line_macro_map=new QPixmap(rml5_xpm); line_chain_map=new QPixmap(chain_xpm); line_track_cart_map=new QPixmap(track_cart_xpm); line_mic16_map=new QPixmap(mic16_xpm); line_notemarker_map=new QPixmap(notemarker_xpm); line_traffic_map=new QPixmap(traffic_xpm); line_music_map=new QPixmap(music_xpm); // // Create Palettes // line_unchanged_stop_palette=palette(); line_unchanged_stop_palette.setColor(QPalette::Active,QColorGroup::Highlight, QColor(BAR_UNCHANGED_STOPPING_COLOR)); line_unchanged_stop_palette.setColor(QPalette::Inactive, QColorGroup::Highlight, QColor(BAR_UNCHANGED_STOPPING_COLOR)); line_unchanged_play_palette=palette(); line_unchanged_play_palette.setColor(QPalette::Active,QColorGroup::Highlight, QColor(BAR_UNCHANGED_TRANSITION_COLOR)); line_unchanged_play_palette.setColor(QPalette::Inactive, QColorGroup::Highlight, QColor(BAR_UNCHANGED_TRANSITION_COLOR)); line_changed_stop_palette=palette(); line_changed_stop_palette.setColor(QPalette::Active,QColorGroup::Highlight, QColor(BAR_CHANGED_STOPPING_COLOR)); line_changed_stop_palette.setColor(QPalette::Inactive,QColorGroup::Highlight, QColor(BAR_CHANGED_STOPPING_COLOR)); line_changed_play_palette=palette(); line_changed_play_palette.setColor(QPalette::Active,QColorGroup::Highlight, QColor(BAR_CHANGED_TRANSITION_COLOR)); line_changed_play_palette.setColor(QPalette::Inactive,QColorGroup::Highlight, QColor(BAR_CHANGED_TRANSITION_COLOR)); line_time_palette=palette(); line_hard_palette=palette(); line_hard_palette.setColor(QPalette::Active,QColorGroup::Foreground, QColor(LOG_HARDTIME_TEXT_COLOR)); line_hard_palette.setColor(QPalette::Inactive,QColorGroup::Foreground, QColor(LOG_HARDTIME_TEXT_COLOR)); line_timescale_palette=palette(); line_timescale_palette.setColor(QPalette::Active,QColorGroup::Foreground, QColor(LOGLINEBOX_TIMESCALE_COLOR)); line_timescale_palette.setColor(QPalette::Inactive,QColorGroup::Foreground, QColor(LOGLINEBOX_TIMESCALE_COLOR)); line_transition_palette=palette(); line_transition_palette.setColor(QPalette::Active,QColorGroup::Foreground, QColor(RD_CUSTOM_TRANSITION_COLOR)); line_transition_palette.setColor(QPalette::Inactive,QColorGroup::Foreground, QColor(RD_CUSTOM_TRANSITION_COLOR)); line_text_palette=palette(); line_text_palette.setColor(QPalette::Active,QColorGroup::Foreground, QColor(black)); line_text_palette.setColor(QPalette::Inactive,QColorGroup::Foreground, QColor(black)); // // Count Up // line_up_label=new QLabel(this); line_up_label->setGeometry(5,65,65,16); line_up_label->setAlignment(AlignLeft|AlignVCenter); line_up_label->setFont(line_font); line_up_label->hide(); // // Position Slider // line_position_bar=new QProgressBar(this); line_position_bar->setGeometry(75,66,sizeHint().width()-150,13); line_position_bar->setPercentageVisible(false); line_position_bar->hide(); // // Count Down // line_down_label=new QLabel(this); line_down_label->setGeometry(sizeHint().width()-72,65,65,16); line_down_label->setAlignment(AlignLeft|AlignVCenter); line_down_label->setFont(line_font); line_down_label->hide(); // // Cut Description // line_description_label=new QLabel(this); line_description_label->setGeometry((sizeHint().width()/2),48,(sizeHint().width()/2 -10),16); line_description_label->setFont(line_font); line_description_label->hide(); // // Outcue // line_outcue_label=new QLabel(this); line_outcue_label->setGeometry(5,48, (sizeHint().width()/2 -10),16); line_outcue_label->setFont(outcue_font); line_outcue_label->hide(); // // Artist // line_artist_label=new QLabel(this); line_artist_label->setGeometry(5,33,sizeHint().width()-10,16); line_artist_label->setFont(line_font); // // Title // line_title_label=new QLabel(this); line_title_label->setGeometry(5,18,sizeHint().width()-10,18); line_title_label->setFont(line_bold_font); // // Marker Comment // line_comment_label=new RDLabel(this); line_comment_label->setGeometry(5,18,sizeHint().width()-10,62); line_comment_label->setFont(line_font); line_comment_label->setAlignment(AlignTop|AlignLeft); line_comment_label->setWordWrapEnabled(true); line_comment_label->hide(); // // Icon // line_icon_label=new QLabel(this); line_icon_label->setGeometry(5,3,45,16); // // Cart // line_cart_label=new QLabel(this); line_cart_label->setGeometry(25,3,53,16); line_cart_label->setFont(line_font); // // Cut // line_cut_label=new QLabel(this); line_cut_label->setGeometry(80,3,24,16); line_cut_label->setFont(line_font); // // Group // line_group_label=new QLabel(this); line_group_label->setGeometry(107,3,75,16); line_group_label->setFont(line_bold_font); // // Time // line_time_label=new QLabel(this); line_time_label->setGeometry(185,3,70,16); line_time_label->setFont(line_font); line_time_label->setAlignment(AlignRight); line_time_label->setPalette(line_time_palette); // // Talk Time // line_talktime_label=new QLabel(this); line_talktime_label->setGeometry(257,3,36,16); line_talktime_label->setFont(talk_font); line_talktime_label->setAlignment(AlignRight); // // Length // line_length_label=new QLabel(this); line_length_label->setGeometry(297,3,40,16); line_length_label->setFont(line_font); line_length_label->setAlignment(AlignRight); // // Transition Type // line_trans_label=new QLabel(this); line_trans_label->setGeometry(sizeHint().width()-53,3,48,16); line_trans_label->setAlignment(AlignRight); line_trans_label->setFont(line_bold_font); SetColor(QColor(LOGLINEBOX_BACKGROUND_COLOR)); // // Countdown Timer // line_countdown_timer=new QTimer(this); connect(line_countdown_timer,SIGNAL(timeout()),this,SLOT(countdownData())); setAcceptDrops(true); }
void print::prepareDocument_All_Thermal(){ mDoc2Print = new QTextDocument(); mDocCursor = QTextCursor(mDoc2Print); QString s; QTextCharFormat form; form.setFont(QFont( "Serif Sans Mono", 9 )); QTextCharFormat defaultFormat=mDocCursor.charFormat(); s=QString("\nAdithya Medical Systems\n"); mDocCursor.insertText(s); mDocCursor.setCharFormat(form); s=QString("\nDoctor:")+QString(currentDoctor->cDocName)+"\n"; mDocCursor.insertText(s); s=QString("\nPatient:")+QString(currentPatient->cPatName)+"\n"; mDocCursor.insertText(s); s=QString("\nPatient ID:")+QString(currentPatient->cId)+"\n"; mDocCursor.insertText(s); s=QString("\nEye:")+eye+"\n"; mDocCursor.insertText(s); s=QString("\nDate:")+QDate::currentDate().toString()+"\n"; mDocCursor.insertText(s); s=QString("\nTime:")+QTime::currentTime().toString()+"\n"; mDocCursor.insertText(s); QImage im("scan.png"); QTransform rotating; rotating.rotate(90); im = im.transformed(rotating); im.invertPixels(); mDocCursor.insertImage(im); // mDocCursor.insertText(emptyLine); mDocCursor.setCharFormat(defaultFormat); s=QString("\nAL:")+QString::number(printLocalreadings[*nCurrentReadingNumber].dAl,'f',2)+QString("\n"); mDocCursor.insertText(s); s=QString("\nLT:")+QString::number(printLocalreadings[*nCurrentReadingNumber].dLt,'f',2)+QString("\n"); mDocCursor.insertText(s); s=QString("\nVIT:")+QString::number(printLocalreadings[*nCurrentReadingNumber].dVit,'f',2)+QString("\n"); mDocCursor.insertText(s); s=QString("ACD:")+QString::number(printLocalreadings[*nCurrentReadingNumber].dAcd,'f',2)+QString("\n"); mDocCursor.insertText(s); s=QString("\nAVG AL:")+QString::number(printLocalreadings[*nCurrentReadingNumber].dAv_al,'f',2)+QString("\n"); mDocCursor.insertText(s); s=QString("\nDeviation:")+QString::number(printLocalreadings[*nCurrentReadingNumber].dDeviation,'f',2)+QString("\n"); mDocCursor.insertText(s); ifstream sd_calc; sd_calc.open("sd.dat"); double sd; sd_calc.read((char*)&sd,sizeof(sd)); s=QString("\nStd_Deviation:")+QString::number(sd)+QString("\n"); mDocCursor.insertText(s); if(eye==QString("Right")){ s=QString("\n\nK1=")+QString(currentPatient->cRk1)+QString("\nK2=")+QString(currentPatient->cRk2)+QString("\n"); } else { s=QString("\nK1=")+QString(currentPatient->cLk1)+QString("\nK2=")+QString(currentPatient->cLk2)+QString("\n"); } s+=QString("\nK=")+QString::number(first[0].K,'f',2)+QString("\n\nAL=")+QString::number(first[0].AL,'f',2)+QString("\t Rx=")+QString::number(first[0].Rx,'f',2); mDocCursor.insertText (s.toStdString().c_str()); mDocCursor.insertText("\n\n"); lens1.truncate(6); lens2.truncate(6); lens3.truncate(6); mDocCursor.setCharFormat(defaultFormat); if(first[0].ftype==0) { mDocCursor.insertText("\nFORMULA: SRKT\n"); s =lens1+" "+lens2+" "+lens3+"\n"; mDocCursor.insertText (s.toStdString().c_str()); s=QString::number(first[0].AConst,'f',2)+" "+QString::number(first[1].AConst,'f',2)+" "+QString::number(first[2].AConst,'f',2)+"\n"; mDocCursor.insertText(s); } else if(first[0].ftype==1) { mDocCursor.insertText("\nFORMULA: SRKII\n"); s =lens1+" "+lens2+" "+lens3+"\n"; mDocCursor.insertText (s.toStdString().c_str()); s=QString::number(first[0].AConst,'f',2)+" "+QString::number(first[1].AConst,'f',2)+" "+QString::number(first[2].AConst,'f',2)+"\n"; mDocCursor.insertText(s); } else if(first[0].ftype==2) { mDocCursor.insertText ("\nFORMULA: HOFFERQ"); s =lens1+" "+lens2+" "+lens3+"\n"; mDocCursor.insertText (s.toStdString().c_str()); s=""; ifstream l; l.open("lens.dat",ios::binary); lens lensVariable; while(l.read((char*)&lensVariable,sizeof(lensVariable))){ qDebug()<<lensVariable.cIol; if(strcmp(lensVariable.cIol,lens1_2.toStdString().c_str())==0) { s=" "+QString(lensVariable.cSf); break; } } l.close(); l.open("lens.dat",ios::binary); while(l.read((char*)&lensVariable,sizeof(lensVariable))){ if(strcmp(lensVariable.cIol,lens2_2.toStdString().c_str())==0) { s+=" "+QString(lensVariable.cSf); break; } } l.close(); l.open("lens.dat",ios::binary); while(l.read((char*)&lensVariable,sizeof(lensVariable))){ if(strcmp(lensVariable.cIol,lens3_2.toStdString().c_str())==0) { s+=" "+QString(lensVariable.cSf); break; } } l.close(); s+="\n"; mDocCursor.insertText(s); } else if(first[0].ftype==3) { mDocCursor.insertText ("\nFORMULA: HOLLADAY\n"); s =lens1+" "+lens2+" "+lens3+"\n"; mDocCursor.insertText (s.toStdString().c_str()); s=""; ifstream l; l.open("lens.dat",ios::binary); lens lensVariable; while(l.read((char*)&lensVariable,sizeof(lensVariable))){ qDebug()<<lensVariable.cIol; if(strcmp(lensVariable.cIol,lens1_2.toStdString().c_str())==0) { s=" "+QString(lensVariable.cSf); break; } } l.close(); l.open("lens.dat",ios::binary); while(l.read((char*)&lensVariable,sizeof(lensVariable))){ if(strcmp(lensVariable.cIol,lens2_2.toStdString().c_str())==0) { s+=" "+QString(lensVariable.cSf); break; } } l.close(); l.open("lens.dat",ios::binary); while(l.read((char*)&lensVariable,sizeof(lensVariable))){ if(strcmp(lensVariable.cIol,lens3_2.toStdString().c_str())==0) { s+=" "+QString(lensVariable.cSf); break; } } l.close(); s+="\n"; mDocCursor.insertText(s); } else if(first[0].ftype=4) { mDocCursor.insertText ("\nFORMULA: HAIGIS\n"); s =lens1+" "+lens2+" "+lens3+"\n"; mDocCursor.insertText (s.toStdString().c_str()); s=""; ifstream l; l.open("lens.dat",ios::binary); lens lensVariable; while(l.read((char*)&lensVariable,sizeof(lensVariable))){ qDebug()<<lensVariable.cIol; if(strcmp(lensVariable.cIol,lens1_2.toStdString().c_str())==0) { s=" "+QString(lensVariable.cA0); break; } } l.close(); l.open("lens.dat",ios::binary); while(l.read((char*)&lensVariable,sizeof(lensVariable))){ if(strcmp(lensVariable.cIol,lens2_2.toStdString().c_str())==0) { s+=" "+QString(lensVariable.cA0); break; } } l.close(); l.open("lens.dat",ios::binary); while(l.read((char*)&lensVariable,sizeof(lensVariable))){ if(strcmp(lensVariable.cIol,lens3_2.toStdString().c_str())==0) { s+=" "+QString(lensVariable.cA0); break; } } l.close(); s+="\n"; mDocCursor.insertText(s); } else if(first[0].ftype==5) { mDocCursor.insertText ("\nFORMULA: BINKHORST\n"); s =lens1+" "+lens2+" "+lens3+"\n"; mDocCursor.insertText (s.toStdString().c_str()); s=QString::number(first[0].AConst,'f',2)+" "+QString::number(first[1].AConst,'f',2)+" "+QString::number(first[2].AConst,'f',2)+"\n"; mDocCursor.insertText(s); } mDocCursor.insertText ("IOL Ref IOL Ref IOL Ref\n"); // mDoc2Print->set mDocCursor.setCharFormat(form); for (int i=0;i<5;i++){ if (second[0].PORx[i] < 0.0){ s=QString::number(second[0].IOLPower[i],'f',1)+" "+QString::number(second[0].PORx[i],'f',2)+" "+QString::number(second[1].IOLPower[i],'f',1)+" "+QString::number(second[1].PORx[i],'f',2)+" "+QString::number(second[2].IOLPower[i],'f',1)+" "+QString::number(second[2].PORx[i],'f',2)+"\n\n"; } else{ s=QString::number(second[0].IOLPower[i],'f',1)+" "+QString::number(second[0].PORx[i],'f',2)+" "+QString::number(second[1].IOLPower[i],'f',1)+" "+QString::number(second[1].PORx[i],'f',2)+" "+QString::number(second[2].IOLPower[i],'f',1)+" "+QString::number(second[2].PORx[i],'f',2)+"\n\n"; } //qDebug()<<s; mDocCursor.insertText (s.toStdString().c_str()); // send 7 character greeting } mDocCursor.insertText("\n"); mDocCursor.setCharFormat(defaultFormat); s="\nPEMMETROPIA\n"; mDocCursor.insertText(s.toStdString().c_str()); s=" "+QString::number(second[0].PEMM,'f',2)+" "+QString::number(second[1].PEMM,'f',2)+" "+QString::number(second[2].PEMM,'f',2)+" "; mDocCursor.insertText(s); // send 7 character greeting // send 7 character greeting mDocCursor.insertText("\n\n\n\n\n"); // qDebug()<<"printing end"; // QFile outfile; // outfile.setFileName("pout.txt"); // outfile.open(QIODevice::Append); // QTextDocumentWriter t; // outfile.write(mDoc2Print->toPlainText().toStdString().c_str(),sizeof(mDoc2Print->toPlainText().toStdString().c_str())); // QProcess process; // process.start("lpr pout.txt"); // process.waitForFinished(-1); }
NCRDSqlTextEdit::NCRDSqlTextEdit(QWidget * parent) : QTextEdit( parent ) { setFont( QFont("Courier New",10) ); }
MainWindow::MainWindow(QStringList files, QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); ui->actionOpen->setIcon( QIcon::fromTheme("document-open") ); ui->actionNew->setIcon( QIcon::fromTheme("document-new") ); ui->actionClose->setIcon( QIcon::fromTheme("document-close")); ui->actionQuit->setIcon( QIcon::fromTheme("application-exit")); ui->actionSave->setIcon( QIcon::fromTheme("document-save")); ui->actionSaveAs->setIcon( QIcon::fromTheme("document-save-as")); ui->actionCut->setIcon( QIcon::fromTheme("edit-cut")); ui->actionCopy->setIcon( QIcon::fromTheme("edit-copy")); ui->actionPaste->setIcon( QIcon::fromTheme("edit-paste")); ui->actionSelectAll->setIcon( QIcon::fromTheme("edit-select-all")); ui->actionUndo->setIcon( QIcon::fromTheme("edit-undo")); ui->actionRedo->setIcon( QIcon::fromTheme("edit-redo")); ui->actionFind->setIcon( QIcon::fromTheme("edit-find")); ui->actionIndent->setIcon( QIcon::fromTheme("format-indent-more")); ui->actionUnindent->setIcon( QIcon::fromTheme("format-indent-less")); ui->actionZoom_In->setIcon( QIcon::fromTheme("format-font-size-more")); ui->actionZoom_Out->setIcon( QIcon::fromTheme("format-font-size-less")); ui->findWidget->hide(); ui->gotoLineWidget->hide(); QSettings set; if( set.contains("font") && set.contains("font-size") && set.contains("font-weight") && set.contains("font-italic") ) { m_textFont = QFont( set.value("font").toString() , set.value("font-size").toInt() , set.value("font-weight").toInt() , set.value("font-italic").toBool() ); } else { m_textFont = font(); set.setValue("font", m_textFont.family() ); set.setValue("font-size", m_textFont.pointSize() ); set.setValue("font-weight", m_textFont.weight() ); set.setValue("font-italic" , m_textFont.italic() ); } if( set.contains("color-red") && set.contains("color-green") && set.contains("color-blue") && set.contains("color-alpha") ) { m_textColor = QColor( set.value("color-red").toInt() , set.value("color-green").toInt() , set.value("color-blue").toInt(), set.value("color-alpha").toInt() ); } else { m_textColor = QColor( Qt::black ); set.setValue("color-red" , m_textColor.red() ); set.setValue("color-green" , m_textColor.green() ); set.setValue("color-blue" , m_textColor.blue() ); set.setValue("color-alpha" , m_textColor.alpha() ); } if( set.contains("last-path")) { m_lastPath = set.value("last-path").toString(); } else { m_lastPath = QDir::homePath(); set.setValue("last-path", m_lastPath ); } //qDebug() << files.count(); if( files.count() == 0) { createTab(""); } else { foreach( QString name, files) { createTab( name ); } }
Tracker::Tracker(QWidget *parent) : QWidget(parent) { //****************construct putton and widget************************// //Calendar Setting calendar = new QCalendarWidget; calendar->setGridVisible(true); QLabel *listname=new QLabel(" Detail Table"); listname->setFont(QFont("Times", 16, QFont::Bold)); listname->setStyleSheet("QLabel { background-color : rgb(255, 165, 0); color : black; }"); detailList=new QListWidget; detailList->setStyleSheet( "QListWidget::item { background-color: white;border-bottom: 1px solid black; }" "QListWidget::item:selected{color: #333538;background-color: qlineargradient(x1: 0, y1: 0, x2: 0, y2: 1,stop: 0 #cdcdcd, stop: 1 #ababab); border-top: 1px solid;border-top-color: #a8abad;border-bottom: 1px solid;border-bottom-color: #bfc7ce;}"); removeButton=new QPushButton(tr("&REMOVE")); removeButton->setFont(QFont("Cambria", 14, QFont::Bold)); QVBoxLayout *LayoutRight=new QVBoxLayout; LayoutRight->addWidget(listname,1); LayoutRight->addWidget(detailList,12); LayoutRight->setSpacing(3); LayoutRight->addWidget(removeButton,2); QHBoxLayout *Layout1=new QHBoxLayout; Layout1->addWidget(calendar,3); Layout1->addLayout(LayoutRight,2); //Background Setting QString newpath (":/image/images/2.jpg"); QPixmap pixmap = QPixmap(newpath).scaled(this->size()); QPalette palette(this->palette()); palette.setBrush(QPalette::Background, QBrush(pixmap)); this->setPalette(palette); //pushbutton declaration addExpenseButton = new QPushButton(tr("&Expense")); addExpenseButton->setFont(QFont("Cambria", 13, QFont::Bold)); addIncomeButton= new QPushButton(tr("&Income")); addIncomeButton->setFont(QFont("Cambria", 13, QFont::Bold)); shoppingListButton= new QPushButton(tr("&Shopping List")); shoppingListButton->setFont(QFont("Cambria", 13, QFont::Bold)); reportButton = new QPushButton(tr("&Report")); reportButton->setFont(QFont("Cambria", 13, QFont::Bold)); searchButton = new QPushButton(tr("&Search")); searchButton->setFont(QFont("Cambria", 13, QFont::Bold)); searchLine = new QLineEdit; // Button horizontal layout QHBoxLayout *buttonLayout1 = new QHBoxLayout; buttonLayout1->addWidget(addExpenseButton,1); buttonLayout1->addWidget(addIncomeButton,1); buttonLayout1->addWidget(reportButton,1); buttonLayout1->addWidget(shoppingListButton,1); QHBoxLayout *searcharea = new QHBoxLayout; searcharea->addWidget(searchLine,3); searcharea->addWidget(searchButton,1); QVBoxLayout *left = new QVBoxLayout; left->addLayout(buttonLayout1); left->addLayout(searcharea); //right area settingbudget=new QPushButton(tr("Monthly Budget")); settingbudget->setFont(QFont("Times", 15, QFont::Bold)); budget=new QLCDNumber; budget->setSegmentStyle(QLCDNumber::Filled); //budget->display(budgetAmount); QPushButton *ratiobar=new QPushButton(tr("Expense Ratio")); ratiobar->setFont(QFont("Times", 15, QFont::Bold)); ratio=new QProgressBar; QGridLayout *showarea=new QGridLayout; showarea->setSpacing(20); showarea->addWidget(settingbudget,0,0); showarea->addWidget(budget,0,1); showarea->addWidget(ratiobar,1,0); showarea->addWidget(ratio,1,1); QHBoxLayout *Layout2=new QHBoxLayout; Layout2->addLayout(left,3); Layout2->addLayout(showarea,2); QVBoxLayout *mainLayout=new QVBoxLayout; mainLayout->addLayout(Layout1,10); mainLayout->addLayout(Layout2,3); setLayout(mainLayout); setWindowTitle("Basic Model"); //! [grid layout] setLayout(mainLayout); setWindowTitle(tr("Basic Model")); //****************construct items and labels************************// // QDir currentDir; // QString path = currentDir.currentPath(); // QString filePathE = path + "/../../../expense_data.csv"; // QString filePathI = path + "/../../../income_data.csv"; // QString filePathEL = path + "/../../../expense_labels.txt"; // QString filePathIL = path + "/../../../income_labels.txt"; QString homePath = QString(getenv("HOME")); //std::cout<<homePath.toStdString().c_str()<<std::endl; QDir *temp = new QDir; bool exist = temp->exists(homePath + "/.ExpenseTracker_withData"); if(exist == 0) temp->mkdir(homePath + "/.ExpenseTracker_withData"); QString filePathE = homePath + "/.ExpenseTracker_withData/expense_data.csv"; QString filePathI = homePath + "/.ExpenseTracker_withData/income_data.csv"; QString filePathEL = homePath + "/.ExpenseTracker_withData/expense_labels.txt"; QString filePathIL = homePath + "/.ExpenseTracker_withData/income_labels.txt"; QString filePathB = homePath + "/.ExpenseTracker_withData/budget.txt"; QString filePathSL = homePath + "/.ExpenseTracker_withData/shoppingList.csv"; std::ifstream fin(filePathE.toStdString().c_str()); if(!fin){ QString dataPath (":/data/resource"); QString filePathEd = dataPath + "/expense_data.csv"; QString filePathId = dataPath + "/income_data.csv"; QString filePathELd = dataPath + "/expense_labels.txt"; QString filePathILd = dataPath + "/income_labels.txt"; QString filePathBd = dataPath + "/budget.txt"; QString filePathSLd = dataPath + "/shoppingList.csv"; expenseItems = readData(filePathEd); incomeItems = readData(filePathId); expenseLabels = readLabel(filePathELd); incomeLabels = readLabel(filePathILd); budgetAmount = readBudget(filePathBd); shoppingItems = readShoppingList(filePathSLd); writeData(expenseItems, filePathE.toStdString().c_str()); writeData(incomeItems, filePathI.toStdString().c_str()); writeLabel(expenseLabels, filePathEL.toStdString().c_str()); writeLabel(incomeLabels, filePathIL.toStdString().c_str()); writeBudget(budgetAmount, filePathB.toStdString().c_str()); writeShoppingList(shoppingItems, filePathSL.toStdString().c_str()); } else{ expenseItems = readData(filePathE.toStdString().c_str()); incomeItems = readData(filePathI.toStdString().c_str()); expenseLabels = readLabel(filePathEL.toStdString().c_str()); incomeLabels = readLabel(filePathIL.toStdString().c_str()); budgetAmount = readBudget(filePathB.toStdString().c_str()); std::ifstream finSL(filePathSL.toStdString().c_str()); if(finSL){ shoppingItems = readShoppingList(filePathSL.toStdString().c_str()); } else{ shoppingItems = NULL; } } budget->display(budgetAmount); selectedDateChanged(); double ratioValue = report_sum_M(QDate::currentDate().month(),QDate::currentDate().year(),expenseItems)/budgetAmount; if(ratioValue < 1){ ratio->setValue(100*ratioValue); } else ratio->setValue(100); searchFlag = 0; //******************connecting signals and slots***************************// connect(addExpenseButton, SIGNAL(clicked()), this, SLOT(addexpensewindow())); connect(addIncomeButton, SIGNAL(clicked()), this, SLOT(addincomewindow())); connect(reportButton, SIGNAL(clicked()), this, SLOT(report())); connect(calendar, SIGNAL(selectionChanged()), this, SLOT(selectedDateChanged())); connect(settingbudget, SIGNAL(clicked()), this, SLOT(settingBudget())); connect(removeButton, SIGNAL(clicked()), this, SLOT(removeItem())); connect(shoppingListButton, SIGNAL(clicked()), this, SLOT(checkShoppingList())); connect(searchButton, SIGNAL(clicked()), this, SLOT(searchItem())); connect(searchLine, SIGNAL(returnPressed()), this, SLOT(searchItem())); }
void UserInterface::SetLabelProperties() { _label->setFont(QFont("Courier New", 12, QFont::Bold)); _label->setMaximumHeight(25); }
void ScaleBarObject::draw(float pixelGLRatio, int screenWidth, int screenHeight, int viewWidth, int viewHeight, bool grabsMouse) { VolumeInformation pvlInfo = VolumeInformation::volumeInformation(); QString str; bool horizontal = m_type; float slen = voxels(); if (pvlInfo.voxelUnit > 0) { float avg = (pvlInfo.voxelSize[0] + pvlInfo.voxelSize[1] + pvlInfo.voxelSize[2])/3.0f; str = QString("%1 %2"). \ arg(slen, 0, 'f', Global::floatPrecision()). \ arg(pvlInfo.voxelUnitStringShort()); slen /= avg; } else str = QString("%1 voxels").arg(slen); slen = slen/pixelGLRatio; Vec s0 = Vec(m_pos.x()*viewWidth, m_pos.y()*viewHeight, 1); Vec s1 = s0; if (horizontal) { slen *= (float)viewWidth/(float)screenWidth; s0 -= Vec(slen/2, 0, 0); s1 += Vec(slen/2, 0, 0); } else { slen *= (float)viewHeight/(float)screenHeight; s0 -= Vec(0, slen/2, 0); s1 += Vec(0, slen/2, 0); } glEnable(GL_BLEND); glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA); // back to front glColor4f(0, 0, 0, 0.8f); if (grabsMouse) { glColor4f(0.5f, 0, 0, 0.8f); glBegin(GL_QUADS); if (horizontal) { glVertex2f(s0.x-5, s0.y-10); glVertex2f(s1.x+5, s0.y-10); glVertex2f(s1.x+5, s0.y+10); glVertex2f(s0.x-5, s0.y+10); } else { glVertex2f(s0.x-10, s0.y-5); glVertex2f(s0.x-10, s1.y+5); glVertex2f(s0.x+10, s1.y+5); glVertex2f(s0.x+10, s0.y-5); } glEnd(); } glDisable(GL_BLEND); glColor3f(1,1,1); glLineWidth(10); glBegin(GL_LINES); glVertex3fv(s0); glVertex3fv(s1); glEnd(); glColor3f(0.5,0.5,0.5); glLineWidth(2); glBegin(GL_LINES); if (horizontal) { glVertex2f(s0.x+slen/2, s0.y-3); glVertex2f(s0.x+slen/2, s1.y+3); } else { glVertex2f(s1.x-3, (s1.y+s0.y)/2); glVertex2f(s0.x+3, (s1.y+s0.y)/2); } glEnd(); glColor3f(0,0,0); glLineWidth(2); glBegin(GL_LINES); if (horizontal) { glVertex2f(s0.x+1, s0.y); glVertex2f(s1.x-1, s1.y); } else { glVertex2f(s0.x, s0.y+1); glVertex2f(s1.x, s1.y-1); } glEnd(); glLineWidth(1); glColor3f(1,1,1); { Vec w0 = Vec(m_pos.x()*screenWidth, (1-m_pos.y())*screenHeight,1); Vec w1 = w0; if (horizontal) { w0 -= Vec(slen/2, 0, 0); w1 += Vec(slen/2, 0, 0); } else { w0 -= Vec(0, slen/2, 0); w1 += Vec(0, slen/2, 0); } QFont tfont = QFont("Helvetica", 12); tfont.setStyleStrategy(QFont::PreferAntialias); QFontMetrics metric(tfont); int mde = metric.descent(); int fht = metric.height()+2; int fwd = metric.width(str)+2; QImage bImage = QImage(fwd, fht, QImage::Format_ARGB32); bImage.fill(0); QPainter bpainter(&bImage); Vec bgcolor = Global::backgroundColor(); bpainter.setBackgroundMode(Qt::OpaqueMode); bpainter.setBackground(QColor(bgcolor.z*255, bgcolor.y*255, bgcolor.x*255)); float bgintensity = (0.3*bgcolor.x + 0.5*bgcolor.y + 0.2*bgcolor.z); QColor penColor(Qt::white); if (bgintensity > 0.5) penColor = Qt::black; bpainter.setPen(penColor); bpainter.setFont(tfont); bpainter.drawText(1, fht-mde, str); QImage cImage = bImage.mirrored(); if (!horizontal) { QMatrix matrix; matrix.rotate(90); cImage = cImage.transformed(matrix); } int x,y; if (horizontal) { x = (w0.x+w1.x)/2 - cImage.width()/2; y = w0.y-3-cImage.height(); if (!m_textpos) y = w0.y+6; } else { x = w1.x+3; if (!m_textpos) x = w1.x-5-cImage.width(); y = (w0.y+w1.y)/2 - cImage.height()/2; } glWindowPos2i(x,y); const uchar *bits = cImage.bits(); glDrawPixels(cImage.width(), cImage.height(), GL_RGBA, GL_UNSIGNED_BYTE, bits); } }
ListGroups::ListGroups(QWidget *parent) : QDialog(parent,"",true) { // // Fix the Window Size // setMinimumWidth(sizeHint().width()); setMinimumHeight(sizeHint().height()); setCaption(tr("Rivendell Group List")); // // Create Fonts // QFont font=QFont("Helvetica",12,QFont::Bold); font.setPixelSize(12); QFont list_font=QFont("Helvetica",12,QFont::Normal); list_font.setPixelSize(12); QFont small_font=QFont("Helvetica",10,QFont::Normal); small_font.setPixelSize(10); // // Add Button // list_add_button=new QPushButton(this); list_add_button->setFont(font); list_add_button->setText(tr("&Add")); connect(list_add_button,SIGNAL(clicked()),this,SLOT(addData())); // // Edit Button // list_edit_button=new QPushButton(this); list_edit_button->setFont(font); list_edit_button->setText(tr("&Edit")); connect(list_edit_button,SIGNAL(clicked()),this,SLOT(editData())); // // Rename Button // list_rename_button=new QPushButton(this); list_rename_button->setFont(font); list_rename_button->setText(tr("&Rename")); connect(list_rename_button,SIGNAL(clicked()),this,SLOT(renameData())); // // Delete Button // list_delete_button=new QPushButton(this); list_delete_button->setFont(font); list_delete_button->setText(tr("&Delete")); connect(list_delete_button,SIGNAL(clicked()),this,SLOT(deleteData())); // // Report Button // list_report_button=new QPushButton(this); list_report_button->setFont(font); list_report_button->setText(tr("Generate\n&Report")); connect(list_report_button,SIGNAL(clicked()),this,SLOT(reportData())); // // Close Button // list_close_button=new QPushButton(this); list_close_button->setDefault(true); list_close_button->setFont(font); list_close_button->setText(tr("&Close")); connect(list_close_button,SIGNAL(clicked()),this,SLOT(closeData())); // // Group List // list_groups_view=new RDListView(this); list_groups_view->setFont(list_font); list_groups_view->setAllColumnsShowFocus(true); list_groups_view->addColumn(tr("NAME")); list_groups_view->addColumn(tr("DESCRIPTION")); list_groups_view->addColumn(tr("START CART")); list_groups_view->setColumnAlignment(2,Qt::AlignCenter); list_groups_view->addColumn(tr("END CART")); list_groups_view->setColumnAlignment(3,Qt::AlignHCenter); list_groups_view->addColumn(tr("ENFORCE RANGE")); list_groups_view->setColumnAlignment(4,Qt::AlignHCenter); list_groups_view->addColumn(tr("DEFAULT TYPE")); list_groups_view->setColumnAlignment(5,Qt::AlignHCenter); list_groups_view->addColumn(tr("TRAFFIC REPORT")); list_groups_view->setColumnAlignment(6,Qt::AlignHCenter); list_groups_view->addColumn(tr("MUSIC REPORT")); list_groups_view->setColumnAlignment(7,Qt::AlignHCenter); list_groups_view->addColumn(tr("NOW & NEXT")); list_groups_view->setColumnAlignment(8,Qt::AlignHCenter); QLabel *list_box_label=new QLabel(list_groups_view,tr("&Groups:"),this); list_box_label->setFont(font); list_box_label->setGeometry(14,11,85,19); connect(list_groups_view, SIGNAL(doubleClicked(QListViewItem *,const QPoint &,int)), this, SLOT(doubleClickedData(QListViewItem *,const QPoint &,int))); RefreshList(); }
void NGLScene::initializeGL() { // we must call this first before any other GL commands to load and link the // gl commands from the lib, if this is not done program will crash ngl::NGLInit::instance(); // Now we will create a basic Camera from the graphics library // This is a static camera so it only needs to be set once // First create Values for the camera position ngl::Vec3 from(0.0f,2.0f,5.0f); ngl::Vec3 to(0.0f,0.0f,0.0f); ngl::Vec3 up(0.0f,1.0f,0.0f); // now load to our new camera m_cam.set(from,to,up); // set the shape using FOV 45 Aspect Ratio based on Width and Height // The final two are near and far clipping planes of 0.5 and 10 m_cam.setShape(45.0f,(float)float(width()/height()),0.05f,350.0f); glClearColor(0.0f, 0.0f, 0.0f, 1.0f); // Grey Background // enable depth testing for drawing glEnable(GL_DEPTH_TEST); // enable multisampling for smoother drawing glEnable(GL_MULTISAMPLE); // now to load the shader and set the values // grab an instance of shader manager ngl::ShaderLib *shader=ngl::ShaderLib::instance(); // we are creating a shader for Pass 1 shader->createShaderProgram("Pass1"); // now we are going to create empty shaders for Frag and Vert shader->attachShader("Pass1Vertex",ngl::ShaderType::VERTEX); shader->attachShader("Pass1Fragment",ngl::ShaderType::FRAGMENT); // attach the source shader->loadShaderSource("Pass1Vertex","shaders/Pass1Vert.glsl"); shader->loadShaderSource("Pass1Fragment","shaders/Pass1Frag.glsl"); // compile the shaders shader->compileShader("Pass1Vertex"); shader->compileShader("Pass1Fragment"); // add them to the program shader->attachShaderToProgram("Pass1","Pass1Vertex"); shader->attachShaderToProgram("Pass1","Pass1Fragment"); // shader->bindFragDataLocation("Pass1",0,"pointDeferred"); // shader->bindFragDataLocation("Pass1",1,"normalDeferred"); // shader->bindFragDataLocation("Pass1",2,"colourDeferred"); // shader->bindFragDataLocation("Pass1",3,"shadingDeferred"); shader->linkProgramObject("Pass1"); shader->use("Pass1"); // we are creating a shader for Pass 2 shader->createShaderProgram("Pass2"); // now we are going to create empty shaders for Frag and Vert shader->attachShader("Pass2Vertex",ngl::ShaderType::VERTEX); shader->attachShader("Pass2Fragment",ngl::ShaderType::FRAGMENT); // attach the source shader->loadShaderSource("Pass2Vertex","shaders/Pass2Vert.glsl"); shader->loadShaderSource("Pass2Fragment","shaders/Pass2Frag.glsl"); // compile the shaders shader->compileShader("Pass2Vertex"); shader->compileShader("Pass2Fragment"); // add them to the program shader->attachShaderToProgram("Pass2","Pass2Vertex"); shader->attachShaderToProgram("Pass2","Pass2Fragment"); shader->linkProgramObject("Pass2"); shader->use("Pass2"); shader->setShaderParam1i("pointTex",0); shader->setShaderParam1i("normalTex",1); shader->setShaderParam1i("colourTex",2); shader->setShaderParam1i("lightPassTex",3); shader->setShaderParam1i("diffusePassTex",4); // we are creating a shader for Debug pass shader->createShaderProgram("Debug"); // now we are going to create empty shaders for Frag and Vert shader->attachShader("DebugVertex",ngl::ShaderType::VERTEX); shader->attachShader("DebugFragment",ngl::ShaderType::FRAGMENT); // attach the source shader->loadShaderSource("DebugVertex","shaders/DebugVert.glsl"); shader->loadShaderSource("DebugFragment","shaders/DebugFrag.glsl"); // compile the shaders shader->compileShader("DebugVertex"); shader->compileShader("DebugFragment"); // add them to the program shader->attachShaderToProgram("Debug","DebugVertex"); shader->attachShaderToProgram("Debug","DebugFragment"); shader->linkProgramObject("Debug"); shader->use("Debug"); shader->setShaderParam1i("pointTex",0); shader->setShaderParam1i("normalTex",1); shader->setShaderParam1i("colourTex",2); shader->setShaderParam1i("lightPassTex",3); shader->setShaderParam1i("diffusePassTex",4); shader->setRegisteredUniform1i("mode",1); // we are creating a shader for Lighting pass shader->createShaderProgram("Lighting"); // now we are going to create empty shaders for Frag and Vert shader->attachShader("LightingVertex",ngl::ShaderType::VERTEX); shader->attachShader("LightingFragment",ngl::ShaderType::FRAGMENT); // attach the source shader->loadShaderSource("LightingVertex","shaders/LightingPassVert.glsl"); shader->loadShaderSource("LightingFragment","shaders/LightingPassFrag.glsl"); // compile the shaders shader->compileShader("LightingVertex"); shader->compileShader("LightingFragment"); // add them to the program shader->attachShaderToProgram("Lighting","LightingVertex"); shader->attachShaderToProgram("Lighting","LightingFragment"); shader->linkProgramObject("Lighting"); shader->use("Lighting"); shader->setShaderParam1i("pointTex",0); shader->setShaderParam1i("normalTex",1); shader->setShaderParam1i("colourTex",2); shader->setShaderParam1i("lightPassTex",3); shader->setShaderParam2f("wh",width()*devicePixelRatio(),height()*devicePixelRatio()); m_text.reset(new ngl::Text(QFont("Arial",14))); m_text->setScreenSize(width(),height()); m_screenQuad = new ScreenQuad("Debug"); ngl::VAOPrimitives *prim=ngl::VAOPrimitives::instance(); prim->createSphere("sphere",0.5f,50.0f); prim->createSphere("lightSphere",0.1f,10.0f); prim->createCylinder("cylinder",0.5f,1.4f,40.0f,40.0f); prim->createCone("cone",0.5f,1.4f,20.0f,20.0f); prim->createDisk("disk",0.8f,120.0f); prim->createTorus("torus",0.15f,0.4f,40.0f,40.0f); prim->createTrianglePlane("plane",14.0f,14.0f,80.0f,80.0f,ngl::Vec3(0.0f,1.0f,0.0f)); createFrameBuffer(); printFrameBufferInfo(m_gbuffer); printFrameBufferInfo(m_lightBuffer); m_fpsTimer =startTimer(0); }
QFont FontSettings::font() const { return QFont(family(), fontSize()); }
QVariant ScriptModel::data(const QModelIndex &index, int role) const { if(!index.isValid()) return QVariant(); ActionTools::ActionInstance *actionInstance = mScript->actionAt(index.row()); if(!actionInstance) return QVariant(); switch(role) { case ActionDataRole: return QVariant::fromValue(*actionInstance); case ActionIdRole: return actionInstance->definition()->id(); case Qt::BackgroundRole: { const QColor &color = actionInstance->color(); if(color.isValid()) return QBrush(color); return QBrush(); } case Qt::FontRole: { if(!actionInstance->definition()->worksUnderThisOS()) { QFont font = QApplication::font(); font.setItalic(true); return font; } return QFont(); } case Qt::ForegroundRole: { const QColor &color = actionInstance->color(); if(color.isValid()) { if(color.lightness() < 128) return QBrush(Qt::white); else return QBrush(Qt::black); } else { const QPalette &palette = QApplication::palette(); if(!actionInstance->isEnabled()) return QBrush(palette.color(QPalette::Disabled, QPalette::WindowText)); return QBrush(); } } } switch(index.column()) { case ColumnLabel: switch(role) { case Qt::CheckStateRole: return QVariant(actionInstance->isEnabled() ? Qt::Checked : Qt::Unchecked); case Qt::DisplayRole: { QString labelString = actionInstance->label(); if(!labelString.isNull() && !labelString.isEmpty()) return labelString; return QString("%1").arg(index.row() + 1, 3, 10, QChar('0')); } case Qt::EditRole: return actionInstance->label(); } break; case ColumnActionName: switch(role) { case Qt::ToolTipRole: return tr("Double-clic to edit the action"); case Qt::DisplayRole: return actionInstance->definition()->name(); case Qt::DecorationRole: return QIcon(actionInstance->definition()->icon()); case Qt::TextAlignmentRole: return Qt::AlignCenter; } break; case ColumnComment: switch(role) { case Qt::DisplayRole: case Qt::EditRole: return actionInstance->comment(); } break; } return QVariant(); }