Beispiel #1
0
void GlMainView::updateShowOverviewButton() {
  if (_showOvButton == nullptr) {
    QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget();
    _showOvButton = new QPushButton();
    _showOvButton->setMaximumSize(10, 10);
    _showOvButton->setCheckable(true);
    _showOvButton->setStyleSheet("QPushButton {font-family: Arial; font-size: 10pt; border:none};");
    proxy->setWidget(_showOvButton);
    addToScene(proxy);
    proxy->setZValue(10);
    connect(_showOvButton, SIGNAL(toggled(bool)), this, SLOT(setOverviewVisible(bool)));
  }
void CopyFilterGUIConnectionItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent* event)
{
	QString text = QString("%1").arg(factor);
	if (isDecibel)
		text += " dB";

	ResizingLineEdit* lineEdit = new ResizingLineEdit("");
	connect(lineEdit, SIGNAL(editingFinished()), this, SLOT(lineEditEditingFinished()));
	QGraphicsProxyWidget* proxyItem = scene()->addWidget(lineEdit);
	QLineF l = line();
	QPointF center = (l.p1() + l.p2()) / 2;
	QRectF rect;
	rect.setSize(lineEdit->size());
	rect.moveCenter(center);
	proxyItem->setPos(rect.topLeft());
	proxyItem->setZValue(10);
	lineEdit->setFocus();
}
Beispiel #3
0
MainWindow::MainWindow(AmViewerState *state) : _state(state) {
    _state->recon_tree = NULL;
    _state->amEvent = NULL;
    _state->show_dBm = false;
    _state->filtered = true;
    _state->sumpols = false;
    _state->resetSearch(); // couldn't hurt?

    setWindowTitle("AmViewer");

    // creat dialogs
    _searchWindow = new SearchWindow(this,_state);
    _visWindow = new VisWindow(this,_state);
    _fovWindow = new FovWindow(this,_state);
    _filterWindow = NULL;
    _infoWindow = NULL;

    QWidget *centralWidget = new QWidget();
    setCentralWidget(centralWidget);
    QVBoxLayout *bigLayout = new QVBoxLayout(centralWidget);

    // File menu
    QAction *quitMenu = new QAction("&Exit",this);
    quitMenu->setShortcut(tr("Ctrl+Q"));
    connect(quitMenu,SIGNAL(triggered()),qApp,SLOT(quit()));

    QAction *openMenu = new QAction("&Open ROOT file...",this);
    openMenu->setShortcut(tr("Ctrl+O"));
    connect(openMenu,SIGNAL(triggered()),this,SLOT(openFile()));

    _saveMenu = new QAction("&Save event candidates...",this);
    connect(_saveMenu,SIGNAL(triggered()),this,SLOT(saveFile()));

    QMenu *fileDrop;
    fileDrop = menuBar()->addMenu("&File");
    fileDrop->addAction(openMenu);
    fileDrop->addAction(_saveMenu);
    fileDrop->addAction(quitMenu);

    _saveMenu->setEnabled(false);

    // View menu
    _unitsMenu = new QAction("&Display dBm",this);
    _unitsMenu->setCheckable(true);
    _unitsMenu->setChecked(false);
    connect(_unitsMenu,SIGNAL(triggered()),this,SLOT(applyUnits()));

    // Filter dialog
    _filterMenu = new QAction("&Filter Settings",this);
    connect(_filterMenu,SIGNAL(triggered()),this,SLOT(openFilter()));

    // Polarization checkbox
    _polMenu = new QAction("&Sum Polarizations",this);
    _polMenu->setCheckable(true);
    _polMenu->setChecked(false);
    _polMenu->setEnabled(false);
    connect(_polMenu,SIGNAL(triggered()),this,SLOT(applySumPol()));

    QMenu *viewDrop;
    viewDrop = menuBar()->addMenu("&View");
    viewDrop->addAction(_unitsMenu);
    viewDrop->addAction(_polMenu);
    viewDrop->addAction(_filterMenu);
    _filterMenu->setEnabled(false);

    // Analysis menu
    QAction *infoMenu = new QAction("&Event Info",this);
    connect(infoMenu,SIGNAL(triggered()),this,SLOT(openInfo()));

    _analysisDrop = menuBar()->addMenu("&Analysis");
    _analysisDrop->addAction(infoMenu);

    QAction *searchMenu = new QAction("&Search Parameters",this);
    connect(searchMenu,SIGNAL(triggered()),this,SLOT(openSearch()));

    _analysisDrop->addAction(searchMenu);
    _analysisDrop->setEnabled(false);

    QAction *visMenu = new QAction("&Event Visualization",this);
    connect(visMenu,SIGNAL(triggered()),this,SLOT(openVis()));
    _analysisDrop->addAction(visMenu);

    QAction*fovMenu = new QAction("&AMBER Field of View",this);
    connect(fovMenu,SIGNAL(triggered()),this,SLOT(openFov()));
    _analysisDrop->addAction(fovMenu);

    // Set up layout for event browser, pixel windows, graphs
    QHBoxLayout *hbox = new QHBoxLayout();
    bigLayout->addLayout(hbox);

    // Event list stuff
    _eventList = new QTreeWidget(this);
    _eventList->setColumnCount(2);
    _eventList->setColumnHidden(1,true); //'true' valid in C++?

    QTreeWidgetItem *_source0 = new QTreeWidgetItem(_eventList);
    _source0->setText(0,"Source:0 (LTRIG)");

    QTreeWidgetItem *_source1 = new QTreeWidgetItem(_eventList);
    _source1->setText(0,"Source:1 (PPS)");

    QTreeWidgetItem *_source2 = new QTreeWidgetItem(_eventList);
    _source2->setText(0,"Source:2 (Auger)");

    _eventList->setHeaderLabel("Events");

    hbox->addWidget(_eventList);

    // Some gross stuff concerning the clickable horns
    _hornDisplay = new HornDisplay(this,1);

    CenterHorns *centerLegend = new CenterHorns("center",true);
    QGraphicsProxyWidget *centerLegendProxy = new QGraphicsProxyWidget();
    centerLegendProxy->setWidget(centerLegend->widget);

    _hornDisplay->hornScene->addItem(centerLegendProxy);

    centerLegendProxy->rotate(45);
    centerLegendProxy->setPos(0,-50);
    centerLegendProxy->setZValue(0.0);

    AmHorn *ppsHorn[4];

    int i;
    stringstream out;

    QToolButton *b;

    for(i=0; i<4; i++) {
        b = new QToolButton();
        b->setFixedSize(25,25);
        out.str("");
        out << (i+1);
        ppsHorn[i] = new AmHorn(b,"PPS" + out.str());
        ppsHorn[i]->proxyWidget = new QGraphicsProxyWidget();
        ppsHorn[i]->proxyWidget->setWidget(ppsHorn[i]->_button);
        _hornDisplay->hornScene->addItem(ppsHorn[i]->proxyWidget);
        ppsHorn[i]->proxyWidget->setPos(25*i-145,375);

        // probably stupid, delete
        //ppsHorn[i]->trigger_color = "blue";
        //ppsHorn[i]->updateStyle();

        //delete b;
    }

    QGraphicsSimpleTextItem *item;

    for(i=0; i<4; i++) {
        item = new QGraphicsSimpleTextItem();
        _hornDisplay->hornScene->addItem(item);
        if(i==0) {
            item->setText("CH");
            item->setPos(-7,-31);
            item->setZValue(1.0);
        }
        if(i==1) {
            item->setText("CV");
            item->setPos(-7,5);
            item->setZValue(1.0);
        }
        if(i==2) {
            item->setText("KH");
            item->setPos(-24,-15);
            item->setZValue(1.0);
        }
        if(i==3) {
            item->setText("KV");
            item->setPos(12,-15);
            item->setZValue(1.0);
        }
        //delete item;
    }

    // CRUFT ALERT
    // THIS WHOLE NEXT LOOP IS HIGHLY SUSPECT, I DOUBT IT DOES ANYTHING
    QString qstr;
    for(i=0; i<16; i++) {
        out.str("");
        out << (i+1);
        qstr = QString::fromStdString(out.str());
        item = new QGraphicsSimpleTextItem(qstr);
        _hornDisplay->hornScene->addItem(item);
        if(i==0)
            item->setPos(-2.5,75.0);
        else if(i==1)
            item->setPos(-105.0,177.5);
        else if(i==2)
            item->setPos(-2.5,280.0);
        else if(i==3)
            item->setPos(102.5,177.5);
        else if(i==4)
            item->setPos(-70.0,55.0);
        else if(i==5)
            item->setPos(-95.0,80.0);
        else if(i==6)
            item->setPos(-120.0,105.0);
        else if(i==7)
            item->setPos(-125.0,250.0);
        else if(i==8)
            item->setPos(-100.0,275.5);
        else if(i==9)
            item->setPos(-75.0,300.0);
        else if(i==10)
            item->setPos(60.0,300.0);
        else if(i==11)
            item->setPos(85.0,275.0);
        else if(i==12)
            item->setPos(110.0,250.0);
        else if(i==13)
            item->setPos(120.0,110.0);
        else if(i==14)
            item->setPos(95.0,85.0);
        else if(i==15)
            item->setPos(70.0,60.0);
    }

    QVBoxLayout *evVbox = new QVBoxLayout();
    hbox->addLayout(evVbox);

    QGridLayout *evInfoGrid = new QGridLayout();
    evVbox->addLayout(evInfoGrid);

    _evIdLabel = new QLabel("");
    _evSourceLabel = new QLabel("");
    _evSecLabel = new QLabel("");
    _evNsLabel = new QLabel("");
    _evInfoLabel = new QLabel("");

    evInfoGrid->addWidget(_evIdLabel,0,0);
    evInfoGrid->addWidget(_evSourceLabel,0,1);
    evInfoGrid->addWidget(_evSecLabel,1,0);
    evInfoGrid->addWidget(_evNsLabel,1,1);
    evInfoGrid->addWidget(_evInfoLabel,2,0);

    evVbox->addWidget(_hornDisplay);

    QVBoxLayout *pixelVbox = new QVBoxLayout();
    hbox->addLayout(pixelVbox);

    for(i=0; i<4; i++) {
        pixelWindow[i] = new PixelWindow(this,i);
        pixelWindow[i]->setMinimumHeight(100);
        pixelWindow[i]->setMinimumWidth(300);
        pixelVbox->addWidget(pixelWindow[i]);
    }

    for(i=0; i<28; i++) {
        _hornDisplay->channel[i]->setHornClickFunction(this);
        connect(_hornDisplay->channel[i]->_button,SIGNAL(clicked()),_hornDisplay->channel[i],SLOT(hornClick()));
    }

    for(i=0; i<4; i++) {
        //ppsHorn[i]->setHornClickFunction(clickHornSetPixel);
        ppsHorn[i]->setHornClickFunction(this);
        connect(ppsHorn[i]->_button,SIGNAL(clicked()),ppsHorn[i],SLOT(hornClick()));
    }
}
Beispiel #4
0
void OverlayEditorScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *e) {
	QGraphicsScene::contextMenuEvent(e);

	if (e->isAccepted())
		return;

	if (! e->widget())
		return;

	QGraphicsPixmapItem *item = childAt(e->scenePos());

	QMenu qm(e->widget());

	QMenu *qmLayout = qm.addMenu(tr("Layout preset"));
	QAction *qaLayoutLargeAvatar = qmLayout->addAction(tr("Large square avatar"));
	QAction *qaLayoutText = qmLayout->addAction(tr("Avatar and Name"));

	QMenu *qmTrans = qm.addMenu(tr("User Opacity"));
	QActionGroup *qagUser = new QActionGroup(&qm);
	QAction *userOpacity[8];
	for (int i=0;i<8;++i) {
		qreal o = (i + 1) / 8.0;

		userOpacity[i] = new QAction(tr("%1%").arg(o * 100.0f, 0, 'f', 1), qagUser);
		userOpacity[i]->setCheckable(true);
		userOpacity[i]->setData(o);

		if (qFuzzyCompare(qgiGroup->opacity(), o))
			userOpacity[i]->setChecked(true);

		qmTrans->addAction(userOpacity[i]);
	}

	QAction *color = NULL;
	QAction *fontAction = NULL;
	QAction *objectOpacity[8];
	for (int i=0;i<8;++i)
		objectOpacity[i] = NULL;
	QAction *boxpen[4] = { NULL, NULL, NULL, NULL};
	QAction *boxpad[4] = { NULL, NULL, NULL, NULL};
	QAction *boxpencolor = NULL;
	QAction *boxfillcolor = NULL;

	QAction *align[6];
	for (int i=0;i<6;++i)
		align[i] = NULL;

	if (item) {
		qm.addSeparator();
		QMenu *qmObjTrans = qm.addMenu(tr("Object Opacity"));
		QActionGroup *qagObject = new QActionGroup(&qm);
		for (int i=0;i<8;++i) {
			qreal o = i + 1 / 8.0;

			objectOpacity[i] = new QAction(tr("%1%").arg(o * 100.0f, 0, 'f', 1), qagObject);
			objectOpacity[i]->setCheckable(true);
			objectOpacity[i]->setData(o);
			if (qFuzzyCompare(item->opacity(), o))
				objectOpacity[i]->setChecked(true);
			qmObjTrans->addAction(objectOpacity[i]);
		}

		QMenu *qmObjAlign = qm.addMenu(tr("Alignment"));
		Qt::Alignment a;
		if (item == qgpiAvatar)
			a = os.qaAvatar;
		else if (item == qgpiChannel)
			a = os.qaChannel;
		else if (item == qgpiMuted)
			a = os.qaMutedDeafened;
		else
			a = os.qaUserName;

		align[0] = qmObjAlign->addAction(tr("Left"));
		align[0]->setCheckable(true);
		align[0]->setData(Qt::AlignLeft);
		if (a & Qt::AlignLeft)
			align[0]->setChecked(true);
		align[1] = qmObjAlign->addAction(tr("Center"));
		align[1]->setCheckable(true);
		align[1]->setData(Qt::AlignHCenter);
		if (a & Qt::AlignHCenter)
			align[1]->setChecked(true);
		align[2] = qmObjAlign->addAction(tr("Right"));
		align[2]->setCheckable(true);
		align[2]->setData(Qt::AlignRight);
		if (a & Qt::AlignRight)
			align[2]->setChecked(true);

		qmObjAlign->addSeparator();

		align[3] = qmObjAlign->addAction(tr("Top"));
		align[3]->setCheckable(true);
		align[3]->setData(Qt::AlignTop);
		if (a & Qt::AlignTop)
			align[3]->setChecked(true);
		align[4] = qmObjAlign->addAction(tr("Center"));
		align[4]->setCheckable(true);
		align[4]->setData(Qt::AlignVCenter);
		if (a & Qt::AlignVCenter)
			align[4]->setChecked(true);
		align[5] = qmObjAlign->addAction(tr("Bottom"));
		align[5]->setCheckable(true);
		align[5]->setData(Qt::AlignBottom);
		if (a & Qt::AlignBottom)
			align[5]->setChecked(true);

		if ((item != qgpiAvatar) && (item != qgpiMuted)) {
			color = qm.addAction(tr("Color..."));
			fontAction = qm.addAction(tr("Font..."));
		}
	}

	if (qgpiBox->isVisible()) {
		qm.addSeparator();
		QMenu *qmBox = qm.addMenu(tr("Bounding box"));
		QMenu *qmPen = qmBox->addMenu(tr("Pen width"));
		QMenu *qmPad = qmBox->addMenu(tr("Padding"));
		boxpencolor = qmBox->addAction(tr("Pen color"));
		boxfillcolor = qmBox->addAction(tr("Fill color"));

		QActionGroup *qagPen = new QActionGroup(qmPen);
		QActionGroup *qagPad = new QActionGroup(qmPad);
		for (int i=0;i<4;++i) {
			qreal v = (i) ? powf(2.0f, static_cast<float>(-10 + i)) : 0.0f;
			boxpen[i] = new QAction(QString::number(i), qagPen);
			boxpen[i]->setData(v);
			boxpen[i]->setCheckable(true);
			if (qFuzzyCompare(os.fBoxPenWidth, v))
				boxpen[i]->setChecked(true);
			qmPen->addAction(boxpen[i]);

			boxpad[i] = new QAction(QString::number(i), qagPad);
			boxpad[i]->setData(v);
			boxpad[i]->setCheckable(true);
			if (qFuzzyCompare(os.fBoxPad, v))
				boxpad[i]->setChecked(true);
			qmPad->addAction(boxpad[i]);
		}
	}

	QAction *act = qm.exec(e->screenPos());

	if (! act)
		return;

	for (int i=0;i<8;++i) {
		if (userOpacity[i] == act) {
			float o = static_cast<float>(act->data().toReal());
			os.fUser[tsColor] = o;

			qgiGroup->setOpacity(o);
		}
	}

	for (int i=0;i<8;++i) {
		if (objectOpacity[i] == act) {
			qreal o = act->data().toReal();

			if (item == qgpiMuted)
				os.fMutedDeafened = o;
			else if (item == qgpiAvatar)
				os.fAvatar = o;
			else if (item == qgpiChannel)
				os.fChannel = o;
			else if (item == qgpiName)
				os.fUserName = o;

			item->setOpacity(o);
		}
	}

	for (int i=0;i<4;++i) {
		if (boxpen[i] == act) {
			os.fBoxPenWidth = act->data().toReal();
			moveBox();
		} else if (boxpad[i] == act) {
			os.fBoxPad = act->data().toReal();
			moveBox();
		}
	}

	for (int i=0;i<6;++i) {
		if (align[i] == act) {
			Qt::Alignment *aptr;
			if (item == qgpiAvatar)
				aptr = & os.qaAvatar;
			else if (item == qgpiChannel)
				aptr = & os.qaChannel;
			else if (item == qgpiMuted)
				aptr = & os.qaMutedDeafened;
			else
				aptr = & os.qaUserName;

			Qt::Alignment a = static_cast<Qt::Alignment>(act->data().toInt());
			if (a & Qt::AlignHorizontal_Mask) {
				*aptr = (*aptr & ~Qt::AlignHorizontal_Mask) | a;
			} else {
				*aptr = (*aptr & ~Qt::AlignVertical_Mask) | a;
			}

			updateSelected();
		}
	}

	if (act == boxpencolor) {
		QColor qc = QColorDialog::getColor(os.qcBoxPen, e->widget(), tr("Pick pen color"), QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel);
		if (! qc.isValid())
			return;
		os.qcBoxPen = qc;
		moveBox();
	} else if (act == boxfillcolor) {
		QColor qc = QColorDialog::getColor(os.qcBoxFill, e->widget(), tr("Pick fill color"), QColorDialog::DontUseNativeDialog | QColorDialog::ShowAlphaChannel);
		if (! qc.isValid())
			return;
		os.qcBoxFill = qc;
		moveBox();
	} else if (act == color) {
		QColor *col = NULL;
		if (item == qgpiChannel)
			col = & os.qcChannel;
		else if (item == qgpiName)
			col = & os.qcUserName[tsColor];
		if (! col)
			return;

		QColor qc = QColorDialog::getColor(*col, e->widget(), tr("Pick color"), QColorDialog::DontUseNativeDialog);
		if (! qc.isValid())
			return;
		qc.setAlpha(255);

		if (qc == *col)
			return;

		*col = qc;
		updateSelected();
	} else if (act == fontAction) {
		QFont *fontptr = (item == qgpiChannel) ? &os.qfChannel : &os.qfUserName;

		qgpiSelected = NULL;
		qgriSelected->hide();

		// QFontDialog doesn't really like graphics view. At all.

		QFontDialog qfd;
		qfd.setOptions(QFontDialog::DontUseNativeDialog);
		qfd.setCurrentFont(*fontptr);
		qfd.setWindowTitle(tr("Pick font"));

		int ret;
		if (g.ocIntercept) {
			QGraphicsProxyWidget *qgpw = new QGraphicsProxyWidget(NULL, Qt::Window);
			qgpw->setWidget(&qfd);

			addItem(qgpw);

			qgpw->setZValue(3.0f);
			qgpw->setPanelModality(QGraphicsItem::PanelModal);
			qgpw->setPos(- qgpw->boundingRect().width() / 2.0f, - qgpw->boundingRect().height() / 2.0f);
			qgpw->show();

			ret = qfd.exec();

			qgpw->hide();
			qgpw->setWidget(NULL);
			delete qgpw;
		} else {
			Qt::WindowFlags wf = g.mw->windowFlags();
			if (wf.testFlag(Qt::WindowStaysOnTopHint))
				qfd.setWindowFlags(qfd.windowFlags() | Qt::WindowStaysOnTopHint);
			ret = qfd.exec();
		}

		if (! ret)
			return;
		*fontptr = qfd.selectedFont();

		resync();
	} else if (act == qaLayoutLargeAvatar) {
		os.setPreset(OverlaySettings::LargeSquareAvatar);
		resync();
	} else if (act == qaLayoutText) {
		os.setPreset(OverlaySettings::AvatarAndName);
		resync();
	}
}