示例#1
0
TEST(grid_can_move, equivalenceClass) {
	//can move
	grid G;

    //have empty space 
    setGrid(G.m_grid,
        2, 2, 2, 0,
        2, 2, 2, 0,
        2, 2, 2, 0,
        2, 2, 2, 0);
    EXPECT_EQ(true, G.can_move());

    //have no empty space but can merge
	set_all_one(G.m_grid);
    EXPECT_EQ(true, G.can_move());

	//can not move
	setGrid(G.m_grid,
		2, 4, 2, 4,
		4, 2, 4, 2,
		2, 4, 2, 4,
     	4, 2, 4, 2);
	EXPECT_EQ(false, G.can_move());
	grid G_ori = G;
	G.action(direction::NORTH);
	EXPECT_EQ(true, isMGridEqual(G.m_grid, G_ori.m_grid));
	G.action(direction::SOUTH);
	EXPECT_EQ(true, isMGridEqual(G.m_grid, G_ori.m_grid));
	G.action(direction::EAST);
	EXPECT_EQ(true, isMGridEqual(G.m_grid, G_ori.m_grid));
	G.action(direction::WEST);
	EXPECT_EQ(true, isMGridEqual(G.m_grid, G_ori.m_grid));
}
示例#2
0
/////////////////////////////////////////////////////////
// renderShape
//
/////////////////////////////////////////////////////////
void mesh_line :: renderShape(GemState *state)
{
  int i;
  GLfloat sizeX = 2. / (gridX-1.);

  if(m_drawType==GL_DEFAULT_GEM)m_drawType=GL_LINE_STRIP;

  glNormal3f(0.0f, 0.0f, 1.0f);
  if (m_drawType == GL_LINE_LOOP)
  m_drawType = GL_LINE_STRIP;

  glNormal3f( 0.0f, 0.0f, 1.0f);

  if (GemShape::m_texType && GemShape::m_texNum>=3)
    {
    if ((xsize0!= GemShape::m_texCoords[0].s) ||
    (xsize != GemShape::m_texCoords[1].s-xsize0))
    alreadyInit = 0;

      if (!alreadyInit)
      {
        xsize0 = GemShape::m_texCoords[0].s;
        xsize  = GemShape::m_texCoords[1].s-xsize0;

        setGrid(gridX);
        alreadyInit = 1;
      }


      glBegin(m_drawType);
      for (int i=0; i<=(gridX-1) ; i++)
      {
        glTexCoord2f( texCoords[i],0. );
        glVertex3f( m_size * (i*sizeX - 1),0 , 0);
      }
      glEnd();
      } else
      {
      if (!alreadyInit)
      {
        xsize = 1;
        xsize0= 0;

        setGrid( gridX);
        alreadyInit = 1;
      }

      glBegin(m_drawType);
      for ( i = 0; i<=(gridX -1); i++)
      {
          glTexCoord2f( texCoords[i], 0. );
          glVertex3f( m_size * (i*sizeX -1), 0 , 0 );
      }
      glEnd();
    }
}
示例#3
0
void MainWindow::solveClicked()
{
    for (int i=0;i<9;++i)
        for(int j=0;j<9;++j)
        {
            if(square[i][j]->text()=="")
                grid[i][j]='0';
            else
            {
            int x = QString(square[i][j]->text())[0].unicode();
            grid[i][j]=(char)x;
            }
        }
    for (int i=0;i<9;++i)
        for(int j=0;j<9;++j)
            if (identical_row(grid, i, j) + identical_collumn(grid, i, j) + identical_block(grid, i, j) != 0)
                return;

    for (int i=0;i<9;++i)
        for(int j=0;j<9;++j)
        {
            square[i][j]->setEnabled(false);
            square[i][j]->setPalette(*blackText);
        }
    solveButton->setEnabled(false);
    char workingArr[9][9];
    copyGrid(workingArr);

    solve(workingArr);
    setGrid(workingArr);
    display();


}
示例#4
0
文件: grid.cpp 项目: nkgeorgiev/FMI
void Grid::setGame(){
    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            arr[i][j]=0;
            grid->at(i)[j]=0;
            gridLayout->removeWidget(button[i][j]);
            buttons->removeButton(button[i][j]);

        }
    }


    QDialog *diff=new QDialog();
    Ui_Dialog *dialog=new Ui_Dialog();
    dialog->setupUi(diff);
    diff->show();

    QObject::connect(dialog->buttonGroup,SIGNAL(buttonClicked(int)),this,SLOT(chooseDifficulty(int)));

    QObject::connect(dialog->buttonBox,SIGNAL(accepted()),this,SLOT(setGrid()));


    for(int i=0;i<m;i++){
        for(int j=0;j<n;j++){
            QAbstractButton *current=button[i][j];
            current->setText("");
            current->setIcon(QIcon());
            current->setEnabled(true);
        }
    }
    cnt=0;



}
示例#5
0
/*!
 * \brief CoOrdinateSystem::CoOrdinateSystem
 * \param coOrdinateSystem
 */
