Ejemplo n.º 1
0
void __fastcall TFlyingSeatCalcForm::meLsPrimeExit(TObject *Sender)
{
  String fLeftForm, fRightForm, fFormula;                 // The left, Right and complete formulas
  if(ResultInKgs)                                      // If we want the total result converted to Kgs
  {
    fLeftForm = GetFormula(efLsPrime, efLsLbs, rbLsKgs,
                            rbLsLbs, "", " / 2" + (String)dxFormatSettings->DecimalSeparator + "2");        // Get the Left hand seat formula
    fRightForm = GetFormula(efRsPrime, efRsLbs, rbRsKgs,
                             rbRsLbs, "", " / 2" + (String)dxFormatSettings->DecimalSeparator + "2");       // Get the right hand seta formula
  }
  else
  {                                                    // Result in Lbs
    fLeftForm = GetFormula(efLsPrime, efLsLbs, rbLsKgs,
                            rbLsLbs, " * 2" + (String)dxFormatSettings->DecimalSeparator + "2", "");        // Get Left seat
    fRightForm = GetFormula(efRsPrime, efRsLbs, rbRsKgs,
                             rbRsLbs, " * 2" + (String)dxFormatSettings->DecimalSeparator + "2", "");       // Get right seat
  }
  if ((fLeftForm.Length() > 0) &&
     (fRightForm.Length() > 0))                          // If both seats return a formula
	fFormula = Format(String("(%s) + %s"), ARRAYOFCONST((fLeftForm,
									 fRightForm)));          // weld them together
  else if (fLeftForm.Length() > 0)                        // If left has the result
	fFormula = fLeftForm;                                  // Copy to the forlula
  else
	fFormula = fRightForm;                                // Right has the result, copy
  btnOk->Enabled = fFormula.Length() > 0;                   // enable the OK button if we have a result to return
  if (btnOk->Enabled)                                     // We have a result
	efFormula->Text = Format(String("= %s"), ARRAYOFCONST((fFormula)));           // Ensure sheet knows it's a formula
  else
    efFormula->Text = "";                                  // Nothing !
}
Ejemplo n.º 2
0
void QFitModelFormulaWidget::FillSpecificData()
{
    QFitNamedWidget::FillSpecificData();
    if (GetFormula()) {
       NumParSpin->setValue(GetFormula()->GetNumberOfExprPar());
       ExprEdt->setText(GetFormula()->GetExpression());
    }
}
Ejemplo n.º 3
0
void ParamEdit::CreateDefinedParam() {

	DefinedParam *np = new DefinedParam(GetBasePrefix(),
			GetParamNameFirstAndSecondPart() + GetParamName(),
			GetUnit(),
			GetFormula(),
			GetPrec(),
			GetFormulaType(),
			GetStartTime(),
			m_network_param);
	np->CreateParam();

	if (m_network_param) {
		m_remarks_handler->GetConnection()->InsertOrUpdateParam(np, this, false);
		delete np;
	} else {
		if (!m_creating_new) {
			m_cfg_mgr->SubstiuteDefinedParams(std::vector<DefinedParam*>(1, m_edited_param), std::vector<DefinedParam*>(1, np));
			m_edited_param = np;
		} else {
			m_cfg_mgr->GetDefinedDrawsSets()->AddDefinedParam(np);
			m_database_manager->AddParams(std::vector<DefinedParam*>(1, np));
		}
	}

}
Ejemplo n.º 4
0
void ParamEdit::FormulaCompiledForExpression(DatabaseQuery *q) {

	DatabaseQuery::CompileFormula& cf = q->compile_formula;
	bool ok = cf.ok;
	if (ok == false) {
		m_error = true;
		m_error_string = wxString::Format(_("Invalid expression %s"), cf.error);
	}
	free(cf.formula);
	free(cf.error);

	delete q;
	if (!ok) {
		return;
	}

	DefinedParam* param = new DefinedParam(m_draws_ctrl->GetCurrentDrawInfo()->GetBasePrefix(),
		L"TEMPORARY:SEARCH:EXPRESSION",
		L"",
		GetFormula(),
		0,
		TParam::LUA_AV,
		-1);
	param->CreateParam();

	std::vector<DefinedParam*> dpv = std::vector<DefinedParam*>(1, param);
	m_cfg_mgr->SubstituteOrAddDefinedParams(dpv);

	DefinedDrawInfo* ddi = new DefinedDrawInfo(L"",
			L"",
			wxColour(),
			0,
			1,
			TDraw::NONE,
			L"",
			param,
			m_cfg_mgr->GetDefinedDrawsSets());

	q = new DatabaseQuery();
	q->type = DatabaseQuery::SEARCH_DATA;
	q->draw_info = ddi;
	q->param = param->GetIPKParam();
	q->draw_no = -1;
	q->search_data.end = -1;
	q->search_data.period_type = m_draws_ctrl->GetPeriod();
	q->search_data.search_condition = new non_zero_search_condition;

	wxDateTime t = m_current_search_date.IsValid() ? m_current_search_date.GetTicks() : m_draws_ctrl->GetCurrentTime();
	DTime dt(m_draws_ctrl->GetPeriod(), t);
	dt.AdjustToPeriod();
	TimeIndex time_index(m_draws_ctrl->GetPeriod());
	switch (m_search_direction) {
		case SEARCHING_LEFT:
			q->search_data.start = (dt - time_index.GetTimeRes() - time_index.GetDateRes()).GetTime().GetTicks();
			q->search_data.direction = -1;
			break;
		case SEARCHING_RIGHT:
			q->search_data.start = (dt + time_index.GetTimeRes() + time_index.GetDateRes()).GetTime().GetTicks();
			q->search_data.direction = 1;
			break;
		case NOT_SEARCHING:
			assert(false);
			break;
	}
	QueryDatabase(q);
}
Ejemplo n.º 5
0
void QFitModelFormulaWidget::NumParSpin_valueChanged( int num)
{
  if(!fbFillWidget && GetFormula())
    if(GetFormula()->SetNumberOfExprPar(num))
      UpdateItemsOfType(FitGui::ot_parslist, false);
}
Ejemplo n.º 6
0
void QFitModelFormulaWidget::ExprEdt_textChanged( const QString & str)
{
  if(!fbFillWidget && GetFormula())
    GetFormula()->SetExpression(str.toLatin1().constData());
}