void QLogicCircuitShapeConnector::updatePosition()
{
    prepareGeometryChange();
    m_breakPoints = breakPoints();
    calcBoundingRect();
    update();
}
void LLToolTip::initFromParams(const LLToolTip::Params& p)
{
	LLPanel::initFromParams(p);

	// do this *after* we've had our size set in LLPanel::initFromParams();
	const S32 REALLY_LARGE_HEIGHT = 10000;
	mTextBox->reshape(p.max_width, REALLY_LARGE_HEIGHT);

	if (p.styled_message.isProvided())
	{
		for (LLInitParam::ParamIterator<LLToolTip::StyledText>::const_iterator text_it = p.styled_message.begin();
			text_it != p.styled_message.end();
			++text_it)
		{
			mTextBox->appendText(text_it->text(), false, text_it->style);
		}
	}
	else
	{
		mTextBox->setText(p.message());
	}

	S32 text_width = llmin(p.max_width(), mTextBox->getTextPixelWidth());
	S32 text_height = mTextBox->getTextPixelHeight();
	mTextBox->reshape(text_width, text_height);

	// reshape tooltip panel to fit text box
	LLRect tooltip_rect = calcBoundingRect();
	tooltip_rect.mTop += mPadding;
	tooltip_rect.mRight += mPadding;
	tooltip_rect.mBottom = 0;
	tooltip_rect.mLeft = 0;

	setShape(tooltip_rect);
}
Exemple #3
0
void NxTrigger::paint() {
    //Color
    if(cursorTrigged)
        color = colorTrigged;
    else if(active) {
        if(colorActive.isEmpty())                                                                                   color = colorActiveColor;
        else if((colorActive.startsWith("_")) && (Render::colors->contains(Application::colorsPrefix() + colorActive)))  color = Render::colors->value(Application::colorsPrefix() + colorActive);
        else if(Render::colors->contains(colorActive))                                                              color = Render::colors->value(colorActive);
        else                                                                                                        color = Qt::gray;
    }
    else {
        if(colorInactive.isEmpty())                                                                                     color = colorInactiveColor;
        else if((colorInactive.startsWith("_")) && (Render::colors->contains(Application::colorsPrefix() + colorInactive)))  color = Render::colors->value(Application::colorsPrefix() + colorInactive);
        else if(Render::colors->contains(colorInactive))                                                                color = Render::colors->value(colorInactive);
        else                                                                                                            color = Qt::gray;
    }
    color.setRgb (qBound(0., color.red()   * colorMultiplyColor.redF(),   255.),
                  qBound(0., color.green() * colorMultiplyColor.greenF(), 255.),
                  qBound(0., color.blue()  * colorMultiplyColor.blueF(),  255.),
                  qBound(0., color.alpha() * colorMultiplyColor.alphaF(), 255.));

    //Size of trigger
    if(cacheSize != Render::objectSize*size) {
        cacheSize = Render::objectSize*size;
        calcBoundingRect();
    }

    if((color.alpha() > 0) && (cacheSize > 0)) {
        if(selectedHover)   color = Render::colors->value(Application::colorsPrefix() + "_gui_object_hover");
        if(selected)        color = Render::colors->value(Application::colorsPrefix() + "_gui_object_selection");

        //Start
        if(!Application::allowSelectionTriggers)
            color.setAlphaF(color.alphaF()/3);

        if(Render::paintThisGroup)
            glColor4f(color.redF(), color.greenF(), color.blueF(), color.alphaF());
        else
            glColor4f(color.redF(), color.greenF(), color.blueF(), 0.1);


        glPushMatrix();
        glTranslatef(pos.x(), pos.y(), pos.z());
        glRotatef(Render::rotation.z(), 0, 0, -1);
        glRotatef(Render::rotation.x(), 0, -1, 0);
        glRotatef(Render::rotation.y(), -1, 0, 0);

        //Label
        if((Render::paintThisGroup) && (Application::paintLabel || selectedHover) && (!label.isEmpty()))
            Application::render->renderText(cacheSize * 1.2, cacheSize * 1.2, 0, label.toUpper(), Application::renderFont);
        else if(selectedHover)
            Application::render->renderText(cacheSize * 1.2, cacheSize * 1.2, 0, QString::number(id), Application::renderFont);
        if((selectedHover) && (!isDrag)) {
            qreal startY = -0.2 - cacheSize * 1.2;
            foreach(const QString & messageLabelItem, messageLabel) {
                Application::render->renderText(cacheSize * 1.2, startY, 0, messageLabelItem.trimmed(), Application::renderFont);
                startY -= 0.2 * Render::zoomLinear;
            }
        }
/**
 * Set the curve values from IFunction1D
 * @param domain :: Domain to set the x values
 * @param fun :: A IFunction which must be a IFunction1D
 */
void FunctionCurve::setData(const Numeric::FunctionDomain& domain, const Numeric::IFunction& fun)
{
  const Numeric::FunctionDomain1D* d1d = dynamic_cast<const Numeric::FunctionDomain1D*>(&domain);
  if ( !d1d )
  {
    throw std::invalid_argument("FunctionCurve: domain does not cast to FunctionDomain1D");
  }
  const Numeric::IFunction1D* f1d = dynamic_cast<const Numeric::IFunction1D*>(&fun);
  if ( !f1d )
  {
    throw std::invalid_argument("FunctionCurve: function does not cast to IFunction1D");
  }
  m_x.reset(new Numeric::FunctionDomain1DVector(*d1d));
  m_y.reset(*m_x);
  fun.function(domain,m_y);
  calcBoundingRect();
}
/**
 * Set the curve values from two std vectors. Throws invalid_argument if x and y have
 * different sizes or x values are not in ascending order.
 * @param x :: The x values
 * @param y :: The y values
 */
void FunctionCurve::setData(const std::vector<double>& x, const std::vector<double>& y)
{
  if ( x.size() != y.size() )
  {
    throw std::invalid_argument("FunctionCurve: trying to set values from vectors of different sizes");
  }
  for(size_t i = 1; i < x.size(); ++i)
  {
    if ( x[i] < x[i - 1] ) // strictly < allow repeating points
    {
      throw std::invalid_argument("FunctionCurve: x values must be in ascending order\n"
        "Line "+QString::number(i).toStdString());
    }
  }
  m_x.reset(new Numeric::FunctionDomain1DVector(x));
  m_y.reset(*m_x);
  m_y.setCalculated(y);
  calcBoundingRect();
}
Exemple #6
0
void NxCursor::calculate() {
    //Cursor line
    if((curve) && (curve->getPathLength() > 0)) {
        qreal timeReal = easing.getValue(time), timeOldReal = easing.getValue(timeOld);
        cursorPos = curve->getPointAt(timeReal) + curve->getPos();

        if(timeReal == 0)
            cursorAngle = -curve->getAngleAt(timeReal + 0.001);
        else if(timeReal == 1)
            cursorAngle = -curve->getAngleAt(timeReal - 0.001);
        else
            cursorAngle = -curve->getAngleAt(timeReal);

        cursorPosOld = curve->getPointAt(timeOldReal) + curve->getPos();

        if(timeOldReal == 0)
            cursorAngleOld = -curve->getAngleAt(timeOldReal + 0.001);
        else if(timeOldReal == 1)
            cursorAngleOld = -curve->getAngleAt(timeOldReal - 0.001);
        else
            cursorAngleOld = -curve->getAngleAt(timeOldReal);

        //Infos en +
        //NxPoint cursorPosDelta = cursorPosOld - cursorPos;
        //cursorAngleRoll = 0;//-qSin(cursorPosDelta.x() * M_PI) * 180 * 2;
        //cursorAnglePitch = 0;//qSin(cursorPosDelta.y() * M_PI) * 180 * 5;
    }
    else {
        cursorPos = pos;

        NxPoint cursorPosDelta = cursorPosOld - cursorPos;
        previousCursorReliable = true;
        previousPreviousCursorReliable = true;

        qreal angleZ = -qAtan2(cursorPosDelta.x(), cursorPosDelta.y()) * 180.0F / M_PI + 90;
        qreal angleY =  qAtan2(qSqrt(cursorPosDelta.x()*cursorPosDelta.x() + cursorPosDelta.y()*cursorPosDelta.y()), cursorPosDelta.z()) * 180.0F / M_PI + 90;
        cursorAngle = NxPoint(0, angleY, angleZ);
    }

    if(cursorAngle != cursorAngle)
        cursorAngle = NxPoint(0, 0, 0);
    cursorRelativePos = getCursorValue(cursorPos);

    //Cursor
    cursorPolyOld = cursorPoly;
    cursorPoly.replace(0, NxPoint(0, -width/2, -depth/2));
    cursorPoly.replace(1, NxPoint(0, -width/2,  depth/2));
    cursorPoly.replace(2, NxPoint(0,  width/2,  depth/2));
    cursorPoly.replace(3, NxPoint(0,  width/2, -depth/2));
    //Rotations + translations
    qreal angle, angleSin, angleCos;
    angle = cursorAngle.y() * M_PI / 180., angleSin = qSin(angle), angleCos = qCos(angle);
    cursorAngleCacheSinY = -angleSin;
    cursorAngleCacheCosY =  angleCos;
    for(quint16 i = 0 ; i < cursorPoly.count() ; i++)
        cursorPoly.replace(i, NxPoint(cursorPoly.at(i).z() * angleSin + cursorPoly.at(i).x() * angleCos,
                                      cursorPoly.at(i).y(),
                                      cursorPoly.at(i).z() * angleCos - cursorPoly.at(i).x() * angleSin));
    angle = cursorAngle.z() * M_PI / 180., angleSin = qSin(angle), angleCos = qCos(angle);
    cursorAngleCacheSinZ = -angleSin;
    cursorAngleCacheCosZ =  angleCos;
    for(quint16 i = 0 ; i < cursorPoly.count() ; i++)
        cursorPoly.replace(i, NxPoint(cursorPos.x() + cursorPoly.at(i).x() * angleCos - cursorPoly.at(i).y() * angleSin,
                                      cursorPos.y() + cursorPoly.at(i).x() * angleSin + cursorPoly.at(i).y() * angleCos,
                                      cursorPos.z() + cursorPoly.at(i).z()));

    calcBoundingRect();

    if((cursorPos.sx() != cursorPosOld.sx()) || (cursorPos.sy() != cursorPosOld.sy()) || (cursorPos.sz() != cursorPosOld.sz()))
        glListRecreate = true;
    if((curve) && (curve->getPathLength() > 0)) {
    }
    else {
        cursorPosOld = cursorPos;
        cursorAngleOld = cursorAngle;
    }
}