Exemple #1
0
void MainWindow::saveWidgets()
{
    QSettings settings("Test", "Test Dock Problem");
    settings.setValue("MainWindow/State", saveState());
}
MainWindow::~MainWindow() {
	userSettings.setValue("mainWindowGeometry", saveGeometry());
	userSettings.setValue("mainWindowState", saveState());
	delete ui;
}
Exemple #3
0
CHelp::~CHelp()
{
    saveState();
}
void RenderWindow::slotMenuSaveDocksPositions()
{
	gMainInterface->settings.setValue("mainWindowGeometry", saveGeometry());
	gMainInterface->settings.setValue("mainWindowState", saveState());
	// qDebug() << "settings saved";
}
void MainWindow::saveSettings()
{
    QSettings settings;
    settings.setValue(cSettingsWindowGeometry, saveGeometry());
    settings.setValue(cSettingsWindowState, saveState());
}
Exemple #6
0
SqlEditor::~SqlEditor()
{
	QSettings settings("yarpen.cz", "sqliteman");
    settings.setValue("sqleditor/state", saveState());
}
void CWidgetDownloads::saveWidget()
{
	quazaaSettings.WinMain.DownloadsToolbar = saveState();
	quazaaSettings.WinMain.DownloadsHeader = ui->tableViewDownloads->horizontalHeader()->saveState();
}
Exemple #8
0
int uniqueMoves(char moves[][256])
{
	/*
	 * complex throw away a lot of equal moves
	 * and symmetries (hopefully)
	*/

	int movesIndex = 0;

	int i, j, k;
	char dl, dr, ur, rr, ul;
	/* which neighbors - default all values 0 */
	int neighbors[BOARD_SIZE + 2][BOARD_SIZE + 2];
	int directionList[BOARD_SIZE + 2][BOARD_SIZE + 2][3];
	/*
	 * which directions for move
	 * 0 -> /
	 * 1 -> \
	 * 2 -> +
	 * true means already used
	 * default all values false
	*/
	int ohs_up, ohs_down, ohs_right, ohs_left, eks_up, eks_down, eks_right, eks_left;
	int up, down, left, right;
	int iBegin, jBegin, iEnd, jEnd;

	int rsym;

	if (current.gameOver != NOPLAYER)
		return 0;

	/* empty board only two moves */
	if (current.boardEmpty) {
		strcpy(moves[movesIndex], "@0/");
		movesIndex++;
		strcpy(moves[movesIndex], "@0+");
		movesIndex++;
		return movesIndex;
	}
	if (getRowSize() * getColSize() == 1) {
		switch (getAt(1, 1)) {
			case NW:
				strcpy(moves[movesIndex], "@1+");
		                movesIndex++;
		                strcpy(moves[movesIndex], "@1/");
		                movesIndex++;
		                strcpy(moves[movesIndex], "@1\\");
		                movesIndex++;
		                strcpy(moves[movesIndex], "B1+");
		                movesIndex++;
		                strcpy(moves[movesIndex], "B1/");
		                movesIndex++;
		                strcpy(moves[movesIndex], "B1\\");
		                movesIndex++;
		                strcpy(moves[movesIndex], "A0\\");
		                movesIndex++;
		                strcpy(moves[movesIndex], "A0/");
		                movesIndex++;
		                strcpy(moves[movesIndex], "A0+");
		                movesIndex++;
		                strcpy(moves[movesIndex], "A2/");
		                movesIndex++;
		                strcpy(moves[movesIndex], "A2\\");
		                movesIndex++;
		                strcpy(moves[movesIndex], "A2+");
		                movesIndex++;
		                break;
			case NS:
				strcpy(moves[movesIndex], "@1+");
		                movesIndex++;
		                strcpy(moves[movesIndex], "@1/");
		                movesIndex++;
		                strcpy(moves[movesIndex], "@1\\");
		                movesIndex++;
		                strcpy(moves[movesIndex], "A0/");
		                movesIndex++;
		                strcpy(moves[movesIndex], "A0+");
		                movesIndex++;
		                strcpy(moves[movesIndex], "A0\\");
		                movesIndex++;
		                strcpy(moves[movesIndex], "B1/");
		                movesIndex++;
		                strcpy(moves[movesIndex], "B1\\");
		                movesIndex++;
		                strcpy(moves[movesIndex], "A2/");
		                movesIndex++;
		                strcpy(moves[movesIndex], "A2\\");
		                movesIndex++;
		                break;
			default:
				/* This should never happen */
				break;
		}
		return movesIndex;
	}

	for (i = 0; i < BOARD_SIZE + 2; i++)
		for (j = 0; j < BOARD_SIZE + 2; j++)
			for (k = 0; k < 3; k++)
				directionList[i][j][k] = false;

	rsym = isRotateMirror();
	iBegin = (canMoveDown()) ? 0 : 1;
	jBegin = (canMoveRight()) ? 0 : 1;
	iEnd = (getRowSize() < BOARD_SIZE) ? getRowSize() : BOARD_SIZE;
	jEnd = (getColSize() < BOARD_SIZE) ? getColSize() : BOARD_SIZE;

	for (i = iBegin; i <= iEnd; i++) {
		for (j = jBegin; j <= jEnd; j++) {
			if (!(isBlank(i, j))) {
				neighbors[i][j] = 0;
			} else {
				ohs_up = 0;
				ohs_down = 0;
				ohs_right = 0;
				ohs_left = 0;
				eks_up = 0;
				eks_down = 0;
				eks_right = 0;
				eks_left = 0;
				up = getAt(i - 1, j);
				down = getAt(i + 1, j);
				left = getAt(i, j - 1);
				right = getAt(i, j + 1);

				if (up == SN || up == SW || up == SE) {
					ohs_up = 1;
				} else if (up != EMPTY) {
					eks_up = 1;
				}

				if (down == NS || down == NW ||
				    down == NE) {
					ohs_down = 1;
				} else if (down != EMPTY) {
					eks_down = 1;
				}

				if (left == EN || left == ES ||
				    left == WE)
					ohs_left = 1;
				else if (left != EMPTY)
					eks_left = 1;

				if (right == WE || right == WS ||
				    right == WN)
					ohs_right = 1;
				else if (right != EMPTY)
					eks_right = 1;

				neighbors[i][j] =
					ohs_up + 2 * ohs_down +
					4 * ohs_left
					+ 8 * ohs_right + 16 * eks_up +
					32 * eks_down + 64 * eks_left +
					128 * eks_right;
			}
		}
	}

	for (i = iBegin; i <= iEnd; i++) {
		for (j = jBegin; j <= jEnd; j++) {
			if (neighbors[i][j] != 0) {
				dl = getAt(i + 1, j - 1);
				dr = getAt(i + 1, j + 1);
				ur = getAt(i - 1, j + 1);
				ul = getAt(i - 1, j - 1);
				rr = getAt(i, j + 2);
				switch (neighbors[i][j]) {
					case 1:
						if (dr == NS || dr == NW ||
						    dr == NE)
							directionList[i][j +
							                 1][1] = true;
				                if (dr == WN || dr == WS ||
				                    dr == WE)
					                directionList[i +
					                              1][j][1] = true;
				                if (dl == EW || dl == ES ||
				                    dl == ES)
					                directionList[i +
					                              1][j][0] = true;
				                if (ur == SW || ur == SE ||
				                    ur == SN)
					                directionList[i][j +
					                                 1][0] = true;
				                break;
					case 2: {
						if (dr == NS || dr == NW ||
						    dr == NE)
							directionList[i][j +
							                 1][1] = true;
						if (ur == SW || ur == SE ||
						    ur == SN)
							directionList[i][j +
							                 1][0] = true;
						break;
					}
					case 4: {
						if (dl == ES || dl == EN ||
						    dl == EW)
							directionList[i +
							              1][j][0] = true;
						if (dr == WN || dr == WS ||
						    dr == WE)
							directionList[i +
							              1][j][1] = true;
						if (ur == SW || ur == SN ||
						    ur == SE)
							directionList[i][j +
							                 1][0] = true;
						if (dr == NS || dr == NE ||
						    dr == NW)
							directionList[i][j +
							                 1][1] = true;
						break;
					}
					case 8: {
						if (dl == ES || dl == EN ||
						    dl == EW)
							directionList[i +
							              1][j][0] = true;
						if (dr == WN || dr == WE ||
						    dr == WS)
							directionList[i +
							              1][j][1] = true;
						break;
					}
					case 16: {
						if (dr == SW || dr == SE ||
						    dr == WE)
							directionList[i][j +
							                 1][1] = true;
						if (dr == SE || dr == SN ||
						    dr == EN)
							directionList[i +
							              1][j][1] = true;
						if (dl == NW || dl == NS ||
						    dl == WS)
							directionList[i +
							              1][j][0] = true;
						if (ur == NW || ur == NE ||
						    ur == WE)
							directionList[i][j +
							                 1][0] = true;
						break;
					}
					case 18:
					case 33: {
						directionList[i][j +
						                 1][1] = true;
						directionList[i][j +
						                 1][0] = true;
						directionList[i][j][2] = true;
						break;
					}
					case 20:
					case 65: {
						if (rr != EMPTY)
							directionList[i][j +
							                 1][2] = true;
						directionList[i +
						              1][j][0] = true;
						directionList[i +
						              1][j][1] = true;
						directionList[i][j +
						                 1][0] = true;
						directionList[i][j][0] = true;
						break;
					}
					case 24:
					case 129: {
						directionList[i +
						              1][j][1] = true;
						directionList[i][j][1] = true;
						break;
					}
					case 32: {
						if (dr == SE || dr == SW ||
						    dr == EW)
							directionList[i][j +
							                 1][1] = true;
						if (ur == NW || ur == NE ||
						    ur == WE)
							directionList[i][j +
							                 1][0] = true;
						break;
					}
					case 36: {
						if (ul == NW || ul == SW ||
						    ul == NS)
							directionList[i -
							              1][j][1] = true;
						directionList[i][j +
						                 1][1] = true;
						directionList[i][j +
						                 1][0] = true;
						directionList[i][j][1] = true;
						break;
					}
					case 40:
					case 130: {
						directionList[i][j][0] = true;
						break;
					}
					case 64: {
						if (dl == WN || dl == WS ||
						    dl == NS)
							directionList[i +
							              1][j][0] = true;
						if (dr == EN || dr == ES ||
						    dr == NS)
							directionList[i +
							              1][j][1] = true;
						if (ur == NW || ur == NE ||
						    ur == WE)
							directionList[i][j +
							                 1][0] = true;
						if (dr == SE || dr == SW ||
						    dr == EW)
							directionList[i][j +
							                 1][1] = true;
						break;
					}
					case 66: {
						if (ul == EW || ul == ES ||
						    ul == EN)
							directionList[i -
							              1][j][1] = true;
						directionList[i][j +
						                 1][1] = true;
						directionList[i][j +
						                 1][0] = true;
						directionList[i][j][1] = true;
						break;
					}
					case 72:
					case 132: {
						directionList[i +
						              1][j][0] = true;
						directionList[i +
						              1][j][1] = true;
						directionList[i][j][2] = true;
						break;
					}
					case 128: {
						if (dl == WS || dl == WN ||
						    dl == SN)
							directionList[i +
							              1][j][0] = true;
						if (dr == EN || dr == ES ||
						    dr == NS)
							directionList[i +
							              1][j][1] = true;
						break;
					}
					default:
						break;
				}
			}
		}
	}

	/* collects the moves */
	for (i = iBegin; i <= iEnd; i++) {
		for (j = jBegin; j <= jEnd; j++) {
			/* remove rotation symmetry moves */
			if (rsym && getRowSize() % 2 == 1) {
				int jMiddle = (getColSize() + 1) / 2;
				if (j > jMiddle && i == iEnd) {
					continue;
				}
			}
			if (neighbors[i][j] != 0) {
				ohs_up = 0;
				ohs_down = 0;
				ohs_right = 0;
				ohs_left = 0;
				eks_up = 0;
				eks_down = 0;
				eks_right = 0;
				eks_left = 0;
				up = getAt(i - 1, j);
				down = getAt(i + 1, j);
				left = getAt(i, j - 1);
				right = getAt(i, j + 1);

				if (up == SN || up == SW || up == SE)
					ohs_up = 1;
				else if (up != EMPTY)
					eks_up = 1;
				if (down == NS || down == NW ||
				    down == NE)
					ohs_down = 1;
				else if (down != EMPTY)
					eks_down = 1;
				if (left == EN || left == ES ||
				    left == WE)
					ohs_left = 1;
				else if (left != EMPTY)
					eks_left = 1;
				if (right == WE || right == WS ||
				    right == WN)
					ohs_right = 1;
				else if (right != EMPTY)
					eks_right = 1;

				if (!directionList[i][j][0]) {
					saveState();
					if ((ohs_up + ohs_left > 0)
					    ||
					    (eks_right + eks_down > 0))
						putAt(i, j, NW);
					if ((eks_up + eks_left > 0)
					    ||
					    (ohs_right + ohs_down > 0))
						putAt(i, j, SE);
					if (forcedMove(i - 1, j) &&
					    forcedMove(i + 1, j)
					    && forcedMove(i, j - 1) &&
					    forcedMove(i, j + 1)) {
						getTraxMoveString(i, j,
							moves[movesIndex],
							'/');
						movesIndex++;
					}
					restoreState();
				}
				if (!directionList[i][j][1]) {
					saveState();
					if ((ohs_up + ohs_right > 0)
					    ||
					    (eks_left + eks_down > 0))
						putAt(i, j, NE);
					if ((eks_up + eks_right > 0)
					    ||
					    (ohs_left + ohs_down > 0))
						putAt(i, j, SW);
					if (forcedMove(i - 1, j) &&
					    forcedMove(i + 1, j)
					    && forcedMove(i, j - 1) &&
					    forcedMove(i, j + 1)) {
						getTraxMoveString(i, j,
							moves[movesIndex],
							'\\');
						movesIndex++;
					}
					restoreState();
				}
				if (!directionList[i][j][2]) {
					saveState();
					if ((ohs_up + ohs_down > 0)
					    ||
					    (eks_left + eks_right > 0))
						putAt(i, j, NS);
					if ((eks_up + eks_down > 0)
					    ||
					    (ohs_left + ohs_right > 0))
						putAt(i, j, WE);
					if (forcedMove(i - 1, j) &&
					    forcedMove(i + 1, j)
					    && forcedMove(i, j - 1) &&
					    forcedMove(i, j + 1)) {
						getTraxMoveString(i, j,
							moves[movesIndex],
							'+');
						movesIndex++;
					}
					restoreState();
				}
			}
		}
	}
	return movesIndex;
}
bool ossimIkonosRpcModel::parseTiffFile(const ossimFilename& filename)
{
   bool result = false;
   
   ossimRefPtr<ossimTiffTileSource> tiff = new ossimTiffTileSource();

   if ( tiff->open(filename) )
   {
      if ( !theSupportData )
      {
         theSupportData = new ossimIkonosMetaData();
      }

      if ( theSupportData->open(filename) == false )
      {
         if(traceDebug())
         {
            // Currently not required by model so we will not error out here.
            ossimNotify(ossimNotifyLevel_DEBUG)
               << "WARNING: ossimIkonosMetaData::open returned false.\n"
               << std::endl;
         }
      }
      else
      {
         // copy ossimIkonosMetada-sensor into ossimIkonosRpcModel-sensorId
         theSensorID = theSupportData->getSensorID();
      }

      //convert file to rpc filename and hdr filename so we can get some info
      ossimFilename rpcfile = filename.noExtension();
      rpcfile += "_rpc.txt";
      
      ossimFilename hdrfile = filename;
      hdrfile.setExtension(ossimString("hdr"));
      
      if( parseHdrData(hdrfile) )
      {
         // parseRpcData sets the error status on error.
         parseRpcData (rpcfile);
         if ( !getErrorStatus() ) //check for errors in parsing rpc data
         {
            finishConstruction();
            
            //---
            // Save current state in RPC model format:
            //---
            ossimString drivePart;
            ossimString pathPart;
            ossimString filePart;
            ossimString extPart;
            filename.split(drivePart,
                           pathPart,
                           filePart,
                           extPart);
            
            ossimFilename init_rpc_geom;
            init_rpc_geom.merge(drivePart,
                                pathPart,
                                INIT_RPC_GEOM_FILENAME,
                                "");

            ossimKeywordlist kwl (init_rpc_geom);
            saveState(kwl);

            // If we get here set the return status to true.
            result = true;

         } // matches: if ( !getErrorStatus() )
   
      } // matches: if( parseHdrData(hdrfile) )

   } // matches:  if ( tiff->open(filename) )
   
   if ( traceExec() )
   {
      ossimNotify(ossimNotifyLevel_DEBUG)
         << "return status: " << (result?"true\n":"false\n")
         << "DEBUG ossimIkonosRpcModel parseTiffFile: returning..."
         << std::endl;
   }

   return result;
}
 void start()
 {
     renderingTarget->BeginDraw();
     saveState();
 }
