--- a/README Mon Aug 07 09:36:23 2006 -0400
+++ b/README Mon Aug 07 10:39:15 2006 -0400
@@ -1,6 +1,6 @@
VEFViewer is written by Dmitriy Morozov <morozov@cs.duke.edu>.
-It uses libQGLViewer, and therefore is licensed under GPL.
+It uses Qt4, libQGLViewer, and is licensed under GPL.
To build (on Linux):
qmake
--- a/VEFViewer.cpp Mon Aug 07 09:36:23 2006 -0400
+++ b/VEFViewer.cpp Mon Aug 07 10:39:15 2006 -0400
@@ -205,17 +205,26 @@
}
+// QDisplayListLWI
+void QDisplayListLWI::draw() const
+{
+ if (!isVisible()) return;
+
+ glColor3f(color_.redF(), color_.greenF(), color_.blueF());
+ glCallList(display_list_);
+}
+
// QVertices
void QVerticesLWI::draw() const
{
if (!isVisible()) return;
-
- glColor3f(.5, .65, .65);
+ glColor3f(color_.redF(), color_.greenF(), color_.blueF());
if (!isSphere())
glCallList(display_list_);
else
glCallList(sphere_display_list_);
+
}
void QVerticesLWI::drawWithNames(int offset) const
{}
@@ -224,8 +233,8 @@
void QVerticesLWI::highlight(int selected)
{}
-QVerticesLWI::QVerticesLWI(const QString& fname, VEFViewer* v):
- isSphere_(false), viewer_(v)
+QVerticesLWI::QVerticesLWI(QString fname, VEFViewer* v):
+ QDisplayListLWI(fname, QColor::fromRgbF(.5, .65, .65)), isSphere_(false), viewer_(v)
{
filename_ = fname;
QFileInfo fi(filename_);
@@ -292,7 +301,7 @@
// Draw selected
if (highlighted_ >= 0)
{
- glColor3f(.9, .4, 0);
+ glColor3f(color_.light(200).redF(), color_.light(200).greenF(), color_.light(200).blueF());
glBegin(GL_TRIANGLES);
const Triangle& t = triangles_[highlighted_];
glNormal3f(t.nx, t.ny, t.nz);
@@ -305,12 +314,12 @@
// Draw the object
if (!isWireframe())
{
- glColor3f(0., .4, .6);
+ glColor3f(color_.light(150).redF(), color_.light(150).greenF(), color_.light(150).blueF());
glCallList(display_list_);
}
else
{
- glColor3f(1., 0, 0);
+ glColor3f(color_.redF(), color_.greenF(), color_.blueF());
glCallList(wireframe_display_list_);
}
}
@@ -347,8 +356,8 @@
std::cout << " " << t.x2 << " " << t.y2 << " " << t.z2 << ")" << std::endl;
}
-QFacesLWI::QFacesLWI(const QString& fname, VEFViewer* v):
- highlighted_(-1), isWireframe_(false), viewer_(v)
+QFacesLWI::QFacesLWI(QString fname, VEFViewer* v):
+ QDisplayListLWI(fname, QColor::fromRgbF(0,.4,.6)), highlighted_(-1), isWireframe_(false), viewer_(v)
{
filename_ = fname;
QFileInfo fi(filename_);
@@ -449,13 +458,6 @@
/* QEdges */
-void QEdgesLWI::draw() const
-{
- if (!isVisible()) return;
-
- glColor3f(.6, .2, .6);
- glCallList(display_list_);
-}
void QEdgesLWI::drawWithNames(int offset) const
{}
int QEdgesLWI::numElements() const
@@ -463,8 +465,8 @@
void QEdgesLWI::highlight(int selected)
{}
-QEdgesLWI::QEdgesLWI(const QString& fname, VEFViewer* v):
- viewer_(v)
+QEdgesLWI::QEdgesLWI(QString fname, VEFViewer* v):
+ QDisplayListLWI(fname, QColor::fromRgbF(.6,.2,.6)), viewer_(v)
{
filename_ = fname;
QFileInfo fi(filename_);
--- a/VEFViewer.h Mon Aug 07 09:36:23 2006 -0400
+++ b/VEFViewer.h Mon Aug 07 10:39:15 2006 -0400
@@ -5,6 +5,7 @@
#include <QFileDialog>
#include <QListWidgetItem>
#include <QMenu>
+#include <QColorDialog>
class VEFViewer: public QGLViewer
{
@@ -47,13 +48,13 @@
Q_OBJECT
public:
- QDisplayListLWI():
- visible_(false)
+ QDisplayListLWI(QString name, QColor color):
+ QListWidgetItem(name), color_(color), visible_(false)
{ toggleVisible(); }
GLuint getDisplayList() const { return display_list_; }
~QDisplayListLWI() { destroy(); }
- virtual void draw() const =0;
+ virtual void draw() const;
virtual void drawWithNames(int offset) const =0;
virtual int numElements() const =0;
virtual void highlight(int selected) =0;
@@ -65,6 +66,9 @@
connect(visible, SIGNAL(triggered()), this, SLOT(toggleVisible()));
visible->setCheckable(true);
visible->setChecked(isVisible());
+
+ QAction* color = m.addAction("Pick color");
+ connect(color, SIGNAL(triggered()), this, SLOT(changeColor()));
}
bool isVisible() const { return visible_; }
@@ -75,10 +79,13 @@
virtual void reload() { destroy(); init(); }
virtual void init() =0;
virtual void destroy() { glDeleteLists(display_list_, 1); }
+ void changeColor()
+ { QColor nw = QColorDialog::getColor(color_); if (nw.isValid()) color_ = nw; }
protected:
GLuint display_list_;
bool visible_;
+ QColor color_;
private:
void adjustFont() { QFont f; if (visible_) f.setBold(true); setFont(f); }
@@ -91,7 +98,7 @@
Q_OBJECT
public:
- QVerticesLWI(const QString& fname, VEFViewer* v);
+ QVerticesLWI(QString fname, VEFViewer* v);
virtual void draw() const;
virtual void drawWithNames(int offset) const;
virtual int numElements() const;
@@ -131,7 +138,7 @@
Q_OBJECT
public:
- QFacesLWI(const QString& fname, VEFViewer* v);
+ QFacesLWI(QString fname, VEFViewer* v);
virtual void draw() const;
virtual void drawWithNames(int offset) const;
virtual int numElements() const;
@@ -176,8 +183,7 @@
class QEdgesLWI: public QDisplayListLWI
{
public:
- QEdgesLWI(const QString& fname, VEFViewer* v);
- virtual void draw() const;
+ QEdgesLWI(QString fname, VEFViewer* v);
virtual void drawWithNames(int offset) const;
virtual int numElements() const;
virtual void highlight(int selected);