Exemple #1
0
//--------------------------------------------------------------------------
// Function:    H5Object::getObjName
///\brief       Gets the name of this object, returning its length.
///\param       obj_name - OUT: Buffer for the name string as \a H5std_string
///\param       len  -  IN: Desired length of the name, default to 0
///\return      Actual length of the object name
///\exception   H5::Exception
///\par Description
///             This function retrieves the object's name as an std string.
///             buf_size can specify a specific length or default to 0, in
///             which case the entire name will be retrieved.
// Programmer   Binh-Minh Ribler - Mar, 2014
//--------------------------------------------------------------------------
ssize_t H5Object::getObjName(H5std_string& obj_name, size_t len) const
{
    ssize_t name_size = 0;

    // If no length is provided, get the entire object name
    if (len == 0)
    {
        obj_name = getObjName();
        name_size = obj_name.length();
    }
    // If length is provided, get that number of characters in name
    else
    {
        char* name_C = new char[len+1];  // temporary C-string
        HDmemset(name_C, 0, len+1); // clear buffer

        // Use overloaded function
        name_size = getObjName(name_C, len+1);

        // Convert the C object name to return
        obj_name = name_C;

        // Clean up resource
        delete []name_C;
    }
    // Otherwise, keep obj_name intact

    // Return name size
    return(name_size);
}
Exemple #2
0
//--------------------------------------------------------------------------
// Function:    H5Object::getObjName
///\brief       Returns the name of this object as an \a H5std_string.
///\return      Name of the object
///\exception   H5::Exception
// Programmer   Binh-Minh Ribler - Mar, 2014
// Modification
//--------------------------------------------------------------------------
H5std_string H5Object::getObjName() const
{
    H5std_string obj_name(""); // object name to return

    // Preliminary call to get the size of the object name
    ssize_t name_size = H5Iget_name(getId(), NULL, static_cast<size_t>(0));

    // If H5Iget_name failed, throw exception
    if (name_size < 0)
    {
        throw Exception(inMemFunc("getObjName"), "H5Iget_name failed");
    }
    else if (name_size == 0)
    {
        throw Exception(inMemFunc("getObjName"), "Object must have a name, but name length is 0");
    }
    // Object's name exists, retrieve it
    else if (name_size > 0)
    {
        char* name_C = new char[name_size+1];  // temporary C-string
        HDmemset(name_C, 0, name_size+1); // clear buffer

        // Use overloaded function
        name_size = getObjName(name_C, name_size+1);

        // Convert the C object name to return
        obj_name = name_C;

        // Clean up resource
        delete []name_C;
    }
    // Return object's name
    return(obj_name);
}
Exemple #3
0
void
Base::exceptionError(std::string str)
{
  // Occurrence of an error usually stops the run at once.
  // But, the calling program unit is due to exit.
  static bool doInit=true;
  if( doInit )
  {
    xcptn.strError = getObjName() ;
    xcptn.strError += "_error" ;

     // base-name if available, i.e. after initialisation of the InFile obj
    if( file.is )
    {
      xcptn.strError += "_";
      xcptn.strError += file.basename ;
    }
    xcptn.strError += ".txt";

    doInit = false;
  }

  // open file for writing
  if( ! xcptn.ofsError )
    xcptn.ofsError = new std::ofstream(xcptn.strError.c_str());

  *xcptn.ofsError << str << std::endl;

  return ;
}
uint32_t NexText::Get_background_image_pic(uint32_t *number)
{
    String cmd = String("get ");
    cmd += getObjName();
    cmd += ".pic";
    sendCommand(cmd.c_str());
    return recvRetNumber(number);
}
bool NexNumber::getValue(uint32_t *number)
{
    String cmd = String("get ");
    cmd += getObjName();
    cmd += ".val";
    sendCommand(cmd.c_str());
    return recvRetNumber(number);
}
bool NexText::Set_font_color_pco(uint32_t number)
{
    char buf[10] = {0};
    String cmd;
    
    utoa(number, buf, 10);
    cmd += getObjName();
    cmd += ".pco=";
    cmd += buf;
    sendCommand(cmd.c_str());
	
    cmd = "";
    cmd += "ref ";
    cmd += getObjName();
    sendCommand(cmd.c_str());
    return recvRetCommandFinished();
}
bool NexButton::getPIC(uint32_t * number)
{
    String cmd = String("get ");
    cmd += getObjName();
    cmd += ".pic";
    sendCommand(cmd.c_str());
    return recvRetNumber(number);
}
bool NexText::Set_background_crop_picc(uint32_t number)
{
    char buf[10] = {0};
    String cmd;
    
    utoa(number, buf, 10);
    cmd += getObjName();
    cmd += ".picc=";
    cmd += buf;
    sendCommand(cmd.c_str());
	
    cmd = "";
    cmd += "ref ";
    cmd += getObjName();
    sendCommand(cmd.c_str());
    return recvRetCommandFinished();
}
uint32_t NexText::Get_background_crop_picc(uint32_t *number)
{
    String cmd;
    cmd += "get ";
    cmd += getObjName();
    cmd += ".picc";
    sendCommand(cmd.c_str());
    return recvRetNumber(number);
}
uint32_t NexText::getFont(uint32_t *number)
{
    String cmd;
    cmd += "get ";
    cmd += getObjName();
    cmd += ".font";
    sendCommand(cmd.c_str());
    return recvRetNumber(number);
}
uint32_t NexText::Get_font_color_pco(uint32_t *number)
{
    String cmd;
    cmd += "get ";
    cmd += getObjName();
    cmd += ".pco";
    sendCommand(cmd.c_str());
    return recvRetNumber(number);
}
uint32_t NexText::Get_place_xcen(uint32_t *number)
{
    String cmd;
    cmd += "get ";
    cmd += getObjName();
    cmd += ".xcen";
    sendCommand(cmd.c_str());
    return recvRetNumber(number);
}
uint16_t NexButton::getText(char *buffer, uint16_t len)
{
    String cmd;
    cmd += "get ";
    cmd += getObjName();
    cmd += ".txt";
    sendCommand(cmd.c_str());
    return recvRetString(buffer,len);
}
bool NexButton::setText(const char *buffer)
{
    String cmd;
    cmd += getObjName();
    cmd += ".txt=\"";
    cmd += buffer;
    cmd += "\"";
    sendCommand(cmd.c_str());
    return recvRetCommandFinished();    
}
bool NexNumber::setValue(uint32_t number)
{
    char buf[10] = {0};
    String cmd;
    
    utoa(number, buf, 10);
    cmd += getObjName();
    cmd += ".val=";
    cmd += buf;

    sendCommand(cmd.c_str());
    return recvRetCommandFinished();
}
bool NexButton::setPIC(uint32_t number)
{
    char buf[10] = {0};
    String cmd;
    
    utoa(number, buf, 10);
    cmd += getObjName();
    cmd += ".pic=";
    cmd += buf;

    sendCommand(cmd.c_str());
    return recvRetCommandFinished();
}
Exemple #17
0
bool NexText::setColor(uint32_t value)
{
    char buf[10] = {0};
    String cmd;

    utoa(value, buf, 10);
    cmd += getObjName();
    cmd += ".pco=";
    cmd += buf;

    sendCommand(cmd.c_str());
    return recvRetCommandFinished();
}
Exemple #18
0
bool NexPicture::setPic(uint32_t number)
{
    char buf[10] = {0};
    String cmd;
    
    sprintf(buf,"%d",number);
    //utoa(number, buf, 10);
    cmd += getObjName();
    cmd += ".pic=";
    cmd += buf;

    sendCommand(cmd.c_str());
    return recvRetCommandFinished();
}
bool NexPage::show(void)
{
    uint8_t buffer[4] = {0};

    const char *name = getObjName();
    if (!name)
    {
        return false;
    }
    
    String cmd = String("page ");
    cmd += name;
    sendCommand(cmd.c_str());
    return recvRetCommandFinished();
}
Exemple #20
0
/*
  Return a row name, according to the current name discipline, truncated if
  necessary. If the row index is out of range, the name becomes an error
  message. By definition, ndx = getNumRows() (i.e., one greater than the
  largest valid row index) is the objective function.
*/
std::string OsiSolverInterface::getRowName (int ndx, unsigned maxLen) const