Exemple #11
0
// ----------------------------------------------------------------------------
// Preserve window state
// ----------------------------------------------------------------------------
void MainWindow::closeEvent(QCloseEvent *e)
{
    QMainWindow::closeEvent(e);
    saveState();
    qApp->quit();
}
Exemple #12
0
//--------------------------------------------------------------------------
void MainWindow::writeSettings()
{
    QSettings settings;
    settings.setValue("MainWindowSize", size());
    settings.setValue("MainWindowState", saveState());
}
Exemple #13
0
mongo::Status mongo::cloneCollectionAsCapped(OperationContext* opCtx,
                                             Database* db,
                                             const std::string& shortFrom,
                                             const std::string& shortTo,
                                             long long size,
                                             bool temp) {
    NamespaceString fromNss(db->name(), shortFrom);
    NamespaceString toNss(db->name(), shortTo);

    Collection* fromCollection = db->getCollection(opCtx, fromNss);
    if (!fromCollection) {
        if (db->getViewCatalog()->lookup(opCtx, fromNss.ns())) {
            return Status(ErrorCodes::CommandNotSupportedOnView,
                          str::stream() << "cloneCollectionAsCapped not supported for views: "
                                        << fromNss.ns());
        }
        return Status(ErrorCodes::NamespaceNotFound,
                      str::stream() << "source collection " << fromNss.ns() << " does not exist");
    }

    if (fromNss.isDropPendingNamespace()) {
        return Status(ErrorCodes::NamespaceNotFound,
                      str::stream() << "source collection " << fromNss.ns()
                                    << " is currently in a drop-pending state.");
    }

    if (db->getCollection(opCtx, toNss)) {
        return Status(ErrorCodes::NamespaceExists,
                      str::stream() << "cloneCollectionAsCapped failed - destination collection "
                                    << toNss.ns()
                                    << " already exists. source collection: "
                                    << fromNss.ns());
    }

    // create new collection
    {
        auto options = fromCollection->getCatalogEntry()->getCollectionOptions(opCtx);
        // The capped collection will get its own new unique id, as the conversion isn't reversible,
        // so it can't be rolled back.
        options.uuid.reset();
        options.capped = true;
        options.cappedSize = size;
        if (temp)
            options.temp = true;

        BSONObjBuilder cmd;
        cmd.append("create", toNss.coll());
        cmd.appendElements(options.toBSON());
        Status status = createCollection(opCtx, toNss.db().toString(), cmd.done());
        if (!status.isOK())
            return status;
    }

    Collection* toCollection = db->getCollection(opCtx, toNss);
    invariant(toCollection);  // we created above

    // how much data to ignore because it won't fit anyway
    // datasize and extentSize can't be compared exactly, so add some padding to 'size'

    long long allocatedSpaceGuess =
        std::max(static_cast<long long>(size * 2),
                 static_cast<long long>(toCollection->getRecordStore()->storageSize(opCtx) * 2));

    long long excessSize = fromCollection->dataSize(opCtx) - allocatedSpaceGuess;

    auto exec = InternalPlanner::collectionScan(opCtx,
                                                fromNss.ns(),
                                                fromCollection,
                                                PlanExecutor::WRITE_CONFLICT_RETRY_ONLY,
                                                InternalPlanner::FORWARD);

    Snapshotted<BSONObj> objToClone;
    RecordId loc;
    PlanExecutor::ExecState state = PlanExecutor::FAILURE;  // suppress uninitialized warnings

    DisableDocumentValidation validationDisabler(opCtx);

    int retries = 0;  // non-zero when retrying our last document.
    while (true) {
        if (!retries) {
            state = exec->getNextSnapshotted(&objToClone, &loc);
        }

        switch (state) {
            case PlanExecutor::IS_EOF:
                return Status::OK();
            case PlanExecutor::ADVANCED: {
                if (excessSize > 0) {
                    // 4x is for padding, power of 2, etc...
                    excessSize -= (4 * objToClone.value().objsize());
                    continue;
                }
                break;
            }
            default:
                // Unreachable as:
                // 1) We require a read lock (at a minimum) on the "from" collection
                //    and won't yield, preventing collection drop and PlanExecutor::DEAD
                // 2) PlanExecutor::FAILURE is only returned on PlanStage::FAILURE. The
                //    CollectionScan PlanStage does not have a FAILURE scenario.
                // 3) All other PlanExecutor states are handled above
                MONGO_UNREACHABLE;
        }

        try {
            // Make sure we are working with the latest version of the document.
            if (objToClone.snapshotId() != opCtx->recoveryUnit()->getSnapshotId() &&
                !fromCollection->findDoc(opCtx, loc, &objToClone)) {
                // doc was deleted so don't clone it.
                retries = 0;
                continue;
            }

            WriteUnitOfWork wunit(opCtx);
            OpDebug* const nullOpDebug = nullptr;
            uassertStatusOK(toCollection->insertDocument(
                opCtx, InsertStatement(objToClone.value()), nullOpDebug, true));
            wunit.commit();

            // Go to the next document
            retries = 0;
        } catch (const WriteConflictException&) {
            CurOp::get(opCtx)->debug().writeConflicts++;
            retries++;  // logAndBackoff expects this to be 1 on first call.
            WriteConflictException::logAndBackoff(retries, "cloneCollectionAsCapped", fromNss.ns());

            // Can't use writeConflictRetry since we need to save/restore exec around call to
            // abandonSnapshot.
            exec->saveState();
            opCtx->recoveryUnit()->abandonSnapshot();
            auto restoreStatus = exec->restoreState();  // Handles any WCEs internally.
            if (!restoreStatus.isOK()) {
                return restoreStatus;
            }
        }
    }

    MONGO_UNREACHABLE;
}