Commit 0038ca35 authored by js9's avatar js9

Adding support for element type as an enumerated scalar from

the molecular VASP files.  Adding support for hinting in
the CreateBonds window as to the allowable types in the
periodic table widget.



git-svn-id: http://visit.ilight.com/svn/visit/trunk/src@3216 18c085ea-50e0-402c-830e-de6fd14e8384
parent 987de7e2
......@@ -131,6 +131,9 @@ avtOUTCARFileFormat::OpenFileAtBeginning()
// Jeremy Meredith, Fri Apr 20 15:01:36 EDT 2007
// Added support for magnetization fields.
//
// Jeremy Meredith, Tue Feb 12 14:09:24 EST 2008
// Support element types as an enumerated scalar.
//
// ****************************************************************************
void
......@@ -157,7 +160,16 @@ avtOUTCARFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md, int ts)
}
md->Add(mmd_bbox);
AddScalarVarToMetaData(md, "element", "mesh", AVT_NODECENT);
avtScalarMetaData *el_smd =
new avtScalarMetaData("element", "mesh", AVT_NODECENT);
el_smd->isEnumeration = true;
for (int i=0; i<element_types.size(); i++)
{
el_smd->enumNames.push_back(element_names[i]);
el_smd->enumValues.push_back(element_types[i]);
}
md->Add(el_smd);
if (ntimesteps != 0)
{
// If only initial consitions are saved, then we don't
......
......@@ -52,6 +52,7 @@
#include <avtDatabaseMetaData.h>
#include <avtSTSDFileFormatInterface.h>
#include <AtomicProperties.h>
#include <Expression.h>
......@@ -129,6 +130,8 @@ avtPOSCARFileFormat::FreeUpResources(void)
// Creation: January 8, 2008
//
// Modifications:
// Jeremy Meredith, Tue Feb 12 14:09:24 EST 2008
// Support element types as an enumerated scalar.
//
// ****************************************************************************
......@@ -158,13 +161,23 @@ avtPOSCARFileFormat::PopulateDatabaseMetaData(avtDatabaseMetaData *md)
AddScalarVarToMetaData(md, "species", "mesh", AVT_NODECENT);
if (element_map.size() > 0)
AddScalarVarToMetaData(md, "element", "mesh", AVT_NODECENT);
{
avtScalarMetaData *el_smd =
new avtScalarMetaData("element", "mesh", AVT_NODECENT);
el_smd->isEnumeration = true;
for (int i=0; i<element_map.size(); i++)
{
el_smd->enumNames.push_back(element_names[element_map[i]-1]);
el_smd->enumValues.push_back(element_map[i]);
}
md->Add(el_smd);
}
if (cx.size() > 0)
AddScalarVarToMetaData(md, "cx", "mesh", AVT_NODECENT);
AddScalarVarToMetaData(md, "cx", "mesh", AVT_NODECENT);
if (cy.size() > 0)
AddScalarVarToMetaData(md, "cy", "mesh", AVT_NODECENT);
AddScalarVarToMetaData(md, "cy", "mesh", AVT_NODECENT);
if (cz.size() > 0)
AddScalarVarToMetaData(md, "cz", "mesh", AVT_NODECENT);
AddScalarVarToMetaData(md, "cz", "mesh", AVT_NODECENT);
}
......
......@@ -323,3 +323,23 @@ QvisElementButton::elementSelected(int element)
emit selectedElement(element);
}
}
// ****************************************************************************
// Method: QvisElementButton::setHintedElements
//
// Purpose:
// Accept a list of atomic numbers that we will use for hinting.
//
// Arguments:
// elements the list of atomic numbers
//
// Programmer: Jeremy Meredith
// Creation: February 12, 2008
//
// ****************************************************************************
void
QvisElementButton::setHintedElements(const std::vector<int> &elements)
{
sharedpopup->setHintedElements(elements);
}
......@@ -69,6 +69,10 @@ class QvisElementSelectionWidget;
// both a periodic table widget and a "match any element" button
// to allow wildcards.
//
// Jeremy Meredith, Tue Feb 12 14:01:52 EST 2008
// Added support for hinting some elements to the user, e.g. to highlight
// the elements that are actually in the database.
//
// ****************************************************************************
class GUI_API QvisElementButton : public QPushButton
......@@ -85,6 +89,7 @@ public:
int elementNumber() const;
void setElementNumber(int);
void setHintedElements(const std::vector<int>&);
signals:
void selectedElement(int element);
......
......@@ -316,3 +316,24 @@ QvisElementSelectionWidget::handleSelectedElement(int element)
// Emit the element changed signal.
emit selectedElement(element);
}
// ****************************************************************************
// Method: QvisElementSelectionWidget::setHintedElements
//
// Purpose:
// Accept a list of atomic numbers that we will use for hinting.
//
// Arguments:
// elements the list of atomic numbers
//
// Programmer: Jeremy Meredith
// Creation: February 12, 2008
//
// ****************************************************************************
void
QvisElementSelectionWidget::setHintedElements(const std::vector<int> &elements)
{
periodicTable->setHintedElements(elements);
}
......@@ -40,6 +40,7 @@
#define QVIS_ELEMENT_SELECTION_WIDGET_H
#include <gui_exports.h>
#include <qwidget.h>
#include <vector>
// Forward declarations.
class QPushButton;
......@@ -60,6 +61,9 @@ class QvisPeriodicTableWidget;
// Note: borrowed heavily from Brad's color selection widget
//
// Modifications:
// Jeremy Meredith, Tue Feb 12 14:01:52 EST 2008
// Added support for hinting some elements to the user, e.g. to highlight
// the elements that are actually in the database.
//
// ****************************************************************************
......@@ -73,7 +77,9 @@ class GUI_API QvisElementSelectionWidget : public QWidget
virtual QSize sizeHint() const;
void setSelectedElement(int);
signals:
void setHintedElements(const std::vector<int>&);
signals:
void selectedElement(int);
public slots:
virtual void show();
......
......@@ -99,6 +99,9 @@ static int element_type_colors[9][3] = {
// Jeremy Meredith, Mon Feb 11 15:21:46 EST 2008
// Removed setting of ispopup to true; it's not for us to decide.
//
// Jeremy Meredith, Tue Feb 12 14:00:26 EST 2008
// Added support for hinting selectable elements.
//
// ****************************************************************************
QvisPeriodicTableWidget::QvisPeriodicTableWidget(QWidget *parent, const char *name,
......@@ -111,6 +114,9 @@ QvisPeriodicTableWidget::QvisPeriodicTableWidget(QWidget *parent, const char *na
boxSizeValue = 24;
boxPaddingValue = 2;
setMinimumSize(minimumSize());
hintedElements = new bool[numGridSquares];
for (int i=0; i<numGridSquares; i++)
hintedElements[i] = false;
}
// ****************************************************************************
......@@ -123,11 +129,14 @@ QvisPeriodicTableWidget::QvisPeriodicTableWidget(QWidget *parent, const char *na
// Creation: August 11, 2006
//
// Modifications:
// Jeremy Meredith, Tue Feb 12 14:00:26 EST 2008
// Added support for hinting selectable elements.
//
// ****************************************************************************
QvisPeriodicTableWidget::~QvisPeriodicTableWidget()
{
delete[] hintedElements;
}
......@@ -234,6 +243,10 @@ QvisPeriodicTableWidget::keyPressEvent(QKeyEvent *e)
// Creation: August 11, 2006
//
// Modifications:
// Jeremy Meredith, Tue Feb 12 14:00:26 EST 2008
// Added support for hinting selectable elements. The hinting method
// that appeared to be the best combination between noticeable and
// distracting, at least on my machine, was simply to boldface the font.
//
// ****************************************************************************
......@@ -250,6 +263,8 @@ QvisPeriodicTableWidget::drawItem(QPainter &paint, int index)
if (element > MAX_ELEMENT_NUMBER)
return;
bool hint = hintedElements[index];
int r = index / numColumns;
int c = index % numColumns;
int *colorvals = element_type_colors[periodic_colors[r][c]-1];
......@@ -261,11 +276,25 @@ QvisPeriodicTableWidget::drawItem(QPainter &paint, int index)
QColor color(colorvals[0], colorvals[1], colorvals[2]);
paint.fillRect(x + 1, y + 1, boxWidth - 2, boxHeight - 2, color);
drawBox(paint, QRect(x+1,y+1,boxWidth-2,boxHeight-2),
color.light(125), color.dark(125), 1);
color.light(125),
color.dark(125), 1);
QFont oldfont(paint.font());
if (hint)
{
QFont newfont(oldfont);
//newfont.setItalic(true);
//newfont.setUnderline(true);
newfont.setBold(true);
paint.setFont(newfont);
}
paint.setPen(colorGroup().foreground());
paint.drawText(QRect(x,y,boxWidth,boxHeight),
Qt::AlignHCenter | Qt::AlignVCenter,
element_names[element-1]);
if (hint)
{
paint.setFont(oldfont);
}
}
......@@ -330,3 +359,36 @@ QvisPeriodicTableWidget::indexToElement(int index)
}
// ****************************************************************************
// Method: QvisPeriodicTableWidget::setHintedElements
//
// Purpose:
// Accept a list of atomic numbers that we will use for hinting.
//
// Arguments:
// elements the list of atomic numbers
//
// Programmer: Jeremy Meredith
// Creation: February 12, 2008
//
// ****************************************************************************
void
QvisPeriodicTableWidget::setHintedElements(const std::vector<int> &elements)
{
for (int i=0; i<numGridSquares; i++)
{
hintedElements[i] = false;
int element = indexToElement(i);
if (element <= 0)
continue;
for (int j=0; j<elements.size(); j++)
{
if (elements[j] == element)
{
hintedElements[i] = true;
break;
}
}
}
}
......@@ -41,6 +41,7 @@
#include <gui_exports.h>
#include <qwidget.h>
#include <QvisGridWidget.h>
#include <vector>
class QPixmap;
class QPainter;
......@@ -57,6 +58,9 @@ class QPainter;
// Creation: July 6, 2006
//
// Modifications:
// Jeremy Meredith, Tue Feb 12 14:01:52 EST 2008
// Added support for hinting some elements to the user, e.g. to highlight
// the elements that are actually in the database.
//
// ****************************************************************************
......@@ -69,6 +73,7 @@ public:
virtual ~QvisPeriodicTableWidget();
void setSelectedElement(int e);
void setHintedElements(const std::vector<int>&);
signals:
void selectedElement(int element);
......@@ -81,6 +86,8 @@ private:
int indexToElement(int);
virtual bool isValidIndex(int);
virtual void emitSelection();
bool *hintedElements;
};
#endif
......@@ -438,6 +438,9 @@ QvisCreateBondsWindow::elementVariableChanged(const QString &varName)
// slightly preferable because it's possible to have a currentItem but
// nothing selected.
//
// Jeremy Meredith, Tue Feb 12 14:00:26 EST 2008
// Added support for hinting selectable elements from what's in the SIL.
//
// ****************************************************************************
void QvisCreateBondsWindow::UpdateWindowSingleItem()
{
......@@ -469,6 +472,41 @@ void QvisCreateBondsWindow::UpdateWindowSingleItem()
delButton->setEnabled(index>=0 && index<=n-1);
upButton->setEnabled(index>0 && index<=n-1);
downButton->setEnabled(index>=0 && index<n-1);
//
// If we have a SIL collection called "elements", and it's not
// fully populated (i.e. less than 100 sets in the collection),
// then we can help the user by hinting which elements are
// used in the current database.
//
std::vector<int> hints;
avtSILRestriction_p sil = GetViewerProxy()->GetPlotSILRestriction();
if (sil->GetNumCollections() > 0 &&
sil->GetTopSet() != -1)
{
for (int i=0; i<sil->GetNumCollections(); i++)
{
avtSILCollection_p col = sil->GetSILCollection(i);
if (col->GetCategory() == "element")
{
const std::vector<int> &sets = col->GetSubsetList();
if (sets.size() < 100)
{
for (int j = 0; j < sets.size(); j++)
{
avtSILSet_p set = sil->GetSILSet(sets[j]);
const string &name = set->GetName();
int element = ElementNameToAtomicNumber(name.c_str());
if (element != -1)
hints.push_back(element);
}
}
break;
}
}
}
firstElement->setHintedElements(hints);
secondElement->setHintedElements(hints);
}
int QvisCreateBondsWindow::GetItemIndex(QListViewItem *item1)
......@@ -692,6 +730,10 @@ void QvisCreateBondsWindow::bondsListDel()
// Programmer: Jeremy Meredith
// Creation: February 11, 2008
//
// Modifications:
// Jeremy Meredith, Tue Feb 12 13:58:12 EST 2008
// Forget to select vectors after making changes. Fixed now.
//
// ****************************************************************************
static void
SwapIndex(CreateBondsAttributes *atts, int oldindex, int newindex)
......@@ -710,6 +752,11 @@ SwapIndex(CreateBondsAttributes *atts, int oldindex, int newindex)
atts->GetAtomicNumber2()[newindex] = oldAN2;
atts->GetMinDist()[newindex] = oldMin;
atts->GetMaxDist()[newindex] = oldMax;
atts->SelectAtomicNumber1();
atts->SelectAtomicNumber2();
atts->SelectMinDist();
atts->SelectMaxDist();
}
// ****************************************************************************
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment