Beispiel #1
0
knob::knob( int _knob_num, QWidget * _parent, const QString & _name ) :
	QWidget( _parent ),
	FloatModelView( new FloatModel( 0, 0, 0, 1, NULL, _name, true ), this ),
	m_knobNum( _knob_num ),
	m_label( "" ),
	m_knobPixmap( NULL ),
	m_volumeKnob( false ),
	m_volumeRatio( 100.0, 0.0, 1000000.0 ),
	m_buttonPressed( false ),
	m_angle( -10 ),
	m_outerColor( NULL )
{
	if( s_textFloat == NULL )
	{
		s_textFloat = new textFloat;
	}

	setWindowTitle( _name );

	if( m_knobNum != knobStyled )
	{
		m_knobPixmap = new QPixmap( embed::getIconPixmap( QString( "knob0" +
			QString::number( m_knobNum + 1 ) ).toUtf8().constData() ) );

		setFixedSize( m_knobPixmap->width(), m_knobPixmap->height() );
	}
	setTotalAngle( 270.0f );
	setInnerRadius( 1.0f );
	setOuterRadius( 10.0f );
	setFocusPolicy( Qt::ClickFocus );
	doConnections();
}
Beispiel #2
0
//------------------------------------------------------------------------------
// updateData() - updates the values
//------------------------------------------------------------------------------
void MapPage::updateData(const LCreal dt)
{
   // find our nearest map page above us and get the data from it!
   MapPage* page = static_cast<MapPage*>(findContainerByType(typeid(MapPage)));
   if (page != nullptr) {
      setHeadingDeg(page->getHeadingDeg());
      setDisplacement(page->getDisplacement());
      setReferenceLatDeg(page->getReferenceLatDeg());
      setReferenceLonDeg(page->getReferenceLonDeg());
      setOuterRadius(page->getOuterRadius());
      setOuterRadiusDC(page->getOuterRadiusDC());
      setCentered(page->getCentered());
      setRange(page->getRange());
      setNorthUp(page->getNorthUp());
      nm2Screen = page->getScale();
   }
   // if we are the top map page, we do the calculations ourself
   else {
      // determine if we are centered or not, and set our displacement and radius accordingly
      if (isCentered) nm2Screen = outerRadius / range;
      else nm2Screen = outerRadiusDC / range;
   }

   // update base class stuff
   BaseClass::updateData(dt);
}
Beispiel #3
0
//------------------------------------------------------------------------------
// setSlotOuterRadius() - sets the OUTER dial radius
//------------------------------------------------------------------------------
bool DialArcSegment::setSlotOuterRadius(const base::Number* const x)
{
    if (x != nullptr) {
        return setOuterRadius(x->getFloat());
    }
    return false;
}
Beispiel #4
0
sk_sp<sksg::GeometryNode> AttachPolystarGeometry(const Json::Value& jstar, AttachContext* ctx) {
    SkASSERT(jstar.isObject());

    static constexpr PolyStarAdapter::Type gTypes[] = {
        PolyStarAdapter::Type::kStar, // "sy": 1
        PolyStarAdapter::Type::kPoly, // "sy": 2
    };

    const auto type = ParseDefault(jstar["sy"], 0) - 1;
    if (type < 0 || type >= SkTo<int>(SK_ARRAY_COUNT(gTypes))) {
        LogFail(jstar, "Unknown polystar type");
        return nullptr;
    }

    auto path_node = sksg::Path::Make();
    auto adapter = sk_make_sp<PolyStarAdapter>(path_node, gTypes[type]);

    BindProperty<VectorValue>(jstar["p"], &ctx->fAnimators,
        [adapter](const VectorValue& p) {
            adapter->setPosition(ValueTraits<VectorValue>::As<SkPoint>(p));
        });
    BindProperty<ScalarValue>(jstar["pt"], &ctx->fAnimators,
        [adapter](const ScalarValue& pt) {
            adapter->setPointCount(pt);
        });
    BindProperty<ScalarValue>(jstar["ir"], &ctx->fAnimators,
        [adapter](const ScalarValue& ir) {
            adapter->setInnerRadius(ir);
        });
    BindProperty<ScalarValue>(jstar["or"], &ctx->fAnimators,
        [adapter](const ScalarValue& otr) {
            adapter->setOuterRadius(otr);
        });
    BindProperty<ScalarValue>(jstar["is"], &ctx->fAnimators,
        [adapter](const ScalarValue& is) {
            adapter->setInnerRoundness(is);
        });
    BindProperty<ScalarValue>(jstar["os"], &ctx->fAnimators,
        [adapter](const ScalarValue& os) {
            adapter->setOuterRoundness(os);
        });
    BindProperty<ScalarValue>(jstar["r"], &ctx->fAnimators,
        [adapter](const ScalarValue& r) {
            adapter->setRotation(r);
        });

    return path_node;
}
int Torus::addValues(string attr, string val){

	if(attr == "inner"){
		setInnerRadius(atof(val.c_str()));
	}else{
		if(attr == "outer"){
			setOuterRadius(atof(val.c_str()));
		}else{
			if(attr == "slices"){
				setSlices(atoi(val.c_str()));
			}else{
				if(attr == "loops"){
					setLoops(atoi(val.c_str()));
					return 1;
				}
			}
		}
	}
	return 0;
}
Beispiel #6
0
void Circle3DOverlay::setProperties(const QScriptValue &properties) {
    Planar3DOverlay::setProperties(properties);

    QScriptValue startAt = properties.property("startAt");
    if (startAt.isValid()) {
        setStartAt(startAt.toVariant().toFloat());
    }

    QScriptValue endAt = properties.property("endAt");
    if (endAt.isValid()) {
        setEndAt(endAt.toVariant().toFloat());
    }

    QScriptValue outerRadius = properties.property("outerRadius");
    if (outerRadius.isValid()) {
        setOuterRadius(outerRadius.toVariant().toFloat());
    }

    QScriptValue innerRadius = properties.property("innerRadius");
    if (innerRadius.isValid()) {
        setInnerRadius(innerRadius.toVariant().toFloat());
    }

    QScriptValue hasTickMarks = properties.property("hasTickMarks");
    if (hasTickMarks.isValid()) {
        setHasTickMarks(hasTickMarks.toVariant().toBool());
    }

    QScriptValue majorTickMarksAngle = properties.property("majorTickMarksAngle");
    if (majorTickMarksAngle.isValid()) {
        setMajorTickMarksAngle(majorTickMarksAngle.toVariant().toFloat());
    }

    QScriptValue minorTickMarksAngle = properties.property("minorTickMarksAngle");
    if (minorTickMarksAngle.isValid()) {
        setMinorTickMarksAngle(minorTickMarksAngle.toVariant().toFloat());
    }

    QScriptValue majorTickMarksLength = properties.property("majorTickMarksLength");
    if (majorTickMarksLength.isValid()) {
        setMajorTickMarksLength(majorTickMarksLength.toVariant().toFloat());
    }

    QScriptValue minorTickMarksLength = properties.property("minorTickMarksLength");
    if (minorTickMarksLength.isValid()) {
        setMinorTickMarksLength(minorTickMarksLength.toVariant().toFloat());
    }

    QScriptValue majorTickMarksColor = properties.property("majorTickMarksColor");
    if (majorTickMarksColor.isValid()) {
        QScriptValue red = majorTickMarksColor.property("red");
        QScriptValue green = majorTickMarksColor.property("green");
        QScriptValue blue = majorTickMarksColor.property("blue");
        if (red.isValid() && green.isValid() && blue.isValid()) {
            _majorTickMarksColor.red = red.toVariant().toInt();
            _majorTickMarksColor.green = green.toVariant().toInt();
            _majorTickMarksColor.blue = blue.toVariant().toInt();
        }
    }

    QScriptValue minorTickMarksColor = properties.property("minorTickMarksColor");
    if (minorTickMarksColor.isValid()) {
        QScriptValue red = minorTickMarksColor.property("red");
        QScriptValue green = minorTickMarksColor.property("green");
        QScriptValue blue = minorTickMarksColor.property("blue");
        if (red.isValid() && green.isValid() && blue.isValid()) {
            _minorTickMarksColor.red = red.toVariant().toInt();
            _minorTickMarksColor.green = green.toVariant().toInt();
            _minorTickMarksColor.blue = blue.toVariant().toInt();
        }
    }
}
Beispiel #7
0
// SLOT FUNCTIONS
//------------------------------------------------------------------------------
// setSlotOuterRadius() - sets the outer radius of our compass rose, if we
// are centered
//------------------------------------------------------------------------------
bool MapPage::setSlotOuterRadius(const Basic::Number* const newRadius)
{
   bool ok = false;
   if (newRadius != nullptr) ok = setOuterRadius(newRadius->getReal());
   return ok;
}
Beispiel #8
0
//------------------------------------------------------------------------------
// onUpdateOuterRadius() - set our new outer map area
//------------------------------------------------------------------------------
bool MapPage::onUpdateOuterRadius(const Basic::Number* const newR)
{
   bool ok = false;
   if (newR != nullptr) ok = setOuterRadius(newR->getReal());
   return ok;
}
Beispiel #9
0
Knob::Knob( knobTypes _knob_num, QWidget * _parent, const QString & _name ) :
	DEFAULT_KNOB_INITIALIZER_LIST,
	m_knobNum( _knob_num )
{
	initUi( _name );
}

