Beispiel #1
0
//--------- Begin of function SiteArray::del_site ----------//
//
// Delete a specified site.
//
// <int> siteRecno = the record no. of the site to be deleted
//
void SiteArray::del_site(int siteRecno)
{
	err_if( siteRecno == 0 )
		err_now( "SiteArray::del_site" );

	Site* sitePtr = site_array[siteRecno];

	switch( sitePtr->site_type )
	{
		case SITE_RAW:
			untapped_raw_count--;
			break;

		case SITE_SCROLL:
			scroll_count--;
			break;

		case SITE_GOLD_COIN:
			gold_coin_count--;
			break;
	}

	//-------------------------------//

	sitePtr->deinit();

	linkout(siteRecno);

	if( siteRecno == site_array.selected_recno )
		site_array.selected_recno = 0;
}
 // ContextObserver impl
 void onActiveSiteChange(const Site& site) override {
   if (isVisible())
     setCel(static_cast<app::Document*>(const_cast<doc::Document*>(site.document())),
            const_cast<Cel*>(site.cel()));
   else if (m_document)
     setCel(nullptr, nullptr);
 }
Beispiel #3
0
//--------- Begin of function SiteArray::add_site ---------//
//
// Add a raw item to the site array
//
// Return : 1 - the raw is added
//          0 - duplicated, not added
//
int SiteArray::add_site(int xLoc, int yLoc, int siteType, int objectId, int reserveQty)
{
	//----- linkin the raw and update raw attribute ----//

	Site site;

	linkin(&site);

	Site* sitePtr = (Site*) get(recno());

	sitePtr->init(recno(), siteType, xLoc, yLoc);

	sitePtr->object_id 	= objectId;
	sitePtr->reserve_qty = reserveQty;

	switch( siteType )
	{
		case SITE_RAW:
			untapped_raw_count++;
			break;

		case SITE_SCROLL:
			scroll_count++;
			break;

		case SITE_GOLD_COIN:
			gold_coin_count++;
			break;
	}

	return 1;
}
TEST_F(ModelFixture, ShadingSurfaceGroup_SetParent)
{
  Model model;

  Site site = model.getUniqueModelObject<Site>();
  Building building = model.getUniqueModelObject<Building>();
  Space space(model);

  ShadingSurfaceGroup group(model);
  EXPECT_EQ("Building", group.shadingSurfaceType());
  ASSERT_TRUE(group.parent());
  EXPECT_EQ(building.handle(), group.parent()->handle());
  EXPECT_FALSE(group.space());

  EXPECT_TRUE(group.setParent(site));
  EXPECT_EQ("Site", group.shadingSurfaceType());
  ASSERT_TRUE(group.parent());
  EXPECT_EQ(site.handle(), group.parent()->handle());
  EXPECT_FALSE(group.space());

  EXPECT_TRUE(group.setParent(space));
  EXPECT_EQ("Space", group.shadingSurfaceType());
  ASSERT_TRUE(group.parent());
  EXPECT_EQ(space.handle(), group.parent()->handle());
  ASSERT_TRUE(group.space());
  EXPECT_EQ(space.handle(), group.space()->handle());

  EXPECT_TRUE(group.setParent(building));
  EXPECT_EQ("Building", group.shadingSurfaceType());
  ASSERT_TRUE(group.parent());
  EXPECT_EQ(building.handle(), group.parent()->handle());
  EXPECT_FALSE(group.space());
}
Beispiel #5
0
	std::vector< Point* > Voronoi::region( Point* p )
	{
		Site* site = _sitesIndexedByLocation[p];
		if( !site )
			return std::vector< Point* >( );
		return site->region( _plotBounds );
	}
