示例#1
0
void print_list(SymbolTableEntry *listHead)
{
     if(listHead == NULL)
	{ // ABORTED
	  return;	
	}
	
	listHead = listHead->up;
	
	int enable = 1;
	
     while( listHead != NULL )
     {
		
		/* if the symbol is libfunc */
		if(listHead->type == 4 && enable)
		{	puts("\n\n ===== Library Functions =====\n");
			enable=0;
		}
		if( listHead->isVariable )
		{
			print_this_entry(listHead->value.varVal->name, getTypeAsString(listHead->type), listHead->value.varVal->scope, listHead->isActive, listHead->value.varVal->line, listHead->offset );
		}
		else
		{
			print_this_entry(listHead->value.funcVal->name, getTypeAsString(listHead->type), listHead->value.funcVal->scope, listHead->isActive, listHead->value.funcVal->line, listHead->offset );
		}	
		
		listHead = listHead->up; 
     }
}
示例#2
0
QtException::QtException(ExceptionType exType,QString msg):exception()
{
    setType(exType);
    setMessage(msg);
    if(exType != ExceptionType::Information)
        qCritical()<<getTypeAsString()<<"::"<<what();
    else
        qDebug()<<getTypeAsString()<<"::"<<what();
}
//------------------------------------------------
bool guiValue::setValueAsPct(float percent, int which){
    if( which >= paramGroup.size() ) return false;
    
    string type = getTypeAsString(which);

    if( type == "float" || type == "" ){
        ofParameter<float> f =  paramGroup.getFloat(which);
        f = f.getMin() + ofClamp(percent, 0, 1) * (f.getMax()-f.getMin());
        return true;
    }
    else if( type == "bool" ){
        ofParameter<bool> f =  paramGroup.getBool(which);
        if( percent == 0.0 ){
            f = false;
        }else{
            f = true;
        }
        return true;
    }
    else if( type == "int" ){
        ofParameter<int> f =  paramGroup.getInt(which);
        f = (float)f.getMin() + ofClamp(percent, 0, 1) * (float)(f.getMax()-f.getMin());
        return true;
    }
    
    return false;
}
示例#4
0
/**
* Pass input arguments, note that argv[0] from the command line should be removed
*/
bool ConfigIO :: parseArgs (int nArgs, const char **argv)
{
	if (nArgs > 0)
		if (_strcmpi(argv [0], "help") == 0 || _strcmpi(argv [0], "?") == 0 || _strcmpi(argv [0], "/h") == 0 || _strcmpi(argv [0], "/?") == 0) {
			std::cout << "------------------------------------------" << std::endl;
			std::cout << "Valid parameters for this application: " << std::endl;
			for (size_t f = 0; f < parameters.size (); f ++)
				std::cout	<< " * " 
				<< getTypeAsString(parameters[f]) 
				<< " "
				<< parameters[f].name 
				<< " ["
				<< getValueAsString(parameters[f]) 
				<< "]" 
				<< std::endl;

			std::cout << "------------------------------------------" << std::endl;
			exit(0);
		}


	for (int i = 0; i < nArgs; i ++)
		loadParam (argv [i]);


	return true;
}
//------------------------------------------------
float guiValue::getPct(int which){
    if( which >= paramGroup.size() ) return 0.0;

    float min = 0.0;
    float max = 1.0;
    float val = 0.0;

    string type = getTypeAsString(which);

    if( type == "float" || type == "" ){
        ofParameter<float> f =  paramGroup.getFloat(which);
        min = f.getMin();
        max = f.getMax();
        val = f;
    }
    else if( type == "bool" ){
        ofParameter<bool> f =  paramGroup.getBool(which);
        val = f;
    }
    else if( type == "int" ){
        ofParameter<int> f =  paramGroup.getInt(which);
        min = f.getMin();
        max = f.getMax();
        val = f;
    }

    float delta = max-min;
    if(delta == 0.0){
        return 0.0;
    }
    
    float pct = (val-min) / delta;
    return ofClamp(pct, 0, 1);
}
bool QgsPythonUtilsImpl::getError( QString& errorClassName, QString& errorText )
{
  if ( !PyErr_Occurred() )
    return false;

  PyObject* obj_str;
  PyObject* err_type;
  PyObject* err_value;
  PyObject* err_tb;

  // get the exception information and clear error
  PyErr_Fetch( &err_type, &err_value, &err_tb );

  // get exception's class name
  errorClassName = getTypeAsString( err_type );

  // get exception's text
  if ( err_value != NULL && err_value != Py_None )
  {
    obj_str = PyObject_Str( err_value ); // new reference
    errorText = PyString_AS_STRING( obj_str );
    Py_XDECREF( obj_str );
  }
  else
    errorText.clear();

  // cleanup
  Py_XDECREF( err_type );
  Py_XDECREF( err_value );
  Py_XDECREF( err_tb );

  return true;
}
    static int Write(const vnv::structuredGrid<_real>& grid,
    		const std::string fileName)
    {
    	std::string vtkFileName = fileName + ".vtk";

    	unsigned pos;
	    if((pos = fileName.rfind(".vtk")) != std::string::npos &&
	    	fileName.size() - pos == 4)
	    	vtkFileName = fileName;

	    std::ofstream fileVTK(vtkFileName.c_str(), std::ios::out);

	    if(!fileVTK.is_open())
	    {
	        std::cout << std::endl;
	        std::cout << "\tCouldn't create specified file '" << vtkFileName;
	        std::cout << "'." << std::endl;
	        return 1;
	    }


		_real delta;

		delta = grid.getDelta();
		std::vector<_real> mn(3), mx(3);
		unsigned N;

		grid.getLimits(mn[0], mn[1], mn[2], mx[0], mx[1], mx[2]);
	    grid.get(N);

	    fileVTK << "# vtk DataFile Version 3.0" << std::endl;
	    fileVTK << "Generated with Meshchk for Vistrails" << std::endl;
	    fileVTK << "ASCII" << std::endl;
	    fileVTK << "DATASET STRUCTURED_POINTS" << std::endl;
	    fileVTK << "DIMENSIONS " << N << " " << N << " " << N << std::endl;
	    fileVTK << "SPACING " << delta  << " " << delta  << " " << delta  << std::endl;
	    fileVTK << "ORIGIN " << mn[0] << " " << mn[1] << " " << mn[2] << std::endl;
	    fileVTK << "POINT_DATA " << N * N * N << std::endl;
	    fileVTK << "SCALARS " << "ImageFile " << getTypeAsString(T()) << std::endl;
	    fileVTK << "LOOKUP_TABLE " << "default" << std::endl;

    	unsigned i, j, k;
    	for(k = 0; k < N; ++k)
			for(i = 0; i < N; ++i)
				for(j = 0; j < N; ++j)
    			{
    				T value = grid.get(i, j, k);
    				fileVTK << value << " ";
    				if((j+1) % 9 == 0)
    					fileVTK << std::endl;
    			}

	    fileVTK.close();

	    return 0;
    }
