예제 #1
0
bool Qtilities::Core::ObserverDotWriter::removeNodeAttribute(QObject* node, const QString& attribute) {
    if (!d->observer)
        return false;

    if (!node)
        return false;

    QList<QObject*> tree_items = d->observer->treeChildren();
    if (!tree_items.contains(node))
        return false;

    QString prop_name("qti.dot.node." + attribute);
    QByteArray byteArray = prop_name.toAscii();
    const char * char_name = byteArray.data();
    if (!ObjectManager::propertyExists(node,char_name))
        return false;

    if (!node->setProperty(char_name,QVariant())) {
        // Set the modification state of the object:
        IModificationNotifier* mod_iface = qobject_cast<IModificationNotifier*> (node);
        if (mod_iface)
            mod_iface->setModificationState(true,IModificationNotifier::NotifyListeners,true);
        return true;
    } else
        return false;
}
예제 #2
0
int
TAO_Trader_Constraint_Evaluator::
visit_property (TAO_Property_Constraint* literal)
{
    int return_value = -1, prop_index = 0;
    // Handle case where property is not, in fact, mapped to a value
    CORBA::String_var prop_name ((const char*) literal->name ());

    if (this->props_.find (prop_name, prop_index) == 0)
    {

        CORBA::Any *value = 0;
        // Retrieve the value of the property from the Property_Evaluator
        try
        {
            value = this->prop_eval_.property_value (prop_index);
        }
        catch (const CORBA::Exception&)
        {
            return -1;
        }

        if (value != 0)
        {
            this->queue_.enqueue_head (TAO_Literal_Constraint (value));
            return_value = 0;
        }
    }

    return return_value;
}
예제 #3
0
Prop structrecord_get_prop_named(StructRecord sr, char *name) {
  for(int i = 0; i < TCOD_list_size(sr->props); i++) {
    Prop p = TCOD_list_get(sr->props, i);
    if(strcmp(prop_name(p), name) == 0) {
      return p;
    }
  }
  return NULL;
}
예제 #4
0
Geostat_grid* 
Simulacre_input_filter::read_cartesian_grid( QDataStream& stream, 
                                            std::string* errors ) {
  char* name;
  stream >> name;
  std::string grid_name( name );

  Q_INT32 version;
  stream >> version;
  if( version < 100 ) {
    errors->append( "file too old" );
    return 0;
  }

  Q_UINT32 nx, ny, nz;
  stream >> nx >> ny >> nz;
  float xsize, ysize, zsize;
  float ox,oy,oz;
  stream >> xsize >> ysize >> zsize >> ox >> oy >> oz;

  std::string final_grid_name;
  SmartPtr<Named_interface> ni = 
    Root::instance()->new_interface( "cgrid", gridModels_manager + "/" + grid_name,
                                     &final_grid_name );
  Cartesian_grid* grid = dynamic_cast<Cartesian_grid*>( ni.raw_ptr() );
  
  grid->set_dimensions( nx, ny, nz, xsize, ysize, zsize );
  grid->origin( Cartesian_grid::location_type( ox,oy,oz ) );

  Q_UINT32 properties_count;
  stream >> properties_count;

  std::vector< char* > prop_names( properties_count );
  for( unsigned int i = 0; i < properties_count; i++ ) 
    stream >> prop_names[i];
  
  for( unsigned int j = 0; j < properties_count; j++ ) {
    std::string prop_name( prop_names[j] );
    GsTLGridProperty* prop = grid->add_property( prop_name );
    for( GsTLInt k = 0; k < nx*ny*nz ; k++ ) {
      float val;
      stream >> val;
      prop->set_value( val, k );
    }
  }

  // clean up
  for( unsigned int k = 0; k < properties_count; k++ ) {
    delete [] prop_names[k];
  }
  delete [] name;

  return grid;
}
예제 #5
0
bool Qtilities::Core::ObserverDotWriter::removeEdgeAttribute(Observer* parent, QObject* child, const QString& attribute) {
    if (!d->observer)
        return false;

    if (!parent || !child)
        return false;


    QList<QObject*> tree_items = d->observer->treeChildren();
    if (parent == d->observer) {
        if (!tree_items.contains(child))
            return false;
    } else {
        if (!tree_items.contains(parent) || !tree_items.contains(child))
            return false;
    }

    // Get the specified MultiContext property:
    QString prop_name("qti.dot.edge." + attribute);
    QByteArray byteArray = prop_name.toAscii();
    const char * char_name = byteArray.data();
    MultiContextProperty property = ObjectManager::getMultiContextProperty(child,char_name);
    if (property.isValid()) {
        // Check if the property exists:
        if (!property.hasContext(parent->observerID()))
            return false;

        // Now remove the property related to the parent:
        property.removeContext(parent->observerID());

        // Set the property again:
        if (property.contextMap().keys().count() == 0)
            child->setProperty(char_name,QVariant());
        else
            ObjectManager::setMultiContextProperty(child,property);

        // Set the modification state of the object:
        IModificationNotifier* mod_iface = qobject_cast<IModificationNotifier*> (child);
        if (mod_iface)
            mod_iface->setModificationState(true,IModificationNotifier::NotifyListeners,true);

        return true;
    }

    return false;
}
예제 #6
0
CORBA::TypeCode*
TAO_Constraint_Validator::extract_type (TAO_Constraint* expr,
                                        TAO_Expression_Type& type)
{
  CORBA::TypeCode* return_value = 0;

  type = expr->expr_type ();
  if (type == TAO_IDENT)
    {
      TAO_Property_Constraint* prop = (TAO_Property_Constraint*) expr;
      CORBA::String_var prop_name (prop->name ());

      if (this->type_map_.find (prop_name, return_value) == 0)
        type = TAO_Literal_Constraint::comparable_type (return_value);
    }

  return return_value;
}
예제 #7
0
GsTLGridProperty*
Histogram_control_panel::get_property( const PropertySelector* object_selector ) {
  if( object_selector->selectedGrid().isEmpty() ||
      object_selector->selectedProperty().isEmpty() ) return 0;
  
  std::string grid_name( object_selector->selectedGrid().latin1() );
  Geostat_grid* grid = dynamic_cast<Geostat_grid*>(
                Root::instance()->interface(
                                            gridModels_manager + "/" + grid_name
                                            ).raw_ptr()
                );

  appli_assert( grid );

  std::string prop_name( object_selector->selectedProperty().latin1() );
  GsTLGridProperty* prop = grid->property( prop_name );
  appli_assert( prop );
  return prop;
}
예제 #8
0
void
TAO_Service_Type_Repository::
validate_properties (Prop_Map &prop_map,
                     const CosTradingRepos::ServiceTypeRepository::PropStructSeq &props)
{
  for (CORBA::ULong i = 0;
       i < props.length ();
       i++)
    {
      const char *n = props[i].name;
      if (TAO_Trader_Base::is_valid_property_name (n) == 0)
        throw CosTrading::IllegalPropertyName (n);
      else
        {
          CORBA::String_var prop_name (n);
          CosTradingRepos::ServiceTypeRepository::PropStruct *prop_val =
            const_cast<CosTradingRepos::ServiceTypeRepository::PropStruct *> (&props[i]);

          if (prop_map.bind (prop_name,
                             prop_val) == 1)
            throw CosTrading::DuplicatePropertyName (n);
        }
    }
}
예제 #9
0
Geostat_grid*
Simulacre_input_filter::read_pointset( QDataStream& stream, 
                                      std::string* errors ) {
  
  char* name;
  stream >> name;
  std::string grid_name( name );

  Q_INT32 version;
  stream >> version;
  if( version < 100 ) {
    errors->append( "file too old" );
    return 0;
  }

  Q_UINT32 size;
  stream >> size;
  
  // create a new point set of the correct size
  std::ostringstream ostr;
  ostr << size;
  std::string final_grid_name;
  SmartPtr<Named_interface> ni = 
    Root::instance()->new_interface( "point_set://" + ostr.str(),
                                     gridModels_manager + "/" + grid_name,
                                     &final_grid_name );
  Point_set* grid = dynamic_cast<Point_set*>( ni.raw_ptr() );

  // get the property names
  Q_UINT32 properties_count;
  stream >> properties_count;

  std::vector< char* > prop_names( properties_count );
  for( unsigned int i = 0; i < properties_count; i++ ) 
    stream >> prop_names[i];
  
  // read the coordinates of the points
  std::vector<Point_set::location_type > coords;
  for( unsigned int k = 0; k < size; k ++ ) {
    float x,y,z;
    stream >> x >> y >> z;
    coords.push_back( Point_set::location_type( x,y,z) );
  }
  grid->point_locations( coords );


  // read all the properties
  for( unsigned int j = 0; j < properties_count; j++ ) {
    std::string prop_name( prop_names[j] );
    GsTLGridProperty* prop = grid->add_property( prop_name );
    for( GsTLInt k = 0; k < size ; k++ ) {
      float val;
      stream >> val;
      prop->set_value( val, k );
    }
  }

  for( unsigned int l = 0; l < properties_count; l++ ) {
    delete [] prop_names[l];
  }
  delete [] name;

  return grid;
}
예제 #10
0
void
TAO_Service_Type_Repository::
validate_inheritance (Prop_Map &prop_map,
                      const CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq &super_types)
{
  CORBA::ULong num_super_types = super_types.length ();

  for (CORBA::ULong i = 0;
       i < num_super_types;
       i++)
    {
      Service_Type_Map::ENTRY *super_type_entry = 0;
      CORBA::String_var super_type (super_types[i]);
      CosTradingRepos::ServiceTypeRepository::ServiceTypeNameSeq place_holder;
      CosTradingRepos::ServiceTypeRepository::PropStructSeq super_props;

      this->type_map_.find (super_type, super_type_entry);

      // Super_type_entry should never be zero.
      if (super_type_entry != 0)
        this->fully_describe_type_i (super_type_entry->int_id_->type_struct_,
                                     super_props,
                                     place_holder);
      else
        continue;

      CORBA::ULong num_props = super_props.length ();

      for (CORBA::ULong j = 0;
           j < num_props;
           j++)
        {
          Prop_Map::ENTRY *existing_prop = 0;
          CORBA::String_var prop_name (super_props[j].name);

          if (prop_map.bind (prop_name,
                             &super_props[j],
                             existing_prop) == 1)
            {
              // If already there, check that it is compatible with
              // properties of other types. Value Types have to be the
              // same.
              const CosTradingRepos::ServiceTypeRepository::PropStruct &property_in_map =
                *existing_prop->int_id_;

              CORBA::TypeCode_ptr prop_type = property_in_map.value_type.in ();
              int compare = 0;
              try
                {
                  compare =
                    super_props[j].value_type->equal (prop_type);
                }
              catch (const CORBA::Exception&)
                {
                throw CosTradingRepos::ServiceTypeRepository::ValueTypeRedefinition(
                  super_props[j].name,
                  super_props[j],
                  property_in_map.name,
                  property_in_map);
                }

              if (compare == 0
                  || super_props[j].mode > property_in_map.mode)
                throw CosTradingRepos::ServiceTypeRepository::ValueTypeRedefinition(
                  super_props[j].name,
                  super_props[j],
                  property_in_map.name,
                  property_in_map);
            }
        }
    }
}
예제 #11
0
Geostat_grid* Gslib_grid_infilter::read( std::ifstream& infile ) {

    int nx = dialog_->nx();
    int ny = dialog_->ny();
    int nz = dialog_->nz();
    float x_size = dialog_->x_size();
    float y_size = dialog_->y_size();
    float z_size = dialog_->z_size();
    float Ox = dialog_->Ox();
    float Oy = dialog_->Oy();
    float Oz = dialog_->Oz();

    QByteArray tmp = dialog_->name().simplified().toLatin1();
    std::string name( tmp.constData() );

    // ask manager to get a new grid and initialize it
    SmartPtr<Named_interface> ni =
        Root::instance()->interface( gridModels_manager + "/" + name );

    if( ni.raw_ptr() != 0 ) {
        GsTLcerr << "object " << name << " already exists\n" << gstlIO::end;
        return 0;
    }

    appli_message( "creating new grid '" << name << "'"
                   << " of dimensions: " << nx << "x" << ny << "x" << nz);

    ni = Root::instance()->new_interface( "cgrid",
                                          gridModels_manager + "/" + name );
    Cartesian_grid* grid = dynamic_cast<Cartesian_grid*>( ni.raw_ptr() );
    appli_assert( grid != 0 );

    grid->set_dimensions( nx, ny, nz,
                          x_size, y_size, z_size);
    grid->origin( GsTLPoint( Ox,Oy,Oz) );
    appli_message( "grid resized to " << nx << "x" << ny << "x" << nz
                   << "  total=: " << grid->size() );

    std::string buffer;

    //-------------------------
    //   now, read the file

    // read title
    std::getline( infile, buffer, '\n');

    // read nb of properties
    int property_count;
    infile >> property_count;
    std::getline( infile, buffer, '\n');


    // check whether the file contains multiple realizations
    bool has_multi_real = false;

    int lines_to_skip = grid->size() + property_count;
    for( int pos=0; pos < lines_to_skip ; pos++ )
        std::getline( infile, buffer, '\n');
    float val;
    if( infile >> val ) has_multi_real = true;

    // reposition the stream
    infile.clear();
    infile.seekg( 0 );
    std::getline( infile, buffer, '\n');
    std::getline( infile, buffer, '\n');

    if( has_multi_real ) {
        std::vector<MultiRealization_property*> properties;
        for( int i=0; i<property_count; i++ ) {
            std::getline( infile, buffer, '\n');
            QString prop_name( buffer.c_str() );
            MultiRealization_property* prop;
            QByteArray tmp = prop_name.simplified().toAscii();
            prop = grid->add_multi_realization_property( tmp.constData() );
            if( !prop ) {
                GsTLcerr << "Several properties share the same name " << gstlIO::end;
                return 0;
            }

            properties.push_back( prop );

        }


        while( infile ) {
            if( !infile ) break;
            char c = infile.peek();
            if( !std::isdigit(c) ) break;

            std::vector<GsTLGridProperty*> props;
            int index = 0;
            for( unsigned int ii=0; ii < property_count; ii++) {

                GsTLGridProperty* prop = properties[index]->new_realization();
                props.push_back( prop );
                ++index;

            }
            read_one_realization( infile, props, grid->size() );
        }
    }

    else {
        std::vector<GsTLGridProperty*> properties;
        for( int i=0; i<property_count; i++ ) {
            std::getline( infile, buffer, '\n');
            QString prop_name( buffer.c_str() );

            QByteArray tmp  =prop_name.simplified().toAscii();
            GsTLGridProperty* prop =
                grid->add_property( tmp.constData() );
            properties.push_back( prop );
        }
        read_one_realization( infile, properties, grid->size() );

    }

    return grid;
}
예제 #12
0
Geostat_grid* Gslib_mgrid_infilter::readRegularGridFormat(std::ifstream& infile,Reduced_grid * grid)
{
    std::vector<std::string> nums;

    int nx = dialog_->nx();
    int ny = dialog_->ny();
    int nz = dialog_->nz();
    float x_size = dialog_->x_size();
    float y_size = dialog_->y_size();
    float z_size = dialog_->z_size();
    float Ox = dialog_->Ox();
    float Oy = dialog_->Oy();
    float Oz = dialog_->Oz();

    grid->set_dimensions( nx, ny, nz,
                          x_size, y_size, z_size);
    grid->origin( GsTLPoint( Ox,Oy,Oz) );

    std::string buffer;

    int maskColNumber = dialog_->mask_column()-1;

    //-------------------------
    //   now, read the file

    // read title
    std::getline( infile, buffer, '\n');

    // read nb of properties
    int total_columns;
    infile >> total_columns;
    std::getline( infile, buffer, '\n');

    if (maskColNumber > total_columns) {
        GsTLcerr << "Invalid mask column" << gstlIO::end;
        return NULL;
    }

    bool has_multi_real = false;
//	std::vector<GsTLGridProperty*> properties;
    for( int i=0; i<total_columns; i++ ) {
        std::getline( infile, buffer, '\n');
        QString prop_name( buffer.c_str() );
//		if( i != maskColNumber ) {
//      GsTLGridProperty* prop = grid->add_property(prop_name.toStdString());
//      properties.push_back( prop );
//		}
    }

    int beg_data_pos = infile.tellg();
    std::vector<bool> mask;
    mask.reserve(grid->rgrid_size());
    int size_active=0;

// Read Mask

    for( int i=0; i < grid->rgrid_size() ; i++ ) {
        std::getline( infile, buffer, '\n');
        QString qbuffer(buffer.c_str());
        QStringList buf = qbuffer.split(" ",QString::SkipEmptyParts);

        //std::vector<std::string> buf = String_Op::decompose_string(buffer, " ", false);
        if(buf.size() < total_columns) {
            GsTLcerr << "Invalid file format\n Line " <<i<<" does not have " <<total_columns<<" columns"<< gstlIO::end;
            return NULL;
        }
        bool is_active = buf[maskColNumber].toFloat() == 1. ;
        mask.push_back( is_active );
    }
    grid->mask( mask );


// We are at the end of the file, if more data are present,
// it is another realizations
    float val;
    if( infile >> val ) has_multi_real = true;

    // reposition the stream
    infile.clear();
    infile.seekg( 0 );
    std::getline( infile, buffer, '\n');
    std::getline( infile, buffer, '\n');

    if( has_multi_real ) {
        std::vector<MultiRealization_property*> properties;
        for( int i=0; i<total_columns; i++ ) {
            std::getline( infile, buffer, '\n');
            QString prop_name( buffer.c_str() );
            MultiRealization_property* prop;

            if (i != maskColNumber ) {
//				QByteArray tmp = prop_name.simplified().toAscii();
                prop = grid->add_multi_realization_property( prop_name.toStdString() );
                if( !prop ) {
                    GsTLcerr << "Several properties share the same name " << gstlIO::end;
                    return 0;
                }
                properties.push_back( prop );
            }
        }

        while( infile ) {
            if( !infile ) break;
            char c = infile.peek();
            if( !std::isdigit(c) ) break;

            std::vector<GsTLGridProperty*> props;
            std::vector<MultiRealization_property*>::iterator multi_prop_it = properties.begin();
            for( unsigned int ii=0; ii < total_columns; ii++) {
                if (ii != maskColNumber) {
                    GsTLGridProperty* prop = (*multi_prop_it)->new_realization();
                    multi_prop_it++;
                    props.push_back( prop );
                }
            }
            if( props.size() > 0 )  // If onyl the mask was present in the file
                read_one_realization( infile, props, grid );
        }
    }

    else {
        std::vector<GsTLGridProperty*> properties;
        for( int i=0; i<total_columns; i++ ) {
            std::getline( infile, buffer, '\n');
            QString prop_name( buffer.c_str() );

            if (i != maskColNumber) {
                GsTLGridProperty* prop =
                    grid->add_property( prop_name.toStdString() );
                properties.push_back( prop );
            }
        }
        if( properties.size() > 0 )  // If onyl the mask was present in the file
            read_one_realization( infile, properties, grid);
    }
    return grid;
}