CoOrdinateSystem::CoOrdinateSystem(const CoOrdinateSystem &coOrdinateSystem)
{
  setExtent(coOrdinateSystem.getExtent());
  setPreserveAspectRatio(coOrdinateSystem.getPreserveAspectRatio());
  setInitialScale(coOrdinateSystem.getInitialScale());
  setGrid(coOrdinateSystem.getGrid());
}
示例#6
0
文件: LogGraph.cpp 项目: tlogger/TMon
CLogGraph::CLogGraph()
{
	m_bCreated = false;
//	m_hQue  = 0;
	m_bNav = false;
	m_tLastNav = time(NULL);
	m_nScaleIndex = -1;
	m_nLastCursorPos = -1;
	m_aTmp = NULL;

	m_bDragSel = false;
	m_bLdown = false;

	m_tStart = time(NULL);
	m_tEnd = time(NULL);
	
	m_nHeaderHeight = 40;
	m_nScaleWidth  = 34;
	m_bAutoZoom = false;

	setZoom(1.0);
	setGrid(20, RGB(70, 70, 70));
	setHeader("Segoe UI", 13, RGB(200, 200, 200), RGB(120, 120, 120));
	setScale("Segoe UI", 13, RGB(200, 200, 0), RGB(100, 100, 100));
	setGraph("Segoe UI", 13, RGB(200, 200, 200), RGB(0, 0, 0));
	setScaleIndex(-1, -1);

	clearGraph();

	m_bLoad = false;
//	uMSH_MOUSEWHEEL = RegisterWindowMessage("MSWHEEL_ROLLMSG");
}
示例#7
0
ModulatedMagneticFieldGrid::ModulatedMagneticFieldGrid(ref_ptr<VectorGrid> grid,
		ref_ptr<ScalarGrid> modGrid) {
	grid->setReflective(false);
	modGrid->setReflective(true);
	setGrid(grid);
	setModulationGrid(modGrid);
}
示例#8
0
void ofApp::update() {

    if (zoom_in && (ofGetKeyPressed(OF_KEY_CONTROL) ||
                    ofGetKeyPressed(OF_KEY_COMMAND))) {
        c.zoomIn();
        zoom_in = false;
        setGrid();
    }

    if (zoom_out && (ofGetKeyPressed(OF_KEY_CONTROL) ||
                     ofGetKeyPressed(OF_KEY_COMMAND))) {
        c.zoomOut();
        zoom_out = false;
        setGrid();
    }
}
示例#9
0
void MeshPartition::trackGrid(vtkUnstructuredGrid *grid)
{
  setGrid(grid);
  setAllCells();
  m_GridMTime = m_Grid->GetMTime();
  m_TrackGrid = true;
}
示例#10
0
void MeshPartition::setRemainder(const MeshPartition& part)
{
  setGrid(part.getGrid());
  QVector<vtkIdType> rcells;
  getRestCells(m_Grid, part.m_Cells, rcells);
  setCells(rcells);
}
PolarGridRenderer& PolarGridRenderer::operator=(const PolarGridRenderer& _renderer) {
    setGrid(_renderer.getGrid(), _renderer.getPhiEdges(), _renderer.getRhoEdges());
    m_color = _renderer.m_color;
    _renderer.getSubdivision(m_subdivision[0], m_subdivision[1]);
    m_depth = _renderer.m_depth;
    return *this;
}
示例#12
0
Node *PuzzlePiece::createPiece(PieceColor color, int x, int y)
{
    auto piece = PuzzlePiece::create();
    piece->setGrid(x, y);
    piece->setPieceColor(color);
    return piece;   
}
示例#13
0
文件: main.c 项目: nfaralli/SPH
int main(int argc, char *argv[]){

  int    nbParts=20000;
  float  minMax[3][2]={{-1,1},{-1,1},{-1,1}};
  float  cellSize=2*0.02*1.001;// 2*particle radius + 0.1%
  float  dt=0.002,simTime=5;
  float  dtFrame=0.02; //0.04 <=> 25 frames per seconds
  int    nbDtPerFrame,i;
  char   filename[]="toto.par";
  float  mass;
  System *sys;
  clock_t time;

/*
  FILE *file;
  float r[3];

  file=fopen("filter.plt","w");
  fprintf(file,"VARIABLES = x w\n");
  r[1]=r[2]=0;
  for(i=0;i<=100;i++){
    r[0]=i/100.;
    fprintf(file,"%e\t%e\n",i/100.,kernelPoly6(r,1));
  }
  fclose(file);
  return 0;*/


  nbDtPerFrame=dtFrame/dt;
  sys=createSystem(nbParts,minMax);
  tmpAddWalls_1(sys);
  setGrid(sys, cellSize);
  //printGrid(sys); //test nico
  //return 0;
  mass=1000*(minMax[0][1]-minMax[0][0])*(minMax[1][1]-minMax[1][0])*(minMax[2][1]-minMax[2][0])/nbParts;
  setParticles(sys,0,nbParts-1,mass/4); //for water, ro0=1000kg/m3, so 1000 parts/Liter => mi=1e-3kg
  setForces(sys);
  generateParFile(sys,filename,CREATE);

  i=0;
  time=clock();
  while(sys->time<=simTime){
    printf("time = %e (i=%d)\n",sys->time,i);fflush(stdout);
    updateSys(sys,dt);
    if((++i)%nbDtPerFrame==0)
      generateParFile(sys,filename,UPDATE);
  }
  time=clock()-time;

  generateParFile(sys,filename,CLOSE);
  deleteSystem(sys);

  updateSys(NULL,0);
#ifdef USE_MULTI_THREADING
  cleanThreads();
#endif
  printf("done in %f sec!\n", (double)(time)/CLOCKS_PER_SEC);
  return 0;
}
示例#14
0
void MainWindow::updateOwner()
{
    qDebug() << add->record["OPERATOR"] << data->operatorstr;
    setOwner(add->record["OPERATOR"]);
    setQTH(add->record["HOME_QTH"]);
    setGrid(add->record["HOME_GRID"]);
    setStation(add->record["STATION_CALL"]);
}
示例#15
0
PUBLIC EdiGrid *readTable(cchar *tableName)
{
    EdiGrid *grid;
    
    grid = ediReadWhere(getDatabase(), tableName, 0, 0, 0);
    setGrid(grid);
    return grid;
}
示例#16
0
void GridCommand::readProperties(boost::property_tree::wptree& pt)
{
    AbstractCommand::readProperties(pt);

    setGrid(pt.get(L"grid", Mixer::DEFAULT_GRID));
    setTransitionDuration(pt.get(L"transitionDuration", Mixer::DEFAULT_DURATION));
    setTween(QString::fromStdWString(pt.get(L"tween", Mixer::DEFAULT_TWEEN.toStdWString())));
    setDefer(pt.get(L"defer", Mixer::DEFAULT_DEFER));
}
示例#17
0
/////////////////////////////////////////////////////////
//
// mesh_line
//
/////////////////////////////////////////////////////////
// Constructor
//
/////////////////////////////////////////////////////////
mesh_line :: mesh_line(t_floatarg sizeX)
  : GemShape(1),
    xsize(0.), xsize0(0.),
    alreadyInit(0)
{
  int sizeXi=static_cast<int>(sizeX);

  setGrid(sizeXi);
}
示例#18
0
/*!
 * \brief CoOrdinateSystem::CoOrdinateSystem
 */
