QEnergyStatWidget::QEnergyStatWidget( QWidget* parent, simulation::Node* node )
    : QGraphStatWidget( parent, node, "Energy", 3 )
{
    setCurve( 0, "Kinetic", Qt::red );
    setCurve( 1, "Potential", Qt::green );
    setCurve( 2, "Mechanical", Qt::blue );

    m_energyVisitor   = new sofa::simulation::MechanicalComputeEnergyVisitor(core::MechanicalParams::defaultInstance());
}
void MixerCurve::CurveMinChanged(double value)
{
    QList<double> points = m_curve->getCurve();
    points.removeFirst();
    points.push_front(value);
    setCurve(&points);
}
void KisBrightnessContrastFilterConfiguration::fromXML(const QDomElement& root)
{
    KisCubicCurve curve;
    int version;
    version  = root.attribute("version").toInt();

    QDomElement e = root.firstChild().toElement();
    QString attributeName;

    while (!e.isNull()) {
        if ((attributeName = e.attribute("name")) != "nTransfers") {
            QRegExp rx("curve(\\d+)");
            if (rx.indexIn(attributeName, 0) != -1) {
                quint16 index = rx.cap(1).toUShort();

                if (index == 0 && !e.text().isEmpty()) {
                    /**
                     * We are going to use first curve only
                     */
                    curve.fromString(e.text());
                }
            }
        }
        e = e.nextSiblingElement();
    }

    setVersion(version);
    setCurve(curve);
}
Exemple #4
0
 DiodeNode::DiodeNode(WebCore::AudioContext* context)
 : vb(0.2f)
 , vl(0.4f)
 , h(1.0)
 {
     waveShaper = context->createWaveShaper();
     setCurve();
 }
 /**
   Decompose the \c curve into segments.
   \return the partiton of the curve as a set of segments.
  */
 std::vector<Segment> decomposeCurve(const Curve & curve)
 {
   std::vector<Segment> result;
   const Curve * myCurveBak = myCurve;
   setCurve(&curve);
   result = decomposeCurve();
   myCurve = myCurveBak;
   return result;
 }
