本文整理汇总了C++中Site类的典型用法代码示例。如果您正苦于以下问题:C++ Site类的具体用法?C++ Site怎么用?C++ Site使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Site类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: err_if
//--------- 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;
}
示例2: onActiveSiteChange
// 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);
}
示例3: linkin
//--------- 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;
}
示例4: TEST_F
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());
}
示例5:
std::vector< Point* > Voronoi::region( Point* p )
{
Site* site = _sitesIndexedByLocation[p];
if( !site )
return std::vector< Point* >( );
return site->region( _plotBounds );
}
示例6: save_eps
// 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;
}
示例7: throw
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()));
}
示例8: getAttributeNames
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;
}
示例9: set_site
//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;
}
示例10: get_mean_intensity
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;
}
示例11: get_site
//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;
}
示例12: qDebug
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;
}
示例13: Rectangle
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 );
}
示例14: getPath
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;
}
示例15: update
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();
}
}
}