CoOrdinateSystem::CoOrdinateSystem()
{
  QList<QPointF> extents;
  extents << QPointF(-100, -100) << QPointF(100, 100);
  setExtent(extents);
  setPreserveAspectRatio(true);
  setInitialScale(0.1);
  setGrid(QPointF(2, 2));
}
示例#19
0
TileView::TileView(int internalId) : PixelEditor(16, 16, 1)
{
    m_tileId = 0;
    m_internalId = internalId;
    m_allowedDragWidget = 0;
    setEditable(false);
    changeZoom(2);
    setGrid(true);
}
示例#20
0
// merge()
TEST(grid_merge, equivalenceClass)
{
	grid gr;
	grid gr_test;

	// Empty
	setGrid(gr.m_grid,
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0);
	gr_test = gr;
	EXPECT_EQ(false, gr.merge(direction::NORTH));
	EXPECT_EQ(true, isMGridEqual(gr_test.m_grid, gr.m_grid));
	EXPECT_EQ(false, gr.merge(direction::SOUTH));
	EXPECT_EQ(true, isMGridEqual(gr_test.m_grid, gr.m_grid));
	EXPECT_EQ(false, gr.merge(direction::EAST));
	EXPECT_EQ(true, isMGridEqual(gr_test.m_grid, gr.m_grid));
	EXPECT_EQ(false, gr.merge(direction::WEST));
	EXPECT_EQ(true, isMGridEqual(gr_test.m_grid, gr.m_grid));

	// Not empty, but cannot merge
	setGrid(gr.m_grid,
		0, 2, 0, 8,
		0, 0, 0, 2,
		8, 0, 2, 1,
		0, 2, 0, 1);
	gr_test = gr;
	EXPECT_EQ(false, gr.merge(direction::EAST));
	EXPECT_EQ(true, isMGridEqual(gr_test.m_grid, gr.m_grid));

	// 1 merge in a row
	setGrid(gr.m_grid,
		0, 0, 512, 512,
		0, 4, 2, 2,
		16, 8, 16, 16,
		0, 1, 4, 1);
	setGrid(gr_test.m_grid,
		0, 0, 0, 1024,
		0, 4, 0, 4,
		16, 8, 0, 32,
		0, 1, 4, 1);
	EXPECT_EQ(true, gr.merge(direction::EAST));
	EXPECT_EQ(true, isMGridEqual(gr_test.m_grid, gr.m_grid));
	
	// 2 merges in a row
	setGrid(gr.m_grid,
		1, 2, 4, 8,
		1, 2, 4, 8,
		1, 2, 4, 8,
		1, 2, 4, 8);
	setGrid(gr_test.m_grid,
		2, 4, 8, 16,
		0, 0, 0, 0,
		2, 4, 8, 16,
		0, 0, 0, 0);
	EXPECT_EQ(true, gr.merge(direction::NORTH));
	EXPECT_EQ(true, isMGridEqual(gr_test.m_grid, gr.m_grid));
}
示例#21
0
/**
	Draws the game grid when called.
*/
void Grid::drawGrid(int height, int width, char grid[])
{
    for (int h = 0; h < height; h++)
    {
        for (int w = 0; w < width; w++)
        {
            setGrid(height, width, grid);
            cout << grid[h*w];
            cout << "grid drawn. ";
        }
        cout << endl;
    }
}
示例#22
0
// action()
TEST(grid_action, EquivalenceClass_WeakNormal) {

	direction north = direction::NORTH;

	grid G;

	// Empty
	setGrid(G.m_grid,
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0);
	EXPECT_EQ(false, G.action(north));
	
	//Not Empty nor doing action
	setGrid(G.m_grid,
		2, 2, 2, 2,
		0, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0);
	EXPECT_EQ(false, G.action(north));

	//Can move at first
	setGrid(G.m_grid,
		0, 2, 2, 2,
		2, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0);
	EXPECT_EQ(true, G.action(north));

	//Can't move at first but can merge
	setGrid(G.m_grid,
		2, 2, 2, 2,
		2, 0, 0, 0,
		0, 0, 0, 0,
		0, 0, 0, 0);
	EXPECT_EQ(true, G.action(north));
}
示例#23
0
KColorGrid::KColorGrid(QWidget *parent, const char *name, int space)
 : QWidget(parent, name, Qt::WResizeNoErase|Qt::WRepaintNoErase)
{
  //kdDebug(4640) << "KColorGrid - constructor" << endl;
  s = space;
  rows = cols = totalwidth = totalheight = 0;
  setCellSize(10);
  setGridState(Plain);
  setGrid(true);
  numcolors.resize(0);
  gridcolors.resize(0);

  //kdDebug(4640) << "KColorGrid - constructor - done" << endl;
}
示例#24
0
void GLESettings::readAll()
{
	// Read the application settings
	setPosition(settingStore->value("application/position", QPoint(200,200)).toPoint());
	setSize(settingStore->value("application/size", QSize(400,400)).toSize());
	setMainWindowState(settingStore->value("application/mainstate").toByteArray());
	setDrawingAreaSize(settingStore->value("application/drawingsize", QSize(400,400)).toSize());
	setStoreSize(settingStore->value("application/storeSize", true).toBool());
	setStoreDirectory(settingStore->value("application/storeDirectory", true).toBool());
	setSaveOnPreview(settingStore->value("application/saveOnPreview", false).toBool());
	setAskAboutObjects(settingStore->value("application/askAboutKeepingObjects", true).toBool());
	setAutoScaleOnOpen(settingStore->value("application/autoScaleOnOpen", true).toBool());
	setLibGSLocation(settingStore->value("application/libGSLocation", QString()).toString());
	setEditorLocation(settingStore->value("application/editorLocation", QString("")).toString());
	setDPI(settingStore->value("application/resolution", 100).toInt());
	setMonitorOpenFile(settingStore->value("application/monitorOpenFile", true).toBool());
	setMonitorAutoReloadFile(settingStore->value("application/monitorAutoReload", true).toBool());
	setSplitterPosition(settingStore->value("application/splitterSizes").toByteArray());
	setConsoleWindowAutoShowSize(settingStore->value("application/consoleAutoShowSize", 0).toInt());
	setEmulateGLEVersion(settingStore->value("application/emulateGLEVersion", 0).toInt());
	setExportFormat(settingStore->value("application/exportFormat", 0).toInt());
	setExportPageSize(settingStore->value("application/exportPageSize", 0).toInt());
	setPreviewPageSize(settingStore->value("application/previewPageSize", 0).toInt());
	setOpenExportedFigure(settingStore->value("application/openExportedFigure", true).toBool());
	setExportGrayScale(settingStore->value("application/exportGrayScale", false).toBool());
	setExportTransparent(settingStore->value("application/exportTransparent", false).toBool());
	setExportBitmapResolution(settingStore->value("application/exportBitmapResolution", 150).toInt());
	setExportVectorResolution(settingStore->value("application/exportVectorResolution", 600).toInt());
	setRenderUsingCairo(settingStore->value("application/renderUsingCairo", false).toBool());

	if (storeDirectory())
		setPwd(settingStore->value("application/workingDirectory", "").toString());

	// Read the server settings
	setPort(settingStore->value("server/portNumber", DEFAULT_PORT).toInt());
	setAutoStartServer(settingStore->value("server/autoStart", true).toBool());

	// Read the drawing settings
	setGrid(QPointF(settingStore->value("drawing/gridX", 1.0).toDouble(),
	                settingStore->value("drawing/gridY", 1.0).toDouble()));
	setEqualGrid(settingStore->value("drawing/equalGrid", false).toBool());
	setPolarSnapStartAngle(settingStore->value("drawing/polarSnapStartAngle", 0.0).toDouble());
	setPolarSnapIncAngle(settingStore->value("drawing/polarSnapIncAngle", 30.0).toDouble());
	setOsnapOnStart(settingStore->value("drawing/osnapOnStart", false).toBool());
	setOrthoSnapOnStart(settingStore->value("drawing/orthoSnapOnStart", false).toBool());
	setPolarSnapOnStart(settingStore->value("drawing/polarSnapOnStart", false).toBool());
	setPolarTrackOnStart(settingStore->value("drawing/polarTrackOnStart", false).toBool());
	setGridSnapOnStart(settingStore->value("drawing/gridSnapOnStart", false).toBool());
}
示例#25
0
void MazeWindow::showDijkstra() {
  auto tmp = std::make_shared<UniDijkstra>(std::max(0, mazeWidget->getClicked()));
  auto colorizer = std::make_shared<DijkstraColorizer>(tmp);

  tmp->setGrid(maker->grid());

  auto start = Clock::now();
  while( !tmp->isDone()) tmp->step();
  auto dur = Clock::now() - start;
  std::cout << "It took " << std::chrono::duration_cast< std::chrono::milliseconds >(dur).count() << "ms" << std::endl;

  mazeWidget->setMaker(tmp);
  mazeWidget->setColorizer(colorizer);
  mazeWidget->repaint();
}
示例#26
0
KColorGrid::KColorGrid(QWidget *parent, const char *name, int space)
 : QWidget(parent, name)
{
  //debug("KColorGrid - constructor");
  initMetaObject();
  s = space;
  rows = cols = totalwidth = totalheight = 0;
  setCellSize(10);
  setGridState(Plain);
  setGrid(true);
  numcolors.resize(0);
  gridcolors.resize(0);

  //debug("KColorGrid - constructor - done");
}
示例#27
0
void BeatGrid::readByteArray(const QByteArray* pByteArray) {
    mixxx::track::io::BeatGrid grid;
    if (grid.ParseFromArray(pByteArray->constData(), pByteArray->length())) {
        m_grid = grid;
        m_dBeatLength = (60.0 * m_iSampleRate / bpm()) * kFrameSize;
        return;
    }

    // Legacy fallback for BeatGrid-1.0
    if (pByteArray->size() != sizeof(BeatGridData))
        return;
    const BeatGridData* blob = (const BeatGridData*)pByteArray->constData();

    // We serialize into frame offsets but use sample offsets at runtime
    setGrid(blob->bpm, blob->firstBeat * kFrameSize);
}
示例#28
0
Palette::Palette(QWidget* parent)
   : QWidget(parent)
      {
      extraMag      = 1.0;
      currentIdx    = -1;
      selectedIdx   = -1;
      _yOffset      = 0.0;
      setGrid(50, 60);
      _drawGrid     = false;
      _selectable   = false;
      setMouseTracking(true);
      setReadOnly(false);
      setSystemPalette(false);
      _moreElements = false;
      setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Ignored);
      }
