Exemplo n.º 1
0
   /*
   * Record current positions of all local atoms and lock storage.
   */
   void AtomStorage::makeSnapshot()
   {
      // Precondition
      if (!isCartesian()) {
         UTIL_THROW("Error: Coordinates not Cartesian in makeSnapshot");
      }
 
      AtomIterator iter;
      int i = 0;
      for (begin(iter); iter.notEnd(); ++iter) {
         snapshot_[i] = iter->position();
         ++i;
      }
      locked_ = true;
   }
Exemplo n.º 2
0
QString DlgEditPointGraph::unitsType (bool isXTheta) const
{
  if (isCartesian ()) {
    if (isXTheta) {
      return coordUnitsNonPolarThetaToBriefType (m_modelCoords.coordUnitsX());
    } else {
      return coordUnitsNonPolarThetaToBriefType (m_modelCoords.coordUnitsY());
    }
  } else {
    if (isXTheta) {
      return coordUnitsPolarThetaToBriefType (m_modelCoords.coordUnitsTheta());
    } else {
      return coordUnitsNonPolarThetaToBriefType (m_modelCoords.coordUnitsRadius());
    }
  }
}
Exemplo n.º 3
0
 /*
 * Transform all atomic coordinates from generalized to Cartesian.
 */
 void AtomStorage::transformGenToCart(const Boundary& boundary) 
 {
    if (isCartesian()) {
       UTIL_THROW("Error: Coordinates are Cartesian on entry");
    }
    Vector r;
    if (nAtom()) {
       AtomIterator atomIter;
       for (begin(atomIter); atomIter.notEnd(); ++atomIter) {
          r = atomIter->position();
          boundary.transformGenToCart(r, atomIter->position());
       }
    }
    if (nGhost()) {
       GhostIterator ghostIter;
       for (begin(ghostIter); ghostIter.notEnd(); ++ghostIter) {
          r = ghostIter->position();
          boundary.transformGenToCart(r, ghostIter->position());
       }
    }
    isCartesian_ = true;
 }
Exemplo n.º 4
0
 /*
 * Return max. sq. displacement of local atoms on this node since snapshot.
 */
 double AtomStorage::maxSqDisplacement()
 {
    if (!isCartesian()) {
       UTIL_THROW("Error: Coordinates not Cartesian in maxSqDisplacement");
    } 
    if (!locked_) {
       UTIL_THROW("Error: AtomStorage not locked in maxSqDisplacement");
    } 
    Vector dr;
    double norm;
    double max = 0.0;
    AtomIterator iter;
    int i = 0;
    for (begin(iter); iter.notEnd(); ++iter) {
       dr.subtract(iter->position(), snapshot_[i]);
       norm = dr.square();
       if (norm > max) {
          max = norm;
       }
       ++i;
    }
    return max;
 }