void MixerCurve::CurveMaxChanged(double value)
{
    // the max changed so redraw the curve
    // mixercurvewidget::setCurve will trim any points above max
    QList<double> points = m_curve->getCurve();
    points.removeLast();
    points.append(value);
    setCurve(&points);
}
void ofxAnimatableOfColor::startBlinking( float blinkDuration) {

    setRepeatType(LOOP_BACK_AND_FORTH);
    setCurve(EASE_IN_EASE_OUT);
    setAlphaOnly(0.0f);
    setDuration( blinkDuration );
    ofColor c = getCurrentColor();
    c.a = 255;
    animateTo( c );
}
Exemple #8
0
void MixerCurve::GenerateCurve()
{
   double scale;
   double newValue;

   //get the user settings
   double value1 = getCurveMin();
   double value2 = getCurveMax();
   double value3 = getCurveStep();

   m_curve->setCommandText("StepValue", QString("%0").arg(value3));

   QString CurveType = m_mixerUI->CurveType->currentText();

   QList<double> points;

   for (int i=0; i<MixerCurveWidget::NODE_NUMELEM; i++)
   {
       scale =((double)i/(double)(MixerCurveWidget::NODE_NUMELEM - 1));

       if ( CurveType.compare("Flat")==0)
       {
           points.append(value3);
       }
       if ( CurveType.compare("Linear")==0)
       {
           newValue =value1 +(scale*(value2-value1));
           points.append(newValue);
       }
       if ( CurveType.compare("Step")==0)
       {
           if (scale*100<value3)
           {
               points.append(value1);
           }
           else
           {
               points.append(value2);
           }
       }
       if ( CurveType.compare("Exp")==0)
       {
           newValue =value1 +(((exp(scale*(value3/10))-1))/(exp((value3/10))-1)*(value2-value1));
           points.append(newValue);
       }
       if ( CurveType.compare("Log")==0)
       {
           newValue = value1 +(((log(scale*(value3*2)+1))/(log(1+(value3*2))))*(value2-value1));
           points.append(newValue);
       }
   }

   setCurve(&points);
}
Exemple #9
0
QMomentumStatWidget::QMomentumStatWidget( QWidget* parent, simulation::Node* node ) : QGraphStatWidget( parent, node, "Momenta", 6 )
{
    setCurve( 0, "Linear X", Qt::red );
    setCurve( 1, "Linear Y", Qt::green );
    setCurve( 2, "Linear Z", Qt::blue );
    setCurve( 3, "Angular X", Qt::cyan );
    setCurve( 4, "Angular Y", Qt::magenta );
    setCurve( 5, "Angular Z", Qt::yellow );

    m_momentumVisitor = new simulation::MechanicalGetMomentumVisitor(core::MechanicalParams::defaultInstance());
}
Exemple #10
0
ProcessModel::ProcessModel(
        const ProcessModel& source,
        const Id<Process::ProcessModel>& id,
        QObject* parent):
    Curve::CurveProcessModel{source, id, Metadata<ObjectKey_k, ProcessModel>::get(), parent},
    m_address(source.address()),
    m_min{source.min()},
    m_max{source.max()},
    m_startState{new ProcessState{*this, 0., this}},
    m_endState{new ProcessState{*this, 1., this}}
{
    setCurve(source.curve().clone(source.curve().id(), this));
    pluginModelList = new iscore::ElementPluginModelList(*source.pluginModelList, this);
    connect(m_curve, &Curve::Model::changed,
            this, &ProcessModel::curveChanged);
    metadata.setName(QString("Automation.%1").arg(*this->id().val()));
}
Exemple #11
0
ProcessModel::ProcessModel(
        const ProcessModel& source,
        const Id<Process::ProcessModel>& id,
        QObject* parent):
    CurveProcessModel{source, id, Metadata<ObjectKey_k, ProcessModel>::get(), parent},
    m_sourceAddress(source.sourceAddress()),
    m_targetAddress(source.targetAddress()),
    m_sourceMin{source.sourceMin()},
    m_sourceMax{source.sourceMax()},
    m_targetMin{source.targetMin()},
    m_targetMax{source.targetMax()}
{
    setCurve(source.curve().clone(source.curve().id(), this));
    pluginModelList = new iscore::ElementPluginModelList(*source.pluginModelList, this);
    connect(m_curve, &Curve::Model::changed,
            this, &ProcessModel::curveChanged);
    metadata.setName(QString("Mapping.%1").arg(*this->id().val()));
}
Exemple #12
0
ProcessModel::ProcessModel(
        const TimeValue& duration,
        const Id<Process::ProcessModel>& id,
        QObject* parent) :
    Curve::CurveProcessModel {duration, id, Metadata<ObjectKey_k, ProcessModel>::get(), parent}
{
    pluginModelList = new iscore::ElementPluginModelList{iscore::IDocument::documentContext(*parent), this};
    setUseParentDuration(true);
    // Named shall be enough ?
    setCurve(new Curve::Model{Id<Curve::Model>(45345), this});

    auto s1 = new Curve::DefaultCurveSegmentModel(Id<Curve::SegmentModel>(1), m_curve);
    s1->setStart({0., 0.0});
    s1->setEnd({1., 1.});

    m_curve->addSegment(s1);
    connect(m_curve, &Curve::Model::changed,
            this, &ProcessModel::curveChanged);

    metadata.setName(QString("Mapping.%1").arg(*this->id().val()));
}
void mouseMotion(GLint x, GLint y) {
	GLfloat thetaX, thetaY;
	if (moving == 1) {
		if (game_start == 1) {
			thetaX = (x - xBegin); //> 0) ? 1 : -1;
			thetaY = (yBegin - y); //> 0) ? 1 : -1;
			myWorld.list[0]->translate(thetaX * 0.003, 0, 0);
			myWorld.list[0]->translate(0, thetaY * 0.003, 0);
			xBegin = x;
			yBegin = y;
			if (check_curve == true) {
				end = glutGet(GLUT_ELAPSED_TIME);
				if ((end - begin) > 30) {
					xCurve2 = x;
					yCurve2 = y;
					check_curve = false;
					setCurve(xCurve1, yCurve1, xCurve2, yCurve2);
				}
			}
		}
	}
	glutPostRedisplay();
}
Exemple #14
0
 void DiodeNode::setDistortion(float distortion)
 {
     // We increase the distortion by increasing the gradient of the linear portion of the waveshaper's curve.
     h = distortion;
     setCurve();
 }