/**
	Constructeur
	@param editor L'editeur d'element concerne
	@param parent le Widget parent
*/
ElementScene::ElementScene(QETElementEditor *editor, QObject *parent) :
	QGraphicsScene(parent),
	m_elmt_type("simple"),
	qgi_manager(this),
	m_event_interface(NULL),
	element_editor(editor),
	decorator_(0)
{
	behavior = Normal;
	setItemIndexMethod(NoIndex);
	setGrid(1, 1);
	initPasteArea();
	undo_stack.setClean();
	decorator_lock_ = new QMutex(QMutex::NonRecursive);
	connect(&undo_stack, SIGNAL(indexChanged(int)), this, SLOT(managePrimitivesGroups()));
	connect(this, SIGNAL(selectionChanged()), this, SLOT(managePrimitivesGroups()));
}
示例#30
0
W_matrix::W_matrix(PWF* matrixPWF, PWF* impurityPWF) {

    _dBasisWF = new double[4][N_tot];
    _dteta = new double[N_Max];
    _dteta2 = new double[N_tot][N_Max];
    _dR2 = new double[N_tot][N_Max];
    _mk_atom2 = new int[N_tot][N_Max];
    d_DeltaR = new double[N_tot];
    _dR = new double[N_tot];
    PARAM_FILE = "Rezults/W_params.txt";
    _dstep_teta = Pi/(N_Max-1);

    _matrixPWF = matrixPWF;
    setBasis(_matrixPWF);
    _impurityPWF = impurityPWF;
    if (_matrixPWF == NULL || _impurityPWF == NULL) {
        cout << "Failed to read files with data for W_matrix\n";
    }
    setGrid(_matrixPWF->nuclearCharge);
}