Knob::Knob( QWidget * _parent, const QString & _name ) :
	DEFAULT_KNOB_INITIALIZER_LIST,
	m_knobNum( knobBright_26 )
{
	initUi( _name );
}

#undef DEFAULT_KNOB_INITIALIZER_LIST




void Knob::initUi( const QString & _name )
{
	if( s_textFloat == NULL )
	{
		s_textFloat = new TextFloat;
	}

	setWindowTitle( _name );

	onKnobNumUpdated();
	setTotalAngle( 270.0f );
	setInnerRadius( 1.0f );
	setOuterRadius( 10.0f );
	setFocusPolicy( Qt::ClickFocus );

	// This is a workaround to enable style sheets for knobs which are not styled knobs.
	//
	// It works as follows: the palette colors that are assigned as the line color previously
	// had been hard coded in the drawKnob method for the different knob types. Now the
	// drawKnob method uses the line color to draw the lines. By assigning the palette colors
	// as the line colors here the knob lines will be drawn in this color unless the stylesheet
	// overrides that color.
	switch (knobNum())
	{
	case knobSmall_17:
	case knobBright_26:
	case knobDark_28:
		setlineColor(QApplication::palette().color( QPalette::Active, QPalette::WindowText ));
		break;
	case knobVintage_32:
		setlineColor(QApplication::palette().color( QPalette::Active, QPalette::Shadow ));
		break;
	default:
		break;
	}

	doConnections();
}




