Пример #1
0
//----------------------------------------
void CXYPlotPanel::SetAnimationDescr(uint32_t indexValue)
{
  if (m_plotDataCollection == NULL)
  {
    return;
  }

 // glbSizerAnimationDescr->Hide(m_animationToolbar->GetDescr());
  m_animationToolbar->GetDescr()->SetLabel("");
  if (m_plotDataCollection->size() <= 0)
  {
    return;
  }

  wxString descr;

  uint32_t nData = m_plotDataCollection->size();

  for (uint32_t i = 0 ; i < nData ; i++)
  {

    CXYPlotData* data = m_plotDataCollection->Get(i);

    if (data->GetVarComplement().GetNbValues() <= 0)
    {
      continue;
    }

    CFieldNetCdf& field = data->GetFieldComplement();
    string fieldDescr = field.GetMostExplicitName();
    string strUnit = field.GetUnit();

    CUnit* unit = field.GetNetCdfUnit();
  
    uint32_t index = indexValue;
    if (index >= data->GetVarComplement().GetNbValues())
    {
      index = data->GetVarComplement().GetNbValues() - 1;
    }
    if (unit->IsDate())
    {
      CDate d1950_01_01 = unit->ConvertToBaseUnit(data->GetVarComplement().GetValues()[index]);
    
      descr.Append(wxString::Format("'%s' value for above plot: %s (field '%s')\n", 
                               fieldDescr.c_str(), 
                               d1950_01_01.AsString("", true).c_str(),
                               data->GetName().c_str()));

    }
    else
    {
      descr.Append(wxString::Format("'%s' value for above plot: %f %s (field '%s')\n", 
                               fieldDescr.c_str(), 
                               data->GetVarComplement().GetValues()[index],
                               strUnit.c_str(),
                               data->GetName().c_str()));
    }


    uint32_t iOtherFields = 0;

    const CObArray& otherFields = data->GetOtherFields();
    //const vector<CExpressionValue>& otherData = data->GetOtherVars();
    const CObArray& otherData = data->GetOtherVars();
    
    //otherFields.Dump(*(CTrace::GetInstance()->GetDumpContext()));

    for (iOtherFields = 0 ; iOtherFields < otherFields.size() ; iOtherFields++)
    {
      CFieldNetCdf* field = dynamic_cast<CFieldNetCdf*>(otherFields.at(iOtherFields));
      if (field == NULL)
      {
        continue;
      }

      string fieldDescr = field->GetMostExplicitName();
      string strUnit = field->GetUnit();

      CUnit* unit = field->GetNetCdfUnit();

      uint32_t index = indexValue;
      CExpressionValue* exprValue = CExpressionValue::GetExpressionValue(otherData.at(iOtherFields));

      if (index >= exprValue->GetNbValues())
      {
        index = exprValue->GetNbValues() - 1;
      }

      if (unit->IsDate())
      {
        CDate d1950_01_01 = unit->ConvertToBaseUnit(exprValue->GetValues()[index]);
  
        descr.Append(wxString::Format("'%s' value for above plot: %s (field '%s')\n", 
                                 fieldDescr.c_str(), 
                                 d1950_01_01.AsString("", true).c_str(),
                                 data->GetName().c_str()));

      }
      else
      {
        double value = exprValue->GetValues()[index];
        wxString valueStr;

        if (CTools::IsDefaultValue(value))
        {
          valueStr = "No value (default value)";
        }
        else
        {
          valueStr = wxString::Format("%f %s", value, strUnit.c_str());
        }

        descr.Append(wxString::Format("'%s' value for above plot: %s (field '%s')\n", 
                                 fieldDescr.c_str(), 
                                 valueStr.c_str(),
                                 data->GetName().c_str()));
      }

    }
  }


  m_animationToolbar->GetDescr()->SetLabel(descr);

}