Beispiel #6
0
// export sites to an EPS image
bool save_eps(const char* filename, const Site<Point2>::Vector& sites, const double width, const double height, const double radius) {
  std::ofstream stream(filename, std::ios::out);
  if (stream.bad()) {
    return false;
  }

  stream << "%!PS-Adobe EPSF-3.0\n";
  stream << "%%HiResBoundingBox: " << 0.0 << " " << 0.0 << " " << width << " " << height << "\n";
  stream << "%%BoundingBox: " << 0 << " " << 0 << " " << static_cast<int>(width) << " " << static_cast<int>(height) << "\n";
  stream << "\n";
  stream << "%% Sites: " << sites.size() << "\n";
  stream << "\n";
  stream << "/radius { " << radius << " } def\n";
  stream << "\n";
  stream << "/p { radius 0 360 arc closepath fill } def\n";
  stream << "\n";
  stream << "0 0 0 setrgbcolor\n";
  stream << "\n";
  for (unsigned int i = 0; i < sites.size(); ++i) {
    stream << sites[i].location.x << " " << sites[i].location.y << " p\n";
  }
  stream << "\n";
  stream << "showpage\n";

  stream.close();
  return true;
}
void VectorSiteContainer::addSite(const Site& site, size_t siteIndex, bool checkPositions) throw (Exception)
{
  if (siteIndex >= getNumberOfSites())
    throw IndexOutOfBoundsException("VectorSiteContainer::addSite", siteIndex, 0, getNumberOfSites() - 1);

  // Check size:
  if (site.size() != getNumberOfSequences())
    throw SiteException("VectorSiteContainer::addSite. Site does not have the appropriate length", &site);

  // New site's alphabet and site container's alphabet matching verification
  if (site.getAlphabet()->getAlphabetType() != getAlphabet()->getAlphabetType())
  {
    throw AlphabetMismatchException("VectorSiteContainer::addSite", getAlphabet(), site.getAlphabet());
  }

  // Check position:
  if (checkPositions)
  {
    int position = site.getPosition();
    // For all positions in vector : throw exception if position already exists
    for (size_t i = 0; i < sites_.size(); i++)
    {
      if (sites_[i]->getPosition() == position)
        throw SiteException("VectorSiteContainer::addSite. Site position already exists in container", &site);
    }
  }

  // insert(begin() + pos, new Site(site));
  sites_.insert(sites_.begin() + siteIndex, dynamic_cast<Site*>(site.clone()));
}
Beispiel #8
0
JSBool JsSite::getAttributeNames(JSContext *cx,JSObject *obj,uintN argc,jsval *argv,jsval *rval)
{
	Site *site = (Site*)JS_GetPrivate(cx,obj);

	JSObject *arr = JS_NewArrayObject(cx,0,NULL);
	if ( arr!=NULL )
	{
		int count=0;

		std::map<std::string,std::string> attributes = site->getAttributes();
		std::map<std::string,std::string>::const_iterator iter;
		for ( iter=attributes.begin(); iter!=attributes.end(); iter++ )
		{
			JSString *str = JS_NewStringCopyN(cx,iter->first.c_str(),iter->first.length());
			jsval element = STRING_TO_JSVAL(str);
			if ( JS_SetElement(cx,arr,count,&element)==JS_TRUE ) {
				count++;
			}
		}

		*rval = OBJECT_TO_JSVAL(arr);
	}

	return JS_TRUE;
}
Beispiel #9
0
//set properties of specified site
int AMUSE_SimpleX::set_site(int id, double x, double y, double z, double rho,
                                              double flux, double xion, double uInt, double metallicity){
    SITE_ITERATOR p;
    Site tmp;
    
    tmp.set_vertex_id((unsigned long long) id);
    p = lower_bound(sites.begin(), sites.end(), tmp, compare_vertex_id_site);
    if(p->get_vertex_id() == (unsigned long long int)id){
        p->set_x(x);
        p->set_y(y);
        p->set_z(z);
        //set number of ionising photons
        if(flux > 0.0){
          if(p->get_source()==0) p->create_flux(numFreq);
          p->set_source(1);
          p->set_flux( 0, flux );
          for(int f=1;f<numFreq;f++) p->set_flux(f,0.);
        }else{
          if(p->get_source()==1) p->delete_flux();
          p->set_source(0);
        }
        p->set_n_HI((1-xion)*rho);
        p->set_n_HII(xion*rho);
	      p->set_internalEnergy( uInt );
        p->set_metallicity( metallicity );
        
        return 1;
    }
    return 0;
}
Beispiel #10
0
int AMUSE_SimpleX::get_mean_intensity(int id, double *mean_intensity){
  
  SITE_ITERATOR p;
  Site tmp;
    
  tmp.set_vertex_id((unsigned long long) id);
  p=lower_bound(sites.begin(), sites.end(), tmp, compare_vertex_id_site);
  if(p->get_vertex_id() == (unsigned long long int)id){
      if (p->get_process() == COMM_RANK){
        
        double meanIntensity = 0.0;
        //in case of ballistic transport, intensity has size of number of neighbours;
        //in case of direction conserving transport, intensity has 
        //the size of the tesselation of the unit sphere
        numPixels = ( p->get_ballistic() ) ? p->get_numNeigh() : number_of_directions;
        
        for(unsigned int i=0; i<numPixels; i++){
          short int start = (rec_rad) ? 1 : 0;
          for(short int f=start;f<numFreq;f++){
            meanIntensity += p->get_intensityOut(f,i) + p->get_intensityIn(f,i);
          }
        }
        *mean_intensity = meanIntensity;
        return 1;
      }
  }
  return 0;
   
}
Beispiel #11
0
//return properties of specified site
int AMUSE_SimpleX::get_site(int id, double *x,double *y,double *z,double *rho,
                                              double *flux,double *xion, double *uInt, double *metallicity){
   SITE_ITERATOR p;
   Site tmp;
   
   tmp.set_vertex_id((unsigned long long) id);
   p=lower_bound(sites.begin(),sites.end(), tmp, compare_vertex_id_site);
   if(p->get_vertex_id() == (unsigned long long int)id){
     if (p->get_process() == COMM_RANK){
       *x=p->get_x();
       *y=p->get_y();
       *z=p->get_z();
       double nH = (double) p->get_n_HI() + (double) p->get_n_HII();
       *rho = nH;
       double totalFlux = 0.0;
       if( p->get_source() ){
         for(short int f=0; f<numFreq;f++){
           totalFlux += p->get_flux(f);
         }
       }
       *flux = totalFlux;
       *xion = (double) p->get_n_HII()/nH;
       *uInt = p->get_internalEnergy();
       *metallicity = p->get_metallicity();
       
       return 1;
     }
   }
   return 0;
}
QList<Site*> SitesDatabaseInterface::getAllSites()
{
    qDebug() << "db: " << this->dbPath;
    QList<Site*> siteList;

    QSqlDatabase db = QSqlDatabase::addDatabase("QSQLITE");
    db.setDatabaseName(this->dbPath);

    if(false == db.open())
    {
        qDebug() << "can not open database";
    }

    QSqlQuery query= db.exec("SELECT * FROM sites");
    while (query.next())
    {
        int id = query.value(0).toInt();
        QString nom = query.value(1).toString();
        QString years = query.value(2).toString();
        QStringList yearsList = years.split(";");
        Site* site = new Site();

        site->setId(id);
        site->setNom(nom);
        site->setYears(yearsList);
        siteList.append(site);
    }
    db.close();

    return siteList;
}
Beispiel #13
0
	Rectangle SiteList::sitesBounds( )
	{
		if( !_sorted ){
			Site::sortSites( _sites );
			_currentIndex = 0;
			_sorted = true;
		}

		Number xmin, xmax, ymin, ymax;
		if( _sites.size() == 0 )
			return Rectangle( 0, 0, 0, 0 );
		xmin = DELAUNAY_NUMBER_MAX;
		xmax = DELAUNAY_NUMBER_MIN;
		for( std::vector<Site*>::iterator it = _sites.begin(); it != _sites.end(); ++it ){
			Site* site = ( *it );
			if( site->x() < xmin )
				xmin = site->x();
			if( site->x() > xmax )
				xmax = site->x();
		}
		// here's where we assume that the sites have been sorted on y:
		ymin = _sites[0]->y();
		ymax = _sites[_sites.size() - 1]->y();

		return Rectangle( xmin, ymin, xmax - xmin, ymax - ymin );
	}
