void FullViewConstraintView::paint(QPainter* painter,
                                   const QStyleOptionGraphicsItem* option,
                                   QWidget* widget)
{
    int min_w = static_cast<int>(minWidth());
    int max_w = static_cast<int>(maxWidth());
    int def_w = static_cast<int>(defaultWidth());

    QColor c;
    if(isSelected())
    {
        c = ScenarioStyle::instance().ConstraintSelected;
    }
    else if(parentItem()->isSelected())
    {
        c = ScenarioStyle::instance().ConstraintFullViewParentSelected;
    }
    else
    {
        c = ScenarioStyle::instance().ConstraintBase;
    }

    m_solidPen.setColor(c);
    m_dashPen.setColor(c);

    if(min_w == max_w)
    {
        painter->setPen(m_solidPen);
        painter->drawLine(0, 0, def_w, 0);
    }
    else
    {
        // Firs the line going from 0 to the min
        painter->setPen(m_solidPen);
        painter->drawLine(0, 0, min_w, 0);

        // The little hat
        painter->drawLine(min_w, -5, min_w, -15);
        painter->drawLine(min_w, -15, max_w, -15);
        painter->drawLine(max_w, -5, max_w, -15);

        // Finally the dashed line
        painter->setPen(m_dashPen);
        painter->drawLine(min_w, 0, max_w, 0);
    }
/*
    QLinearGradient gradient {qreal(max_w), 0, qreal(max_w + 200), 0};
    gradient.setColorAt(0, Qt::black);
    gradient.setColorAt(1, Qt::transparent);

    QBrush brush {gradient};
    painter->setBrush(brush);
    painter->setPen(QPen(brush, 4));

    painter->drawLine(max_w, 0, max_w + 200, 0);
    */
}
Esempio n. 2
0
HorizonBand::HorizonBand()
{
    m_scale = defaultScale();
    m_width = defaultWidth();
    m_offset = defaultOffset();

    m_color = defaultColor();
    m_bottomColor = defaultBottomColor();
}
Esempio n. 3
0
 // Default constructor
 SpectraCnPlotArgs() : BasePlotArgs(MIN_ARGS),
     mx_arg(""), x_max(DEFAULT_X_MAX), y_max(DEFAULT_Y_MAX), ignore_absent(DEFAULT_IGNORE_ABSENT), max_duplication(DEFAULT_DUPLICATION), columns("")
 {
     title = defaultTitle();
     x_label = defaultXLabel();
     y_label = defaultYLabel();
     width = defaultWidth();
     height = defaultHeight();
 }