示例#8
0
void Repository::Git::GitFile::printContent()
{

	// vypise informacie o subore
	qDebug() << "filename: " << getFilename();
	qDebug() << "filepath: " << getFilepath();
	qDebug() << "type: " << getTypeAsString();

	// pre kazdy diff blok vypis informacie o danom bloku
	foreach ( GitFileDiffBlock* block, getGitFileDiffBlocks() ) {
		block->printInfo();
	}
}
//------------------------------------------------
void guiValue::setMin(float newMin, int which){

    string type = getTypeAsString(which);

    if( type == "float" || type == "" ){
        ofParameter<float> f =  paramGroup.getFloat(which);
        f.setMin(newMin);
    }
    else if( type == "bool" ){
        ofParameter<bool> f =  paramGroup.getBool(which);
        f.setMin(newMin);
    }
    else if( type == "int" ){
        ofParameter<int> f =  paramGroup.getInt(which);
        f.setMin(newMin);
    }
}
//------------------------------------------------
float guiValue::getValueB(int which){
    string type = getTypeAsString(which);

    if( type == "float" || type == "" ){
        ofParameter<float> f =  paramGroup.getFloat(which);
        return f;
    }
    else if( type == "bool" ){
        ofParameter<bool> f =  paramGroup.getBool(which);
        return f;
    }
    else if( type == "int" ){
        ofParameter<int> f =  paramGroup.getInt(which);
        return f;
    }

    return false;
}
//------------------------------------------------
bool guiValue::setValue(float val, int which){
    string type = getTypeAsString(which);
    
    if( type == "float" || type == "" ){
        ofParameter<float> f =  paramGroup.getFloat(which);
        f = val;
        return true;
    }
    else if( type == "bool" ){
        ofParameter<bool> f =  paramGroup.getBool(which);
        f = val;
        return true;
    }
    else if( type == "int" ){
        ofParameter<int> f =  paramGroup.getInt(which);
        f = val;
        return true;
    }

    return false;
}
示例#12
0
bool QgsPythonUtilsImpl::getError( QString& errorClassName, QString& errorText )
{
  // acquire global interpreter lock to ensure we are in a consistent state
  PyGILState_STATE gstate;
  gstate = PyGILState_Ensure();

  if ( !PyErr_Occurred() )
  {
    PyGILState_Release( gstate );
    return false;
  }

  PyObject* err_type;
  PyObject* err_value;
  PyObject* err_tb;

  // get the exception information and clear error
  PyErr_Fetch( &err_type, &err_value, &err_tb );

  // get exception's class name
  errorClassName = getTypeAsString( err_type );

  // get exception's text
  if ( nullptr != err_value && err_value != Py_None )
  {
    errorText = PyObjectToQString( err_value );
  }
  else
    errorText.clear();

  // cleanup
  Py_XDECREF( err_type );
  Py_XDECREF( err_value );
  Py_XDECREF( err_tb );

  // we are done calling python API, release global interpreter lock
  PyGILState_Release( gstate );

  return true;
}
// -----------------------------------------------------------------------------
//
// -----------------------------------------------------------------------------
QString ModifiedLambertProjectionArray::getInfoString(DREAM3D::InfoStringFormat format)
{
  QString info;
  QTextStream ss (&info);
  if(format == DREAM3D::HtmlFormat)
  {
    ss << "<html><head></head>\n";
    ss << "<body>\n";
    ss << "<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\">\n";
    ss << "<tbody>\n";
    ss << "<tr bgcolor=\"#D3D8E0\"><th colspan=2>Attribute Array Info</th></tr>";

    ss << "<tr bgcolor=\"#C3C8D0\"><th align=\"right\">Name:</th><td>" << getName() << "</td></tr>";


    ss << "<tr bgcolor=\"#C3C8D0\"><th align=\"right\">Type:</th><td>" << getTypeAsString() << "</td></tr>";
    ss << "<tr bgcolor=\"#C3C8D0\"><th align=\"right\">Attribute Array Count:</th><td>" << getNumberOfTuples() << "</td></tr>";

    //        QString compDimStr = "(";
    //        for(int i = 0; i < m_CompDims.size(); i++)
    //        {
    //          compDimStr = compDimStr + QString::number(m_CompDims[i]);
    //          if(i < m_CompDims.size() - 1) {
    //             compDimStr = compDimStr + QString(", ");
    //          }
    //        }
    //        compDimStr = compDimStr + ")";
    //        ss << "<tr bgcolor=\"#C3C8D0\"><th align=\"right\">Component Dimensions:</th><td>" << compDimStr << "</td></tr>";
    //        ss << "<tr bgcolor=\"#C3C8D0\"><th align=\"right\">Total Elements:</th><td>" << m_Size << "</td></tr>";

    ss << "</tbody></table>\n";
    ss << "<br/>";
    ss << "</body></html>";
  }
  else
  {

  }
  return info;
}
示例#14
0
/**
 * @private.
 * Print Argument Or Result
 * @return the size of the argument
 */