Beispiel #14
0
JSBool JsSite::getPath(JSContext *cx,JSObject *obj,uintN argc,jsval *argv,jsval *rval)
{
	Site *site = (Site*)JS_GetPrivate(cx,obj);
	JSString *str = JS_NewStringCopyN(cx,site->getPath().c_str(),site->getPath().length());
	*rval = STRING_TO_JSVAL(str);

	return JS_TRUE;
}
Beispiel #15
0
void ContextFlags::update(Context* context)
{
  Site site = context->activeSite();
  Document* document = static_cast<Document*>(site.document());

  m_flags = 0;

  if (document) {
    m_flags |= HasActiveDocument;

    if (document->lock(Document::ReadLock, 0)) {
      m_flags |= ActiveDocumentIsReadable;

      if (document->isMaskVisible())
        m_flags |= HasVisibleMask;

      Sprite* sprite = site.sprite();
      if (sprite) {
        m_flags |= HasActiveSprite;

        if (sprite->backgroundLayer())
          m_flags |= HasBackgroundLayer;

        Layer* layer = site.layer();
        if (layer) {
          m_flags |= HasActiveLayer;

          if (layer->isBackground())
            m_flags |= ActiveLayerIsBackground;

          if (layer->isVisible())
            m_flags |= ActiveLayerIsVisible;

          if (layer->isEditable())
            m_flags |= ActiveLayerIsEditable;

          if (layer->isImage()) {
            m_flags |= ActiveLayerIsImage;

            Cel* cel = layer->cel(site.frame());
            if (cel) {
              m_flags |= HasActiveCel;

              if (cel->image())
                m_flags |= HasActiveImage;
            }
          }
        }
      }

      if (document->lockToWrite(0))
        m_flags |= ActiveDocumentIsWritable;

      document->unlock();
    }
  }
}
Beispiel #16
0
bool SiteIsEdge(const Site& site) {
	const Index& ind = site.GetIndex();
	if (_CheckMin(ind))
		return true;

	if (_CheckMax(ind, site.GetBlock().GetDomain().GetSiteCounts() - 1))
		return true;
	return false;
}
Beispiel #17
0
void sourcesWindow::checkForUpdates()
{
	QStringList keys = m_sites->keys();
	for (int i = 0; i < m_sites->size(); i++)
	{
		Site *site = m_sites->value(keys[i]);
		site->checkForUpdates();
		connect(site, SIGNAL(checkForUpdatesFinished(Site*)), this, SLOT(checkForUpdatesReceived(Site*)));
	}
}
Beispiel #18
0
Site *searchByWebSite(Site *site, Token *listTokens){
    bool match;
    Site *newSite = new Site(site->getName(), site->getAddress());
    newSite->setAddress(site->getAddress());
    int numberMatches;
    for(Token *tempToken = listTokens; tempToken != NULL; tempToken = tempToken->sig){
        //
        numberMatches = 0;
        string strToken = tempToken->getStrToken();
        string strTitle = site->getName();
        string strBody = site->getBody();
        //cout<<"TITLE"<<endl;
        for(int n = 0; n < strTitle.length(); n++){
            if(strTitle[n] == strToken[0]){
                int tempN = n; match = true;
                for(int m = 0; m < strToken.length(); m++){
                    //cout<< strTitle[tempN] << " == "<< strToken[m]<<endl;
                    if(tempN >= strTitle.length() || strTitle[tempN] != strToken[m]){
                        match = false;
                        break;
                    }
                    tempN = tempN + 1;
                }
                if(match){
                    numberMatches ++;
                }
            }
        }
        //cout<<"BODY:"<<strBody<<endl;
        for(int n = 0; n < strBody.length(); n++){
            if(strBody[n] == strToken[0]){
                int tempN = n; match = true;
                for(int m = 0; m < strToken.length(); m++){
                    //cout<< strBody[tempN] << " == "<< strToken[m]<<endl;
                    if(tempN >= strBody.length() || strBody[tempN] != strToken[m]){
                        match = false;
                        break;
                    }
                    tempN = tempN + 1;
                }
                if(match){
                    numberMatches ++;
                    //cout<<">> Match in: "<<strToken<<endl;
                }
            }
        }
        //
        if(numberMatches > 0){
            //cout<<">> Match in: "<<strToken<<endl;
            Token *newToken = new Token(tempToken->getStrToken(), numberMatches);
            newSite->addToken(newToken);
        }
    }
    return newSite;
}
Beispiel #19
0
void Node::add_root_consensus(vector<Fasta_entry> *aligned_sequences)
{
    Sequence *root = this->get_sequence();
    int root_length = root->sites_length();
    Fasta_entry entry;
    entry.name = "consensus";
    entry.comment = "";

    for(int j=1;j<root_length-1;j++)
    {
        Site *site = root->get_site_at(j);
        int sA = site->get_sumA();
        int sC = site->get_sumC();
        int sG = site->get_sumG();
        int sT = site->get_sumT();

        if(sA+sC+sG+sT<Settings_handle::st.get("consensus-minimum").as<int>())
        {
            entry.sequence.append("-");
        }
        else{
            if(sA>sC && sA>sG && sA>sT)
                entry.sequence.append("A");
            else if(sC>sA && sC>sG && sC>sT)
                entry.sequence.append("C");
            else if(sG>sA && sG>sC && sG>sT)
                entry.sequence.append("G");
            else if(sT>sA && sT>sC && sT>sG)
                entry.sequence.append("T");
            else if(sA>sC && sA==sG && sA>sT)
                entry.sequence.append("R");
            else if(sC>sA && sC>sG && sC==sT)
                entry.sequence.append("Y");
            else if(sA==sC && sA>sG && sA>sT)
                entry.sequence.append("M");
            else if(sG>sA && sG>sC && sG==sT)
                entry.sequence.append("K");
            else if(sA>sC && sA>sG && sA==sT)
                entry.sequence.append("W");
            else if(sC>sA && sC==sG && sC>sT)
                entry.sequence.append("S");
            else if(sC>sA && sC==sG && sC==sT)
                entry.sequence.append("B");
            else if(sA>sC && sA==sG && sA==sT)
                entry.sequence.append("D");
            else if(sA==sC && sA>sG && sA==sT)
                entry.sequence.append("H");
            else if(sA==sC && sA==sG && sA>sT)
                entry.sequence.append("V");
            else if(sA==sC && sA==sG && sA==sT)
                entry.sequence.append("N");
        }
    }
    aligned_sequences->push_back(entry);
}
Beispiel #20
0
void Value::split(Context* c)
{
  this->grow(c);
  for (SiteIterator it(c, this); it.hasMore();) {
    Site* s = it.next();
    this->removeSite(c, s);

    this->addSite(c, s->copyLow(c));
    this->nextWord->addSite(c, s->copyHigh(c));
  }
}
void Site::addCategory(const QString &name)
{
  QDomElement cat = m_element.ownerDocument().createElement("category");

  // Create a new category
  Site *site = new Site(m_manager, cat);
  site->setAttribute("name", name, false);
  m_element.appendChild(cat);
  m_manager->cacheSite(site);
  
  emit m_manager->siteAdded(site);
}
Beispiel #22
0
int AMUSE_SimpleX::set_metallicity(int id, double metallicity){
    SITE_ITERATOR p;
    Site tmp;
    
    tmp.set_vertex_id((unsigned long long) id);
    p=lower_bound(sites.begin(), sites.end(), tmp, compare_vertex_id_site);
    if(p->get_vertex_id() == (unsigned long long int)id){
      p->set_metallicity( metallicity );
      return 1;
    }
    return 0;
}
Beispiel #23
0
int AMUSE_SimpleX::set_dinternalEnergydt(int id, double uInt){
    SITE_ITERATOR p;
    Site tmp;
    
    tmp.set_vertex_id((unsigned long long) id);
    p=lower_bound(sites.begin(), sites.end(), tmp, compare_vertex_id_site);
    if(p->get_vertex_id() == (unsigned long long int)id){
      p->set_dinternalEnergydt( uInt );
      return 1;
    }
    return 0;
}
TEST_F(ModelFixture, ClimateZones_Site)
{
  // construct Site
  Model model;
  Site site = model.getUniqueModelObject<Site>();
  EXPECT_FALSE(site.climateZones());

  // set value creates ClimateZones object
  StringVector validValues = ClimateZones::validClimateZoneValues(
      ClimateZones::ashraeInstitutionName(),ClimateZones::ashraeDefaultYear());
  ASSERT_EQ(17u,validValues.size());
}
Beispiel #25
0
bool operator==(const Site& site1, const Site& site2)
{
	// Verify that site's size, position and content are equals
	if(site1.size() != site2.size()) return false;
	if(site1.getPosition() != site2.getPosition()) return false;
	else {
		for(unsigned int i = 0; i < site1.size(); i++) {
			if(site1[i] != site2[i]) return false;
		}
		return true;
	}
}
Beispiel #26
0
void printListSites(Site *listSites, int option){
    int c = 0;
    for(Site *tempSites = listSites; tempSites!=NULL;tempSites = tempSites->sig){
        if(option == 0){
            cout<<c<<"- ";
            tempSites->print();
            c++;
        }
        else if(option == 1){
            tempSites->printAll();
        }
    }
}
Beispiel #27
0
JSBool JsSite::removeOption(JSContext *cx,JSObject *obj,uintN argc,jsval *argv,jsval *rval)
{
	char *name = {0};

	if ( !JS_ConvertArguments(cx,argc,argv,"s",&name) ) {
		return Engine::throwUsageError(cx,argv);
	}

	Site *site = (Site*)JS_GetPrivate(cx,obj);
	site->removeOption(name);

	return JS_TRUE;
}
Beispiel #28
0
	std::vector<Circle*> SiteList::circles( )
	{
		std::vector<Circle*> circles;
		for( std::vector<Site*>::iterator it = _sites.begin(); it != _sites.end(); ++it ){
			Site* site = ( *it );
			Number radius = 0;
			Edge* nearestEdge = site->nearestEdge();
			if( !(nearestEdge->isPartOfConvexHull()) )
				radius = nearestEdge->sitesDistance() * 0.5;
			circles.push_back( new Circle( site->x(), site->y(), radius ) );
		}
		return circles;
	}
Beispiel #29
0
	std::vector< const Point* > Voronoi::neighborSitesForSite( Point* coord )
	{
		std::vector< const Point* > points;
		Site* site = _sitesIndexedByLocation[coord];
		if( !site )
			return points;
		std::vector< Site* > sites = site->neighborSites( );
		for( std::vector< Site* >::iterator it = sites.begin( ); it != sites.end( );
				++it ){
			points.push_back( (*it)->coord( ) );
		}
		return points;
	}
Beispiel #30
0
Site *searchEngine(Site *listSites, Token *listTokens){
    bool match;Site *listMatchSites = NULL;
    Site *tempSiteToAdd;
    for(Site *tempSite = listSites; tempSite != NULL; tempSite = tempSite->sig){
        tempSiteToAdd = searchByWebSite(tempSite, listTokens);
        if(tempSiteToAdd->getListTokensMatches() != NULL)
        {
            //cout<<"SE ENCONTRARON VARIOS TOKENS en:"<<endl;
            //tempSiteToAdd->print();
            listMatchSites = addSiteToList(listMatchSites, tempSiteToAdd);
        }
    }
    return listMatchSites;
}