void applyTemplate(uint8_t idx)
#endif
{
    MixData *md = &g_model.mixData[0];

    //CC(STK)   -> vSTK
    //ICC(vSTK) -> STK
#define ICC(x) icc[(x)-1]
    uint8_t icc[4] = {0};
    for(uint8_t i=1; i<=4; i++) //generate inverse array
        for(uint8_t j=1; j<=4; j++) if(CC(i)==j) icc[j-1]=i;


#ifndef NO_TEMPLATES
    uint8_t j = 0;

    //Simple 4-Ch
    if(idx==j++)
    {
#endif
        clearMixes();
        md=setDest(ICC(STK_RUD));
        md->srcRaw=CM(STK_RUD);
        md=setDest(ICC(STK_ELE));
        md->srcRaw=CM(STK_ELE);
        md=setDest(ICC(STK_THR));
        md->srcRaw=CM(STK_THR);
        md=setDest(ICC(STK_AIL));
        md->srcRaw=CM(STK_AIL);

#ifndef NO_TEMPLATES
    }

    //T-Cut
    if(idx==j++)
    {
        md=setDest(ICC(STK_THR));
        md->srcRaw=MIX_MAX;
        md->weight=-100;
        md->swtch=DSW_THR;
        md->mltpx=MLTPX_REP;
    }

    //sticky t-cut
    if(idx==j++)
    {
        md=setDest(ICC(STK_THR));
        md->srcRaw=MIX_MAX;
        md->weight=-100;
        md->swtch=DSW_SWC;
        md->mltpx=MLTPX_REP;
        md=setDest(14);
        md->srcRaw=CH(14);
        md=setDest(14);
        md->srcRaw=MIX_MAX;
        md->weight=-100;
        md->swtch=DSW_SWB;
        md->mltpx=MLTPX_REP;
        md=setDest(14);
        md->srcRaw=MIX_MAX;
        md->swtch=DSW_THR;
        md->mltpx=MLTPX_REP;

        setSwitch(0xB,CS_VNEG, CM(STK_THR), -99);
        setSwitch(0xC,CS_VPOS, CH(14), 0);
    }

    //V-Tail
    if(idx==j++)
    {
        clearMixes();
        md=setDest(ICC(STK_RUD));
        md->srcRaw=CM(STK_RUD);
        md=setDest(ICC(STK_RUD));
        md->srcRaw=CM(STK_ELE);
        md->weight=-100;
        md=setDest(ICC(STK_ELE));
        md->srcRaw=CM(STK_RUD);
        md=setDest(ICC(STK_ELE));
        md->srcRaw=CM(STK_ELE);
    }

    //Elevon\\Delta
    if(idx==j++)
    {
        clearMixes();
        md=setDest(ICC(STK_ELE));
        md->srcRaw=CM(STK_ELE);
        md=setDest(ICC(STK_ELE));
        md->srcRaw=CM(STK_AIL);
        md=setDest(ICC(STK_AIL));
        md->srcRaw=CM(STK_ELE);
        md=setDest(ICC(STK_AIL));
        md->srcRaw=CM(STK_AIL);
        md->weight=-100;
    }


    //Heli Setup
    if(idx==j++)
    {
        clearMixes();  //This time we want a clean slate
        clearCurves();

        //Set up Mixes
        //3 cyclic channels
        md=setDest(1);
        md->srcRaw=MIX_CYC1;
        md=setDest(2);
        md->srcRaw=MIX_CYC2;
        md=setDest(3);
        md->srcRaw=MIX_CYC3;

        //rudder
        md=setDest(4);
        md->srcRaw=CM(STK_RUD);

        //Throttle
        md=setDest(5);
        md->srcRaw=CM(STK_THR);
        md->swtch= DSW_ID0;
        md->curve=CV(1);
        md->carryTrim=TRIM_OFF;
        md=setDest(5);
        md->srcRaw=CM(STK_THR);
        md->swtch= DSW_ID1;
        md->curve=CV(2);
        md->carryTrim=TRIM_OFF;
        md=setDest(5);
        md->srcRaw=CM(STK_THR);
        md->swtch= DSW_ID2;
        md->curve=CV(3);
        md->carryTrim=TRIM_OFF;
        md=setDest(5);
        md->srcRaw=MIX_MAX;
        md->weight=-100;
        md->swtch= DSW_THR;
        md->mltpx=MLTPX_REP;

        //gyro gain
        md=setDest(6);
        md->srcRaw=MIX_FULL;
        md->weight=30;
        md->swtch=-DSW_GEA;

        //collective
        md=setDest(11);
        md->srcRaw=CM(STK_THR);
        md->weight=70;
        md->swtch= DSW_ID0;
        md->curve=CV(4);
        md->carryTrim=TRIM_OFF;
        md=setDest(11);
        md->srcRaw=CM(STK_THR);
        md->weight=70;
        md->swtch= DSW_ID1;
        md->curve=CV(5);
        md->carryTrim=TRIM_OFF;
        md=setDest(11);
        md->srcRaw=CM(STK_THR);
        md->weight=70;
        md->swtch= DSW_ID2;
        md->curve=CV(6);
        md->carryTrim=TRIM_OFF;

        g_model.swashType = SWASH_TYPE_120;
        g_model.swashCollectiveSource = CH(11);

        //Set up Curves
        setCurve(CURVE5(1),heli_ar1);
        setCurve(CURVE5(2),heli_ar2);
        setCurve(CURVE5(3),heli_ar3);
        setCurve(CURVE5(4),heli_ar4);
        setCurve(CURVE5(5),heli_ar5);
        setCurve(CURVE5(6),heli_ar5);
    }

    //Gyro Gain
    if(idx==j++)
    {
        md=setDest(6);
        md->srcRaw=STK_P2;
        md->weight= 50;
        md->swtch=-DSW_GEA;
        md->sOffset=100;
        md=setDest(6);
        md->srcRaw=STK_P2;
        md->weight=-50;
        md->swtch= DSW_GEA;
        md->sOffset=100;
    }

    //Servo Test
    if(idx==j++)
    {
        md=setDest(15);
        md->srcRaw=CH(16);
        md->speedUp = 8;
        md->speedDown = 8;
        md=setDest(16);
        md->srcRaw=MIX_FULL;
        md->weight= 110;
        md->swtch=DSW_SW1;
        md=setDest(16);
        md->srcRaw=MIX_MAX;
        md->weight=-110;
        md->swtch=DSW_SW2;
        md->mltpx=MLTPX_REP;
        md=setDest(16);
        md->srcRaw=MIX_MAX;
        md->weight= 110;
        md->swtch=DSW_SW3;
        md->mltpx=MLTPX_REP;

        setSwitch(1,CS_LESS,CH(15),CH(16));
        setSwitch(2,CS_VPOS,CH(15),   105);
        setSwitch(3,CS_VNEG,CH(15),  -105);
    }



    STORE_MODELVARS;
    eeWaitComplete() ;

#endif

}
Exemple #16
0
void MainWindow::on_SetGradeCurveButton_clicked() {
    SetCurveWindow setCurve(gradeMinimums);
    setCurve.exec();
    calculateAverages();
}
Exemple #17
0
void EqualizationDialog::OnLoadCurve(wxCommandEvent &event)
{
   setCurve(mEnvelope, predefined->GetSelection());
   mPanel->Refresh(false);
}
Exemple #18
0
void applyTemplate(uint8_t idx)
{
    MixData *md;

    //CC(STK)   -> vSTK
    //ICC(vSTK) -> STK
#define ICC(x) icc[(x)-1]
    uint8_t icc[4] = {0};
    for (uint8_t i=0; i<4; i++) { //generate inverse array
      for(uint8_t j=0; j<4; j++)
        if(CC(i+1)==j+MIXSRC_Rud) icc[j]=i;
    }

    switch (idx) {
      case TMPL_CLEAR_MIXES:
      case TMPL_SIMPLE_4CH:
      case TMPL_HELI_SETUP:
        clearMixes();
        break;
    }

    switch (idx) {
      // Simple 4-Ch
      case TMPL_SIMPLE_4CH:
        defaultInputs();
        setDest(ICC(STK_RUD), TMPL_INPUT(STK_RUD));
        setDest(ICC(STK_ELE), TMPL_INPUT(STK_ELE));
        setDest(ICC(STK_THR), TMPL_INPUT(STK_THR));
        setDest(ICC(STK_AIL), TMPL_INPUT(STK_AIL));
        break;

      // Sticky-T-Cut
      case TMPL_STI_THR_CUT:
        md=setDest(ICC(STK_THR), MIXSRC_MAX); mixSetWeight(md, -100);  md->swtch=SWSRC_SWC;  md->mltpx=MLTPX_REP;
        md=setDest(13, MIXSRC_CH14); // md->weight= 100; done by setDest anyway
        md=setDest(13, MIXSRC_MAX); mixSetWeight(md, -100);  md->swtch=SWSRC_SWB;  md->mltpx=MLTPX_REP;
        md=setDest(13, MIXSRC_MAX); /* md->weight= 100;*/  md->swtch=SWSRC_THR;  md->mltpx=MLTPX_REP;
        setLogicalSwitch(11, LS_FUNC_VNEG, STK_THR, -99);
        setLogicalSwitch(12, LS_FUNC_VPOS, MIXSRC_CH14, 0);
        break;

      // V-Tail
      case TMPL_V_TAIL:
        defaultInputs();
        setDest(ICC(STK_RUD), TMPL_INPUT(STK_RUD), true);
        md=setDest(ICC(STK_RUD), TMPL_INPUT(STK_ELE)); mixSetWeight(md, -100);
        setDest(ICC(STK_ELE), TMPL_INPUT(STK_RUD), true);
        setDest(ICC(STK_ELE), TMPL_INPUT(STK_ELE));
        break;

      // Elevon\\Delta
      case TMPL_ELEVON_DELTA:
        defaultInputs();
        setDest(ICC(STK_ELE), MIXSRC_Ele, true);
        setDest(ICC(STK_ELE), MIXSRC_Ail);
        setDest(ICC(STK_AIL), MIXSRC_Ele, true);
        md=setDest(ICC(STK_AIL), MIXSRC_Ail); mixSetWeight(md, -100);
        break;

      // eCCPM
      case TMPL_ECCPM:
        md=setDest(ICC(STK_ELE), MIXSRC_Ele, true); md->weight= 72;
        md=setDest(ICC(STK_ELE), MIXSRC_Thr);  md->weight= 55;
        md=setDest(ICC(STK_AIL), MIXSRC_Ele, true);  mixSetWeight(md, -36);
        md=setDest(ICC(STK_AIL), MIXSRC_Ail);  md->weight= 62;
        md=setDest(ICC(STK_AIL), MIXSRC_Thr);  md->weight= 55;
        md=setDest(5, MIXSRC_Ele, true);       mixSetWeight(md, -36);
        md=setDest(5, MIXSRC_Ail);             mixSetWeight(md, -62);
        md=setDest(5, MIXSRC_Thr);             md->weight= 55;
        break;

      // Heli Setup
      case TMPL_HELI_SETUP:
        clearCurves();

        //Set up Mixes
        // 3 cyclic channels
        md=setDest(0, MIXSRC_CYC1); // md->weight=100;
        md=setDest(1, MIXSRC_CYC2); // md->weight=100;
        md=setDest(2, MIXSRC_CYC3); // md->weight=100;

        // rudder
        md=setDest(3, MIXSRC_Rud); // md->weight=100;

        // throttle
#if defined(PCBTARANIS)
        // TODO
#else
        md=setDest(4, MIXSRC_Thr); md->swtch=SWSRC_ID0; mixSetCurve(md, 0); md->carryTrim=TRIM_OFF;
        md=setDest(4, MIXSRC_Thr); md->swtch=SWSRC_ID1; mixSetCurve(md, 1); md->carryTrim=TRIM_OFF;
        md=setDest(4, MIXSRC_Thr); md->swtch=SWSRC_ID2; mixSetCurve(md, 2); md->carryTrim=TRIM_OFF;
#endif
        md=setDest(4, MIXSRC_MAX); mixSetWeight(md, -100); md->swtch=SWSRC_THR;  md->mltpx=MLTPX_REP;

        // gyro gain
        md=setDest(5, MIXSRC_MAX); md->weight= 30; md->swtch=-SWSRC_GEA;
        md=setDest(5, MIXSRC_MAX); mixSetWeight(md, -30); md->swtch= SWSRC_GEA;
   
        // collective
#if defined(PCBTARANIS)
        // TODO
#else
        md=setDest(10, MIXSRC_Thr); /*md->weight= 100;*/ md->swtch=SWSRC_ID0; mixSetCurve(md, 3); md->carryTrim=TRIM_OFF;
        md=setDest(10, MIXSRC_Thr); /*md->weight= 100;*/ md->swtch=SWSRC_ID1; mixSetCurve(md, 4); md->carryTrim=TRIM_OFF;
        md=setDest(10, MIXSRC_Thr); /*md->weight= 100;*/ md->swtch=SWSRC_ID2; mixSetCurve(md, 5); md->carryTrim=TRIM_OFF;
#endif

        g_model.swashR.collectiveSource = MIXSRC_CH11;
        g_model.swashR.type = SWASH_TYPE_120;

        // curves
        setCurve(0, heli_ar1);
        setCurve(1, heli_ar2);
        setCurve(2, heli_ar3);
        setCurve(3, heli_ar4);
        setCurve(4, heli_ar5);
        setCurve(5, heli_ar5);
        break;

      // Servo Test
      case TMPL_SERVO_TEST:
        md=setDest(NUM_CHNOUT-1, MIXSRC_SW1, true); md->weight=110; md->mltpx=MLTPX_ADD; md->delayUp = 6; md->delayDown = 6; md->speedUp = 8; md->speedDown = 8;
        setLogicalSwitch(1, LS_FUNC_VNEG, MIXSRC_LAST_CH, 0);
        break;

    default:
        break;

    }

    eeDirty(EE_MODEL);
}