unsigned int printArgument(OutputStream* outputStream, DeviceArgument* deviceArgument, int argumentIndex) {
	appendStringTableData(outputStream, "", DEVICE_USAGE_HEADER_COLUMN_LENGTH);
	appendStringTableData(outputStream, "", DEVICE_USAGE_NAME_COLUMN_LENGTH);
	appendStringTableData(outputStream, "", DEVICE_USAGE_IO_COLUMN_LENGTH);
	appendStringTableData(outputStream, "", DEVICE_USAGE_IO_SIZE_COLUMN_LENGTH);

    const char* argumentName = deviceArgument->name;
	appendStringTableData(outputStream, argumentName, DEVICE_USAGE_PARAM_NAME_COLUMN_LENGTH);

    unsigned char type = deviceArgument->type;

	unsigned int result = getLengthOfType(type);
	appendDecTableData(outputStream, result, DEVICE_USAGE_PARAM_SIZE_COLUMN_LENGTH);
	if (result == -1) {
		writeError(DEVICE_INTERFACE_PROBLEM);
	}

	const char* typeAsString = getTypeAsString(outputStream, type);
	appendStringTableData(outputStream, typeAsString, DEVICE_USAGE_PARAM_TYPE_COLUMN_LENGTH);
	appendTableSeparator(outputStream);
	println(outputStream);
   
    return result;
}
示例#15
0
 /**
 * @brief Returns the HDF Type for a given primitive value.
  * @param value A value to use. Can be anything. Just used to get the type info
  * from
  * @return The HDF5 native type for the value
  */
 QString getFullNameOfClass()
 {
   QString theType = getTypeAsString();
   theType = "DataArray<" + theType + ">";
   return theType;
 }
 /**
  * @brief writeXdmfAttribute
  * @param out
  * @param volDims
  * @param hdfFileName
  * @param groupPath
  * @return
  */
 virtual int writeXdmfAttribute(QTextStream& out, int64_t* volDims, const QString& hdfFileName,
                                const QString& groupPath, const QString& labelb)
 {
   out << "<!-- Xdmf is not supported for " << getNameOfClass() << " with type " << getTypeAsString() << " --> ";
   return -1;
 }
