Exemple #1
0
void Variable::writeTimeStep( int exodusFileId, std::size_t timeStep ) {
  EXODUS_CALL(
    ex_put_var(
      exodusFileId,
      (int)( timeStep + 1 ),
      mExodusObjectType,
      mVariableIndex,
      mObjectId,
      (int)dataItem()->data()->array()->size(),
      (void*)dataItem()->typedArray< double >()->begin() ),
    "Unable to write variable." );
}
Exemple #2
0
void Variable::readTimeStep( int exodusFileId, std::size_t timeStep ) {
  EXODUS_CALL(
    ex_get_var(
      exodusFileId,
      (int)( timeStep + 1 ),
      mExodusObjectType,
      mVariableIndex,
      mObjectId,
      (int)dataItem()->data()->array()->size(),
      dataItem()->data()->array()->data() ),
    "Could not read variable values." );
}
Exemple #3
0
  foreach ( QString key, providersList )
  {
    QLibrary *library = QgsProviderRegistry::instance()->providerLibrary( key );
    if ( !library )
      continue;

    dataCapabilities_t * dataCapabilities = ( dataCapabilities_t * ) cast_to_fptr( library->resolve( "dataCapabilities" ) );
    if ( !dataCapabilities )
    {
      QgsDebugMsg( library->fileName() + " does not have dataCapabilities" );
      continue;
    }

    int capabilities = dataCapabilities();
    if ( capabilities == QgsDataProvider::NoDataCapabilities )
    {
      QgsDebugMsg( library->fileName() + " does not have any dataCapabilities" );
      continue;
    }

    dataItem_t *dataItem = ( dataItem_t * ) cast_to_fptr( library->resolve( "dataItem" ) );
    if ( !dataItem )
    {
      QgsDebugMsg( library->fileName() + " does not have dataItem" );
      continue;
    }

    QgsDataItem *item = dataItem( "", NULL );  // empty path -> top level
    if ( item )
    {
      QgsDebugMsg( "Add new top level item : " + item->name() );
      connectItem( item );
      providerMap.insertMulti( capabilities, item );
    }
  }
Exemple #4
0
void VisGlyph::inputMouseMotion(int x, int y)
{
	// If the visual mapping result is NULL, do noting and return
	if (!this->getOkcVisualMapResult()) {
		return;
	}

	int pointNo;
	Vec2 p = m_canvas->mapScreenToData(Vec2(x, y));
	inputGlyphFindPointNear(p.X, p.Y, pointNo);

	if(pointNo == -1){
		return;
	}

	std::vector<double> dataItem(m_dim_size);
	OkcVisualMapResult* vmr = getOkcVisualMapResult();
	Data* data = vmr->getData();
	OkcData* okcdata = dynamic_cast<OkcData*>(data);
	okcdata->getData(dataItem, pointNo);

	char buffer [5000];
	buffer[0] = 0;

	char glyphNo [10];
	sprintf (glyphNo, "%d", pointNo);

	double dimValue;
	char dimValueChar [30];


	strcat(buffer, "Glyph:");
	strcat(buffer, glyphNo);
	strcat(buffer, " [");

	for(int i=0; i<m_dim_size; i++){
		char *temp = m_dim_names[i];
		strcat(buffer, temp);
		strcat(buffer, "=");
		dimValue  = dataItem[i];
		sprintf(dimValueChar,"%.2lf",dimValue);
		strcat(buffer, dimValueChar);
		if(i==m_dim_size-1){
			break;
		}
		strcat(buffer, ",");
	}



	strcat(buffer, "]");

	this->getViewManager()->getMainWnd()->statusBar->showMessage(QString(buffer));

}
Exemple #5
0
QVariant QgsBrowserModel::data( const QModelIndex &index, int role ) const
{
  if ( !index.isValid() )
    return QVariant();

  QgsDataItem *item = dataItem( index );
  if ( !item )
  {
    return QVariant();
  }
  else if ( role == Qt::DisplayRole || role == Qt::EditRole )
  {
    return item->name();
  }
  else if ( role == QgsBrowserModel::SortRole )
  {
    return item->sortKey();
  }
  else if ( role == Qt::ToolTipRole )
  {
    return item->toolTip();
  }
  else if ( role == Qt::DecorationRole && index.column() == 0 )
  {
    return item->icon();
  }
  else if ( role == QgsBrowserModel::PathRole )
  {
    return item->path();
  }
  else if ( role == QgsBrowserModel::CommentRole )
  {
    if ( item->type() == QgsDataItem::Layer )
    {
      QgsLayerItem *lyrItem = qobject_cast<QgsLayerItem *>( item );
      return lyrItem->comments();
    }
    return QVariant();
  }
  else
  {
    // unsupported role
    return QVariant();
  }
}
        void addIntKeyword_(Opm::DeckPtr subDeck,
                               const std::string& keywordName,
                               const std::vector<int>& data)
        {
            if (data.empty())
                return;

            Opm::DeckKeywordPtr dataKw(new Opm::DeckKeyword(keywordName));
            Opm::DeckRecordPtr dataRecord(new Opm::DeckRecord());
            Opm::DeckIntItemPtr dataItem(new Opm::DeckIntItem("DATA"));

            for (size_t i = 0; i < data.size(); ++i) {
                dataItem->push_back(data[i]);
            }

            dataRecord->addItem(dataItem);
            dataKw->addRecord(dataRecord);
            subDeck->addKeyword(dataKw);
        }