{ int nameDiscipline ;
  std::string name ;
/*
  Check for valid row index.
*/
  int m = getNumRows() ;
  if (ndx < 0 || ndx > m)
  { name = invRowColName('r',ndx) ;
    return (name) ; }
/*
  The objective is kept separately, so we don't always have an entry at
  index m in the names vector. If no name is set, return the default.
*/
  if (ndx == m)
  { return (getObjName(maxLen)) ; }
/*
  Determine how we're handling names. It's possible that the underlying solver
  has overridden getIntParam, but doesn't recognise OsiNameDiscipline. In that
  case, we want to default to auto names
*/
  bool recognisesOsiNames = getIntParam(OsiNameDiscipline,nameDiscipline) ;
  if (recognisesOsiNames == false)
  { nameDiscipline = 0 ; }
/*
  Find/generate the proper name, based on discipline.
*/
  switch (nameDiscipline)
  { case 0:
    { name = dfltRowColName('r',ndx) ;
      break ; }
    case 1:
    case 2:
    { name = "" ;
      if (static_cast<unsigned>(ndx) < rowNames_.size())
	name = rowNames_[ndx] ;
      if (name.length() == 0)
	name = dfltRowColName('r',ndx) ;
      break ; }
    default:
    { name = invRowColName('d',nameDiscipline) ;
      return (name) ; } }
/*
  Return the (possibly truncated) substring. The default for maxLen is npos
  (no truncation).
*/
  return (name.substr(0,maxLen)) ; }
