Exemple #1
0
   /*! \brief Construct a TreeView object and initialize it.
    * \author Ingemar Axelsson
    *
    * For parameter information, see the Qt manual.
    */
   TreeView::TreeView(QWidget *parent)
      :QWidget(parent),
       selected_(false),
       closed_(false),
     selectedColor_(QColor(160,160,160))
   {
      setFixedWidth(std::max(12,logicalDpiX()/9));
      setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding));

      setBackgroundRole( QPalette::Base );
   }
void Matrix::exportRasterImage(const QString& fileName, int quality, int dpi)
{
	if (!dpi)
		dpi = logicalDpiX();

	QImage image = d_matrix_model->renderImage();
	int dpm = (int)ceil(100.0/2.54*dpi);
	image.setDotsPerMeterX(dpm);
	image.setDotsPerMeterY(dpm);
	image.save(fileName, 0, quality);
}
Exemple #3
0
GLGaze::GLGaze(Store* st)
{
    // Make our GL Gaze widget self-contained.
    setWindowTitle("GorgonEye - Gaze Control");
    setWindowFlags(Qt::FramelessWindowHint);
    setFrameShape(QFrame::NoFrame);

    // Create new viewport with OpenGL capabilities
    setViewport(new QGLWidget(QGLFormat(QGL::SampleBuffers)));
    setViewportUpdateMode(QGraphicsView::FullViewportUpdate);

    // Create scene and attempt to use full screen res for training/gaze estimation
    setScene(new GLGazeScene(st, DPI_SCALE, logicalDpiX(), logicalDpiY()));
    setGeometry(QApplication::desktop()->screenGeometry()); // other: availableGeometry
}
Exemple #4
0
void AbstractController::createAndAddWidget( QBoxLayout *controlLayout_,
                                             int i_index,
                                             buttonType_e i_type,
                                             int i_option )
{
    VLC_UNUSED( i_index ); // i_index should only be required for edition

    /* Close the current buttonGroup if we have a special widget or a spacer */
    if( buttonGroupLayout && i_type > BUTTON_MAX )
    {
        controlLayout_->addLayout( buttonGroupLayout );
        buttonGroupLayout = NULL;
    }

    qreal scalingFactorX = static_cast<qreal>(logicalDpiX())/DPI_REF_VALUE;
    /* Special case for SPACERS, who aren't QWidgets */
    if( i_type == WIDGET_SPACER )
    {
        controlLayout_->addSpacing( static_cast<int>(12*scalingFactorX) );
    }
    else if(  i_type == WIDGET_SPACER_EXTEND )
    {
        controlLayout_->addStretch( static_cast<int>(12*scalingFactorX) );
    }
    else
    {
        /* Create the widget */
        QWidget *widg = createWidget( i_type, i_option );
        if( !widg ) return;

        /* Buttons */
        if( i_type < BUTTON_MAX )
        {
            if( !buttonGroupLayout )
            {
                buttonGroupLayout = new QHBoxLayout;

            }
            buttonGroupLayout->addWidget( widg );
        }
        else /* Special widgets */
        {
            controlLayout_->addWidget( widg );
        }
    }
}
void Matrix::exportRasterImage(const QString& fileName, int quality, int dpi)
{
	if (!dpi)
		dpi = logicalDpiX();

	QImage image = d_matrix_model->renderImage();
	int dpm = (int)ceil(100.0/2.54*dpi);
	image.setDotsPerMeterX(dpm);
	image.setDotsPerMeterY(dpm);
	if (fileName.endsWith(".odf")){
		QTextDocument *document = new QTextDocument();
		QTextCursor cursor = QTextCursor(document);
		cursor.movePosition(QTextCursor::End);
		cursor.insertText(objectName());
		cursor.insertBlock();
		cursor.insertImage(image);

		QTextDocumentWriter writer(fileName);
		writer.write(document);
	} else
		image.save(fileName, 0, quality);
}
Exemple #6
0
/*!
    Maps \a point from viewport co-ordinates to eye co-ordinates.

    The returned vector will have its x and y components set to the
    position of the point on the near plane, and the z component
    set to the inverse of the camera's near plane.

    This function is used for converting a mouse event's position
    into eye co-ordinates within the current camera view.

    \sa QGLCamera::mapPoint()
*/
QVector3D QGLView::mapPoint(const QPoint &point) const
{
    QSize viewportSize(size());
    qreal aspectRatio;

    // Get the size of the underlying paint device.
    int width = viewportSize.width();
    int height = viewportSize.height();

    // Use the device's DPI setting to determine the pixel aspect ratio.
    int dpiX = logicalDpiX();
    int dpiY = logicalDpiY();
    if (dpiX <= 0 || dpiY <= 0)
        dpiX = dpiY = 1;

    // Derive the aspect ratio based on window and pixel size.
    if (width <= 0 || height <= 0)
        aspectRatio = 1.0f;
    else
        aspectRatio = ((qreal)(width * dpiY)) / ((qreal)(height * dpiX));

    // Map the point into eye co-ordinates.
    return d->camera->mapPoint(point, aspectRatio, viewportSize);
}
Exemple #7
0
SoundSlider::SoundSlider( QWidget *_parent, float _i_step,
                          char *psz_colors, int max )
                        : QAbstractSlider( _parent )
{
    qreal scalingFactorX = static_cast<qreal>(logicalDpiX()) / DPI_REF_VALUE;
    qreal scalingFactorY = static_cast<qreal>(logicalDpiY()) / DPI_REF_VALUE;

    wlength = WLENGTH_BASE * scalingFactorX;
    wheight = WHEIGHT_BASE * scalingFactorY;

    f_step = (float)(_i_step * 10000)
           / (float)((max - SOUNDMIN) * AOUT_VOLUME_DEFAULT);
    setRange( SOUNDMIN, max);
    setMouseTracking( true );
    isSliding = false;
    b_mouseOutside = true;
    b_isMuted = false;

    const QPixmap pixOutsideRaw(Helper::getIconPath("volume-slider-outside.png"));
    const QSize pixOutsideSize(
                static_cast<qreal>(pixOutsideRaw.width()) * scalingFactorX,
                static_cast<qreal>(pixOutsideRaw.height()) * scalingFactorY
            );
    pixOutside = pixOutsideRaw.scaled(pixOutsideSize);

    const QPixmap tempRaw(Helper::getIconPath("volume-slider-inside.png"));
    const QSize tempSize(
                    static_cast<qreal>(tempRaw.width()) * scalingFactorX,
                    static_cast<qreal>(tempRaw.height()) * scalingFactorY
            );
    const QPixmap temp = tempRaw.scaled(tempSize);

    const QBitmap mask( temp.createHeuristicMask() );

    setFixedSize( pixOutside.size() );

    pixGradient = QPixmap( mask.size() );
    pixGradient2 = QPixmap( mask.size() );

    /* Gradient building from the preferences */
    QLinearGradient gradient( paddingL, 2, wlength + paddingL , 2 );
    QLinearGradient gradient2( paddingL, 2, wlength + paddingL , 2 );

    QStringList colorList = qfu( psz_colors ).split( ";" );
    free( psz_colors );

    /* Fill with 255 if the list is too short */
    if( colorList.count() < 12 )
        for( int i = colorList.count(); i < 12; i++)
            colorList.append( "255" );

    background = palette().color( QPalette::Active, QPalette::Window );
    foreground = palette().color( QPalette::Active, QPalette::WindowText );
    foreground.setHsv( foreground.hue(),
                    ( background.saturation() + foreground.saturation() ) / 2,
                    ( background.value() + foreground.value() ) / 2 );

    textfont.setPointSize( 9 );
    textrect.setRect( 0, 0, 34.0*scalingFactorX, 15.0*scalingFactorY );

    /* Regular colors */
#define c(i) colorList.at(i).toInt()
#define add_color(gradient, range, c1, c2, c3) \
    gradient.setColorAt( range, QColor( c(c1), c(c2), c(c3) ) );

    /* Desaturated colors */
#define desaturate(c) c->setHsvF( c->hueF(), 0.2 , 0.5, 1.0 )
#define add_desaturated_color(gradient, range, c1, c2, c3) \
    foo = new QColor( c(c1), c(c2), c(c3) );\
    desaturate( foo ); gradient.setColorAt( range, *foo );\
    delete foo;

    /* combine the two helpers */
#define add_colors( gradient1, gradient2, range, c1, c2, c3 )\
    add_color( gradient1, range, c1, c2, c3 ); \
    add_desaturated_color( gradient2, range, c1, c2, c3 );

    float f_mid_point = ( 100.0 / maximum() );
    QColor * foo;
    add_colors( gradient, gradient2, 0.0, 0, 1, 2 );
    if (f_mid_point + 0.05 <= 1.0) {
        add_colors( gradient, gradient2, f_mid_point - 0.05, 3, 4, 5 );
        add_colors( gradient, gradient2, f_mid_point + 0.05, 6, 7, 8 );
    }
    add_colors( gradient, gradient2, 1.0, 9, 10, 11 );

    painter.begin( &pixGradient );
    painter.setPen( Qt::NoPen );
    painter.setBrush( gradient );
    painter.drawRect( pixGradient.rect() );
    painter.end();

    painter.begin( &pixGradient2 );
    painter.setPen( Qt::NoPen );
    painter.setBrush( gradient2 );
    painter.drawRect( pixGradient2.rect() );
    painter.end();

    pixGradient.setMask( mask );
    pixGradient2.setMask( mask );
}