Esempio n. 1
1
BalloonMsg::BalloonMsg(void *param, const QString &_text, QStringList &btn, QWidget *parent, const QRect *rcParent,
                       bool bModal, bool bAutoHide, unsigned bwidth, const QString &box_msg, bool *bChecked)
        : QDialog(parent, "ballon", bModal,
                  (bAutoHide ? WType_Popup : WType_TopLevel | WStyle_StaysOnTop)
                  | WStyle_Customize | WStyle_NoBorderEx | WStyle_Tool | WDestructiveClose | WX11BypassWM)
{
    m_param = param;
    m_parent = parent;
    m_width = bwidth;
    m_bAutoHide = bAutoHide;
    m_bYes = false;
    m_bChecked = bChecked;
    bool bTailDown = true;
    setPalette(QToolTip::palette());
    text = _text;
    QFrame *frm = new QFrame(this);
    frm->setPalette(palette());
    QVBoxLayout *vlay = new QVBoxLayout(frm);
    vlay->setMargin(0);
    m_check = NULL;
    if (!box_msg.isEmpty()){
        m_check = new QCheckBox(box_msg, frm);
        vlay->addWidget(m_check);
        if (m_bChecked)
            m_check->setChecked(*m_bChecked);
    }
    QHBoxLayout *lay = new QHBoxLayout(vlay);
    lay->setSpacing(5);
    lay->addStretch();
    unsigned id = 0;
    bool bFirst = true;
    for (QStringList::Iterator it = btn.begin(); it != btn.end(); ++it, id++){
        BalloonButton *b = new BalloonButton(*it, frm, id);
        connect(b, SIGNAL(action(int)), this, SLOT(action(int)));
        lay->addWidget(b);
        if (bFirst){
            b->setDefault(true);
            bFirst = false;
        }
    }
    setButtonsPict(this);
    lay->addStretch();
    int wndWidth = frm->minimumSizeHint().width();
    int hButton  = frm->minimumSizeHint().height();

    int txtWidth = bwidth;
    QRect rc;
    if (rcParent){
        rc = *rcParent;
    }else{
        QPoint p = parent->mapToGlobal(parent->rect().topLeft());
        rc = QRect(p.x(), p.y(), parent->width(), parent->height());
    }
    if (rc.width() > txtWidth) txtWidth = rc.width();

    QSimpleRichText richText(_text, font(), "", QStyleSheet::defaultSheet(), QMimeSourceFactory::defaultFactory(), -1, Qt::blue, false);
    richText.setWidth(wndWidth);
    richText.adjustSize();
    QSize s(richText.widthUsed(), richText.height());
    QSize sMin = frm->minimumSizeHint();
    if (s.width() < sMin.width())
        s.setWidth(sMin.width());
    int BALLOON_SHADOW = BALLOON_SHADOW_DEF;
#ifdef WIN32
	/* FIXME */
/*    if ((GetClassLong(winId(), GCL_STYLE) & CS_DROPSHADOW) && style().inherits("QWindowsXPStyle"))
        BALLOON_SHADOW = 0; */
#endif
    resize(s.width() + BALLOON_R * 2 + BALLOON_SHADOW,
           s.height() + BALLOON_R * 2 + BALLOON_TAIL + BALLOON_SHADOW + hButton + BALLOON_MARGIN);
    mask = QBitmap(width(), height());
    int w = width() - BALLOON_SHADOW;
    int tailX = w / 2;
    int posX = rc.left() + rc.width() / 2 + BALLOON_TAIL_WIDTH - tailX;
    if (posX <= 0) posX = 1;
    QRect rcScreen = screenGeometry();
    if (posX + width() >= rcScreen.width())
        posX = rcScreen.width() - 1 - width();
    int tx = posX + tailX - BALLOON_TAIL_WIDTH;
    if (tx < rc.left()) tx = rc.left();
    if (tx > rc.left() + rc.width()) tx = rc.left() + rc.width();
    tailX = tx + BALLOON_TAIL_WIDTH - posX;
    if (tailX < BALLOON_R) tailX = BALLOON_R;
    if (tailX > width() - BALLOON_R - BALLOON_TAIL_WIDTH) tailX = width() - BALLOON_R - BALLOON_TAIL_WIDTH;
    if (rc.top() <= height() + 2){
        bTailDown = false;
        move(posX, rc.top() + rc.height() + 1);
    }else{
        move(posX, rc.top() - height() - 1);
    }
    int pos = 0;
    int h = height() - BALLOON_SHADOW - BALLOON_TAIL;
    if (!bTailDown) pos += BALLOON_TAIL;
    textRect.setRect(BALLOON_R, pos + BALLOON_R, w - BALLOON_R * 2, h);
    frm->resize(s.width(), hButton);
    frm->move(BALLOON_R, pos + h - BALLOON_R - hButton);
    QPainter p;
    p.begin(&mask);
#ifdef WIN32
    QColor bg(255, 255, 255);
    QColor fg(0, 0, 0);
#else
    QColor bg(0, 0, 0);
    QColor fg(255, 255, 255);
#endif
    p.fillRect(0, 0, width(), height(), bg);
    p.fillRect(0, pos + BALLOON_R, w, h - BALLOON_R * 2, fg);
    p.fillRect(BALLOON_R, pos, w - BALLOON_R * 2, h, fg);
    p.fillRect(BALLOON_SHADOW, pos + BALLOON_R + BALLOON_SHADOW, w, h - BALLOON_R * 2, fg);
    p.fillRect(BALLOON_R + BALLOON_SHADOW, pos + BALLOON_SHADOW, w - BALLOON_R * 2, h, fg);
    p.setBrush(fg);
    p.drawEllipse(0, pos, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2, pos, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2, pos + h - BALLOON_R * 2, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(0, pos + h - BALLOON_R * 2, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(BALLOON_SHADOW, pos + BALLOON_SHADOW, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2 + BALLOON_SHADOW, pos + BALLOON_SHADOW, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2 + BALLOON_SHADOW, pos + h - BALLOON_R * 2 + BALLOON_SHADOW, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(BALLOON_SHADOW, pos + h - BALLOON_R * 2 + BALLOON_SHADOW, BALLOON_R * 2, BALLOON_R * 2);
    QPointArray arr(3);
    arr.setPoint(0, tailX, bTailDown ? h : pos);
    arr.setPoint(1, tailX + BALLOON_TAIL_WIDTH, bTailDown ? h : pos);
    arr.setPoint(2, tailX - BALLOON_TAIL_WIDTH, bTailDown ? height() - BALLOON_SHADOW : 0);
    p.drawPolygon(arr);
    arr.setPoint(0, tailX + BALLOON_SHADOW, (bTailDown ? h : pos) + BALLOON_SHADOW);
    arr.setPoint(1, tailX + BALLOON_TAIL_WIDTH + BALLOON_SHADOW, (bTailDown ? h : pos) + BALLOON_SHADOW);
    arr.setPoint(2, tailX - BALLOON_TAIL_WIDTH + BALLOON_SHADOW, bTailDown ? height() : BALLOON_SHADOW);
    p.drawPolygon(arr);
    p.end();
    setMask(mask);
    qApp->syncX();
    QPixmap pict = QPixmap::grabWindow(QApplication::desktop()->winId(), x(), y(), width(), height());
    intensity(pict, -0.50f);
    p.begin(&pict);
    p.setBrush(colorGroup().background());
    p.drawEllipse(0, pos, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2, pos, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2, pos + h - BALLOON_R * 2, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(0, pos + h - BALLOON_R * 2, BALLOON_R * 2, BALLOON_R * 2);
    arr.setPoint(0, tailX, bTailDown ? h - 1 : pos + 1);
    arr.setPoint(1, tailX + BALLOON_TAIL_WIDTH, bTailDown ? h - 1 : pos + 1);
    arr.setPoint(2, tailX - BALLOON_TAIL_WIDTH, bTailDown ? height() - BALLOON_SHADOW : 0);
    p.drawPolygon(arr);
    p.fillRect(0, pos + BALLOON_R, w, h - BALLOON_R * 2, colorGroup().background());
    p.fillRect(BALLOON_R, pos, w - BALLOON_R * 2, h, colorGroup().background());
    p.drawLine(0, pos + BALLOON_R, 0, pos + h - BALLOON_R);
    p.drawLine(w - 1, pos + BALLOON_R, w - 1, pos + h - BALLOON_R);
    if (bTailDown){
        p.drawLine(BALLOON_R, 0, w - BALLOON_R, 0);
        p.drawLine(BALLOON_R, h - 1, tailX, h - 1);
        p.drawLine(tailX + BALLOON_TAIL_WIDTH, h - 1, w - BALLOON_R, h - 1);
    }else{
        p.drawLine(BALLOON_R, pos + h - 1, w - BALLOON_R, pos + h - 1);
        p.drawLine(BALLOON_R, pos, tailX, pos);
        p.drawLine(tailX + BALLOON_TAIL_WIDTH, pos, w - BALLOON_R, pos);
    }
    p.end();
    setBackgroundPixmap(pict);
    setAutoMask(true);
    if (!bAutoHide)
        setFocusPolicy(NoFocus);

    QWidget *top = NULL;
    if (parent)
        top = parent->topLevelWidget();
    if (top){
        raiseWindow(top);
        top->installEventFilter(this);
    }
}
Esempio n. 2
0
void XyzWindow::CreateXYZView()
{
	QFrame *XyFrame;
	QFrame *XzFrame;
	QFrame *ZyFrame;
	QWidget *centralWidget;
	
	centralWidget = new QWidget(this);
	QPalette palette;
	palette.setColor(QPalette::Background , QColor(/*200,200,200*/167, 210, 200));
	centralWidget->setAutoFillBackground(true);
	centralWidget->setPalette(palette);
	
	XzFrame = new QFrame(centralWidget);
	XzFrame->setGeometry(QRect(mXorigin1,mYorigin1 , mx+2*FRAM_BORDER , mz+2*FRAM_BORDER));
	XzFrame->setFrameShape(QFrame::StyledPanel);
	XzFrame->setFrameShadow(QFrame::Raised);
	ZyFrame = new QFrame(centralWidget);
	ZyFrame->setGeometry(QRect(mXorigin2 , mYorigin2 , mz+2*FRAM_BORDER ,my+2*FRAM_BORDER));
	ZyFrame->setFrameShape(QFrame::StyledPanel);
	ZyFrame->setFrameShadow(QFrame::Raised);
	XyFrame = new QFrame(centralWidget);
	XyFrame->setGeometry(QRect(mXorigin1 , mYorigin2 , mx+2*FRAM_BORDER  ,my+2*FRAM_BORDER));
	XyFrame->setFrameShape(QFrame::StyledPanel);
	XyFrame->setFrameShadow(QFrame::Raised);
	
	
	palette.setColor(QPalette::Background , QColor(255,0,0));
	XzFrame->setAutoFillBackground(true);
	XzFrame->setPalette(palette);
	ZyFrame->setAutoFillBackground(true);
	ZyFrame->setPalette(palette);
	XyFrame->setAutoFillBackground(true);
	XyFrame->setPalette(palette);
	setCentralWidget(centralWidget);
	
	QGLFormat glFormat;
	glFormat.setRgba(true);
	glFormat.setDoubleBuffer(true);
	glFormat.setDepth(true);
	mXY_GLw = new XyzGL(glFormat , XY_VIEW , XyFrame , this);
	mXY_GLw->setGeometry(FRAM_BORDER , FRAM_BORDER,mx,my);
	mXY_GLw->setAttribute(Qt::WA_DeleteOnClose);
	
	mXZ_GLw = new XyzGL(glFormat , XZ_VIEW , XzFrame , this);
	mXZ_GLw->setGeometry(FRAM_BORDER , FRAM_BORDER , mx ,mz);
	mXZ_GLw->setAttribute(Qt::WA_DeleteOnClose);
	
	mYZ_GLw = new XyzGL(glFormat , ZY_VIEW , ZyFrame , this);
	mYZ_GLw->setGeometry(FRAM_BORDER , FRAM_BORDER ,mz ,my);
	mYZ_GLw->setAttribute(Qt::WA_DeleteOnClose);
}
Esempio n. 3
0
void ClsIqrGUI::createAnimation() {
    QFrame *qframeSpace = new QFrame(qtoolbarToolbar);
    qtoolbarToolbar->setStretchableWidget ( qframeSpace );


    QFrame *qframeAnimation = new QFrame(qtoolbarToolbar);
    QPalette palette;
    palette.setColor(qframeAnimation->backgroundRole(), QColor(255,0,0));
    qframeAnimation->setPalette(palette);
    

    qframeAnimation->setFixedWidth(30);
    qlblStatus = new QLabel(qframeAnimation, "animation");

#ifdef USE_MEMARRAY_LOGO
    QByteArray qbaMoview;
    qbaMoview.setRawData( movie_data, sizeof(movie_data) );
    qlblStatus->setMovie(QMovie(qbaMoview));
#else
    QString filename = "/usr/lib/iqr/iqr-logo.gif";
    if(QFile::exists(filename)){
	qlblStatus->setMovie(QMovie(filename));
    }
#endif

    if(qlblStatus->movie()!=NULL){
	qlblStatus->movie()->pause();
	qlblStatus->movie()->step();
    }
}
Esempio n. 4
0
void stkSlicerAppPrivate::setupUi(QMainWindow * mainWindow)
{
	Q_Q(stkSlicerApp);

	this->Ui_stkSlicerApp::setupUi(mainWindow);

	// Color of the spacing between views:
	QFrame* layoutFrame = new QFrame(this->slicerWidget);
	layoutFrame->setObjectName("CentralWidgetLayoutFrame");
	QHBoxLayout* centralLayout = new QHBoxLayout(this->slicerWidget);
	centralLayout->setContentsMargins(0, 0, 0, 0);
	centralLayout->addWidget(layoutFrame);

	QColor windowColor = this->slicerWidget->palette().color(QPalette::Window);
	QPalette centralPalette = this->slicerWidget->palette();
	centralPalette.setColor(QPalette::Window, QColor(95, 95, 113));
	this->slicerWidget->setAutoFillBackground(true);
	this->slicerWidget->setPalette(centralPalette);

	// Restore the palette for the children
	centralPalette.setColor(QPalette::Window, windowColor);
	layoutFrame->setPalette(centralPalette);
	layoutFrame->setAttribute(Qt::WA_NoSystemBackground, true);
	layoutFrame->setAttribute(Qt::WA_TranslucentBackground, true);


	//----------------------------------------------------------------------------
	// Layout Manager
	//----------------------------------------------------------------------------
	// Instanciate and assign the layout manager to the slicer application
	this->LayoutManager = new qSlicerLayoutManager(layoutFrame);
	qSlicerApplication::application()->setLayoutManager(this->LayoutManager);

	// Layout manager should also listen the MRML scene
	this->LayoutManager->setMRMLScene(qSlicerApplication::application()->mrmlScene());
	QObject::connect(qSlicerApplication::application(), SIGNAL(mrmlSceneChanged(vtkMRMLScene*)), this->LayoutManager, SLOT(setMRMLScene(vtkMRMLScene*)));

	//3d View Appearence setting
	stkSlicerDisplayHelper::Set3DViewNodeAppearence();
}
Esempio n. 5
0
bool PreferencesDialog::eventFilter(QObject *obj, QEvent *event)
{
    // Use mouse click and enter press on the frames to pop up a colour dialog
    if (obj == ui->fr_bin_bg  || obj == ui->fr_bin_fg ||
        obj == ui->fr_reg_bg  || obj == ui->fr_reg_fg ||
        obj == ui->fr_null_bg || obj == ui->fr_null_fg)
    {
        if (event->type() == QEvent::KeyPress)
        {
            QKeyEvent *key = static_cast<QKeyEvent *>(event);
            // Not interesting, so send to the parent (might be shortcuts)
            if((key->key() != Qt::Key_Enter) && (key->key() != Qt::Key_Return))
            {
                return QDialog::eventFilter(obj, event);
            }
        }
        else if (event->type() != QEvent::MouseButtonPress)
        {
            // Not a key event neither a mouse event, send to the parent
            return QDialog::eventFilter(obj, event);
        }

        QFrame *frame = qobject_cast<QFrame *>(obj);
        QColor oldColour = frame->palette().color(frame->backgroundRole());
        QColor colour = QColorDialog::getColor(oldColour, frame);

        if (colour.isValid())
        {
            QPalette palette = frame->palette();
            palette.setColor(frame->backgroundRole(), colour);
            frame->setPalette(palette);
        }
        // Consume
        return true;
    }

    // Send any other events to the parent
    return QDialog::eventFilter(obj, event);
}
QmitkFillHoleToolGUI::QmitkFillHoleToolGUI()
:QmitkToolGUI()
{
	//std::cout << "hi from " << __FUNCSIG__ << std::endl;
	// create the visible widgets
	QBoxLayout* verticalLayout = new QVBoxLayout( this );

	m_HorizontalLayout = new QHBoxLayout();
	verticalLayout->addLayout(m_HorizontalLayout);
	m_HorizontalLayout1 = new QHBoxLayout();
	verticalLayout->addLayout(m_HorizontalLayout1);
	m_HorizontalLayout2 = new QHBoxLayout();
	verticalLayout->addLayout(m_HorizontalLayout2);

	m_SelectSurfaceBox = new QComboBox();
	m_HorizontalLayout->addWidget(m_SelectSurfaceBox);
	connect(m_SelectSurfaceBox, SIGNAL(activated(int)), this, SLOT(SelectSurface(int)));

	m_PbtnSelectSurfaceViaMouse = new QPushButton();
	QIcon icn_OpenFile;
	icn_OpenFile.addFile(":/threeDEditing/res/threeDEditing/mousepointer.png");
	m_PbtnSelectSurfaceViaMouse->setIcon(icn_OpenFile);
	m_PbtnSelectSurfaceViaMouse->setFixedSize(22,22);
	m_HorizontalLayout->addWidget(m_PbtnSelectSurfaceViaMouse);
	connect(m_PbtnSelectSurfaceViaMouse, SIGNAL(clicked()), this, SLOT(SelectSurfaceViaMouse()));
	
	m_PbtnReinitSelection = new QPushButton();
	m_PbtnReinitSelection->setText("Reinit Selection");
	m_PbtnReinitSelection->setCheckable(true);
	m_HorizontalLayout1->addWidget(m_PbtnReinitSelection);
	connect(m_PbtnReinitSelection, SIGNAL(clicked()), this, SLOT(ReinitSelection()));

	m_PbtnJumpToPosition = new QPushButton();
	m_PbtnJumpToPosition->setText("Jump to Position");
	m_PbtnJumpToPosition->setCheckable(true);
	m_HorizontalLayout1->addWidget(m_PbtnJumpToPosition);
	connect(m_PbtnJumpToPosition, SIGNAL(clicked()), this, SLOT(JumpToPosition()));

	QLabel* label = new QLabel( "Radius", this );
	QFont f = label->font();
	f.setBold(false);
	label->setFont( f );
	m_HorizontalLayout2->addWidget(label);

	m_RadiusSlider = new QSlider(Qt::Horizontal);
	m_RadiusSlider->setSliderPosition(20);
	m_HorizontalLayout2->addWidget(m_RadiusSlider);
	QObject::connect(m_RadiusSlider, SIGNAL(sliderMoved(int)), this, SLOT(RadiusChanged(int)));


	// Tool Specific
	QBoxLayout* horizontalLayout3 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout3);
	QBoxLayout* horizontalLayout4 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout4);
	QBoxLayout* horizontalLayout5 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout5);
	QBoxLayout* horizontalLayout6 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout6);

	QFrame *frame = new QFrame( this );
	frame->setFrameStyle( QFrame::Box | QFrame::Plain );
	frame->setLineWidth(10);
	frame->setFixedSize(200,10);
	QColor color(214,247,202);
	QPalette colorPalette(color);
	colorPalette.setColor(QPalette::Foreground, color);
	frame->setPalette(colorPalette);
	horizontalLayout3->addWidget(frame);

	QPushButton* pbtn_DetectHoles = new QPushButton();
	pbtn_DetectHoles->setText("Detect Holes");
	horizontalLayout4->addWidget(pbtn_DetectHoles);
	connect(pbtn_DetectHoles, SIGNAL(clicked()), this, SLOT(DetectHoles()));

	QPushButton* pbtn_FillHoles = new QPushButton();
	pbtn_FillHoles->setText("Fill Holes");
	horizontalLayout5->addWidget(pbtn_FillHoles);
	connect(pbtn_FillHoles, SIGNAL(clicked()), this, SLOT(FillHoles()));

	QPushButton* pbtn_FillHolesVOI = new QPushButton();
	pbtn_FillHolesVOI->setText("Fill Holes VOI");
	horizontalLayout6->addWidget(pbtn_FillHolesVOI);
	connect(pbtn_FillHolesVOI, SIGNAL(clicked()), this, SLOT(FillHolesVOI()));

	connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) );
	//std::cout << "ciao from " << __FUNCSIG__ << std::endl;
}
QmitkBulgeToolGUI::QmitkBulgeToolGUI()
:QmitkToolGUI()
{
	std::cout << "hi from " << __FUNCSIG__ << std::endl;
	// create the visible widgets
	QBoxLayout* verticalLayout = new QVBoxLayout( this );

	m_HorizontalLayout = new QHBoxLayout();
	verticalLayout->addLayout(m_HorizontalLayout);
	m_HorizontalLayout1 = new QHBoxLayout();
	verticalLayout->addLayout(m_HorizontalLayout1);
	m_HorizontalLayout2 = new QHBoxLayout();
	verticalLayout->addLayout(m_HorizontalLayout2);

	m_SelectSurfaceBox = new QComboBox();
	m_HorizontalLayout->addWidget(m_SelectSurfaceBox);
	connect(m_SelectSurfaceBox, SIGNAL(activated(int)), this, SLOT(SelectSurface(int)));

	m_PbtnSelectSurfaceViaMouse = new QPushButton();
	QIcon icn_OpenFile;
	icn_OpenFile.addFile(":/threeDEditing/res/threeDEditing/mousepointer.png");
	m_PbtnSelectSurfaceViaMouse->setIcon(icn_OpenFile);
	m_PbtnSelectSurfaceViaMouse->setFixedSize(22,22);
	m_HorizontalLayout->addWidget(m_PbtnSelectSurfaceViaMouse);
	connect(m_PbtnSelectSurfaceViaMouse, SIGNAL(clicked()), this, SLOT(SelectSurfaceViaMouse()));

	m_PbtnReinitSelection = new QPushButton();
	m_PbtnReinitSelection->setText("Reinit Selection");
	m_PbtnReinitSelection->setCheckable(true);
	m_HorizontalLayout1->addWidget(m_PbtnReinitSelection);
	connect(m_PbtnReinitSelection, SIGNAL(clicked()), this, SLOT(ReinitSelection()));

	m_PbtnJumpToPosition = new QPushButton();
	m_PbtnJumpToPosition->setText("Jump to Position");
	m_PbtnJumpToPosition->setCheckable(true);
	m_HorizontalLayout1->addWidget(m_PbtnJumpToPosition);
	connect(m_PbtnJumpToPosition, SIGNAL(clicked()), this, SLOT(JumpToPosition()));

	QLabel* label = new QLabel( "Radius", this );
	QFont f = label->font();
	f.setBold(false);
	label->setFont( f );
	m_HorizontalLayout2->addWidget(label);

	m_RadiusSlider = new QSlider(Qt::Horizontal);
	m_RadiusSlider->setSliderPosition(20);
	m_HorizontalLayout2->addWidget(m_RadiusSlider);
	QObject::connect(m_RadiusSlider, SIGNAL(sliderMoved(int)), this, SLOT(RadiusChanged(int)));


	// Tool Specific
	QBoxLayout* horizontalLayout3 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout3);
	QBoxLayout* horizontalLayout4 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout4);
	QBoxLayout* horizontalLayout5 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout5);
	QBoxLayout* horizontalLayout6 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout6);
	QBoxLayout* horizontalLayout7 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout7);
	QBoxLayout* horizontalLayout8 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout8);
	QBoxLayout* horizontalLayout9 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout9);
	QBoxLayout* horizontalLayout10 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout10);
	QBoxLayout* horizontalLayout11 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout11);

	QFrame *frame = new QFrame( this );
	frame->setFrameStyle( QFrame::Box | QFrame::Plain );
	frame->setLineWidth(10);
	frame->setFixedSize(200,10);
	QColor color(214,247,202);
	QPalette colorPalette(color);
	colorPalette.setColor(QPalette::Foreground, color);
	frame->setPalette(colorPalette);
	horizontalLayout3->addWidget(frame);

	QLabel* label2 = new QLabel( "Select move points technique:", this );
	QFont f2 = label2->font();
	f2.setBold(false);
	label->setFont( f2 );
	horizontalLayout4->addWidget(label2);

	m_pbtn_Collinear = new QPushButton();
	m_pbtn_Collinear->setText("Collinear");
	m_pbtn_Collinear->setToolTip("Move points in the same direction as the mouse moves.");
	m_pbtn_Collinear->setCheckable(true);
	m_pbtn_Collinear->setChecked(true);
	horizontalLayout5->addWidget(m_pbtn_Collinear);
	connect(m_pbtn_Collinear, SIGNAL(clicked()), this, SLOT(Collinear()));

	m_pbtn_Radial = new QPushButton();
	m_pbtn_Radial->setText("Radial");
	m_pbtn_Radial->setToolTip("Move points outside radial from the origin of the tool.");
	m_pbtn_Radial->setCheckable(true);
	horizontalLayout5->addWidget(m_pbtn_Radial);
	connect(m_pbtn_Radial, SIGNAL(clicked()), this, SLOT(Radial()));

	QFrame *frame1 = new QFrame( this );
	frame1->setFrameStyle( QFrame::Box | QFrame::Plain );
	frame1->setLineWidth(10);
	frame1->setFixedSize(200,10);
	frame1->setPalette(colorPalette);
	horizontalLayout6->addWidget(frame1);

	QLabel* label3 = new QLabel( "The tool can add further points while bulging.", this );
	QFont f3 = label3->font();
	f3.setBold(false);
	label3->setFont( f );
	horizontalLayout7->addWidget(label3);

	m_SelectRefinementMethodeBox = new QComboBox();
	m_SelectRefinementMethodeBox->addItem("Off. Don't add points");
	m_SelectRefinementMethodeBox->addItem("Automatic");
	m_SelectRefinementMethodeBox->addItem("Insert Point(s)");
	m_SelectRefinementMethodeBox->addItem("Subdivide Edge(s)");
	horizontalLayout8->addWidget(m_SelectRefinementMethodeBox);
	connect(m_SelectRefinementMethodeBox, SIGNAL(activated(int)), this, SLOT(SelectRefinementMethode(int)));

	QFrame *frame2 = new QFrame( this );
	frame2->setFrameStyle( QFrame::Box | QFrame::Plain );
	frame2->setLineWidth(10);
	frame2->setFixedSize(200,10);
	frame2->setPalette(colorPalette);
	horizontalLayout9->addWidget(frame2);

	QPushButton* pbtn_ShowTool = new QPushButton();
	pbtn_ShowTool->setText("Show Bulge Tool");
	pbtn_ShowTool->setCheckable(true);
	horizontalLayout10->addWidget(pbtn_ShowTool);
	connect(pbtn_ShowTool, SIGNAL(clicked()), this, SLOT(ShowTool()));

	QPushButton* pbtnReinitNow = new QPushButton();
	pbtnReinitNow->setText("Reinit Now");
	horizontalLayout11->addWidget(pbtnReinitNow);
	connect(pbtnReinitNow, SIGNAL(clicked()), this, SLOT(ReinitNow()));

	connect(this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)));
	std::cout << "ciao from " << __FUNCSIG__ << std::endl;
}
QmitkActiveSurfaceToolGUI::QmitkActiveSurfaceToolGUI()
:QmitkToolGUI()
{
	//std::cout << "hi from " << __FUNCSIG__ << std::endl;
	// create the visible widgets
	QBoxLayout* verticalLayout = new QVBoxLayout( this );

	m_HorizontalLayout = new QHBoxLayout();
	verticalLayout->addLayout(m_HorizontalLayout);
	m_HorizontalLayout1 = new QHBoxLayout();
	verticalLayout->addLayout(m_HorizontalLayout1);
	m_HorizontalLayout2 = new QHBoxLayout();
	verticalLayout->addLayout(m_HorizontalLayout2);

	m_SelectSurfaceBox = new QComboBox();
	m_HorizontalLayout->addWidget(m_SelectSurfaceBox);
	connect(m_SelectSurfaceBox, SIGNAL(activated(int)), this, SLOT(SelectSurface(int)));

	m_PbtnSelectSurfaceViaMouse = new QPushButton();
	QIcon icn_OpenFile;
	icn_OpenFile.addFile(":/threeDEditing/res/threeDEditing/mousepointer.png");
	m_PbtnSelectSurfaceViaMouse->setIcon(icn_OpenFile);
	m_PbtnSelectSurfaceViaMouse->setFixedSize(22,22);
	m_HorizontalLayout->addWidget(m_PbtnSelectSurfaceViaMouse);
	connect(m_PbtnSelectSurfaceViaMouse, SIGNAL(clicked()), this, SLOT(SelectSurfaceViaMouse()));
	
	m_PbtnReinitSelection = new QPushButton();
	m_PbtnReinitSelection->setText("Reinit Selection");
	m_PbtnReinitSelection->setCheckable(true);
	m_HorizontalLayout1->addWidget(m_PbtnReinitSelection);
	connect(m_PbtnReinitSelection, SIGNAL(clicked()), this, SLOT(ReinitSelection()));

	m_PbtnJumpToPosition = new QPushButton();
	m_PbtnJumpToPosition->setText("Jump to Position");
	m_PbtnJumpToPosition->setCheckable(true);
	m_HorizontalLayout1->addWidget(m_PbtnJumpToPosition);
	connect(m_PbtnJumpToPosition, SIGNAL(clicked()), this, SLOT(JumpToPosition()));

	QLabel* label = new QLabel( "Radius", this );
	QFont f = label->font();
	f.setBold(false);
	label->setFont( f );
	m_HorizontalLayout2->addWidget(label);

	m_RadiusSlider = new QSlider(Qt::Horizontal);
	m_RadiusSlider->setSliderPosition(20);
	m_HorizontalLayout2->addWidget(m_RadiusSlider);
	QObject::connect(m_RadiusSlider, SIGNAL(sliderMoved(int)), this, SLOT(RadiusChanged(int)));


	// Tool Specific
	QBoxLayout* horizontalLayout3 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout3);
	QBoxLayout* horizontalLayout4 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout4);
	QBoxLayout* horizontalLayout5 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout5);
	QBoxLayout* horizontalLayout6 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout6);
	QBoxLayout* horizontalLayout7 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout7);
	QBoxLayout* horizontalLayout8 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout8);
	QBoxLayout* horizontalLayout9 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout9);
	QBoxLayout* horizontalLayout10 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout10);
	QBoxLayout* horizontalLayout11 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout11);
	QBoxLayout* horizontalLayout12 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout12);
	QBoxLayout* horizontalLayout13 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout13);
	QBoxLayout* horizontalLayout14 = new QHBoxLayout();
	verticalLayout->addLayout(horizontalLayout14);

	QFrame *frame = new QFrame( this );
	frame->setFrameStyle( QFrame::Box | QFrame::Plain );
	frame->setLineWidth(10);
	frame->setFixedSize(200,10);
	QColor color(214,247,202);
	QPalette colorPalette(color);
	colorPalette.setColor(QPalette::Foreground, color);
	frame->setPalette(colorPalette);
	horizontalLayout3->addWidget(frame);

	QLabel* label2 = new QLabel( "Select feature image:", this );
	QFont f2 = label2->font();
	f2.setBold(false);
	label2->setFont( f2 );
	horizontalLayout4->addWidget(label2);

	m_SelectImageBox = new QComboBox();
	horizontalLayout5->addWidget(m_SelectImageBox);
	connect(m_SelectImageBox, SIGNAL(activated(int)), this, SLOT(SelectImage(int)));

	QLabel* label3 = new QLabel( "Set seed point bubble\n(left click):\nRemove bubble\n(shift + left click)", this );
	QFont f3 = label3->font();
	f3.setPointSize(7);
	f3.setBold(false);
	label3->setFont( f3 );
	horizontalLayout6->addWidget(label3);

	QPushButton* pbtn_RemoveBubble = new QPushButton();
	pbtn_RemoveBubble->setText("Remove Bubble");
	horizontalLayout6->addWidget(pbtn_RemoveBubble);
	connect(pbtn_RemoveBubble, SIGNAL(clicked()), this, SLOT(RemoveBubble()));

	m_VCR = new std::vector<QPushButton*>;
	int size = 24;

	QPushButton* pbtn_Stop = new QPushButton();
	QIcon icn_Stop;
	icn_Stop.addFile(":/threeDEditing/res/threeDEditing/Backward_01.png");
	pbtn_Stop->setIcon(icn_Stop);
	pbtn_Stop->setIconSize(QSize(size,size));
	horizontalLayout7->addWidget(pbtn_Stop);	
	connect(pbtn_Stop, SIGNAL(clicked()), this, SLOT(Stop()));

	QPushButton* pbtn_StepBack = new QPushButton();
	QIcon icn_StepBack;
	icn_StepBack.addFile(":/threeDEditing/res/threeDEditing/left.png");
	pbtn_StepBack->setIcon(icn_StepBack);
	pbtn_StepBack->setIconSize(QSize(size,size));
	horizontalLayout7->addWidget(pbtn_StepBack);	
	connect(pbtn_StepBack, SIGNAL(clicked()), this, SLOT(StepBack()));

	QPushButton* pbtn_ReversePlay = new QPushButton();
	m_VCR->push_back(pbtn_ReversePlay);
	QIcon icn_ReversePlay;
	icn_ReversePlay.addFile(":/threeDEditing/res/threeDEditing/Backward.png");
	pbtn_ReversePlay->setIcon(icn_ReversePlay);
	pbtn_ReversePlay->setCheckable(true);
	pbtn_ReversePlay->setIconSize(QSize(size,size));
	horizontalLayout7->addWidget(pbtn_ReversePlay);	
	connect(pbtn_ReversePlay, SIGNAL(clicked()), this, SLOT(ReversePlay()));

	QPushButton* pbtn_Pause = new QPushButton();
	m_VCR->push_back(pbtn_Pause);
	QIcon icn_Pause;
	icn_Pause.addFile(":/threeDEditing/res/threeDEditing/pause.png");
	pbtn_Pause->setIcon(icn_Pause);
	pbtn_Pause->setCheckable(true);
	pbtn_Pause->setChecked(true);
	pbtn_Pause->setIconSize(QSize(size,size));
	horizontalLayout7->addWidget(pbtn_Pause);	
	connect(pbtn_Pause, SIGNAL(clicked()), this, SLOT(Pause()));

	QPushButton* pbtn_Play = new QPushButton();
	m_VCR->push_back(pbtn_Play);
	QIcon icn_Play;
	icn_Play.addFile(":/threeDEditing/res/threeDEditing/Forward.png");
	pbtn_Play->setIcon(icn_Play);
	pbtn_Play->setCheckable(true);
	pbtn_Play->setIconSize(QSize(size,size));
	horizontalLayout7->addWidget(pbtn_Play);	
	connect(pbtn_Play, SIGNAL(clicked()), this, SLOT(Play()));

	QPushButton* pbtn_StepForward = new QPushButton();
	QIcon icn_StepForward;
	icn_StepForward.addFile(":/threeDEditing/res/threeDEditing/right.png");
	pbtn_StepForward->setIcon(icn_StepForward);
	pbtn_StepForward->setIconSize(QSize(size,size));
	horizontalLayout7->addWidget(pbtn_StepForward);	
	connect(pbtn_StepForward, SIGNAL(clicked()), this, SLOT(StepForward()));

	QLabel* label5 = new QLabel( "Step size:", this );
	QFont f5 = label5->font();
	f5.setBold(false);
	label5->setFont( f5 );
	horizontalLayout8->addWidget(label5);
	QSpinBox* selectStepSize = new QSpinBox();
	selectStepSize->setRange(1, 50);
	selectStepSize->setValue(1);
	horizontalLayout8->addWidget(selectStepSize);
	connect(selectStepSize, SIGNAL(valueChanged(int)), this, SLOT(SelectStepSize(int)));

	QLabel* label6 = new QLabel( "Iteration:", this );
	QFont f6 = label6->font();
	f6.setBold(false);
	label6->setFont( f6 );
	horizontalLayout8->addWidget(label6);
	numberOfIterations = new QLineEdit(this);
	numberOfIterations->setText("0");
	numberOfIterations->setReadOnly(true);
	horizontalLayout8->addWidget(numberOfIterations);

	QFrame *frame1 = new QFrame( this );
	frame1->setFrameStyle( QFrame::Box | QFrame::Plain );
	frame1->setLineWidth(10);
	frame1->setFixedSize(200,10);
	frame1->setPalette(colorPalette);
	horizontalLayout9->addWidget(frame1);

	// Parameters
	QLabel* label7 = new QLabel( "Parameters:", this );
	QFont f7 = label7->font();
	f7.setBold(true);
	label7->setFont( f7 );
	horizontalLayout10->addWidget(label7);


	// make the "InputMask" for values between 1.11 and 17.93 with 2 digits after the comma
	QValidator *inputRange = new QDoubleValidator(0.000, 100000.000, 3, this);

	// table layout
	QBoxLayout* verticalLayout1 = new QVBoxLayout();
	horizontalLayout11->addLayout(verticalLayout1);
	QBoxLayout* verticalLayout2 = new QVBoxLayout();
	horizontalLayout11->addLayout(verticalLayout2);
	QBoxLayout* verticalLayout3 = new QVBoxLayout();
	horizontalLayout11->addLayout(verticalLayout3);

	QLabel* label8 = new QLabel( "Curvature\nForce:", this );
	QFont f8 = label8->font();
	f8.setBold(false);
	f8.setPointSize(7);
	label8->setFont( f8 );
	verticalLayout1->addWidget(label8);
	m_CurvatureForce = new QLineEdit(this);
	m_CurvatureForce->setText("0");
	m_CurvatureForce->setReadOnly(false);
	m_CurvatureForce->setValidator(inputRange);
	QObject::connect(m_CurvatureForce, SIGNAL(returnPressed()), this, SLOT(EditedCurvatureForce()));
	verticalLayout2->addWidget(m_CurvatureForce);
	QmitkCrossWidget* curvatureForceCross = new QmitkCrossWidget();
	QPixmap pixCurvatureForce(":/threeDEditing/res/threeDEditing/CrossArrow.png");
	curvatureForceCross->setPixmap(pixCurvatureForce.scaledToWidth(100));
	curvatureForceCross->setFixedSize(100,20);
	curvatureForceCross->setToolTip("Drag with a left mouse click from the center circle to the sides.");
	verticalLayout3->addWidget(curvatureForceCross);
	connect( curvatureForceCross, SIGNAL( SignalDeltaMove( int, int ) ), this, SLOT( CurvatureForceCross( int, int ) ) );

	QLabel* label10 = new QLabel( "Area\nForce:", this );
	QFont f10 = label10->font();
	f10.setBold(false);
	f10.setPointSize(7);
	label10->setFont( f10 );
	verticalLayout1->addWidget(label10);
	m_AreaForce = new QLineEdit(this);
	m_AreaForce->setText("0");
	m_AreaForce->setReadOnly(false);
	m_AreaForce->setValidator(inputRange);
	QObject::connect(m_AreaForce, SIGNAL(returnPressed()), this, SLOT(EditedAreaForce()));
	verticalLayout2->addWidget(m_AreaForce);
	QmitkCrossWidget* areaForceCross = new QmitkCrossWidget();
	QPixmap pixAreaForce(":/threeDEditing/res/threeDEditing/CrossArrow.png");
	areaForceCross->setPixmap(pixAreaForce.scaledToWidth(100));
	areaForceCross->setFixedSize(100,20);
	areaForceCross->setToolTip("Drag with a left mouse click from the center circle to the sides.");
	verticalLayout3->addWidget(areaForceCross);
	connect( areaForceCross, SIGNAL( SignalDeltaMove( int, int ) ), this, SLOT( AreaForceCross( int, int ) ) );

	QLabel* label11 = new QLabel( "Volume\nForce:", this );
	QFont f11 = label11->font();
	f11.setBold(false);
	f11.setPointSize(7);
	label11->setFont( f11 );
	verticalLayout1->addWidget(label11);
	m_VolumeForce = new QLineEdit(this);
	m_VolumeForce->setText("0");
	m_VolumeForce->setReadOnly(false);
	m_VolumeForce->setValidator(inputRange);
	QObject::connect(m_VolumeForce, SIGNAL(returnPressed()), this, SLOT(EditedVolumeForce()));
	verticalLayout2->addWidget(m_VolumeForce);
	QmitkCrossWidget* volumeForceCross = new QmitkCrossWidget();
	QPixmap pixVolumeForce(":/threeDEditing/res/threeDEditing/CrossArrow.png");
	volumeForceCross->setPixmap(pixVolumeForce.scaledToWidth(100));
	volumeForceCross->setFixedSize(100,20);
	volumeForceCross->setToolTip("Drag with a left mouse click from the center circle to the sides.");
	verticalLayout3->addWidget(volumeForceCross);
	connect( volumeForceCross, SIGNAL( SignalDeltaMove( int, int ) ), this, SLOT( VolumeForceCross( int, int ) ) );

	QFrame *frame2 = new QFrame( this );
	frame2->setFrameStyle( QFrame::Box | QFrame::Plain );
	frame2->setLineWidth(10);
	frame2->setFixedSize(200,10);
	frame2->setPalette(colorPalette);
	horizontalLayout12->addWidget(frame2);

	QPushButton* pbtnClosing = new QPushButton();
	pbtnClosing->setText("Closing by one pixel");
	pbtnClosing->setCheckable(true);
	horizontalLayout13->addWidget(pbtnClosing);
	connect(pbtnClosing, SIGNAL(clicked()), this, SLOT(Closing()));

	QLabel* label12 = new QLabel( "Zoom:", this );
	QFont f12 = label12->font();
	f12.setBold(false);
	//f12.setPointSize(6);
	label12->setFont( f12 );
	horizontalLayout14->addWidget(label12);
	QmitkCrossWidget* zoomCross = new QmitkCrossWidget();
	QPixmap pixZoom(":/threeDEditing/res/threeDEditing/CrossArrow.png");
	zoomCross->setPixmap(pixZoom.scaledToWidth(100));
	zoomCross->setFixedSize(100,20);
	zoomCross->setToolTip("Drag with a left mouse click from the center circle to the sides.");
	horizontalLayout14->addWidget(zoomCross);
	connect( zoomCross, SIGNAL( SignalDeltaMove( int, int ) ), this, SLOT( ZoomCross( int, int ) ) );

	connect( this, SIGNAL(NewToolAssociated(mitk::Tool*)), this, SLOT(OnNewToolAssociated(mitk::Tool*)) );
	//std::cout << "ciao from " << __FUNCSIG__ << std::endl;
}
Esempio n. 9
0
BalloonMsg::BalloonMsg(const QString &_text, const QRect &rc, QStringList &btn, QWidget *parent, bool bModal, bool bAutoHide)
        : QDialog(parent, "ballon", bModal,
                  (bAutoHide ? WType_Popup : WType_TopLevel | WStyle_StaysOnTop)
                  | WStyle_Customize | WStyle_NoBorderEx | WStyle_Tool | WDestructiveClose | WX11BypassWM)
{
    m_bAutoHide = bAutoHide;
    bool bTailDown = true;
    setPalette(QToolTip::palette());
    text = _text;
    int hButton = 0;
    QFrame *frm = new QFrame(this);
    frm->setPalette(palette());
    QHBoxLayout *lay = new QHBoxLayout(frm);
    lay->setSpacing(5);
    lay->addStretch();
    unsigned id = 0;
    bool bFirst = true;
    for (QStringList::Iterator it = btn.begin(); it != btn.end(); ++it, id++){
        BalloonButton *b = new BalloonButton(*it, frm, id);
        connect(b, SIGNAL(action(int)), this, SIGNAL(action(int)));
        lay->addWidget(b);
        if (bFirst){
            b->setDefault(true);
            bFirst = false;
        }
        hButton = b->height();
    }
    setButtonsPict(this);
    lay->addStretch();
    int wndWidth = frm->minimumSizeHint().width();

    int txtWidth = BALLOON_WIDTH;
    if (rc.width() > txtWidth) txtWidth = rc.width();

    QPainter p(this);
    QRect rcText = p.boundingRect(0, 0, QMAX(wndWidth, txtWidth), 1000, AlignLeft | AlignTop | WordBreak, _text);
    if (rcText.width() < wndWidth) rcText.setWidth(wndWidth);
    resize(rcText.width() + BALLOON_R * 2 + BALLOON_SHADOW,
           rcText.height() + BALLOON_R * 2 + BALLOON_TAIL + BALLOON_SHADOW + hButton + BALLOON_MARGIN);
    p.end();
    mask = QBitmap(width(), height());
    int w = width() - BALLOON_SHADOW;
    int tailX = w / 2;
    int posX = rc.left() + rc.width() / 2 + BALLOON_TAIL_WIDTH - tailX;
    if (posX <= 0) posX = 1;
    if (posX + width() >= QApplication::desktop()->width())
        posX = QApplication::desktop()->width() - 1 - width();
    int tx = posX + tailX - BALLOON_TAIL_WIDTH;
    if (tx < rc.left()) tx = rc.left();
    if (tx > rc.left() + rc.width()) tx = rc.left() + rc.width();
    tailX = tx + BALLOON_TAIL_WIDTH - posX;
    if (tailX < BALLOON_R) tailX = BALLOON_R;
    if (tailX > width() - BALLOON_R - BALLOON_TAIL_WIDTH) tailX = width() - BALLOON_R - BALLOON_TAIL_WIDTH;
    if (rc.top() <= height() + 2){
        bTailDown = false;
        move(posX, rc.top() + rc.height() + 1);
    }else{
        move(posX, rc.top() - height() - 1);
    }
    int pos = 0;
    int h = height() - BALLOON_SHADOW - BALLOON_TAIL;
    if (!bTailDown) pos += BALLOON_TAIL;
    textRect.setRect(BALLOON_R, pos + BALLOON_R, w - BALLOON_R * 2, h);
    frm->resize(rcText.width(), hButton);
    frm->move(BALLOON_R, pos + h - BALLOON_R - hButton);
    p.begin(&mask);
#ifdef WIN32
    QColor bg(255, 255, 255);
    QColor fg(0, 0, 0);
#else
    QColor bg(0, 0, 0);
    QColor fg(255, 255, 255);
#endif
    p.fillRect(0, 0, width(), height(), bg);
    p.fillRect(0, pos + BALLOON_R, w, h - BALLOON_R * 2, fg);
    p.fillRect(BALLOON_R, pos, w - BALLOON_R * 2, h, fg);
    p.fillRect(BALLOON_SHADOW, pos + BALLOON_R + BALLOON_SHADOW, w, h - BALLOON_R * 2, fg);
    p.fillRect(BALLOON_R + BALLOON_SHADOW, pos + BALLOON_SHADOW, w - BALLOON_R * 2, h, fg);
    p.setBrush(fg);
    p.drawEllipse(0, pos, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2, pos, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2, pos + h - BALLOON_R * 2, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(0, pos + h - BALLOON_R * 2, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(BALLOON_SHADOW, pos + BALLOON_SHADOW, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2 + BALLOON_SHADOW, pos + BALLOON_SHADOW, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2 + BALLOON_SHADOW, pos + h - BALLOON_R * 2 + BALLOON_SHADOW, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(BALLOON_SHADOW, pos + h - BALLOON_R * 2 + BALLOON_SHADOW, BALLOON_R * 2, BALLOON_R * 2);
    QPointArray arr(3);
    arr.setPoint(0, tailX, bTailDown ? h : pos);
    arr.setPoint(1, tailX + BALLOON_TAIL_WIDTH, bTailDown ? h : pos);
    arr.setPoint(2, tailX - BALLOON_TAIL_WIDTH, bTailDown ? height() - BALLOON_SHADOW : 0);
    p.drawPolygon(arr);
    arr.setPoint(0, tailX + BALLOON_SHADOW, (bTailDown ? h : pos) + BALLOON_SHADOW);
    arr.setPoint(1, tailX + BALLOON_TAIL_WIDTH + BALLOON_SHADOW, (bTailDown ? h : pos) + BALLOON_SHADOW);
    arr.setPoint(2, tailX - BALLOON_TAIL_WIDTH + BALLOON_SHADOW, bTailDown ? height() : BALLOON_SHADOW);
    p.drawPolygon(arr);
    p.end();
    setMask(mask);
    qApp->syncX();
    QPixmap pict = QPixmap::grabWindow(QApplication::desktop()->winId(), x(), y(), width(), height());
    intensity(pict, -0.50f);
    p.begin(&pict);
    p.setBrush(colorGroup().background());
    p.drawEllipse(0, pos, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2, pos, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(w - BALLOON_R * 2, pos + h - BALLOON_R * 2, BALLOON_R * 2, BALLOON_R * 2);
    p.drawEllipse(0, pos + h - BALLOON_R * 2, BALLOON_R * 2, BALLOON_R * 2);
    arr.setPoint(0, tailX, bTailDown ? h - 1 : pos + 1);
    arr.setPoint(1, tailX + BALLOON_TAIL_WIDTH, bTailDown ? h - 1 : pos + 1);
    arr.setPoint(2, tailX - BALLOON_TAIL_WIDTH, bTailDown ? height() - BALLOON_SHADOW : 0);
    p.drawPolygon(arr);
    p.fillRect(0, pos + BALLOON_R, w, h - BALLOON_R * 2, colorGroup().background());
    p.fillRect(BALLOON_R, pos, w - BALLOON_R * 2, h, colorGroup().background());
    p.drawLine(0, pos + BALLOON_R, 0, pos + h - BALLOON_R);
    p.drawLine(w - 1, pos + BALLOON_R, w - 1, pos + h - BALLOON_R);
    if (bTailDown){
        p.drawLine(BALLOON_R, 0, w - BALLOON_R, 0);
        p.drawLine(BALLOON_R, h - 1, tailX, h - 1);
        p.drawLine(tailX + BALLOON_TAIL_WIDTH, h - 1, w - BALLOON_R, h - 1);
    }else{
        p.drawLine(BALLOON_R, pos + h - 1, w - BALLOON_R, pos + h - 1);
        p.drawLine(BALLOON_R, pos, tailX, pos);
        p.drawLine(tailX + BALLOON_TAIL_WIDTH, pos, w - BALLOON_R, pos);
    }
    p.end();
    setBackgroundPixmap(pict);
    setAutoMask(true);
    if (!bAutoHide)
        setFocusPolicy(NoFocus);
}
Esempio n. 10
0
void gpSessionView::InitLayout()
{
    // layout to hold the two main vboxlayouts;
    QHBoxLayout* pMainLayout = new QHBoxLayout;

    QVBoxLayout* pThumbLayout = new QVBoxLayout;
    QVBoxLayout* pImageLayout = new QVBoxLayout;

    // Create the image section
    m_pImageLabel = new QLabel;

    // This pixmap is set so that the label will demand the max size possible
    QPixmap placeHolderPixmap(GP_IMAGE_SECTION_WIDTH, GP_IMAGE_SECTION_WIDTH);
    m_pImageLabel->setPixmap(placeHolderPixmap);

    m_pImageLabel->setMaximumWidth(GP_IMAGE_SECTION_WIDTH);
    m_pImageLabel->setMaximumHeight(GP_IMAGE_SECTION_WIDTH);

    // Create the frame analysis section:
    m_pCurrentFrameCaptionLabel = new QLabel(GPU_STR_dashboard_MainImageCaptionRunning);
    m_pCurrentFrameCaptionLabel->setStyleSheet(AF_STR_captionLabelStyleSheetMain);

    m_pCurrentFrameDetailsLabel = new QLabel;
    QLabel* pPropsHTMLLabelCaption = new QLabel(GPU_STR_dashboard_ExecutionCaption);
    m_pCurrentFrameDetailsLabel->setStyleSheet("font-weight: bold; color: gray; font-size: 15px;");

    pPropsHTMLLabelCaption->setStyleSheet(AF_STR_captionLabelStyleSheetMain);
    m_pPropsHTMLLabel = new QLabel;
    m_pPropsHTMLLabel->setTextFormat(Qt::RichText);

    QFrame* pImageFrameWidget = new QFrame;
    QPalette p = pImageFrameWidget->palette();
    p.setColor(backgroundRole(), Qt::white);
    p.setColor(QPalette::Base, Qt::white);
    p.setColor(QPalette::Shadow, Qt::red);
    pImageFrameWidget->setAutoFillBackground(true);
    pImageFrameWidget->setPalette(p);
    pImageFrameWidget->setLineWidth(1);
    pImageFrameWidget->setMidLineWidth(1);
    pImageFrameWidget->setFrameStyle(QFrame::Panel | QFrame::Raised);


    QVBoxLayout* pImageFrameLayout = new QVBoxLayout;
    m_pCurrentFrameDetailsLabel->setContentsMargins(0, 0, 0, 0);

    pImageFrameLayout->addWidget(m_pCurrentFrameDetailsLabel, 0, Qt::AlignCenter);
    pImageFrameLayout->addWidget(m_pImageLabel, 0, Qt::AlignCenter);
    pImageFrameWidget->setLayout(pImageFrameLayout);

    pImageLayout->addWidget(m_pCurrentFrameCaptionLabel);
    pImageLayout->addSpacing(4);
    pImageLayout->addWidget(pImageFrameWidget);
    pImageLayout->addStretch();
    pImageLayout->addWidget(pPropsHTMLLabelCaption);
    pImageLayout->addWidget(m_pPropsHTMLLabel);

    FillExecutionDetails();

    // Create the frame analysis section:
    m_pCapturedFramesCaptionLabel = new QLabel(GPU_STR_dashboard_CapturedFramesCaption);
    m_pCapturedFramesCaptionLabel->setStyleSheet(AF_STR_captionLabelStyleSheetMain);

#define GP_SessionViewButtonStyle "QToolButton { border: 1px solid transparent; background-color: transparent; font-weight: bold; color: gray; }" \
    "QToolButton:hover { border: 1px solid gray; background-color: #CDE6F7; color: black;}"

    QHBoxLayout* pButtonsLayout = new QHBoxLayout;
    pButtonsLayout->addStretch();

    m_pCaptureButton = new QToolButton;
    m_pCaptureButton->setText(GPU_STR_dashboard_CaptureButton);
    m_pCaptureButton->setStyleSheet(GP_SessionViewButtonStyle);
    m_pCaptureButton->setToolTip(GPU_STR_dashboard_CaptureTooltip);

    m_pStopButton = new QToolButton;
    m_pStopButton->setStyleSheet(GP_SessionViewButtonStyle);
    m_pStopButton->setText(GPU_STR_dashboard_StopButton);
    m_pStopButton->setToolTip(GPU_STR_dashboard_StopTooltip);

    m_pOpenTimelineButton = new QToolButton;
    m_pOpenTimelineButton->setStyleSheet(GP_SessionViewButtonStyle);
    m_pOpenTimelineButton->setText(GPU_STR_dashboard_OpenTimelineButton);
    m_pOpenTimelineButton->setToolTip(GPU_STR_dashboard_OpenTimelineTooltip);

    bool rc = connect(m_pCaptureButton, SIGNAL(clicked()), this, SLOT(OnCaptureButtonClick()));
    GT_ASSERT(rc);

    rc = connect(m_pStopButton, SIGNAL(clicked()), this, SLOT(OnStopButtonClick()));
    GT_ASSERT(rc);

    rc = connect(m_pOpenTimelineButton, SIGNAL(clicked()), this, SLOT(OnOpenTimelineButtonClick()));
    GT_ASSERT(rc);

    QPixmap captureButtonIcon;
    acIconSize largerButtonIcon = acGetScaledIconSize(AC_32x32_ICON);
    int iconDim = acIconSizeToPixelSize(largerButtonIcon);
    QSize iconSize(iconDim, iconDim);
    acSetIconInPixmap(captureButtonIcon, AC_ICON_EXECUTION_CAPTURE, largerButtonIcon);
    m_pCaptureButton->setIcon(captureButtonIcon);
    m_pCaptureButton->setIconSize(iconSize);
    m_pCaptureButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    m_pCaptureButton->setFixedWidth(acScalePixelSizeToDisplayDPI(GP_SESSION_VIEW_BUTTON_SIZE));

    QPixmap stopButtonIcon;
    acSetIconInPixmap(stopButtonIcon, AC_ICON_EXECUTION_STOP, largerButtonIcon);
    m_pStopButton->setIcon(stopButtonIcon);
    m_pStopButton->setIconSize(iconSize);
    m_pStopButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    m_pStopButton->setFixedWidth(acScalePixelSizeToDisplayDPI(GP_SESSION_VIEW_BUTTON_SIZE));

    QPixmap openTimelineButtonIcon;
    acSetIconInPixmap(openTimelineButtonIcon, AC_ICON_FRAME_ANALYSIS_APP_TREE_TIMELINE, largerButtonIcon);
    m_pOpenTimelineButton->setIcon(openTimelineButtonIcon);
    m_pOpenTimelineButton->setIconSize(iconSize);
    m_pOpenTimelineButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    m_pOpenTimelineButton->setFixedWidth(acScalePixelSizeToDisplayDPI(GP_SESSION_VIEW_BUTTON_SIZE));

#if AMDT_BUILD_CONFIGURATION == AMDT_DEBUG_BUILD
    m_pSimulateUserCaptureButton = new QToolButton;
    m_pSimulateUserCaptureButton->setText("Capture Simulate");
    QImage captureInv(captureButtonIcon.toImage());
    captureInv.invertPixels(QImage::InvertRgb);
    m_pSimulateUserCaptureButton->setIcon(QPixmap::fromImage(captureInv));
    m_pSimulateUserCaptureButton->setIconSize(iconSize);
    m_pSimulateUserCaptureButton->setToolButtonStyle(Qt::ToolButtonTextUnderIcon);
    m_pSimulateUserCaptureButton->setStyleSheet(GP_SessionViewButtonStyle);
    rc = connect(m_pSimulateUserCaptureButton, SIGNAL(clicked()), this, SLOT(OnSimulateCaptureButtonClick()));
    GT_ASSERT(rc);
    // pButtonsLayout->addWidget(m_pSimulateUserCaptureButton);
#endif

    pButtonsLayout->addWidget(m_pCaptureButton);
    pButtonsLayout->addWidget(m_pStopButton);
    pButtonsLayout->addWidget(m_pOpenTimelineButton);
    pButtonsLayout->addStretch();
    pImageFrameLayout->addLayout(pButtonsLayout, Qt::AlignCenter | Qt::AlignVCenter);
    pImageFrameLayout->addStretch();

    // Initialize and fill the thumbnail view
    m_pSnapshotsThumbView = new acThumbnailView;
    m_pSnapshotsThumbView->SetItemTooltip(GPU_STR_dashboard_ItemTooltip);

    rc = connect(m_pSnapshotsThumbView, SIGNAL(ItemDoubleClicked(const QVariant&)), this, SLOT(OnItemDoubleClicked(const QVariant&)));
    GT_ASSERT(rc);
    rc = connect(m_pSnapshotsThumbView, SIGNAL(ItemPressed(const QVariant&)), this, SLOT(OnItemPressed(const QVariant&)));
    GT_ASSERT(rc);

    pThumbLayout->addWidget(m_pCapturedFramesCaptionLabel);
    pThumbLayout->addWidget(m_pSnapshotsThumbView, Qt::AlignLeft);

    QWidget* pLeftWidget = new QWidget;
    QWidget* pRightWidget = new QWidget;
    pLeftWidget->setLayout(pImageLayout);
    pRightWidget->setLayout(pThumbLayout);
    pLeftWidget->setMinimumWidth(200);
    pRightWidget->setMinimumWidth(200);

    pMainLayout->addWidget(pLeftWidget, 0);
    pMainLayout->addWidget(pRightWidget, 1);

    setLayout(pMainLayout);
}
Esempio n. 11
0
MainWindow::MainWindow(DVRServerRepository *serverRepository, QWidget *parent)
    : QMainWindow(parent), m_serverRepository(serverRepository), m_trayIcon(0)
{
    Q_ASSERT(m_serverRepository);

    bcApp->mainWindow = this;
    connect(bcApp->eventDownloadManager(), SIGNAL(eventVideoDownloadAdded(EventVideoDownload*)),
            this, SLOT(showDownloadsWindow()));

    setUnifiedTitleAndToolBarOnMac(true);
	resize(1100, 750);
    createMenu();
    updateTrayIcon();
    setObjectName("MainWindow");

    statusBar()->addPermanentWidget(new StatusBandwidthWidget(statusBar()));
    statusBar()->addWidget(new StatusBarServerAlert(m_serverRepository, statusBar()));

#ifdef Q_OS_MAC
    statusBar()->setSizeGripEnabled(false);
    if (style()->inherits("QMacStyle"))
        statusBar()->setFixedHeight(24);
#endif

    /* Experimental toolbar */
    m_mainToolbar = new QToolBar(tr("Main"));
    m_mainToolbar->setMovable(false);
    m_mainToolbar->setIconSize(QSize(16, 16));
    m_mainToolbar->addAction(QIcon(QLatin1String(":/icons/cassette.png")), tr("Events"), this, SLOT(showEventsWindow()));
	m_expandAllServersAction = m_mainToolbar->addAction(QIcon(QLatin1String(":/icons/expand-all.png")), tr("Expand All Servers"));
	m_collapseAllServersAction = m_mainToolbar->addAction(QIcon(QLatin1String(":/icons/collapse-all.png")), tr("Collapse All Servers"));
    addToolBar(Qt::TopToolBarArea, m_mainToolbar);

    /* Splitters */
    m_leftSplit = new MacSplitter(Qt::Horizontal);
    m_centerSplit = new MacSplitter(Qt::Vertical);

    /* Live view */
    m_liveView = new LiveViewWindow(serverRepository, this);

    /* Recent events */
    QWidget *eventsWidget = createRecentEvents();

    /* Layouts */
    m_leftSplit->addWidget(createSourcesList());
    m_leftSplit->addWidget(m_centerSplit);
    m_leftSplit->setStretchFactor(1, 1);
    m_leftSplit->setCollapsible(0, false);
    m_leftSplit->setCollapsible(1, false);

    m_centerSplit->addWidget(m_liveView);
    m_centerSplit->addWidget(eventsWidget);
    m_centerSplit->setStretchFactor(0, 1);
    m_centerSplit->setCollapsible(0, false);
    m_centerSplit->setCollapsible(1, false);

    /* Set center widget */
    QWidget *center = new QWidget;
    QBoxLayout *centerLayout = new QVBoxLayout(center);
    centerLayout->setMargin(0);
    centerLayout->setSpacing(0);
    centerLayout->addWidget(m_leftSplit, 1);
    setCentralWidget(center);

#ifdef Q_OS_WIN
    /* There is no top border on the statusbar on Windows, and we need one. */
    if (style()->inherits("QWindowsStyle"))
    {
        QFrame *line = new QFrame;
        line->setFrameStyle(QFrame::Plain | QFrame::HLine);
        QPalette p = line->palette();
        p.setColor(QPalette::WindowText, QColor(171, 175, 183));
        line->setPalette(p);
        line->setFixedHeight(1);
        centerLayout->addWidget(line);
    }
#endif

    QSettings settings;
    bcApp->liveView->setBandwidthMode(settings.value(QLatin1String("ui/liveview/bandwidthMode")).toInt());
    restoreGeometry(settings.value(QLatin1String("ui/main/geometry")).toByteArray());
    if (!m_centerSplit->restoreState(settings.value(QLatin1String("ui/main/centerSplit")).toByteArray()))
    {
        m_centerSplit->setSizes(QList<int>() << 1000 << 130);
    }
    if (!m_leftSplit->restoreState(settings.value(QLatin1String("ui/main/leftSplit")).toByteArray()))
    {
#ifdef Q_OS_MAC
        m_leftSplit->setSizes(QList<int>() << 210 << 1000);
#else
        m_leftSplit->setSizes(QList<int>() << 190 << 1000);
#endif
    }

    m_leftSplit->setHandleWidth(2);
    m_centerSplit->setHandleWidth(2);

    QString lastLayout = settings.value(QLatin1String("ui/cameraArea/lastLayout"), tr("Default")).toString();
    m_liveView->setLayout(lastLayout);

    connect(m_liveView, SIGNAL(layoutChanged(QString)), SLOT(liveViewLayoutChanged(QString)));
    connect(m_leftSplit, SIGNAL(splitterMoved(int,int)), SLOT(updateToolbarWidth()));
    updateToolbarWidth();

    connect(bcApp, SIGNAL(sslConfirmRequired(DVRServer*,QList<QSslError>,QSslConfiguration)),
            SLOT(sslConfirmRequired(DVRServer*,QList<QSslError>,QSslConfiguration)));
    connect(bcApp, SIGNAL(queryLivePaused()), SLOT(queryLivePaused()));
    connect(m_serverRepository, SIGNAL(serverAdded(DVRServer*)), SLOT(onServerAdded(DVRServer*)));

    foreach (DVRServer *s, m_serverRepository->servers())
        onServerAdded(s);

    connect(qApp, SIGNAL(aboutToQuit()), SLOT(saveSettings()));

    m_sourcesList->setFocus(Qt::OtherFocusReason);

    connect(m_expandAllServersAction, SIGNAL(triggered()), m_sourcesList, SLOT(expandAll()));
    connect(m_collapseAllServersAction, SIGNAL(triggered()), m_sourcesList, SLOT(collapseAll()));

    retranslateUI();

    if (settings.value(QLatin1String("ui/saveSession"), false).toBool())
        m_liveView->restoreSession();
}