示例#1
0
void WorldUIView::drawSurface(){	
	//Utils::LOG("DRAW SURFACE");
	int wXStart = (xOffset-rect.width/2)/sbSize;
	int wYStart = (yOffset-rect.height/2)/sbSize;
	int wWidth = rect.width/sbSize+3;
	int wHeight = rect.height/sbSize+3;
	COORDS crd(0, 0);

	for(int i = wXStart; i < wXStart+wWidth; i++) {
		for(int j = wYStart; j < wYStart+wHeight; j++){
			crd.x = i;
			crd.y = j;
			worldMutex.lock();
			shared_ptr<SurfaceBlock> sb = client->world->getSurfaceBlockByCoords(crd);
			worldMutex.unlock();

			if(sb != NULL){
				int wX = sb->getCoords().x;
				int wY = sb->getCoords().y;	

				UIRect sbRect = UIRect(
					rect.x + rect.width/2 + wX*sbSize - sbSize/2 - xOffset,
					rect.y + rect.height/2 + wY*sbSize - sbSize/2 - yOffset,
					sbSize,
					sbSize
					);

				sb->draw(sbRect);				
			}
		}
	}
}
示例#2
0
void DisassemblerView::showCrossReference(Block *b)
{
    if(!b->hasSources())
        return;

    CrossReferenceDialog crd(b, this->_disassembler);
    int res = crd.exec();

    if(res == CrossReferenceDialog::Accepted && crd.selectedBlock())
        ui->disassemblerWidget->jumpTo(crd.selectedBlock());
}
示例#3
0
void DisassemblerView::showCrossReference(const DataValue &address)
{
    Block* b = this->_listing->findBlock(address);

    if(!b || !b->hasSources())
        return;

    CrossReferenceDialog crd(b, this->_disassembler);
    int res = crd.exec();

    if(res == CrossReferenceDialog::Accepted && crd.selectedBlock())
        ui->disassemblerWidget->jumpTo(crd.selectedBlock());
}
示例#4
0
void DisassemblerView::onFunctionsMenuXRefsTriggered()
{
    QItemSelectionModel* model = ui->functionList->selectionModel();
    QModelIndex index = model->currentIndex();

    if(index.isValid())
    {
        CrossReferenceDialog crd(reinterpret_cast<Function*>(index.internalPointer()), this->_disassembler);
        int res = crd.exec();

        if(res == CrossReferenceDialog::Accepted && crd.selectedBlock())
            ui->disassemblerWidget->jumpTo(crd.selectedBlock());
    }
}
 setPuzzle() {
     for( size_t c = red; c <= purple; c++ ) {
         for( size_t s = oval; s <= diamond; s++ ) {
             for( size_t n = one; n <= three; n++ ) {
                 for( size_t h = solid; h <= striped; h++ ) {
                     card crd( static_cast<color>  ( c ),
                               static_cast<symbol> ( s ),
                               static_cast<number> ( n ),
                               static_cast<shading>( h ) );
                     _cards.push_back( crd );
                 }
             }
         }
     }
 }