Exemple #21
0
/*
  Return the vector of row names. The vector we need depends on the name
  discipline:
    0: return a vector of length 0
    1: return rowNames_, no tweaking required
    2: Check that rowNames_ is complete. Generate a complete vector on
       the spot if we need it.
*/
const OsiSolverInterface::OsiNameVec &OsiSolverInterface::getRowNames ()

{ int nameDiscipline ;
/*
  Determine how we're handling names. It's possible that the underlying solver
  has overridden getIntParam, but doesn't recognise OsiNameDiscipline. In that
  case, we want to default to auto names
*/
  bool recognisesOsiNames = getIntParam(OsiNameDiscipline,nameDiscipline) ;
  if (recognisesOsiNames == false)
  { nameDiscipline = 0 ; }
/*
  Return the proper vector, as described at the head of the routine. If we
  need to generate a full vector, resize the existing vector and scan, filling
  in entries as required.
*/
  switch (nameDiscipline)
  { case 0:
    { return (zeroLengthNameVec) ; }
    case 1:
    { return (rowNames_) ; }
    case 2:
    { int m = getNumRows() ;
      if (rowNames_.size() < static_cast<unsigned>(m+1))
      { rowNames_.resize(m+1) ; }
      for (int i = 0 ; i < m ; i++)
      { if (rowNames_[i].length() == 0)
	{ rowNames_[i] = dfltRowColName('r',i) ; } }
      if (rowNames_[m].length() == 0)
      { rowNames_[m] = getObjName() ; }
      return (rowNames_) ; }
    default:
    { /* quietly fail */
      return (zeroLengthNameVec) ; } }
/*
  We should never reach here.
*/
  assert(false) ;

  return (zeroLengthNameVec) ; }