Esempio n. 4
0
static void usage()
{
    qWarning() << "VNC Platform Integration options:";
    qWarning() << "    size=<Width>x<Height> - set the display width and height";
    qWarning() << "         defaults to" << defaultWidth() << "x" << defaultHeight();
    qWarning() << "    display=<ID> - set the VNC display port to ID + 5900";
    qWarning() << "         defaults to" << defaultDisplay();
    qWarning() << "    offset=<X>x<Y> - set the current screens offset";
    qWarning() << "    vnc - start configuration of a new screen";
    qWarning() << "         size and offset are inherited from the previous screen if not set";
    qWarning() << "         display id is incremented from the previous screen if not set";
    qWarning() << "    virtual - manage the set of screens as a virtual desktop";
}
Esempio n. 5
0
QVNCIntegration::QVNCIntegration(const QStringList& paramList)
    : virtualDesktop(false), fontDb(new QGenericUnixFontDatabase())
{
    int sizeX = defaultWidth();
    int sizeY = defaultHeight();
    int offsetX = 0;
    int offsetY = 0;
    int display = defaultDisplay();
    bool showUsage = false;

    foreach(QString confString, paramList) {
        if (confString.startsWith(QLatin1String("size="))) {
            QString val = confString.section(QLatin1Char('='), 1, 1);
            sizeX = val.section(QLatin1Char('x'), 0, 0).toInt();
            sizeY = val.section(QLatin1Char('x'), 1, 1).toInt();
        }
        else if (confString.startsWith(QLatin1String("display="))) {
            display = confString.section(QLatin1Char('='), 1, 1).toInt();
        }
        else if (confString.startsWith(QLatin1String("offset="))) {
            QString val = confString.section(QLatin1Char('='), 1, 1);
            offsetX = val.section(QLatin1Char('x'), 0, 0).toInt();
            offsetY = val.section(QLatin1Char('x'), 1, 1).toInt();
        }
        else if (confString == QLatin1String("vnc")) {
            QRect screenRect(offsetX, offsetY, sizeX, sizeY);
            QVNCScreen *screen = new QVNCScreen(screenRect, display);
            mScreens.append(screen);
            screen->setObjectName(QString("screen %1").arg(display));
            screen->setDirty(screenRect);
            ++display;
        }
        else if (confString == QLatin1String("virtual")) {
            virtualDesktop = true;
        }
        else {
            qWarning() << "Unknown VNC option:" << confString;
            showUsage = true;
        }
    }

    if (showUsage)
        usage();

    QRect screenRect(offsetX, offsetY, sizeX, sizeY);
    QVNCScreen *screen = new QVNCScreen(screenRect, display);
    mScreens.append(screen);
    mPrimaryScreen = qobject_cast<QVNCScreen *>(mScreens.first());
    screen->setObjectName(QString("screen %1").arg(display));
    screen->setDirty(screenRect);
}
Esempio n. 6
0
void HorizonBand::initialize(osg::StateSet *stateSet)
{
    if(!stateSet)
        return;

    u_params = new osg::Uniform("hbandParams", 
        osg::Vec3f(defaultScale(), defaultWidth(), defaultOffset()));

    u_color       = new osg::Uniform("hbandColor", defaultColor());
    u_bottomColor = new osg::Uniform("hbandBackground", defaultBottomColor());

    stateSet->addUniform(u_params);
    stateSet->addUniform(u_color);
    stateSet->addUniform(u_bottomColor);
};
Esempio n. 7
0
        const string optionsDescription() const
        {
            ostringstream help_str;

            help_str << " -p, --output_type=string    The plot file type to create: png, ps, pdf.  Warning... if pdf is selected" << endl
                     << "                             please ensure your gnuplot installation can export pdf files. (\"" << DEFAULT_OUTPUT_TYPE << "\")" << endl
                     << " -o, --output=string         Output file (\"" << defaultOutputPrefix() << "." << DEFAULT_OUTPUT_TYPE << "\")" << endl
                     << " -t, --title=string          Title for plot (\"" << defaultTitle() << "\")" << endl
                     << " -i, --x_label=string        Label for the x-axis (\"" << defaultXLabel() << "\")" << endl
                     << " -j, --y_label=string        Label for the y-axis (\"" << defaultYLabel() << "\")" << endl
                     << " -w, --width=uint16          Width of canvas (" << defaultWidth() << ")" << endl
                     << " -h, --height=uint16         Height of canvas (" << defaultHeight() << ")";

            return help_str.str();
        }