示例#6
0
文件: main.cpp 项目: tjgiese/atizer
std::vector<double> read_xyz( char const * fname )
{
  std::ifstream cin;
  cin.open( fname );
  int nat;
  std::string s;
  cin >> nat;
  cin >> s;
  std::vector<double> crd(3*nat,0.);
  for ( int i=0; i<nat; ++i )
    cin >> s >> crd[0+i*3] >> crd[1+i*3] >> crd[2+i*3];
  for ( int i=0; i<3*nat; ++i )
    crd[i] *= 1.88972613373440e+00;

  return crd;
}
示例#7
0
int OPS_GetNodeCrd(int *nodeTag, int *sizeCrd, double *data)
{
  Node *theNode = theDomain->getNode(*nodeTag);
  if (theNode == 0) {
    opserr << "OPS_GetNodeCrd - no node with tag " << *nodeTag << endln;
    return -1;
  }
  int size = *sizeCrd;
  const Vector &crd = theNode->getCrds();
  if (crd.Size() != size) {
    opserr << "OPS_GetNodeCrd - crd size mismatch\n";
    return -1;
  }
  for (int i=0; i < size; i++) 
    data[i] = crd(i);
    
  return 0;
}
示例#8
0
文件: main.cpp 项目: tjgiese/atizer
int main()
{
  std::vector<double> crd( read_xyz("ade.xyz") );
  int const nat = crd.size()/3;
  std::vector<double> grd(3*nat,0.);

  pucker p( "ade.2dbspl" );
  p.push_back( dihed(0,1,2,3), dihed(2,3,4,5) );

  double E = p.eval( crd.data(), grd.data() );

  std::cout.precision(4);
  std::cout.setf( std::ios::scientific, std::ios::floatfield );
  std::cout << "E = " << std::setw(12) << E << "\n";
  for ( int i=0; i<nat; ++i )
    {
      for ( int k=0; k<3; ++k )
	std::cout << std::setw(12) << grd[k+i*3];
      std::cout << "\n";
    };

  return 0;
}
示例#9
0
文件: Ant.cpp 项目: zabsv/mANTiS
inline bool Ant::operator<(const Ant &a) const{
    return (a.crd()<crd());
}
示例#10
0
void tet_hp::tobasis(init_bdry_cndtn *ibc, int tlvl) {
	int tind,i,j,k,m,n,v0,v1,eind,find;
	TinyVector<FLT,3> pt;
	int stridey = MXGP;
	int stridex = MXGP*MXGP; 
		
		
	/* LOOP THROUGH VERTICES */
	for(i=0;i<npnt;++i)
		for(n=0;n<NV;++n)
			ugbd(tlvl).v(i,n) = ibc->f(n,pnts(i),gbl->time);

	if (basis::tet(log2p).em == 0) return;

	/* LOOP THROUGH EDGES */   
	for(eind = 0; eind < nseg; ++eind) {

		v0 = seg(eind).pnt(0);
		v1 = seg(eind).pnt(1);
		
		if (seg(eind).info < 0){
			for(n=0;n<ND;++n)
				basis::tet(log2p).proj1d(pnts(v0)(n),pnts(v1)(n),&crd1d(n)(0));
		}
		else {
			crdtocht1d(eind,tlvl);
			for(n=0;n<ND;++n)
				basis::tet(log2p).proj1d(&cht(n)(0),&crd1d(n)(0));
		}
		
		for(n=0;n<NV;++n)
			basis::tet(log2p).proj1d(ugbd(tlvl).v(v0,n),ugbd(tlvl).v(v1,n),&u1d(n)(0));

		for(i=0;i<basis::tet(log2p).gpx; ++i) {
			pt(0) = crd1d(0)(i);
			pt(1) = crd1d(1)(i);
			pt(2) = crd1d(2)(i);
			for(n=0;n<NV;++n){
				// difference between actual function and linear 
				u1d(n)(i) -= ibc->f(n,pt,gbl->time);
			}
		}

		for(n=0;n<NV;++n)
			basis::tet(log2p).intgrt1d(&lf(n)(0),&u1d(n)(0));
		 
		for(n=0;n<NV;++n) {
			for(m=0;m<basis::tet(log2p).em;++m){ 
				ugbd(tlvl).e(eind,m,n) = -lf(n)(2+m)*basis::tet(log2p).diag1d(m);
			}
		}
	}
	
	if (basis::tet(log2p).fm == 0) return;
	
	/* LOOP THROUGH FACES */
	for(find = 0; find < ntri; ++find) {
		ugtouht2d_bdry(find,tlvl);
		for(n=0;n<NV;++n)
			basis::tet(log2p).proj2d_bdry(&uht(n)(0),&u2d(n)(0)(0),stridey);

		if (tri(find).info < 0) {
			for(n=0;n<ND;++n)
				basis::tet(log2p).proj2d(vrtxbd(tlvl)(tri(find).pnt(0))(n),vrtxbd(tlvl)(tri(find).pnt(1))(n),vrtxbd(tlvl)(tri(find).pnt(2))(n),&crd2d(n)(0)(0),stridey);
				
		}
		else {
			crdtocht2d(find,tlvl);
			for(n=0;n<ND;++n)
				basis::tet(log2p).proj2d_bdry(&cht(n)(0),&crd2d(n)(0)(0),stridey);
		}
			
		for (i=0; i < basis::tet(log2p).gpx; ++i ) {
			for (j=0; j < basis::tet(log2p).gpy; ++j ) {
				pt(0) = crd2d(0)(i)(j);
				pt(1) = crd2d(1)(i)(j);
				pt(2) = crd2d(2)(i)(j);
				for(n=0;n<NV;++n) {
					u2d(n)(i)(j) -= ibc->f(n,pt,gbl->time);
				}
			}
		}
	  

		for(n=0;n<NV;++n) {
			basis::tet(log2p).intgrt2d(&lf(n)(0),&u2d(n)(0)(0),stridey);
			for(i=0;i<basis::tet(log2p).fm;++i){
				ugbd(tlvl).f(find,i,n) = -lf(n)(3+3*basis::tet(log2p).em+i)*basis::tet(log2p).diag2d(i);
			}
		}
	}

	if (basis::tet(log2p).im == 0) return;
	
	/* LOOP THROUGH TETS */
	for(tind = 0; tind < ntet; ++tind) {
		ugtouht_bdry(tind,tlvl);
		for(n=0;n<NV;++n)
			basis::tet(log2p).proj_bdry(&uht(n)(0),&u(n)(0)(0)(0),stridex,stridey);
			
		if (tet(tind).info < 0) {
			for(n=0;n<ND;++n)
				basis::tet(log2p).proj(vrtxbd(tlvl)(tet(tind).pnt(0))(n),vrtxbd(tlvl)(tet(tind).pnt(1))(n),vrtxbd(tlvl)(tet(tind).pnt(2))(n),vrtxbd(tlvl)(tet(tind).pnt(3))(n),&crd(n)(0)(0)(0),stridex,stridey);
		}
		else {
			crdtocht(tind,tlvl);
			for(n=0;n<ND;++n)
				basis::tet(log2p).proj_bdry(&cht(n)(0),&crd(n)(0)(0)(0),stridex,stridey);
		}
			
		for (i=0; i < basis::tet(log2p).gpx; ++i ) {
			for (j=0; j < basis::tet(log2p).gpy; ++j ) {
				for (k=0; k < basis::tet(log2p).gpz; ++k ) {
					pt(0) = crd(0)(i)(j)(k);
					pt(1) = crd(1)(i)(j)(k);
					pt(2) = crd(2)(i)(j)(k);
					for(n=0;n<NV;++n)
						u(n)(i)(j)(k) -= ibc->f(n,pt,gbl->time);
				}
			}
		}

		for(n=0;n<NV;++n) {
			basis::tet(log2p).intgrt(&lf(n)(0),&u(n)(0)(0)(0),stridex,stridey);
			for(i=0;i<basis::tet(log2p).im;++i) {
				ugbd(tlvl).i(tind,i,n) = -lf(n)(basis::tet(log2p).bm+i)*basis::tet(log2p).diag3d(i);
			}
		}
	}
	
	return;
}   
示例#11
0
void STPlaceView::relayout() {
    if(m_size.isEmpty())
        return;
    if(m_coords.isEmpty() && m_place.isEmpty())
        return;

    bool loaded=m_lastWidth!=m_size.width();
    m_lastWidth=m_size.width();

    const int labelHeight=16;
    QSize mapSize(m_size.width(), m_size.height()-labelHeight);
    m_mapView->setSize(mapSize);

    if((!m_coords.isEmpty()) || (!m_place.isEmpty())) {
        if((!mapSize.isEmpty()) &&  !m_mapView->ticket()) {
            m_mapView->setTicket(STStaticMapImageManager::sharedManager()->requestWithObjects(m_coords,
                                 m_place,
                                 mapSize-QSize(4,4)));
        }
    }

    if(loaded) {
        if(m_coords.isEmpty()) {

        } else {
            QString txt;
            STMapCoord crd(m_coords["coordinates"]);
            if(crd.latitude>=0.) {
                txt=tr(":degN, ").replace(QLatin1String(":deg"),
                                          QString::number(crd.latitude, 'f', 1));
            } else {
                txt=tr(":degS, ").replace(QLatin1String(":deg"),
                                          QString::number(-crd.latitude, 'f', 1));
            }
            if(crd.longitude>=0.) {
                txt+=tr(":degE").replace(QLatin1String(":deg"),
                                         QString::number(crd.longitude, 'f', 1));
            } else {
                txt+=tr(":degW").replace(QLatin1String(":deg"),
                                         QString::number(-crd.longitude, 'f', 1));
            }

            QList<STObjectManager::EntityRange> ranges;
            STObjectManager::EntityRange range;
            range.charIndexStart=0;
            range.charIndexEnd=txt.length();
            range.entityType="st_url";
            range.entity=QString("https://maps.google.com/maps?q=%1,%2&z=5").arg(QString::number(crd.latitude, 'f'),
                         QString::number(crd.longitude, 'f'));
            ranges.append(range);
            m_coordView->setContents(STFont::defaultFont(), txt, ranges);
        }
    }

    int labelPos=m_size.height()-labelHeight+3;

    int coordsLeft=m_size.width()-(int)m_coordView->boundingRect().right();
    m_coordView->setPos(coordsLeft, labelPos);


    if(loaded) {
        if(!m_place.isEmpty()) {
            QString txt=m_place["name"].toString();
            m_nameView->setContents(STFont::defaultBoldFont(), txt,(float)coordsLeft+m_coordView->boundingRect().left()-3,true);

        }
    }

    m_nameView->setPos(1, labelPos);

}