Exemple #22
0
void
Base::exceptionWarning(std::string str)
{
  // a warning does not stop the run

  static bool doInit=true;
  if( doInit )
  {
    // This happens only once. All error and warning
    // calls on the global scale and in any class-related
    // objects refer to this.

    xcptn.strWarning = getObjName() ;
    xcptn.strWarning += "_warning" ;

    if( file.is )
    {
      xcptn.strWarning += "_";
      xcptn.strWarning += file.basename ;
    }
    xcptn.strWarning += ".txt";

    doInit = false;
  }

  // open file for writing
  if( ! xcptn.ofsWarning )
    xcptn.ofsWarning = new std::ofstream(xcptn.strWarning.c_str());

  if( xcptn.ofsWarning->is_open() )
  {
    // write message
    xcptn.ofsWarning->write(str.c_str(), str.size()+1);
    *xcptn.ofsWarning << std::endl;
  }

  return ;
}
Exemple #23
0
void CEnemy01::Render()
{
	drawTexture(getObjInfo(), RefPos_Center, 0, getObjkey(), getObjName(), getTexturekey(), getStatekey());
}
Exemple #24
0
bool rtEPDataObject::saveFile(QFile *file) {
  if (!file->open(QIODevice::WriteOnly)) {
    rtApplication::instance().getMessageHandle()->error(__LINE__, __FILE__, QString("Failed to open file for writing. Error Code: ").append(QString::number(file->error())));
    return false;
  }
  QList<rtCardiacMeshPointData> tempPT;
  QList<int> slices;
  QXmlStreamWriter writer(file);
  writer.setAutoFormatting(true);
  writer.writeStartDocument();
  writer.writeStartElement("VurtigoFile");
  rtDataObject::saveHeader(&writer, getObjectType(), getObjName());
  rtRenderObject *rObj = rtApplication::instance().getObjectManager()->getObjectWithID(this->getId());
  rObj->saveVisibilities(&writer);

  writer.writeTextElement("numPhases", QString::number(m_phaseDataList.size()));

  writer.writeStartElement("Properties");
  if ((m_inPlaneInterval < 1.0) || (m_crossPlaneInterval < 1.0))
  {
      QApplication::restoreOverrideCursor();
      QMessageBox::StandardButton button;
      button = QMessageBox::warning(0,"Saving High Quality Mesh","Warning: saving a mesh with small spacing will cause longer load times. Save spacing information anyway?",
                                    QMessageBox::Yes | QMessageBox::No, QMessageBox::No);
      if (button == QMessageBox::Yes)
      {
          writer.writeAttribute("inPlaneInterval",QString::number(m_inPlaneInterval));
          writer.writeAttribute("crossPlaneInterval",QString::number(m_crossPlaneInterval));
      }
      QApplication::setOverrideCursor(QCursor(Qt::WaitCursor));
  }
  writer.writeAttribute("pointOpacity",QString::number(m_pointsOpacity));
  writer.writeAttribute("surfaceOpacity",QString::number(m_surfaceOpacity));
  writer.writeAttribute("currentPhase",QString::number(m_currentPhase));
  writer.writeEndElement();

  // save some mapping properties too
  rtRenderObject *tmp = rtApplication::instance().getObjectManager()->getObjectWithID(m_objectSelectionBox.getCurrentObjectId());
  if (tmp)
  {
      writer.writeStartElement("Mapping");
      writer.writeAttribute("colorByProperty",QString::number(m_optionsWidget.colorByComboBox->currentIndex()));
      writer.writeAttribute("effectSlider",QString::number(m_optionsWidget.effectSlider->value()));
      writer.writeEndElement();
  }

  for (int ix1=0; ix1<m_phaseDataList.size(); ix1++)
  {
      writer.writeStartElement("Phase");
      writer.writeAttribute("phaseNumber", QString::number(ix1));
      writer.writeAttribute("Trigger",QString::number(m_phaseDataList.value(ix1).triggerDelay));
      slices = m_phaseDataList.value(ix1).pointList.uniqueKeys();
      writer.writeAttribute("numSlices",QString::number(slices.size()));

      for (int ix2 = 0; ix2 < slices.size() ;ix2++)
      {
          writer.writeStartElement("Slice");
          tempPT = m_phaseDataList.value(ix1).pointList.values(slices[ix2]);
          writer.writeAttribute("sliceNumber",QString::number(ix2));
          writer.writeAttribute("numPoints",QString::number(tempPT.size()));
          for (int ix3 = 0; ix3 < tempPT.size(); ix3++)
          {
              writer.writeStartElement("Point");
              writer.writeAttribute("numPoint",QString::number(ix3));
              writer.writeAttribute("Location",QString::number(tempPT[ix3].getLocation()));
              writer.writeAttribute("X",QString::number(tempPT[ix3].getX()));
              writer.writeAttribute("Y",QString::number(tempPT[ix3].getY()));
              writer.writeAttribute("Z",QString::number(tempPT[ix3].getZ()));
              writer.writeEndElement(); // point
          }
          writer.writeEndElement(); // slice
      }      
      writer.writeEndElement(); // phase
  }
  writer.writeEndElement(); // vurtigofile
  writer.writeEndDocument();

  file->close();
  // save the 3D points as well
  if (tmp)
      tmp->getDataObject()->saveFile(&QFile(file->fileName() + "_points"));

  return true;
}
Exemple #25
0
void
Base::applyOptions()
{
   // options only applicable to Base properties

   Split split;
   split.setSeparator("=");

   // now we apply to the varNames found
   for( size_t j=0 ; j < optStr.size() ; ++j)
   {
     split = optStr[j];
     if( split.size() == 2 )
     {
       if( isVarname( split[0] ) )
       {
         if( getObjName() == "IN" )
           continue;
         else
         {
           Split list(split[1], ",");
           for( size_t i=0 ; i < list.size() ; i++)
             varName.push_back( list[i] );
         }
       }

       if( split[0][0] == 'f' )
       {
         setFilename( split[1] );

         continue;
       }

       if( split[0] == "filling_value" ||
              split[0] == "fillingValue" || split[0] == "fV"
                  || split[0] == "_FillValue" )
       {
         isMissValSet=true;
         Split spltFV(split[1],",");
         for( size_t i=0 ; i < spltFV.size() ; ++i)
           fillingValue.push_back( spltFV.toDouble(i) ) ;
         continue;
       }

     }

     // skip ident number
     if( split.isNumber(0) )
        continue;

     // these are applied to each GD obj
//     for( size_t i=0 ; i < pGM.size() ; ++i)
/*
     {
       if( split[0] == "back_rotation"
            || split[0] == "backRotation")
       {
         isBackRotation=true;
         pGM[i]->setBackRotation();
         continue;
       }
*/

/*
       if( split[0] == "gmt_multi_segment"
            || split[0] == "gmtMultiSegment" )
       {
         pGM[i]->setOutputGMT_MultiSegment();
         continue;
       }

       if( split[0] == "oF" )
       {
         pGM[i]->setPrintFilename(split[1]);
         continue;
       }

       if( split[0] == "print_cells" || split[0] == "printCells" )
       {
         pGM[i]->setPrintWithGeoCoord();
         continue;
       }

       if( split[0].substr(0,3) == "reg"
            || split[0].substr(0,3) == "Reg" )
       {
         regionFile = split[1];
         continue;
       }
*/
//     }
   }

   return;
}