Пример #1
0
Foam::Map<Foam::label> Foam::refinementIterator::setRefinement
(
    const List<refineCell>& refCells
)
{
    Map<label> addedCells(2*refCells.size());

    Time& runTime = const_cast<Time&>(mesh_.time());

    label nRefCells = refCells.size();

    label oldRefCells = -1;

    // Operate on copy.
    List<refineCell> currentRefCells(refCells);

    bool stop = false;

    do
    {
        if (writeMesh_)
        {
            // Need different times to write meshes.
            runTime++;
        }

        polyTopoChange meshMod(mesh_);

        if (debug)
        {
            Pout<< "refinementIterator : refining "
                << currentRefCells.size() << " cells." << endl;
        }

        // Determine cut pattern.
        cellCuts cuts(mesh_, cellWalker_, currentRefCells);

        label nCuts = cuts.nLoops();
        reduce(nCuts, sumOp<label>());

        if (nCuts == 0)
        {
            if (debug)
            {
                Pout<< "refinementIterator : exiting iteration since no valid"
                    << " loops found for " << currentRefCells.size() 
                    << " cells" << endl;


                fileName cutsFile("failedCuts_" + runTime.timeName() + ".obj");

                Pout<< "Writing cuts for time " <<  runTime.timeName()
                    << " to " << cutsFile << endl;

                OFstream cutsStream(cutsFile);


                labelList refCells(currentRefCells.size());
                forAll(currentRefCells, i)
                {
                    refCells[i] = currentRefCells[i].cellNo();
                }
                meshTools::writeOBJ
                (
                    cutsStream,
                    mesh().cells(),
                    mesh().faces(),
                    mesh().points(),
                    refCells
                );
            }

            break;
        }
            
        if (debug)
        {
            fileName cutsFile("cuts_" + runTime.timeName() + ".obj");

            Pout<< "Writing cuts for time " <<  runTime.timeName()
                << " to " << cutsFile << endl;

            OFstream cutsStream(cutsFile);
            cuts.writeOBJ(cutsStream);
        }


        // Insert mesh refinement into polyTopoChange.
        meshRefiner_.setRefinement(cuts, meshMod);


        //
        // Do all changes
        //

        autoPtr<mapPolyMesh> morphMap = meshMod.changeMesh
        (
            mesh_,
            false
        );

        // Move mesh (since morphing does not do this)
        if (morphMap().hasMotionPoints())
        {
            mesh_.movePoints(morphMap().preMotionPoints());
        }

        // Update stored refinement pattern
        meshRefiner_.updateMesh(morphMap());

        // Write resulting mesh
        if (writeMesh_)
        {
            if (debug)
            {
                Pout<< "Writing refined polyMesh to time "
                    << runTime.timeName() << endl;
            }

            mesh_.write();
        }

        // Update currentRefCells for new cell numbers. Use helper function
        // in meshCutter class.
        updateLabels
        (
            morphMap->reverseCellMap(),
            currentRefCells
        );

        // Update addedCells for new cell numbers
        updateLabels
        (
            morphMap->reverseCellMap(),
            addedCells
        );

        // Get all added cells from cellCutter (already in new numbering
        // from meshRefiner.updateMesh call) and add to global list of added
        const Map<label>& addedNow = meshRefiner_.addedCells();

        for
        (
            Map<label>::const_iterator iter = addedNow.begin();
            iter != addedNow.end();
            ++iter
        )
        {
            if (!addedCells.insert(iter.key(), iter()))
            {
                FatalErrorIn("refinementIterator")
                    << "Master cell " << iter.key()
                    << " already has been refined" << endl
                    << "Added cell:" << iter() << abort(FatalError);
            }
        }


        // Get failed refinement in new cell numbering and reconstruct input
        // to the meshRefiner. Is done by removing all refined cells from
        // current list of cells to refine.

        // Update refCells for new cell numbers.
        updateLabels
        (
            morphMap->reverseCellMap(),
            currentRefCells
        );

        // Pack refCells acc. to refined status
        nRefCells = 0;

        forAll(currentRefCells, refI)
        {
            const refineCell& refCell = currentRefCells[refI];

            if (!addedNow.found(refCell.cellNo()))
            {
                if (nRefCells != refI)
                {
                    currentRefCells[nRefCells++] =
                        refineCell
                        (
                            refCell.cellNo(),
                            refCell.direction()
                        );
                }
            }
        }

        oldRefCells = currentRefCells.size();

        currentRefCells.setSize(nRefCells);

        if (debug)
        {
            Pout<< endl;
        }

        // Stop only if all finished or all can't refine any further.
        stop = (nRefCells == 0) || (nRefCells == oldRefCells);
        reduce(stop, andOp<bool>());
    }
    while (!stop);


    if (nRefCells == oldRefCells)
    {
        WarningIn("refinementIterator")
            << "stopped refining."
            << "Did not manage to refine a single cell" << endl
            << "Wanted :" << oldRefCells << endl;
    }

    return addedCells;
}
Client::Client(QWidget *parent)
    : QDialog(parent), networkSession(0)
{
	 // find out which IP to connect to
	QList<QHostAddress> ipAddressesList = QNetworkInterface::allAddresses();
	// use the first non-localhost IPv4 address
	for (int i = 0; i < ipAddressesList.size(); ++i) {
		if (ipAddressesList.at(i) != QHostAddress::LocalHost &&
			ipAddressesList.at(i).toIPv4Address()) {
			ipAddress = ipAddressesList.at(i).toString();
			break;
		}
	}
	// if we did not find one, use IPv4 localhost
	if (ipAddress.isEmpty())
		ipAddress = QHostAddress(QHostAddress::LocalHost).toString();

	userLabel = new QLabel("Username: "******"Password: "******"Register");
	loginButton = new QPushButton("Login");
	cancelButton = new QPushButton("Cancel");

	buttonBox = new QDialogButtonBox();
	buttonBox->addButton(registerButton, QDialogButtonBox::ActionRole);
	buttonBox->addButton(loginButton, QDialogButtonBox::ActionRole);
	buttonBox->addButton(cancelButton, QDialogButtonBox::RejectRole);

	mainLayout = new QGridLayout;
	mainLayout->addWidget(userLabel, 0, 0, 1, 2);
	mainLayout->addWidget(userLineEdit, 1, 0, 1, 5);
	mainLayout->addWidget(passLabel, 2, 0, 1, 2);
	mainLayout->addWidget(passLineEdit, 3, 0, 1, 5);
	mainLayout->addWidget(statusLabel, 4, 0, 3, 4);
	mainLayout->addWidget(buttonBox, 7, 1, 1, 2);

	setLayout(mainLayout);

	tcpSocket = new QTcpSocket(this);

	connect(registerButton, SIGNAL(clicked()), this, SLOT(registerWithServer()));
	connect(cancelButton, SIGNAL(clicked()), this, SLOT(close()));
	connect(loginButton, SIGNAL(clicked()), this, SLOT(requestNewConnection()));
	connect(tcpSocket, SIGNAL(connected()), this, SLOT(sendLoginInfo()));
	connect(tcpSocket, SIGNAL(readyRead()), this, SLOT(updateLabels()));
	//connect(tcpSocket, SIGNAL(disconnected()), this, SLOT(connectionClosedByServer()));

	QNetworkConfigurationManager manager;
	if (manager.capabilities() & QNetworkConfigurationManager::NetworkSessionRequired) {
		// Get saved network configuration
		QSettings settings(QSettings::UserScope, QLatin1String("Trolltech"));
		settings.beginGroup(QLatin1String("QtNetwork"));
		const QString id = settings.value(QLatin1String("DefaultNetworkConfiguration")).toString();
		settings.endGroup();

		// If the saved network configuration is not currently discovered use the system default
		QNetworkConfiguration config = manager.configurationFromIdentifier(id);
		if ((config.state() & QNetworkConfiguration::Discovered) !=
			QNetworkConfiguration::Discovered) {
			config = manager.defaultConfiguration();
		}

		networkSession = new QNetworkSession(config, this);
		connect(networkSession, SIGNAL(opened()), this, SLOT(sessionOpened()));

		statusLabel->setText(tr("Opening network session."));
		networkSession->open();
	}

}
Пример #3
0
void ThreeDMolDialog::moleculeDestroyed()
{
  m_molecule = nullptr;
  updateLabels();
}
Пример #4
0
void MainWindow::changedSlot()
{
    changed = true;
    saveSlot();
    updateLabels();
}
Пример #5
0
bool CGroupChar::updateFromXML(QDomNode node)
{
  bool updated;


  updated = false;
  if (node.nodeName() != "playerData") {
    qDebug( "Called updateFromXML with wrong node. The name does not fit.");
    return false;
  }

  QString s;
  QByteArray str;
  int newval;

  QDomElement e = node.toElement();

  unsigned int newpos  = e.attribute("room").toInt();
  if (newpos != pos) {
    updated = true;
    pos = newpos;
  }


  str = e.attribute("name").toLatin1();
  if (str != name) {
    updated = true;
    name = str;
  }

  str = e.attribute("lastMovement").toLatin1();
  if (str != lastMovement) {
    updated = true;
    lastMovement = str;
  }


  str = e.attribute("color").toLatin1();
  if (str != color.name().toLatin1()) {
    updated = true;
    color = QColor(QString(str) );
  }

//  printf(" 6.\r\n");

  str = e.attribute("textHP").toLatin1();
  if (s != textHP) {
    updated = true;
    textHP = str;
  }

  str = e.attribute("textMana").toLatin1();
  if (s != textMana) {
    updated = true;
    textMana = str;
  }

  str = e.attribute("textMoves").toLatin1();
  if (s != textMoves) {
    updated = true;
    textMoves = str;
  }

  newval  = e.attribute("hp").toInt();
  if (newval != hp) {
    updated = true;
    hp = newval;
  }

  newval  = e.attribute("maxhp").toInt();
  if (newval != maxhp) {
    updated = true;
    maxhp = newval;
  }

  newval  = e.attribute("mana").toInt();
  if (newval != mana) {
    updated = true;
    mana = newval;
  }

  newval  = e.attribute("maxmana").toInt();
  if (newval != maxmana) {
    updated = true;
    maxmana = newval;
  }

  newval  = e.attribute("moves").toInt();
  if (newval != moves) {
    updated = true;
    moves = newval;
  }

  newval  = e.attribute("maxmoves").toInt();
  if (newval != maxmoves) {
    updated = true;
    maxmoves = newval;
  }

  newval  = e.attribute("state").toInt();
  if (newval != state) {
    updated = true;
    state = newval;
  }

//  printf("Tut 6.\r\n");

  if (updated == true)
    updateLabels();

//  printf("Tut 7.\r\n");

  return updated; // hrmpf!
}
Пример #6
0
 void TradeWindow::onMaxSaleButtonClicked(MyGUI::Widget* _sender)
 {
     mCurrentBalance = getMerchantGold();
     updateLabels();
 }