示例#17
0
    /**
     * @brief getInfoString
     * @return Returns a formatted string that contains general infomation about
     * the instance of the object.
     */
    virtual QString getInfoString(DREAM3D::InfoStringFormat format)
    {

      QLocale usa(QLocale::English, QLocale::UnitedStates);

      QString info;
      QTextStream ss (&info);
      if(format == DREAM3D::HtmlFormat)
      {
        ss << "<html><head></head>\n";
        ss << "<body>\n";
        ss << "<table cellpadding=\"4\" cellspacing=\"0\" border=\"0\">\n";
        ss << "<tbody>\n";
        ss << "<tr bgcolor=\"#D3D8E0\"><th colspan=2>Attribute Array Info</th></tr>";

        ss << "<tr bgcolor=\"#C3C8D0\"><th align=\"right\">Name:</th><td>" << getName() << "</td></tr>";


        ss << "<tr bgcolor=\"#C3C8D0\"><th align=\"right\">Type:</th><td> DataArray&lt;" << getTypeAsString() << "&gt;</td></tr>";
        QString numStr = usa.toString(static_cast<qlonglong>(getNumberOfTuples() ));
        ss << "<tr bgcolor=\"#C3C8D0\"><th align=\"right\">Number of Tuples:</th><td>" << numStr << "</td></tr>";

        QString compDimStr = "(";
        for(int i = 0; i < m_CompDims.size(); i++)
        {
          compDimStr = compDimStr + QString::number(m_CompDims[i]);
          if(i < m_CompDims.size() - 1)
          {
            compDimStr = compDimStr + QString(", ");
          }
        }
        compDimStr = compDimStr + ")";
        ss << "<tr bgcolor=\"#C3C8D0\"><th align=\"right\">Component Dimensions:</th><td>" << compDimStr << "</td></tr>";
        numStr = usa.toString(static_cast<qlonglong>(m_Size));
        ss << "<tr bgcolor=\"#C3C8D0\"><th align=\"right\">Total Elements:</th><td>" << numStr << "</td></tr>";
        numStr = usa.toString(static_cast<qlonglong>(m_Size * sizeof(T)));
        ss << "<tr bgcolor=\"#C3C8D0\"><th align=\"right\">Total Memory Required:</th><td>" << numStr << "</td></tr>";
        ss << "</tbody></table>\n";
        ss << "<br/>";
        ss << "</body></html>";
      }
      else
      {

      }
      return info;
    }