void TemporalConstraintView::paint(
        QPainter* painter,
        const QStyleOptionGraphicsItem*,
        QWidget*)
{
    qreal min_w = minWidth();
    qreal max_w = maxWidth();
    qreal def_w = defaultWidth();
    qreal play_w = playWidth();

    // Draw the stuff present if there is a rack *in the model* ?
    if(presenter().rack())
    {
        // Background
        auto rect = boundingRect();
        rect.adjust(0,15,0,-10);
        rect.setWidth(this->defaultWidth());
        painter->fillRect(rect, m_bgColor);

        // Fake timenode continuation
        auto color = ScenarioStyle::instance().RackSideBorder;
        QPen pen{color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin};
        painter->setPen(pen);
        painter->drawLine(rect.topLeft(), rect.bottomLeft());
        painter->drawLine(rect.topRight(), rect.bottomRight());
    }


    QPainterPath solidPath, dashedPath, leftBrace, rightBrace;

    // Paths
    if(infinite())
    {
        if(min_w != 0.)
        {
            solidPath.lineTo(min_w, 0);

            leftBrace.moveTo(min_w, -10);
            leftBrace.arcTo(min_w - 10, -10, 20, 20, 90, 180);
        }

        // TODO end state should be hidden
        dashedPath.moveTo(min_w, 0);
        dashedPath.lineTo(def_w, 0);
    }
    else if(min_w == max_w) // TODO rigid()
    {
        solidPath.lineTo(def_w, 0);
    }
    else
    {
        if(min_w != 0.)
            solidPath.lineTo(min_w, 0);

        dashedPath.moveTo(min_w, 0);
        dashedPath.lineTo(max_w, 0);

        leftBrace.moveTo(min_w + 10, -10);
        leftBrace.arcTo(min_w, -10, 20, 20, 90, 180);
        leftBrace.closeSubpath();

        rightBrace.moveTo(max_w, 10);
        rightBrace.arcTo(max_w - 10, -10, 20, 20, 270, 180);
        rightBrace.closeSubpath();
        rightBrace.translate(-10, 0); // TODO bleh.
    }

    QPainterPath playedPath;
    if(play_w != 0.)
    {
        playedPath.lineTo(play_w, 0);
    }

    // Colors
    QColor constraintColor;
    // TODO make a switch instead
    if(isSelected())
    {
        constraintColor = ScenarioStyle::instance().ConstraintSelected;
    }
    else if(warning())
    {
        constraintColor = ScenarioStyle::instance().ConstraintWarning;
    }
    else
    {
        constraintColor = ScenarioStyle::instance().ConstraintBase;
    }
    if(! isValid())
    {
        constraintColor = ScenarioStyle::instance().ConstraintInvalid;
        this->setZValue(this->zValue()+ 1);
    }
    else
    {
        this->setZValue(parentObject()->zValue() + 3);
    }

    m_solidPen.setColor(constraintColor);
    m_dashPen.setColor(constraintColor);

    // Drawing
    painter->setPen(m_solidPen);
    if(!solidPath.isEmpty())
        painter->drawPath(solidPath);
    if(!leftBrace.isEmpty())
        painter->drawPath(leftBrace);
    if(!rightBrace.isEmpty())
        painter->drawPath(rightBrace);

    painter->setPen(m_dashPen);
    if(!dashedPath.isEmpty())
        painter->drawPath(dashedPath);

    leftBrace.closeSubpath();
    rightBrace.closeSubpath();

    QPen anotherPen(Qt::transparent, 4);
    painter->setPen(anotherPen);
    QColor blueish = m_solidPen.color().lighter();
    blueish.setAlphaF(0.3);
    painter->setBrush(blueish);
    painter->drawPath(leftBrace);
    painter->drawPath(rightBrace);

    static const QPen playedPen{
        QBrush{ScenarioStyle::instance().ConstraintPlayFill},
        4,
        Qt::SolidLine,
                Qt::RoundCap,
                Qt::RoundJoin
    };

    painter->setPen(playedPen);
    if(!playedPath.isEmpty())
        painter->drawPath(playedPath);


    static const int fontSize = 12;
    QRectF labelRect{0,0, defaultWidth(), (-fontSize - 2.)};
    auto f = ProcessFonts::Sans();
    f.setPointSize(fontSize);

    painter->setFont(f);
    painter->setPen(m_labelColor);
    painter->drawText(labelRect, Qt::AlignCenter, m_label);

#if defined(ISCORE_SCENARIO_DEBUG_RECTS)
    painter->setPen(Qt::darkRed);
    painter->setBrush(Qt::NoBrush);
    painter->drawRect(boundingRect());
#endif
}
void TemporalConstraintView::paint(
        QPainter* painter,
        const QStyleOptionGraphicsItem* option,
        QWidget* widget)
{
    // Draw the rack bg
    if(auto rack = presenter().rack())
    {
        auto rackRect = rack->view().boundingRect();
        painter->fillRect(rackRect, QColor::fromRgba(qRgba(0, 127, 229, 76)));

        auto color = qApp->palette("ScenarioPalette").base().color();
        QPen pen{color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin};
        painter->setPen(pen);
        painter->drawLine(rackRect.topLeft(), rackRect.bottomLeft());
        painter->drawLine(rackRect.topRight(), rackRect.bottomRight());
    }


    QPainterPath solidPath, dashedPath, leftBrace, rightBrace;

//    m_endState->setPos(defaultWidth(), 0);

    // Paths
    if(infinite())
    {
        if(minWidth() != 0)
        {
            solidPath.lineTo(minWidth(), 0);

            leftBrace.moveTo(minWidth(), -10);
            leftBrace.arcTo(minWidth() - 10, -10, 20, 20, 90, 180);
        }

        // TODO end state should be hidden
        dashedPath.moveTo(minWidth(), 0);
        dashedPath.lineTo(defaultWidth(), 0);
    }
    else if(minWidth() == maxWidth()) // TODO rigid()
    {
        solidPath.lineTo(defaultWidth(), 0);
    }
    else
    {
        if(minWidth() != 0)
            solidPath.lineTo(minWidth(), 0);

        dashedPath.moveTo(minWidth(), 0);
        dashedPath.lineTo(maxWidth(), 0);

        leftBrace.moveTo(minWidth(), -10);
        leftBrace.arcTo(minWidth() - 10, -10, 20, 20, 90, 180);

        rightBrace.moveTo(maxWidth(), 10);
        rightBrace.arcTo(maxWidth() - 10, -10, 20, 20, 270, 180);
    }

    QPainterPath playedPath;
    if(playWidth() != 0)
    {
        playedPath.lineTo(playWidth(), 0);
    }

    // Colors
    QColor constraintColor;
    if(isSelected())
    {
        constraintColor = QColor::fromRgbF(0.188235, 0.54902, 0.776471);
    }
    else
    {
        constraintColor = qApp->palette("ScenarioPalette").base().color();
    }
    if(warning())
    {
        constraintColor = QColor{200,150,0};
    }
    if(! isValid())
    {
        constraintColor = Qt::red;
    }

    m_solidPen.setColor(constraintColor);
    m_dashPen.setColor(constraintColor);

    // Drawing
    painter->setPen(m_solidPen);
    if(!solidPath.isEmpty())
        painter->drawPath(solidPath);
    if(!leftBrace.isEmpty())
        painter->drawPath(leftBrace);
    if(!rightBrace.isEmpty())
        painter->drawPath(rightBrace);

    painter->setPen(m_dashPen);
    if(!dashedPath.isEmpty())
        painter->drawPath(dashedPath);

    leftBrace.closeSubpath();
    rightBrace.closeSubpath();

    QPen anotherPen(Qt::transparent, 4);
    painter->setPen(anotherPen);
    QColor blueish = m_solidPen.color().lighter();
    blueish.setAlphaF(0.3);
    painter->setBrush(blueish);
    painter->drawPath(leftBrace);
    painter->drawPath(rightBrace);

    static const QPen playedPen{
        QBrush{Qt::green},
        4,
        Qt::SolidLine,
                Qt::RoundCap,
                Qt::RoundJoin
    };
    static const QPen dashedPlayedPen{
        QBrush{Qt::green},
        4,
        Qt::DashLine,
                Qt::RoundCap,
                Qt::RoundJoin
    };

    painter->setPen(playedPen);
    if(!playedPath.isEmpty())
        painter->drawPath(playedPath);


    int fontSize = 12;
    QRectF labelRect{0,0, defaultWidth(), (-fontSize - 2.)};
    QFont f("Ubuntu");
    f.setPixelSize(fontSize);
    painter->setFont(f);
    painter->setPen(m_labelColor);
    painter->drawText(labelRect, Qt::AlignCenter, m_label);
/*
    painter->setPen(Qt::darkRed);
    painter->setBrush(Qt::NoBrush);
    painter->drawRect(boundingRect());
*/
}
Esempio n. 10
0
void TemporalConstraintView::paint(
        QPainter* painter,
        const QStyleOptionGraphicsItem*,
        QWidget*)
{
    auto& skin = ScenarioStyle::instance();

    qreal min_w = minWidth();
    qreal max_w = maxWidth();
    qreal def_w = defaultWidth();
    qreal play_w = playWidth();

    m_labelItem->setPos(def_w / 2. - m_labelItem->boundingRect().width() / 2., -17);
    m_counterItem->setPos(def_w - m_counterItem->boundingRect().width() - 5, 5);
    m_leftBrace->setX(min_w);
    m_rightBrace->setX(max_w);

    // Draw the stuff present if there is a rack *in the model* ?
    if(presenter().rack())
    {
        // Background
        auto rect = boundingRect();
        rect.adjust(0,4,0,-10);
        rect.setWidth(this->defaultWidth());

        QColor bgColor = m_bgColor.getColor();
        bgColor.setAlpha(m_hasFocus ? 84 : 76);
        painter->fillRect(rect, bgColor);

        // Fake timenode continuation
        auto color = skin.RackSideBorder.getColor();
        QPen pen{color, 2, Qt::SolidLine, Qt::RoundCap, Qt::RoundJoin};
        painter->setPen(pen);
        painter->drawLine(rect.topLeft(), rect.bottomLeft());
        painter->drawLine(rect.topRight(), rect.bottomRight());
    }


    QPainterPath solidPath, dashedPath, leftBrace, rightBrace;

    // Paths
    if(infinite())
    {
        if(min_w != 0.)
        {
            solidPath.lineTo(min_w, 0);

            m_leftBrace->show();
        }
        m_rightBrace->hide();

        // TODO end state should be hidden
        dashedPath.moveTo(min_w, 0);
        dashedPath.lineTo(def_w, 0);
    }
    else if(min_w == max_w) // TODO rigid()
    {
        solidPath.lineTo(def_w, 0);
        m_leftBrace->hide();
        m_rightBrace->hide();
    }
    else
    {
        if(min_w != 0.)
            solidPath.lineTo(min_w, 0);

        dashedPath.moveTo(min_w, 0);
        dashedPath.lineTo(max_w, 0);

        m_leftBrace->show();
        m_rightBrace->show();

    }

    QPainterPath playedPath;
    if(play_w != 0.)
    {
        playedPath.lineTo(std::min(play_w, std::max(def_w, max_w)), 0);
    }

    // Colors
    QColor constraintColor;
    // TODO make a switch instead
    if(isSelected())
    {
        constraintColor = skin.ConstraintSelected.getColor();
    }
    else if(warning())
    {
        constraintColor = skin.ConstraintWarning.getColor();
    }
    else
    {
        constraintColor = skin.ConstraintBase.getColor();
    }
    if(! isValid() || m_state == ConstraintExecutionState::Disabled)
    {
        constraintColor = skin.ConstraintInvalid.getColor();
    }


    m_solidPen.setColor(constraintColor);
    m_dashPen.setColor(constraintColor);

    // Drawing
    painter->setPen(m_solidPen);
    if(!solidPath.isEmpty())
        painter->drawPath(solidPath);

    painter->setPen(m_dashPen);
    if(!dashedPath.isEmpty())
        painter->drawPath(dashedPath);

    leftBrace.closeSubpath();
    rightBrace.closeSubpath();

    QPen anotherPen(Qt::transparent, 4);
    painter->setPen(anotherPen);
    QColor blueish = m_solidPen.color().lighter();
    blueish.setAlphaF(0.3);
    painter->setBrush(blueish);


    const QPen playedPen{
        skin.ConstraintPlayFill.getColor(),
        4,
        Qt::SolidLine,
                Qt::RoundCap,
                Qt::RoundJoin
    };

    painter->setPen(playedPen);
    if(!playedPath.isEmpty())
        painter->drawPath(playedPath);

    {
        auto& dur = presenter().model().duration;
        auto progress = dur.defaultDuration() * dur.playPercentage();
        if(!progress.isZero())
        {
            QString percent = progress.toString();
            m_counterItem->setText(percent);
        }
    }


#if defined(ISCORE_SCENARIO_DEBUG_RECTS)
    painter->setPen(Qt::darkRed);
    painter->setBrush(Qt::NoBrush);
    painter->drawRect(boundingRect());
#endif
}
Esempio n. 11
0
File: ui.cpp Progetto: JUX84/3tXc4
void ui ( void ) { // main menu

	uint8_t selected ( 1 );
	uint8_t defaultHeight ( 5 );
	uint8_t defaultWidth ( 5 );
	uint8_t defaultAlignWinSize ( 5 );
	uint8_t defaultAlignWinTotal ( 1 );
	uint8_t defaultAI_prof ( 3 );
	int32_t Key;
	uint8_t row , col;

	while ( true ) {

		clear ();

		getmaxyx ( stdscr , row , col );

		if ( selected < 1 )
			selected = 1;

		if ( selected > 3 )
			selected = 3;

		attron ( A_BOLD );

		mvprintw ( row / 4 , ( col - STR_TITLE_GAME.length () + 1 ) / 2 , STR_TITLE_GAME.c_str () );

		mvprintw ( ( row / 2 ) + ( ( selected - 1 ) * 2 ) , 5 * col / 20 , STR_ARROW_RIGHT.c_str () );
		mvprintw ( ( row / 2 ) + ( ( selected - 1 ) * 2 ) , 15 * col / 20 , STR_ARROW_LEFT.c_str () );

		mvprintw ( 2 , 2 , STR_HELP.c_str () );

		attroff ( A_BOLD );

		mvprintw ( row / 2 , ( col - STR_PLAY.length () + 1 ) / 2 , STR_PLAY.c_str () );
		mvprintw ( ( row / 2 ) + 2 , ( col - STR_OPTIONS.length () + 1 ) / 2 , STR_OPTIONS.c_str () );
		mvprintw ( ( row / 2 ) + 4 , ( col - STR_EXIT.length () + 1 ) / 2 , STR_EXIT.c_str () );

		refresh();

		Key = getch ();

		if ( Key == KEY_DOWN )
			selected += 1;

		if ( Key == KEY_UP )
			selected -= 1;

		if ( Key == ENTER ) {

			if ( selected == 1 ) {

				play_menu ( defaultHeight , defaultWidth , defaultAlignWinSize , defaultAlignWinTotal , defaultAI_prof );
			}

			if ( selected == 2 )
				options ( defaultHeight , defaultWidth , defaultAlignWinSize , defaultAlignWinTotal , defaultAI_prof );

			if ( selected == 3 ) {
				if ( warnExit () ) {
					endwin ();
					return;
				}
			}
		}

		if ( Key == KEY_P ) {

			play_menu ( defaultHeight , defaultWidth , defaultAlignWinSize , defaultAlignWinTotal , defaultAI_prof );
		}

		if ( Key == KEY_O )
			options ( defaultHeight , defaultWidth , defaultAlignWinSize , defaultAlignWinTotal , defaultAI_prof );

		if ( Key == ESC || Key == KEY_E ) {
			if ( warnExit () ) {
				endwin ();
				return;
			}
		}

		if ( Key == KEY_F ( 5 ) )
			ui_help ();
	}
}