Exemplo n.º 5
0
void DlgEditPointGraph::createCoords (QVBoxLayout *layoutOuter)
{
  // Constraints on x and y are needed for log scaling
  bool isConstraintX = (m_modelCoords.coordScaleXTheta() == COORD_SCALE_LOG);
  bool isConstraintY = (m_modelCoords.coordScaleYRadius() == COORD_SCALE_LOG);
  DlgValidatorFactory dlgValidatorFactory;
  m_validatorGraphX = dlgValidatorFactory.createCartesianOrPolarWithPolarPolar (m_modelCoords.coordScaleXTheta(),
                                                                                isCartesian (),
                                                                                m_modelCoords.coordUnitsX(),
                                                                                m_modelCoords.coordUnitsTheta(),
                                                                                m_modelCoords.coordUnitsDate(),
                                                                                m_modelCoords.coordUnitsTime(),
                                                                                m_modelMainWindow.locale());
  m_validatorGraphY = dlgValidatorFactory.createCartesianOrPolarWithNonPolarPolar (m_modelCoords.coordScaleYRadius(),
                                                                                   isCartesian (),
                                                                                   m_modelCoords.coordUnitsY(),
                                                                                   m_modelCoords.coordUnitsRadius(),
                                                                                   m_modelCoords.coordUnitsDate(),
                                                                                   m_modelCoords.coordUnitsTime(),
                                                                                   m_modelMainWindow.locale());

  // Label, with guidance in terms of legal ranges and units
  QString description = QString ("%1 (%2, %3)%4%5%6%7%8%9 %10:")
                        .arg (tr ("Graph Coordinates"))
                        .arg (nameXTheta ())
                        .arg (nameYRadius ())
                        .arg (isConstraintX || isConstraintY ? " with " : "")
                        .arg (isConstraintX                  ? QString (nameXTheta ()) : "")
                        .arg (isConstraintX                  ? " > 0" : "")
                        .arg (isConstraintX && isConstraintY ? " and " : "")
                        .arg (                 isConstraintY ? QString (nameYRadius ()) : "")
                        .arg (                 isConstraintY ? " > 0" : "")
                        .arg (tr ("as"));
  QGroupBox *panel = new QGroupBox (description, this);
  layoutOuter->addWidget (panel);

  QHBoxLayout *layout = new QHBoxLayout (panel);
  panel->setLayout (layout);

  // Row
  QLabel *labelGraphParLeft = new QLabel (tr ("("), this);
  layout->addWidget(labelGraphParLeft, 0);

  m_editGraphX = new DlgEditPointGraphLineEdit;
  m_editGraphX->setMinimumWidth(MIN_WIDTH_TO_FIT_STRANGE_UNITS);
  m_editGraphX->setAlignment (ALIGNMENT);
  m_editGraphX->setValidator (m_validatorGraphX);
  // setStatusTip does not work for modal dialogs
  m_editGraphX->setWhatsThis (tr ("Enter the first graph coordinate value to be applied to the graph points.\n\n"
                                  "Leave this field empty if no value is to be applied to the graph points.\n\n"
                                  "For cartesian plots this is the X coordinate. For polar plots this is the radius R.\n\n"
                                  "The expected format of the coordinate value is determined by the locale setting. If "
                                  "typed values are not recognized as expected, check the locale setting in Settings / Main Window..."));
  layout->addWidget(m_editGraphX, 0);
  connect (m_editGraphX, SIGNAL (textChanged (const QString &)), this, SLOT (slotTextChanged (const QString &)));

  QLabel *labelGraphComma = new QLabel (tr (", "), this);
  layout->addWidget(labelGraphComma, 0);

  m_editGraphY = new DlgEditPointGraphLineEdit;
  m_editGraphY->setMinimumWidth(MIN_WIDTH_TO_FIT_STRANGE_UNITS);
  m_editGraphY->setAlignment (ALIGNMENT);
  m_editGraphY->setValidator (m_validatorGraphY);
  // setStatusTip does not work for modal dialogs
  m_editGraphY->setWhatsThis (tr ("Enter the second graph coordinate value to be applied to the graph points.\n\n"
                                  "Leave this field empty if no value is to be applied to the graph points.\n\n"
                                  "For cartesian plots this is the Y coordinate. For plot plots this is the angle Theta.\n\n"
                                  "The expected format of the coordinate value is determined by the locale setting. If "
                                  "typed values are not recognized as expected, check the locale setting in Settings / Main Window..."));
  layout->addWidget(m_editGraphY, 0);
  connect (m_editGraphY, SIGNAL (textChanged (const QString &)), this, SLOT (slotTextChanged (const QString &)));

  QLabel *labelGraphParRight = new QLabel (tr (")"), this);
  layout->addWidget(labelGraphParRight, 0);
}
Exemplo n.º 6
0
QChar DlgEditPointGraph::nameYRadius () const
{
  return (isCartesian () ? QChar ('Y') : QChar ('R'));
}
Exemplo n.º 7
0
QChar DlgEditPointGraph::nameXTheta () const
{
  return (isCartesian () ? QChar ('X') : THETA);
}