void SummaryWidget::paintEvent(QPaintEvent *) {
    QPainter painter(this);

    QRect rect = painter.viewport();
    painter.setBrush(QBrush(Qt::gray));
    painter.drawRect(rect);

    QPointF curPos(5,5);

    QFont serifFont("Times", 9);
    QFontMetricsF fm(serifFont);
    int fontPixHeight = fm.height();

    // box at the right edge of widget, labeled with week number
    painter.save();
    QRect weekOfYearRect(width()-fontPixHeight-4, 0, fontPixHeight+4, height());
    painter.setBrush(QBrush(Qt::black));
    painter.drawRect(weekOfYearRect);
    painter.rotate(90);
    painter.setPen(Qt::white);
    painter.setRenderHint(QPainter::Antialiasing, true);
    QString sideLabel = QString("WEEK %1").arg(week.week());
    int sideLabelLen = fm.width(sideLabel);
    painter.drawText(0, -width(),height(), fontPixHeight+8,  Qt::AlignCenter, sideLabel);
    painter.restore();

//    QFont serifFont("Times", 10);
//    QFontMetricsF fm(serifFont);
//    int fontPixHeight = fm.height();

    for (int i=0; i<summary->getSessions().length(); i++) {
        curPos = summary->getSessions().value(i)->paint(*spainter, curPos, painter);
    }
    // no session this week => print "recomp"
    if (summary->getSessions().length() == 0) {
        QFont serifFont("Times", 14, QFont::Bold);
        QFontMetricsF fm(serifFont);
        fontPixHeight = fm.height();
        painter.setFont(serifFont);
        painter.setPen(QPen(Qt::red));

        curPos += QPointF(0, fontPixHeight);
        painter.drawText(curPos, "recomp");
        int space = sideLabelLen - curPos.y() + 20;

        curPos += QPointF(0, space);
    }

    plotHeight = curPos.y();

    emit plotHeightChanged(week);
}
//Input Port #0: Buffer_Size = 1, Params_Type = ProcessorMulti_Processor_Control_Params, Data_Type = ProcessorMulti_Processor_Control_Data
//Input Port #1: Buffer_Size = 1, Params_Type = SensorInternalEvent_Sensor_Joystick_Params, Data_Type = SensorInternalEvent_Sensor_Joystick_Data
bool DECOFUNC(processMultiDrainData)(void * paramsPtr, void * varsPtr, QVector<QVector<void *> > drainParams, QVector<QVector<void *> > drainData)
{
	VisualizationMulti_VisualMisc_ControlJoy_Params * params=(VisualizationMulti_VisualMisc_ControlJoy_Params *)paramsPtr;
	VisualizationMulti_VisualMisc_ControlJoy_Vars * vars=(VisualizationMulti_VisualMisc_ControlJoy_Vars *)varsPtr;
	QVector<ProcessorMulti_Processor_Control_Params *> drainparams_0; copyQVector(drainparams_0,drainParams[0]);
	QVector<SensorInternalEvent_Sensor_Joystick_Params *> drainparams_1; copyQVector(drainparams_1,drainParams[1]);
	QVector<ProcessorMulti_Processor_Control_Data *> draindata_0; copyQVector(draindata_0,drainData[0]);
	QVector<SensorInternalEvent_Sensor_Joystick_Data *> draindata_1; copyQVector(draindata_1,drainData[1]);
	if(draindata_0.size()==0){return 0;}
	if(draindata_1.size()==0){return 0;}
	/*======Please Program below======*/
	/*
	Function: process draindata_index.
	*/
    ProcessorMulti_Processor_Control_Data* controldata = draindata_0.front();
    SensorInternalEvent_Sensor_Joystick_Data* joystick_data = draindata_1.front();

    if(controldata->isManualControl == 1)//manual control
    {
        QImage image(vars->width, vars->height, QImage::Format_ARGB32);

        QPainter painter;

        //vars->joystick_label->resize(vars->width, vars->height);
        painter.begin(&image);
        painter.setBackground(QBrush(QColor(241,241,241)));
        painter.eraseRect(0,0, vars->width, vars->height);

         if(joystick_data->forward)
            painter.drawImage(vars->width/2-16, vars->height/2-56, vars->forwardArrowImg);

        if(joystick_data->left)
            painter.drawImage(vars->width/2 -56, vars->height/2-16, vars->leftArrowImg);

        if(joystick_data->right)
            painter.drawImage(vars->width/2+24, vars->height/2-16, vars->rightArrowImg);

        if(joystick_data->back)
            painter.drawImage(vars->width/2-16, vars->height/2+24, vars->backArrowImg);
        painter.end();

        vars->label->setPixmap(QPixmap::fromImage(image));
    }
    else //Auto control
    {
        QFont serifFont("Times", vars->fontSize);
        vars->label->setFont(serifFont);
        QPalette pa;
        pa.setColor(QPalette::WindowText,Qt::red);
        vars->label->setPalette(pa);
        //vars->label->setAlignment(Qt::AlignLeft);

        QString outputstr = QString("Left_Motor: %1\nRight_Motor: %2\n").arg(controldata->left_motor).arg(controldata->right_motor);
        vars->label->setText(outputstr);
    }

    //vars->label->setFixedHeight(250);
	return 1;
}
CustomTooltip::~CustomTooltip()
{
//TODO: Implement Custom tooltip
    setMouseTracking(true);
    QFont serifFont("Arial", 14, QFont::Normal);
    setFont(serifFont);
    setStyleSheet("color:blue;");
}
Exemple #4
0
void Dashboard::createRight(){
    right = new QGraphicsRectItem(QRectF(right_pixmap.rect()), this);

    avatar = new Pixmap;
    avatar->setPos(22, 64);
    avatar->setParentItem(right);

    small_avatar = new Pixmap;
    small_avatar->setPos(21, 63);
    small_avatar->setParentItem(right);
    small_avatar->setOpacity(0.75);

    if(button_widget){
        kingdom = new QGraphicsPixmapItem(button_widget);
        kingdom->setPos(57, 0);
    }else{
        kingdom = new QGraphicsPixmapItem(right);
        kingdom->setPos(91, 54);
    }

    ready_item = new QGraphicsPixmapItem(QPixmap("image/system/ready.png"), avatar);
    ready_item->setPos(2, 43);
    ready_item->hide();

    chain_icon = new Pixmap("image/system/chain.png");
    chain_icon->setParentItem(right);
    chain_icon->setPos(small_avatar->pos());
    chain_icon->moveBy(-25 ,-45);
    chain_icon->hide();
    chain_icon->setZValue(1.0);

    back_icon = new Pixmap("image/system/big-back.png");
    back_icon->setParentItem(right);
    back_icon->setPos(59, 105);
    back_icon->setZValue(1.0);
    back_icon->hide();

    QGraphicsPixmapItem *handcard_pixmap = new QGraphicsPixmapItem(right);
    handcard_pixmap->setPixmap(QPixmap("image/system/handcard.png"));
    handcard_pixmap->setPos(25, 127);

    handcard_num = new QGraphicsSimpleTextItem(handcard_pixmap);
    handcard_num->setPos(6,8);

    QFont serifFont("Times", 10, QFont::Bold);
    handcard_num->setFont(serifFont);
    handcard_num->setBrush(Qt::white);

    handcard_pixmap->hide();

    mark_item = new QGraphicsTextItem(right);
    mark_item->setPos(-128 - getButtonWidgetWidth(), 0);
    mark_item->setDefaultTextColor(Qt::white);

    action_item = NULL;
}
clsMyDisplayItem::clsMyDisplayItem(QWidget *parent) :
    QWidget(parent)
{
    setupUi(this);
    connect(this->chkTask,SIGNAL(deleteMe(QString)),this,SIGNAL(deleteMe(QString)));

     QFont serifFont("楷体", 12, QFont::Bold);
     //this->dateTimeEdit->setFont(serifFont);
    // this->comboBox->setFont(serifFont);
}
void DialogVideoPlayer::paintNoFrameFound() {
    QPixmap pixmap(display_width, display_height);
    pixmap.fill(Qt::transparent);

    QPainter painter(&pixmap);
    QFont serifFont("Times", 12, QFont::Bold);
    painter.setFont(serifFont);
    painter.drawText( QPoint( 5, 20 ), "No valid data found!" );
    painter.end();

    visualizationPixmapItem->setPixmap(pixmap);

    // Clear time line
    QPixmap timeLinePixmap = QPixmap(ui->timeLineView->width(), ui->timeLineView->height());
    timeLinePixmap.fill(Qt::white);
    timeLinePixmapItem->setPixmap(timeLinePixmap);


}
Exemple #7
0
void MainWindow::paintEvent(QPaintEvent*)
{
    painter.begin(this);
    if (rate!=0) {
             if (color == Qt::red)          color = Qt::darkRed;
        else if (color == Qt::darkRed)      color = Qt::red;
        else if (color == Qt::blue)         color = Qt::darkBlue;
        else if (color == Qt::darkBlue)     color = Qt::blue;
        else if (color == Qt::green)        color = Qt::darkGreen;
        else if (color == Qt::darkGreen)    color = Qt::green;
    }
    painter.setBrush(QBrush(color));
    QRectF rect(0,0,this->width(),this->height());
    painter.drawEllipse(rect);
    QFont serifFont("Arial", 10);
    painter.setFont(serifFont);
    painter.drawText(rect,"LED");
    painter.end();
}
BFont
SettingsWindow::_FindDefaultSerifFont() const
{
	// Default to the first "serif" font we find.
	BFont serifFont(*be_plain_font);
	font_family family;
	int32 familyCount = count_font_families();
	for (int32 i = 0; i < familyCount; i++) {
		if (get_font_family(i, &family) == B_OK) {
			BString familyString(family);
			if (familyString.IFindFirst("sans") >= 0)
				continue;
			if (familyString.IFindFirst("serif") >= 0) {
				serifFont.SetFamilyAndFace(family, B_REGULAR_FACE);
				break;
			}
		}
	}
	return serifFont;
}
void SkillPanel::buildGui(QString img,QString name, QString des){
    //add picture
    QPixmap myImage(img);
    img1 = this->addPixmap(myImage);
    img1->setPos(90,0);

    //font list
    QFont serifFont("Times", 12, QFont::Bold);

    //add name
    skillNameItem1 = this->addText(name);
    skillNameItem1->setPos(80,27);
    skillNameItem1->setFont(serifFont);



    //add strength
    Description1 = this->addText(des);
    Description1->setPos(0, 67);
}
ShowFlowsDialog::ShowFlowsDialog(NetworkSimulationPlatform *_platform,QWidget *parent) :
    QDialog(parent),m_platform(_platform),
    ui(new Ui::ShowFlowsDialog)
{
    ui->setupUi(this);
    m_curl = new SDNCurl();

    //ui->flowShowWidget->verticalHeader()->setHidden(true);

    ui->flowShowWidget->setSelectionBehavior(QAbstractItemView::SelectRows);//按行选中
   // ui->flowShowWidget->setEditTriggers(QAbstractItemView::NoEditTriggers);//不能编辑
    ui->flowShowWidget->setSelectionMode(QAbstractItemView::ExtendedSelection);//多选

    ui->flowShowWidget->setRowCount(16);
    ui->flowShowWidget->setColumnCount(3);

    QFont serifFont("Ubuntu", 13);
    QTableWidgetItem *HeaderItem0 = new QTableWidgetItem(QString(tr("交换机")));
    HeaderItem0->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
    HeaderItem0->setFont(serifFont);
    ui->flowShowWidget->setHorizontalHeaderItem(0,HeaderItem0);

    QTableWidgetItem *HeaderItem1 = new QTableWidgetItem(QString(tr("流表名字")));
    HeaderItem1->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
    HeaderItem1->setFont(serifFont);
    ui->flowShowWidget->setHorizontalHeaderItem(1,HeaderItem1);

    QTableWidgetItem *HeaderItem2 = new QTableWidgetItem(QString(tr("流表内容")));
    HeaderItem2->setTextAlignment(Qt::AlignCenter|Qt::AlignVCenter);
    HeaderItem2->setFont(serifFont);
    ui->flowShowWidget->setHorizontalHeaderItem(2,HeaderItem2);
//    ui->flowShowWidget->setSpan(0,0,3,1);
//    ui->flowShowWidget->setSpan(3,0,3,1);

    getDeviceName();
    //getFlowsFromController();
}
Exemple #11
0
void MainWindow::delete_clicked()
{
    QString tk_id;
    if (current_tab==2)
    {
        //tk_id=tasks_model->data(tasks_model->index(ui->tableView->currentIndex().row(),0)).toString();
    //else
        tk_id=tasks_full_model->data(tasks_full_model->index(ui->tableView_2->currentIndex().row(),0)).toString();

    QMessageBox m;
    m.setText(trUtf8("Θέλετε να διαγράψετε την επιλεγμένη κίνηση"));
    m.setInformativeText(trUtf8("ΠΡΟΣΟΧΗ!!!"));
    QAbstractButton *acc = m.addButton(trUtf8("Ναί"),
                    QMessageBox::ActionRole);
    QAbstractButton *rej = m.addButton(trUtf8("Όχι"), QMessageBox::ActionRole);

    m.move(100, 100);
    QFont serifFont("Times", 18, QFont::Bold);
    m.setFont(serifFont);
    m.setDefaultButton((QPushButton*)rej);

    m.exec();
    if (m.clickedButton() == rej)
        return;

    if (m.clickedButton() == acc)
    {
        QSqlQuery query(db1);
        //qDebug()<<"TID"<<tk_id;
        query.exec("delete from tasks where id="+tk_id);
    }
    refresh_tasks();
    refresh_full_tasks();
    ui->pushDelete->setEnabled(FALSE);
    }
}
Exemple #12
0
Calender::Calender(QWidget *parent, const char *name, WeekStarts wS, bool dLZ) : QTable(6, 7, parent, name)
{
    QFont serifFont( "Times", 10);
    setLeftMargin(2);
    setDragEnabled(false);
    setFont(serifFont);

    weekStarts = wS;
    dayLeadingZero = dLZ;
    
    int i;
    for (i = 0; i < 7; i++) {
      setColumnStretchable(i, true);
    }

    for (i = 0; i < 6; i++) {
      setRowStretchable(i, true);
    }
    
    QObject::connect(this, 
       SIGNAL(doubleClicked(int, int, int, const QPoint&)), 
       this,
       SLOT(selectedLine(int, int, int, const QPoint&)));
}
void QtHistoTfuncPixmap::draw_histogram(QPainter* p)
{	
	//find the max value in our histogram
	max_histogram=0;
	float max_loghisto =0;
	float min_loghisto = log(1024.0*1024.0*1024.0);
	for(int iii=1; iii<graph_size; iii++)
	{
		max_histogram = max(max_histogram, data[iii]);

		if(data[iii]!=0)
		{
			max_loghisto = max((float)max_loghisto, (float)log(data[iii]));
			min_loghisto= min((float)min_loghisto, (float)log(data[iii]));
		}
	}

	//draw a background rect
	p->setPen(Qt::NoPen);
	p->setBrush(Qt::NoBrush);

	p->setPen(Qt::black);
	p->setBrush(Qt::white);
	p->drawRect(0,0,graph_size, graph_size);

	//reset our painter's brush
	p->setBrush(Qt::NoBrush);

	//draw a grid
	p->setPen(Qt::black);
	float fontsize = pensize*2.0;
	QFont serifFont("Arial", fontsize, QFont::Bold);
	p->setFont(serifFont);
	float grid_steps = (graph_size)/8.0;
		
	float grid_step=0;
	float loggrid_step=0;
	float logrid_stepincr=max_histogram/8.0;

	QString label;
	for(int ii=0; ii<9; ii++)
	{
		//linear scale
		if(logscale==0)
		{
			//x,y grid lines
			p->drawLine(grid_step, 0, grid_step, graph_size+border*0.25);
			p->drawLine(-border*0.25, grid_step, graph_size, grid_step);

			//x,y labels
			label.setNum((int)(grid_step),10);
                        p->drawText( QRectF(grid_step-grid_steps/2.0, graph_size+border*0.4, grid_steps, fontsize*1.25), Qt::AlignCenter, label);
                        p->drawText( QRectF(-border, graph_size-grid_step-4, grid_steps, fontsize*1.25), Qt::AlignCenter, label);
		}
		else
		{	
			//x,y grid lines

			//Y AXIS LINES
			p->drawLine(grid_step, 0, grid_step, graph_size+border*0.25);
			label.setNum((int)(grid_step),10);
                        p->drawText( QRectF(grid_step-grid_steps/2.0, graph_size+border*0.4, grid_steps, fontsize*2.0), Qt::AlignCenter, label);

                        p->drawText( QRectF(-border, graph_size-grid_step-4, grid_steps, fontsize*2.0), Qt::AlignCenter, label);
			p->drawLine(-border*0.25, grid_step, graph_size, grid_step);
		}
		grid_step+=grid_steps;
	}

	if(hist_enable==1)
	{
		//dray our histogram bars
		//editor->fe_seleted
		// 1 = RGB// 2 = RGBA// 3 = R// 4 = G// 5 = B// 6 = A
		p->setBrush(Qt::NoBrush);
		p->setPen(Qt::NoPen);

		if(mode==0) p->setBrush( QColor(32,32,32, 255) );
		else p->setBrush( QColor(64,64,64, 255) );
		
		double height;
		int i;
		float xpos=0.0;
	
		//QPolygonF polygon;
		float iterp=0;

		if(max_histogram==0) max_histogram=1;

		for(i=0 ; i<graph_size; i++)
		{
			//linear scale
			if(logscale==1)
			{
				if(data[i]!=0) iterp = (double)(log(data[i])-min_loghisto)/(double)(max_loghisto-min_loghisto);
				else iterp = 0;
			}
			else
			{
				iterp = ((double)data[i]/(double)max_histogram);
			}

			if(iterp>1.0) iterp=1.0;
			if(iterp<0.0) iterp=0.0;

			height = (graph_size)*iterp;
			height = (int)(height+0.5);

			xpos = i;

			//polygon << QPointF(xpos, graph_size-height) ;
			QRectF rectangle((float)xpos-0.5, graph_size, 1.0, -height);
			p->drawRect(rectangle);
		}

		//p->drawPolygon(polygon, Qt::OddEvenFill);
	}
	if(cumfreq_enable==1)
	{
		//draw our cummulatative frequency
		//dray our histogram bars
		double sum =0;
		double maxsum =0;
		double height;
        for(int i=0 ; i<graph_size; i++)
		{
			maxsum += data[i];
		}

		if(maxsum)
		{
			QPainterPath cumpath;
			cumpath.moveTo(0,0);
                        for(int i=0 ; i<graph_size; i++)
			{
				sum += data[i];
				height = (graph_size)*(((double)sum/(double)maxsum));
                                height = graph_size-(int)(height+0.5);
				cumpath.lineTo (i, height );
			}
			p->setPen(Qt::red);
			p->setBrush(Qt::NoBrush);

			//p->setBrush(Qt::red);
			p->drawPath(cumpath);
		}
	}

	//draw our thresholding...
	p->setPen(Qt::black);
	p->setBrush(QBrush ( QColor(128,128,128,128), Qt::SolidPattern ));
	QRectF rectangle(0.0, 0.0, minthr, graph_size);
	p->drawRect(rectangle);
	QRectF rectangle2(maxthr, 0.0, graph_size-maxthr, graph_size);
	p->drawRect(rectangle2);
	p->setBrush(Qt::NoBrush);
}
Exemple #14
0
void FrmLegend::init()
{
    QFont normal("Times", 10, QFont::Normal);
    QFont italic("Times", 10, -1, true);
    QFont serifFont("Times", 13, QFont::Bold);

    //TODO: return errors here!

    levels = new QTreeWidgetItem(treeWidget);
    initTreeParent(serifFont,tr("Levels"),
        tr("Different herarchical instances"),levels);

    root = new QTreeWidgetItem(levels);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/exec.png")),tr("Root"),
        tr("Frame Root"),root);

    bin = new QTreeWidgetItem(levels);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/trashcan.png")),tr("Bin"),
        tr("Recycled Bin, where we store (permanent or temporarily) inactive instances"),bin);

    gls = new QTreeWidgetItem(levels);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/gls.png")),tr("Group of Landing Sites"),
        tr("A Group of Landing Sites, aggregating multiple landing sites"),gls);

    ls = new QTreeWidgetItem(levels);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/ls.png")),tr("Landing Site"),
        tr("A Site: can be a port, a collector vessel or simply a virtual aggregation of vessels"),ls);

    vessel = new QTreeWidgetItem(levels);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/vessel.png")),tr("Vessel"),
        tr("A vessel"),vessel);

    recycled = new QTreeWidgetItem(treeWidget);
    initTreeParent(serifFont,tr("Recycled"),
        tr("Items that are inactive (on the recycle bin)"),recycled);

    glsd = new QTreeWidgetItem(recycled);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/glsd.png")),tr("Group of Landing Sites"),
        tr("An inactive Group of Landing Sites"),glsd);

    lsd = new QTreeWidgetItem(recycled);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/lsd.png")),tr("Landing Site"),
        tr("An inactive Landing Site"),lsd);

    vesseld = new QTreeWidgetItem(recycled);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/vesseld.png")),tr("Vessel"),
        tr("An inactive vessel"),vesseld);

    status = new QTreeWidgetItem(treeWidget);
    initTreeParent(serifFont,tr("Vessel Status"),
        tr("Special statuses of the vessels, regarding different characteristics"),status);

    unmovable = new QTreeWidgetItem(status);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/vesself.png")),tr("Unmovable"),
        tr("A vessel that is flaged as unmovable (locked)"),unmovable);

    merged = new QTreeWidgetItem(status);
    initTreeChild(normal, italic,QIcon(QString::fromUtf8(":/app_new/unmovable.png")),tr("Merged"),
        tr("A vessel that is is merged from another temporary frame"),merged);

    treeWidget->setSizePolicy(QSizePolicy::Expanding,QSizePolicy::Expanding);

    treeWidget->expandAll();

    for (int col=0; col < treeWidget->model()->columnCount(); ++col) {
        treeWidget->header()->setResizeMode(col,QHeaderView::ResizeToContents);
    }

}
void DialogVideoPlayer::paintCurrentVisualizationFrame() {


    bool show_fixation_numbers = true;

    QPixmap pixmap(display_width, display_height);
    pixmap.fill(Qt::transparent);
    QPainter painter(&pixmap);


    QPen myPen(QColor(0,0,0,127), 1, Qt::SolidLine);
    myPen.setCapStyle(Qt::RoundCap);
    painter.setPen(myPen);

    if (show_fixation_numbers && p_fixAllM->n_rows > 0) {
        QFont serifFont("Times", 64, QFont::Bold);
        painter.setFont(serifFont);
        uvec fixIndex =  arma::find((*p_fixAllM).col(FIXCOL_START) <= currentIndex);
        mat aux = (*p_fixAllM).rows(fixIndex);
        fixIndex =  arma::find(aux.col(FIXCOL_END) >= currentIndex);
        if (fixIndex.n_rows != 0) {
            painter.drawText( QRect(0, 0, display_width, display_height), Qt::AlignCenter, QString::number(fixIndex(0)) );
        }
    }


    mat *matrixToUse = settingPlaySmooth ? p_smoothM : p_roughM;

    if (matrixToUse->is_empty()) return;

    QPen *pensToUse = settingPlaySmooth ? smoothPens : roughPens;
    int nPensToUse = settingPlaySmooth ? 1 : 2;
    double width_multi = settingPlaySmooth ? (double)display_width / (double)expWidth : display_width;
    double height_multi = settingPlaySmooth ? (double)display_height / (double)expHeight : display_height;

    for(int i = 0; i < nPensToUse; ++i) {
        myPen.setColor(pensToUse[i * 2].color());

        // Pupil width
        if (p_roughM->n_cols >= 8 && p_roughM->at(currentIndex, 6) > 0 && p_roughM->at(currentIndex, 7) > 0) {
            double width = (p_roughM->at(currentIndex, 6) + p_roughM->at(currentIndex, 7)) / 6;
            int penWidth = (int)floor(width * actualDotSize);
            myPen.setWidth(penWidth);
        } else {
            myPen.setWidth(actualDotSize);
        }



        uword index = 2 * (i + 1);
        int x = matrixToUse->at(currentIndex, index) * width_multi;
        int y = matrixToUse->at(currentIndex, index + 1) * height_multi;

        painter.setPen(myPen);
        painter.drawPoint(x,y);
        painter.setPen(whitePen);
        painter.drawPoint(x,y);
    }


    painter.end();
    visualizationPixmapItem->setPixmap(pixmap);

}
Exemple #16
0
void SkyView::paintEvent(QPaintEvent *)
{
	// Draw stuff in drawing area
	int w= width();
	int h= height();
	QPainter painter(this);
	painter.setPen(Qt::gray);
	QRect r1(0, 0, w-1, h-1);
	QBrush br1(Qt::white);
	painter.fillRect(r1, br1);

	draw_arc(painter, w/2, h / 2, 6);

	// draw the 45 degree circle
	int i = min(w, h);
	draw_arc(painter, w / 2, h / 2, (unsigned)((i - RM) * 0.7));

	painter.setPen(Qt::black);
	draw_arc(painter, w / 2, h / 2, (unsigned)(i - RM));
	
	int x, y;
	pol2cart(w, h, 0, 0, &x, &y);
	painter.drawText(x, y, "N");
	pol2cart(w, h, 90, 0, &x, &y);
	painter.drawText(x + 2, y, "E");
	pol2cart(w, h, 180, 0, &x, &y);
	painter.drawText(x, y + 10, "S");
	pol2cart(w, h, 270, 0, &x, &y);
	painter.drawText(x - 5, y, "W");

	if(gpsdata == NULL)
		return;

	QFont serifFont("Times", 6);
	painter.setFont(serifFont);
	
	/* Now draw the satellites... */
	for (int i = 0; i < gpsdata->satellites_visible; i++) {
		QColor col;
		pol2cart(w, h, (double)gpsdata->azimuth[i], 
				 (double)gpsdata->elevation[i], &x, &y);
		if (gpsdata->ss[i] < 10) 
			col= Qt::black;
		else if (gpsdata->ss[i] < 30)
			col= Qt::red;
		else if (gpsdata->ss[i] < 35)
			col= Qt::yellow;
		else if (gpsdata->ss[i] < 40)
			col= Qt::darkGreen;
		else
			col= Qt::green;

		painter.setPen(col);
		br1.setColor(col);
		painter.setBrush(br1);

		if (gpsdata->PRN[i] > GPS_PRNMAX) {
				/* SBAS satellites */
			QPoint vertices[5];

			vertices[0].setX(x);
			vertices[0].setY(y-IDIAM);
			vertices[1].setX(x+IDIAM);
			vertices[1].setY(y);
			vertices[2].setX(x);
			vertices[2].setY(y+IDIAM);
			vertices[3].setX(x-IDIAM);
			vertices[3].setY(y);
			vertices[4].setX(x);
			vertices[4].setY(y-IDIAM);

	
			if (gpsdata->used[i])
				painter.drawPolygon(vertices, 4);
			else
				painter.drawPolyline(vertices, 5);
	
		} else {
				/* ordinary GPS satellites */
			if (gpsdata->used[i])
				painter.drawChord(x - IDIAM, y - IDIAM, 2 * IDIAM + 1, 2 * IDIAM + 1, 0, 360 * 64);
			else
				painter.drawArc(x - IDIAM, y - IDIAM, 2 * IDIAM + 1, 2 * IDIAM + 1, 0, 360 * 64);
		}
		QString buf;
		buf.setNum(gpsdata->PRN[i]);
		painter.setPen(Qt::black);
		painter.drawText(x, y+14, buf);
	}
}
Exemple #17
0
ConfigWindow::ConfigWindow(Config& cfg, MessageServer * msgServer, 
    ControlWindow * ctrlWindow)
{
    QString datetime = getcurrentTime();
    m_msgServer = msgServer;
    m_ctrlWindow = ctrlWindow;
    
    m_demo = cfg.demo;
    m_videoFile = cfg.videoFile;
    m_soundFile = cfg.soundFile;
    m_speechSelected = cfg.speechSelected;

    m_logo = new QLabel(tr(""));
    m_logo->setPixmap(QPixmap(":images/hdr_ti_logo.png"));

    QFont serifFont("Times", 22, QFont::Bold);
    m_bannerLabel = new QLabel(m_demo + tr(" Demo"));
    m_bannerLabel->setFont(serifFont);

    createVideoGroupBox(cfg);
    createSoundGroupBox(cfg);
    createOtherGroupBox();

    QGridLayout *buttonsLayout = new QGridLayout;
    m_startButton = createButton(tr("Start demo"), SLOT(startDemo()));
    m_exitButton = createButton(tr("Exit"), SLOT(exit()));
    buttonsLayout->setRowMinimumHeight(2, 60);
    buttonsLayout->addWidget(m_logo, 1, 0, 1, 1);
    buttonsLayout->addWidget(m_startButton, 1, 2, 1, 1);
    buttonsLayout->addWidget(m_exitButton, 1, 3, 1, 1);
    buttonsLayout->setColumnStretch(0, 10);
    buttonsLayout->setColumnStretch(1, 10);

    QVBoxLayout *mainLayout = new QVBoxLayout;

    mainLayout->addWidget(m_bannerLabel);
    mainLayout->addWidget(m_videoGroupBox);
    mainLayout->addWidget(m_soundGroupBox);
    mainLayout->addWidget(m_otherGroupBox);
    mainLayout->addLayout(buttonsLayout);

    mainLayout->setStretchFactor(m_bannerLabel, 1);
    mainLayout->setStretchFactor(m_videoGroupBox, 5);
    mainLayout->setStretchFactor(m_soundGroupBox, 5);
    mainLayout->setStretchFactor(m_otherGroupBox, 2);

    /* To prevent rows from overlapping one another */
    mainLayout->setSpacing(0);
    
    mainLayout->setContentsMargins(0,0,0,0);
    #if defined(Platform_dm365)
    mainLayout->setContentsMargins(50,39,50,39);
    #endif
  
    setLayout(mainLayout);

    disableUnusedWidgets(cfg);

    if (!m_videoBitRateComboBox->isHidden()) {
        videoBitRateChanged();
    }
    if (!m_videoCodecComboBox->isHidden()) {
        videoCodecChanged();
    }
    if (!m_videoStdComboBox->isHidden()) {
        if (cfg.videoStd == "3") {
            m_videoStdComboBox->setCurrentIndex(0);   //720P
        }
        else {
            m_videoStdComboBox->setCurrentIndex(1);   //1080I
        }
        videoStdChanged();
    }
    if (!m_soundCodecComboBox->isHidden()) {
        soundCodecChanged();
    }
    if (!m_soundBitRateComboBox->isHidden()) {
        soundBitRateChanged();
    }
    if (!m_samplingRateComboBox->isHidden()) {
        samplingRateChanged();
    }
    if (!m_loopingCheckBox->isHidden()) {
        m_loopingCheckBox->setChecked(cfg.looping);
    }
    if (!m_disablePreviewCheckBox->isHidden()) {
        m_disablePreviewCheckBox->setChecked(cfg.disablePreview);
    }
    if (!m_disableFileWriteCheckBox->isHidden()) {
        m_disableFileWriteCheckBox->setChecked(cfg.disableFileWrite);
    }
    if (!m_passthroughCheckBox->isHidden()) {
        m_passthroughCheckBox->setChecked(cfg.passthrough);
    }
    if (!m_encodeVideoCheckBox->isHidden()) {
        m_encodeVideoCheckBox->setChecked(false);
    }
    if (!m_encodeSoundCheckBox->isHidden()) {
        m_encodeSoundCheckBox->setChecked(true); // Sound is disabled by default
    }

    /* 
     * For encode demo, set default filenames given we do not officially
     * support keyboard input.
     */
    if (cfg.demo == "Encode") { 
        if (cfg.videoFile.isEmpty()) {   
            m_videoFile = DEFAULT_VIDEO_FILE + datetime + getVideoExtension();
            m_videoFileLineEdit->setText(m_videoFile);
        }
        if (cfg.soundFile.isEmpty()) {
            m_soundFile = DEFAULT_SOUND_FILE + datetime + getSoundExtension();
            m_soundFileLineEdit->setText(m_soundFile);
        }
    }

    setWindowTitle(tr("Demo configuration"));
}
Exemple #18
0
void QAbsFrame::paintEvent(QPaintEvent *pEvent) {
    Q_UNUSED(pEvent);
    QPainter painter(this);

    QPen redPM(Qt::red);

    QPen grayPM(Qt::darkGray);
    grayPM.setWidthF(0);

    QPen blackPM(Qt::black);
    QPen blackPF(Qt::black);
    blackPM.setWidth(2);
    QBrush blackB(Qt::black);
    painter.setRenderHint(QPainter::Antialiasing, true);

    if(!this->isEnabled() ) {
        float centerW   = m_fWidth / 2;
        float centerH   = m_fWidth / 2;

        QFont serifFont("Times", 16, QFont::Bold);
        QRectF rect(-centerW/2.0, -centerH, centerW, centerH);

        painter.translate(m_fWidth/2, m_fHeight/2);
        painter.setFont(serifFont);
        painter.setPen(blackPM);
        painter.drawText(rect, Qt::AlignCenter, tr("No connection.") );
        painter.resetTransform();

        redPM = QPen(Qt::gray);
        grayPM = QPen(Qt::gray);
        blackPF = QPen(Qt::gray);
        blackPM = QPen(Qt::gray);
        blackB = QBrush(Qt::gray);

    }
    // Center plate black
    painter.setBrush(blackB);
    painter.setPen(blackPM);
    float diameter  = m_fWidth / 4;
    float centerW   = m_fWidth / 8;
    float centerH   = m_fWidth / 5.5;

    painter.translate(m_fWidth/2, m_fHeight/2);
    painter.rotate(m_fYaw);
    painter.drawEllipse(QRectF(-centerW/2.0, -centerH/2.0, centerW, centerH));

    // Rotor bottom right
    painter.resetTransform();
    painter.translate(m_fWidth/2, m_fHeight/2);
    painter.rotate(m_fYaw);
    painter.translate(m_fWidth/4, m_fHeight/4);
    painter.setBrush(blackB);
    painter.drawEllipse(QRectF(-diameter/8.0, -diameter/8.0, diameter/4, diameter/4));
    painter.setBrush(Qt::NoBrush);
    painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));

    // Rotor top left
    painter.resetTransform();
    painter.translate(m_fWidth/2, m_fHeight/2);
    painter.rotate(m_fYaw);
    painter.translate(-m_fWidth/4, -m_fHeight/4);
    painter.setBrush(blackB);
    painter.drawEllipse(QRectF(-diameter/8.0, -diameter/8.0, diameter/4, diameter/4));
    painter.setBrush(Qt::NoBrush);
    painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));

    // Rotor bottom left
    painter.resetTransform();
    painter.translate(m_fWidth/2, m_fHeight/2);
    painter.rotate(m_fYaw);
    painter.translate(-m_fWidth/4, m_fHeight/4);
    painter.setBrush(blackB);
    painter.drawEllipse(QRectF(-diameter/8.0, -diameter/8.0, diameter/4, diameter/4));
    painter.setBrush(Qt::NoBrush);
    painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));

    // Rotor top right
    painter.resetTransform();
    painter.translate(m_fWidth/2, m_fHeight/2);
    painter.rotate(m_fYaw);
    painter.translate(m_fWidth/4, -m_fHeight/4);
    painter.setBrush(blackB);
    painter.drawEllipse(QRectF(-diameter/8.0, -diameter/8.0, diameter/4, diameter/4));
    painter.setBrush(Qt::NoBrush);
    painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));


    // Now draw the other frame parts
    QLineF bl_fr(-m_fWidth/4, m_fHeight/4, m_fWidth/4, -m_fHeight/4);
    QLineF br_fl(m_fWidth/4, m_fHeight/4, -m_fWidth/4, -m_fHeight/4);

    blackPF.setWidth(m_fWidth < m_fHeight ? m_fWidth/48 : m_fHeight/48);
    painter.setPen(blackPF);

    painter.resetTransform();
    painter.translate(m_fWidth/2, m_fHeight/2);
    painter.rotate(m_fYaw);

    painter.drawLine(bl_fr);
    painter.drawLine(br_fl);

    if(this->isEnabled() ) {
        // Highlighting active motors ..
        QPen redHighlightP(QColor(255,0,0, 45));
        redHighlightP.setWidth(16);
        QBrush redHighlightB(QColor(255,0,0, 25));
        painter.setPen(redHighlightP);
        painter.setBrush(redHighlightB);
        // bottom in red
        if(m_customKeyStatus[Qt::Key_W] == true) {
            // Rotor bottom left
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(-m_fWidth/4, m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));

            // Rotor bottom right
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(m_fWidth/4, m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));
        }
        // top in red
        if(m_customKeyStatus[Qt::Key_S] == true) {
            // Rotor top left
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(-m_fWidth/4, -m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));

            // Rotor top right
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(m_fWidth/4, -m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));
        }

        // right in red
        if(m_customKeyStatus[Qt::Key_A] == true) {
            // Rotor bottom right
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(m_fWidth/4, m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));

            // Rotor top right
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(m_fWidth/4, -m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));
        }

        // left in red
        if(m_customKeyStatus[Qt::Key_D] == true) {
            // Rotor top left
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(-m_fWidth/4, -m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));

            // Rotor bottom left
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(-m_fWidth/4, m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));
        }


        // bottom left and top right in red
        if(m_customKeyStatus[Qt::Key_Q] == true) {
            // Rotor bottom left
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(-m_fWidth/4, m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));

            // Rotor top right
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(m_fWidth/4, -m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));
        }

        // bottom right and top left in red
        if(m_customKeyStatus[Qt::Key_E] == true) {
            // Rotor bottom right
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(m_fWidth/4, m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));

            // Rotor top left
            painter.resetTransform();
            painter.translate(m_fWidth/2, m_fHeight/2);
            painter.rotate(m_fYaw);
            painter.translate(-m_fWidth/4, -m_fHeight/4);
            painter.drawEllipse(QRectF(-diameter/2.0, -diameter/2.0, diameter, diameter));
        }
    }

    // Draw Coordinate system
    painter.setRenderHint(QPainter::Antialiasing, false);
    painter.setPen(grayPM);
    painter.setBrush(Qt::NoBrush);

    float fWAx = 0.1 * m_fWidth;
    float fHAx = 0.1 * m_fHeight;

    float fWC = 0.025 * m_fWidth;
    float fHC = 0.025 * m_fHeight;

    painter.resetTransform();
    painter.translate(m_fWidth/2, m_fHeight/2);

    painter.drawEllipse(QRectF(-(m_fWidth/2-fWC/2), -(m_fHeight/2-fHC/2), m_fWidth-fWC, m_fHeight-fHC));
    QLineF lineC90 ( m_fWidth/2 -fWC/2 - 5, 0, m_fWidth/2 -fWC/2 + 5, 0 );
    QLineF lineC270( -(m_fWidth/2 -fWC/2 - 5), 0, -(m_fWidth/2 -fWC/2 + 5), 0 );
    QLineF lineC180( 0, m_fHeight/2 -fHC/2 - 5, 0, m_fHeight/2 -fHC/2 + 5 );
    QLineF lineC360( 0, -(m_fHeight/2 -fHC/2 - 5), 0, -(m_fHeight/2 -fHC/2 + 5) );

    painter.drawLine(lineC90);
    painter.drawLine(lineC180);
    painter.drawLine(lineC270);
    painter.drawLine(lineC360);

    // X and Y axis
    QLineF lineAxisY( 0, -m_fHeight/2 + fHAx, 0, 0 );
    QLineF lineAxisX( 0, 0, m_fWidth/2 - fWAx, 0 );

    painter.rotate(m_fYaw);
    painter.drawLine(lineAxisY);
    painter.setPen(redPM);
    painter.drawLine(lineAxisX);
}