Пример #7
0
 void TradeWindow::onDecreaseButtonTriggered()
 {
     if (mCurrentBalance < 0) mCurrentBalance += 1;
     else mCurrentBalance -= 1;
     updateLabels();
 }
Пример #8
0
void EnchantingDialog::onTypeButtonClicked(MyGUI::Widget* sender)
{
    mEnchanting.nextCastStyle();
    updateLabels();
}
Пример #9
0
void EnchantingDialog::notifyEffectsChanged ()
{
    mEffectList.mList = mEffects;
    mEnchanting.setEffect(mEffectList);
    updateLabels();
}
Пример #10
0
 void TradeWindow::onIncreaseButtonTriggered()
 {
     if(mCurrentBalance<=-1) mCurrentBalance -= 1;
     if(mCurrentBalance>=1) mCurrentBalance += 1;
     updateLabels();
 }
Пример #11
0
 void MosaicTrackTool::mouseMove(QPointF p) {
   updateLabels(p);
 }
Пример #12
0
MainWindow::MainWindow(QWidget *parent) :
    QMainWindow(parent),
    ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    // Create an instance of a ScoreKeeper that will keep track of correct/incorrect answers and provide statistics on them
    score_keeper = new ScoreKeeper(this);

    // Upon retrieving the two sound file URLs, send a request to Playback to open them and assign them to the Players
    connect(this, SIGNAL(loadSoundsRequest(QUrl,QUrl)), ui->playbackWidget, SLOT(loadSounds(QUrl,QUrl)));
    // When a guess is made by the user, send whether it was correct or incorrect to ScoreKeeper
    connect(this, SIGNAL(guessMade(ScoreKeeper::Guesses)), score_keeper, SLOT(guessMade(ScoreKeeper::Guesses)));
    // When the user makes a guess, Playback starts a new trial
    connect(this, SIGNAL(startNewTrialRequest()), ui->playbackWidget, SLOT(startNewTrial()));
    // When ScoreKeeper has updated its scores, it notifies this window to update their display
    connect(score_keeper, SIGNAL(scoreUpdated(ScoreKeeper::Score,ScoreKeeper::Score)), this, SLOT(updateLabels(ScoreKeeper::Score,ScoreKeeper::Score)));
}