Exemple #7
0
Variable::Variable(
  int exodusObjectType,
  int variableIndex,
  int objectId,
  std::size_t numberOfEntries ) :

  xdmGrid::Attribute( xdmGrid::Attribute::kScalar, xdmGrid::Attribute::kElement ),
  mExodusObjectType( exodusObjectType ),
  mVariableIndex( variableIndex ),
  mObjectId( objectId ) {

  xdm::RefPtr< xdm::VectorStructuredArray< double > > data(
    new xdm::VectorStructuredArray< double >( numberOfEntries ) );
  xdm::RefPtr< xdm::UniformDataItem > dataItem(
    new xdm::UniformDataItem( xdm::primitiveType::kDouble, xdm::makeShape( numberOfEntries ) ) );
  dataItem->setData( xdm::makeRefPtr( new xdm::ArrayAdapter( data ) ) );
  dataItem->data()->setIsDynamic( true );
  setDataItem( dataItem );
}
        void addDoubleKeyword_(Opm::DeckPtr subDeck,
                               const std::string& keywordName,
                               const std::string& dimensionString,
                               const std::vector<double>& data)
        {
            if (data.empty())
                return;

            Opm::DeckKeywordPtr dataKw(new Opm::DeckKeyword(keywordName));
            Opm::DeckRecordPtr dataRecord(new Opm::DeckRecord());
            Opm::DeckDoubleItemPtr dataItem(new Opm::DeckDoubleItem("DATA"));

            for (size_t i = 0; i < data.size(); ++i) {
                dataItem->push_back(data[i]);
            }

            std::shared_ptr<const Dimension> dimension = metricUnits_->parse(dimensionString);
            dataItem->push_backDimension(/*active=*/dimension, /*default=*/dimension);

            dataRecord->addItem(dataItem);
            dataKw->addRecord(dataRecord);
            subDeck->addKeyword(dataKw);
        }
Exemple #9
0
bool QgsBrowserModel::setData( const QModelIndex &index, const QVariant &value, int role )
{
  if ( !index.isValid() )
    return false;


  QgsDataItem *item = dataItem( index );
  if ( !item )
  {
    return false;
  }

  if ( !( item->capabilities2() & QgsDataItem::Rename ) )
    return false;

  switch ( role )
  {
    case Qt::EditRole:
    {
      return item->rename( value.toString() );
    }
  }
  return false;
}
Exemple #10
0
xdm::RefPtr< xdmGrid::UniformGrid > build2DGrid() {
  xdm::RefPtr< xdmGrid::UniformGrid > grid( new xdmGrid::UniformGrid );
  grid->setName( "FunctionEvaluationGrid" );

  // Time
  {
    grid->setTime( xdm::makeRefPtr( new xdmGrid::Time( 0.0 ) ) );
  }

  // Topology
  {
     xdm::RefPtr< xdmGrid::RectilinearMesh > topology( new xdmGrid::RectilinearMesh );
    topology->setShape( xdm::makeShape( kMeshSize[0]-1, kMeshSize[1]-1 ) );
    grid->setTopology( topology );
  }

  // Geometry
  xdm::RefPtr< xdm::VectorStructuredArray< float > > meshValues[2];
  {
    xdm::RefPtr< xdmGrid::TensorProductGeometry > geometry(
      new xdmGrid::TensorProductGeometry( 2 ) );
    for ( int i = 0; i < 2; i++ ) {
      // Build the Geometry data as single precision to force an up conversion
      // upon read.
      xdm::RefPtr< xdm::UniformDataItem > dataItem( new xdm::UniformDataItem );
      dataItem->setDataType( xdm::primitiveType::kFloat );
      dataItem->setDataspace( xdm::makeShape( kMeshSize[i] ) );
      meshValues[i] = xdm::makeRefPtr(
        new xdm::VectorStructuredArray< float >( kMeshSize[i] ) );
      for ( int j = 0; j < kMeshSize[i]; j++ ) {
        (*meshValues[i])[j] = kRange[i][0] + j * ( (kRange[i][1] - kRange[i][0]) / kMeshSize[i] );
      }
      dataItem->setData( xdm::makeRefPtr( new xdm::ArrayAdapter( meshValues[i] ) ) );
      geometry->setCoordinateValues( i, dataItem );
    }
    grid->setGeometry( geometry );
  }

  // Give it an attribute.
  {
    xdm::RefPtr< xdmGrid::Attribute > attribute( new xdmGrid::Attribute(
      xdmGrid::Attribute::kScalar,
      xdmGrid::Attribute::kNode ) );
    attribute->setName( "attr" );
    xdm::RefPtr< xdm::VectorStructuredArray< double > > attrValues(
      new xdm::VectorStructuredArray< double >( kMeshSize[1] * kMeshSize[0] ) );
    for ( int j = 0; j < kMeshSize[1]; j++ ) {
      for ( int i = 0; i < kMeshSize[0]; i++ ) {
        double xpoint = (*meshValues[0])[i];
        double ypoint = (*meshValues[1])[j];
        (*attrValues)[j*kMeshSize[0] + i] = function( xpoint, ypoint );
      }
    }
    xdm::RefPtr< xdm::UniformDataItem > dataItem(
      new xdm::UniformDataItem(
        xdm::primitiveType::kDouble,
        xdm::makeShape( kMeshSize[1], kMeshSize[0] ) ) );
    dataItem->setData( xdm::makeRefPtr( new xdm::ArrayAdapter( attrValues, true ) ) );
    attribute->setDataItem( dataItem );
    grid->addAttribute( attribute );
  }

  return grid;
}