void Knob::onKnobNumUpdated()
{
	if( m_knobNum != knobStyled )
	{
		QString knobFilename;
		switch (m_knobNum)
		{
		case knobDark_28:
			knobFilename = "knob01";
			break;
		case knobBright_26:
			knobFilename = "knob02";
			break;
		case knobSmall_17:
			knobFilename = "knob03";
			break;
		case knobVintage_32:
			knobFilename = "knob05";
			break;
		case knobStyled: // only here to stop the compiler from complaining
			break;
		}

		// If knobFilename is still empty here we should get the fallback pixmap of size 1x1
		m_knobPixmap = new QPixmap( embed::getIconPixmap( knobFilename.toUtf8().constData() ) );

		setFixedSize( m_knobPixmap->width(), m_knobPixmap->height() );
	}
}




Knob::~Knob()
{
	if( m_knobPixmap )
	{
		delete m_knobPixmap;
	}
}




void Knob::setLabel( const QString & txt )
{
	m_label = txt;
	if( m_knobPixmap )
	{
		setFixedSize( qMax<int>( m_knobPixmap->width(),
					QFontMetrics( pointSizeF( font(), 6.5) ).width( m_label ) ),
						m_knobPixmap->height() + 10 );
	}
	update();
}
Beispiel #10
0
// Set slot functions
bool OcclusionArc::setSlotOuterRadius(const Basic::Number* const x)
{
    bool ok = false;
    if (x != nullptr) ok = setOuterRadius(x->getReal());
    return ok;
}