());
- gpl->setText(QString("GNU GENERAL PUBLIC LICENSE
"
- "Version 2, June 1991
"
- " Copyright (C) 1989, 1991 Free Software Foundation, Inc. "
- "59 Temple Place, Suite 330, Boston, MA 02111-1307 USA: "
- "Everyone is permitted to copy and distribute verbatim copies "
- "of this license document, but changing it is not allowed.
"));
- gpl->setDetailedText(QString(str.c_str()));
+ gpl->setDetailedText(QString(str.c_str()));
+ }
+
+ gpl->setText(QString( "GNU GENERAL PUBLIC LICENSE
"
+ "Version 3, 29 June 2007
"
+ "Copyright © 2007 Free Software Foundation, Inc. "
+ "<http://fsf.org/>
"
+ "Everyone is permitted to copy and distribute verbatim copies "
+ "of this license document, but changing it is not allowed.
"
+ "GNU GENERAL PUBLIC LICENSE
"));
+
gpl->setButtonText( 1, "Dismiss" );
gpl->show();
}
diff --git a/src/parameter.cpp b/src/parameter.cpp
--- a/src/parameter.cpp
+++ b/src/parameter.cpp
@@ -31,6 +31,8 @@
#include "xmlwrite.h"
#include "warning.h"
#include
+#include
+#include
using namespace std;
@@ -45,7 +47,7 @@ Parameter::Parameter() {
node_mag = 1.0;
outlinewidth = 1.0;
cell_outline_color = strdup("forestgreen");
- resize_stride = 10;
+ resize_stride = 0;
T = 1.0;
lambda_length = 100.;
lambda_celllength = 0.;
@@ -180,14 +182,19 @@ Parameter::Parameter() {
b4 = false;
dir1 = strdup(".");
dir2 = strdup(".");
+ // reassign datadir outside the loop
+ QDir dataDir(datadir);
+ if (dataDir.isRelative()){
+ QStringList path;
+ path << QDir::homePath() << dataDir.dirName();
+ datadir = strdup((char *) path.join("/").toStdString().c_str());
+ }
}
Parameter::~Parameter() {
-
+
// destruct parameter object
-
// free string parameter
-
CleanUp();
}
@@ -216,17 +223,18 @@ void Parameter::CleanUp(void) {
free(dir1);
if (dir2)
free(dir2);
+
}
void Parameter::Read(const char *filename) {
-
+
static bool ReadP=false;
if (ReadP) {
//throw "Run Time Error in parameter.cpp: Please Read parameter file only once!!";
CleanUp();
-
+
} else
ReadP=true;
@@ -241,7 +249,7 @@ void Parameter::Read(const char *filenam
node_mag = fgetpar(fp, "node_mag", 1.0, true);
outlinewidth = fgetpar(fp, "outlinewidth", 1.0, true);
cell_outline_color = sgetpar(fp, "cell_outline_color", "forestgreen", true);
- resize_stride = igetpar(fp, "resize_stride", 10, true);
+ resize_stride = igetpar(fp, "resize_stride", 0, true);
T = fgetpar(fp, "T", 1.0, true);
lambda_length = fgetpar(fp, "lambda_length", 100., true);
lambda_celllength = fgetpar(fp, "lambda_celllength", 0., true);
@@ -468,6 +476,7 @@ void Parameter::Write(ostream &os) const
if (dir2)
os << " dir2 = " << dir2 << endl;
}
+
void Parameter::XMLAdd(xmlNode *root) const {
xmlNode *xmlparameter = xmlNewChild(root, NULL, BAD_CAST "parameter", NULL);
{
@@ -1838,43 +1847,18 @@ void Parameter::AssignValArrayToPar(cons
k[i++]=*(v++);
}
}
+ // reassign datadir outside the loop
+ if (!strcmp(namec, "datadir")) {
+ if (datadir) { free(datadir); }
+ QDir dataDir(datadir);
+ if (dataDir.isRelative()){
+ QStringList path;
+ path << QDir::homePath() << dataDir.dirName();
+ datadir = strdup((char *) path.join("/").toStdString().c_str());
+ }
+ }
}
-/* void Parameter::XMLRead(xmlNode *root) {
-
- xmlNode *cur = root->xmlChildrenNode;
- while (cur!=NULL) {
- if ((!xmlStrcmp(cur->name, (const xmlChar *)"parameter"))){
- xmlNode *par_node = cur->xmlChildrenNode;
- while (par_node!=NULL) {
- {
- if (!xmlStrcmp(par_node->name, (const xmlChar *)"par")) {
- xmlChar *namec = xmlGetProp(par_node, BAD_CAST "name");
- xmlChar *valc = xmlGetProp(par_node, BAD_CAST "val");
- if (valc) {
- AssignValToPar((const char*)namec,(const char*)valc);
- } else {
- // Probably a valarray
- xmlNode *sub_par_node = par_node->xmlChildrenNode;
- vector valarray;
- while (sub_par_node != NULL) {
- if (!xmlStrcmp(sub_par_node->name, (const xmlChar *)"valarray")) {
- valarray = XMLIO::XMLReadValArray(sub_par_node);
- }
- sub_par_node = sub_par_node->next;
- }
- AssignValArrayToPar((const char*)namec, valarray);
- }
- }
- }
- par_node = par_node->next;
- }
-
- }
- cur=cur->next;
- }
- }*/
-
ostream &operator<<(ostream &os, Parameter &p) {
p.Write(os);
return os;
diff --git a/src/parameter.h b/src/parameter.h
--- a/src/parameter.h
+++ b/src/parameter.h
@@ -30,7 +30,7 @@
#include
class Parameter {
-
+
public:
Parameter();
~Parameter();
diff --git a/src/pardialog.cpp b/src/pardialog.cpp
--- a/src/pardialog.cpp
+++ b/src/pardialog.cpp
@@ -137,7 +137,7 @@ ParameterDialog::ParameterDialog(QWidget
dir2_edit = new QLineEdit( QString("%1").arg(par.dir2), this, "dir2_edit" );
// make a 1x1 grid; it will auto-expand
QGridLayout *grid = new QGridLayout( this, 1, 1 );
-
+
// add the first four widgets with (row, column) addressing
setWindowTitle( QString( " Parameter values for The Virtual Leaf") );
grid->addWidget( new QLabel( " Parameter values for The Virtual Leaf
",this), 0, 0, 1, -1, Qt::AlignCenter);
@@ -463,7 +463,7 @@ ParameterDialog::~ParameterDialog(void)
}
void ParameterDialog::write(void) {
-
+
extern Parameter par;
QString tmpval;
par.arrowcolor = strdup((const char *)arrowcolor_edit->text());
@@ -694,6 +694,7 @@ void ParameterDialog::write(void) {
par.dir1 = strdup((const char *)dir1_edit->text());
par.dir2 = strdup((const char *)dir2_edit->text());
Reset();
+
}
void ParameterDialog::Reset(void) {
extern Parameter par;
@@ -803,5 +804,4 @@ void ParameterDialog::Reset(void) {
dir2_edit->setText( QString("%1").arg(par.dir2) );
}
-
/* finis */
diff --git a/src/pardialog.h b/src/pardialog.h
--- a/src/pardialog.h
+++ b/src/pardialog.h
@@ -1,26 +1,3 @@
-/*
- *
- * $Id$
- *
- * This file is part of the Virtual Leaf.
- *
- * The Virtual Leaf is free software: you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation, either version 3 of the License, or
- * (at your option) any later version.
- *
- * The Virtual Leaf is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with the Virtual Leaf. If not, see .
- *
- * Copyright 2010 Roeland Merks.
- *
- */
-
#ifndef PARAMETER_DIALOG_H
#define PARAMETER_DIALOG_H
#include
@@ -31,18 +8,18 @@
#include
class ParameterDialog : public QDialog {
- Q_OBJECT
+ Q_OBJECT
+
+ public:
+ ParameterDialog(QWidget *parent=0, const char *name = 0, Qt::WindowFlags f = 0);
+ virtual ~ParameterDialog(void);
+ public slots:
+ void Reset(void);
- public:
- ParameterDialog(QWidget *parent=0, const char *name = 0, Qt::WindowFlags f = 0);
- virtual ~ParameterDialog(void);
- public slots:
- void Reset(void);
+ private slots:
+ void write(void);
- private slots:
- void write(void);
-
- private:
+ private:
QLineEdit *arrowcolor_edit;
QLineEdit *arrowsize_edit;
QLineEdit *textcolor_edit;
@@ -142,7 +119,4 @@ class ParameterDialog : public QDialog {
QLineEdit *dir1_edit;
QLineEdit *dir2_edit;
};
-
#endif
-
-/* finis */
diff --git a/src/perl/ChangeLog b/src/perl/ChangeLog
new file mode 100644
--- /dev/null
+++ b/src/perl/ChangeLog
@@ -0,0 +1,6 @@
+2010-06-21
+
+ * make_pardialog_source.pl: Reformatted. If datadir is relative append it to the user's home directory.
+ * make_parameter_source.pl: Ditto.
+ * make_xmlwritecode.pl: Ditto.
+
diff --git a/src/perl/make_parameter_source.pl b/src/perl/make_parameter_source.pl
--- a/src/perl/make_parameter_source.pl
+++ b/src/perl/make_parameter_source.pl
@@ -103,293 +103,273 @@ print cppfile <
+#include
+#include
- using namespace std;
-
+using namespace std;
Parameter::Parameter() {
- END_HEADER
+END_HEADER
- for ($i=0;$i<$lines;$i++) {
- if ($convtype[$i] ne "label" && $convtype[$i] ne "title") {
- if ($convtype[$i] eq "char *") {
- print cppfile " $param[$i] = strdup($value[$i]);\n";
- } else {
- if ($convtype[$i] eq "double *") {
- #comma separated list expected
- @paramlist = split(/,/, $value[$i]);
- $length = $#paramlist+1;
- print cppfile " $param[$i] = new double\[$length\];\n";
- for ($j=0;$j<=$#paramlist;$j++) {
- print cppfile " $param[$i]\[$j\] = $paramlist[$j];\n";
- }
- } else {
- print cppfile " $param[$i] = $value[$i];\n";
- }
+for ($i=0;$i<$lines;$i++) {
+ if ($convtype[$i] ne "label" && $convtype[$i] ne "title") {
+ if ($convtype[$i] eq "char *") {
+ print cppfile " $param[$i] = strdup($value[$i]);\n";
+ } else {
+ if ($convtype[$i] eq "double *") {
+ #comma separated list expected
+ @paramlist = split(/,/, $value[$i]);
+ $length = $#paramlist+1;
+ print cppfile " $param[$i] = new double\[$length\];\n";
+ for ($j=0;$j<=$#paramlist;$j++) {
+ print cppfile " $param[$i]\[$j\] = $paramlist[$j];\n";
}
+ } else {
+ print cppfile " $param[$i] = $value[$i];\n";
}
+ }
}
+}
- print cppfile < valarray) {\n";
- print cppfile;
+print cppfile "void Parameter::AssignValArrayToPar(const char *namec, vector valarray) {\n";
+print cppfile;
- for ($i=0;$i<$lines;$i++) {
+for ($i=0;$i<$lines;$i++) {
- if ($convtype[$i] eq "double *") {
- @paramlist = split(/,/,$value[$i]);
- print cppfile "if (!strcmp(namec, \"$param[$i]\")) {\n";
- print cppfile " int i=0;\n";
- print cppfile " vector::const_iterator v=valarray.begin();\n";
- print cppfile " while (v!=valarray.end() && i <= $#paramlist ) {\n";
- print cppfile " $param[$i]\[i++\]=*(v++);\n";
- print cppfile " }\n";
- print cppfile "}\n";
- }
- }
+ if ($convtype[$i] eq "double *") {
+ @paramlist = split(/,/,$value[$i]);
+ print cppfile "if (!strcmp(namec, \"$param[$i]\")) {\n";
+ print cppfile " int i=0;\n";
+ print cppfile " vector::const_iterator v=valarray.begin();\n";
+ print cppfile " while (v!=valarray.end() && i <= $#paramlist ) {\n";
+ print cppfile " $param[$i]\[i++\]=*(v++);\n";
+ print cppfile " }\n";
print cppfile "}\n";
-
-
- print cppfile <xmlChildrenNode;
- while (cur!=NULL) {
- if ((!xmlStrcmp(cur->name, (const xmlChar *)"parameter"))){
- xmlNode *par_node = cur->xmlChildrenNode;
- while (par_node!=NULL) {
- {
- if (!xmlStrcmp(par_node->name, (const xmlChar *)"par")) {
- xmlChar *namec = xmlGetProp(par_node, BAD_CAST "name");
- xmlChar *valc = xmlGetProp(par_node, BAD_CAST "val");
- if (valc) {
- AssignValToPar((const char*)namec,(const char*)valc);
- } else {
- // Probably a valarray
- xmlNode *sub_par_node = par_node->xmlChildrenNode;
- vector valarray;
- while (sub_par_node != NULL) {
- if (!xmlStrcmp(sub_par_node->name, (const xmlChar *)"valarray")) {
- valarray = XMLIO::XMLReadValArray(sub_par_node);
- }
- sub_par_node = sub_par_node->next;
- }
- AssignValArrayToPar((const char*)namec, valarray);
- }
- }
- }
- par_node = par_node->next;
- }
+print cppfile <next;
- }
-
- }*/
+print cppfile "}\n";
+
+print cppfile <parameter.h";
- print hfile <parameter.h";
+print hfile <
#include
- class Parameter {
+ class Parameter {
- public:
- Parameter();
- ~Parameter();
- void CleanUp(void);
- void Read(const char *filename);
- void Write(ostream &os) const;
- void XMLAdd(xmlNode *root) const;
- void XMLRead(xmlNode *root);
- void AssignValToPar(const char *namec, const char *valc);
- void AssignValArrayToPar(const char *namec, vector valarray);
- END_HEADER2
+ public:
+ Parameter();
+ ~Parameter();
+ void CleanUp(void);
+ void Read(const char *filename);
+ void Write(ostream &os) const;
+ void XMLAdd(xmlNode *root) const;
+ void XMLRead(xmlNode *root);
+ void AssignValToPar(const char *namec, const char *valc);
+ void AssignValArrayToPar(const char *namec, vector valarray);
+END_HEADER2
- for ($i=0;$i<$lines;$i++) {
- if ($convtype[$i] ne "label" && $convtype[$i] ne "title") {
- print hfile " $convtype[$i] $param[$i];\n";
- }
- }
+ for ($i=0;$i<$lines;$i++) {
+ if ($convtype[$i] ne "label" && $convtype[$i] ne "title") {
+ print hfile " $convtype[$i] $param[$i];\n";
+ }
+ }
- print hfile <default.par";
+open parfile,">default.par";
- for ($i=0;$i<$lines;$i++) {
- if ($type[$i] ne "title" && $type[$i] ne "label") {
- $value[$i] =~ s/\"//g;
- print parfile " $param[$i] = $value[$i]\n";
- }
- }
+for ($i=0;$i<$lines;$i++) {
+ if ($type[$i] ne "title" && $type[$i] ne "label") {
+ $value[$i] =~ s/\"//g;
+ print parfile " $param[$i] = $value[$i]\n";
+ }
+}
# finis
diff --git a/src/perl/make_pardialog_source.pl b/src/perl/make_pardialog_source.pl
--- a/src/perl/make_pardialog_source.pl
+++ b/src/perl/make_pardialog_source.pl
@@ -98,140 +98,139 @@ print cppfile <addWidget( new QLabel( \"$value[$i]\", this), $row, $col, 1, 2 );\n";
+$numrows = 30;
+$c = 0;
+for ($i=0;$i<$lines;$i++) {
+ $col = 2*int($c/($numrows-3));
+ $row = $c % ($numrows-3) + $ntitles * 3;
+ if ($convtype[$i] eq "label") {
+ print cppfile " grid->addWidget( new QLabel( \"$value[$i]\", this), $row, $col, 1, 2 );\n";
+ $c++;
+ } else {
+ if ($convtype[$i] eq "title") {
+ if ($ntitles) {
+ print stderr "Sorry, only one title allowed. Aborting source construction...\n";
+ exit(1);
+ }
+ print cppfile " setWindowTitle( QString( \"$value[$i]\") );\n";
+ print cppfile " grid->addWidget( new QLabel( \"$value[$i]
\",this), $row, $col, 1, -1, Qt::AlignCenter);\n";
+ print cppfile " grid->addWidget( new QLabel( \"\", this), $row+1, $col, 1, -1);\n";
+ $ntitles++;
+ } else {
+ print cppfile " grid->addWidget( new QLabel( \"$param[$i]\", this ),$row, $col );\n";
+ print cppfile " grid->addWidget( $param[$i]_edit, $row, $col+1 );\n";
$c++;
- } else {
- if ($convtype[$i] eq "title") {
- if ($ntitles) {
- print stderr "Sorry, only one title allowed. Aborting source construction...\n";
- exit(1);
- }
- print cppfile " setWindowTitle( QString( \"$value[$i]\") );\n";
- print cppfile " grid->addWidget( new QLabel( \"$value[$i]
\",this), $row, $col, 1, -1, Qt::AlignCenter);\n";
- print cppfile " grid->addWidget( new QLabel( \"\", this), $row+1, $col, 1, -1);\n";
- $ntitles++;
- } else {
- print cppfile " grid->addWidget( new QLabel( \"$param[$i]\", this ),$row, $col );\n";
- print cppfile " grid->addWidget( $param[$i]_edit, $row, $col+1 );\n";
- $c++;
- }
}
}
+}
- $row = $numrows+1;
- $col = 2*int($i/$numrows);
+$row = $numrows+1;
+$col = 2*int($i/$numrows);
- print cppfile <addWidget(pb, $row, $col );
- connect( pb, SIGNAL( clicked() ), this, SLOT( write() ) );
- QPushButton *pb2 = new QPushButton( \"&Close\", this );
- grid->addWidget(pb2,$row, $col+1 );
- connect( pb2, SIGNAL( clicked() ), this, SLOT( close() ) );
- QPushButton *pb3 = new QPushButton( \"&Reset\", this );
- grid->addWidget(pb3, $row, $col+2 );
- connect( pb3, SIGNAL( clicked() ), this, SLOT( Reset() ) );
- show();
+print cppfile <addWidget(pb, $row, $col );
+connect( pb, SIGNAL( clicked() ), this, SLOT( write() ) );
+QPushButton *pb2 = new QPushButton( \"&Close\", this );
+grid->addWidget(pb2,$row, $col+1 );
+connect( pb2, SIGNAL( clicked() ), this, SLOT( close() ) );
+QPushButton *pb3 = new QPushButton( \"&Reset\", this );
+grid->addWidget(pb3, $row, $col+2 );
+connect( pb3, SIGNAL( clicked() ), this, SLOT( Reset() ) );
+show();
};
ParameterDialog::~ParameterDialog(void) {
- ANOTHER_LABEL
+ANOTHER_LABEL
- for ($i=0;$i<$lines;$i++) {
- if ($convtype[$i] ne "label" && $convtype[$i] ne "title") {
- print cppfile "delete $param[$i]_edit;\n";
- }
+for ($i=0;$i<$lines;$i++) {
+ if ($convtype[$i] ne "label" && $convtype[$i] ne "title") {
+ print cppfile "delete $param[$i]_edit;\n";
}
-
- print cppfile <text().section(',', $j, $j);\n";
+ print cppfile " par.$param[$i]\[$j\] = tmpval.toDouble();\n";
}
- if ($convtype[$i] eq "double *") {
- @paramlist = split(/,/,$value[$i]);
- for ($j=0;$j<=$#paramlist;$j++) {
- print cppfile " tmpval = $param[$i]_edit->text().section(',', $j, $j);\n";
- print cppfile " par.$param[$i]\[$j\] = tmpval.toDouble();\n";
- }
+ } else {
+ if ($convtype[$i] eq "bool") {
+ print cppfile " tmpval = $param[$i]_edit->text().stripWhiteSpace();\n";
+ print cppfile " if (tmpval == \"true\" || tmpval == \"yes\" ) par.$param[$i] = true;\n";
+ print cppfile " else if (tmpval == \"false\" || tmpval == \"no\") par.$param[$i] = false;\n";
+ print cppfile " else {\n";
+ print cppfile " if (QMessageBox::question(this, \"Syntax error\", tr(\"Value %1 of parameter %2 is not recognized as Boolean.\\nDo you mean TRUE or FALSE?\").arg(tmpval).arg(\"$param[$i]\"),\"True\",\"False\", QString::null, 0, 1)==0) par.$param[$i]=true;\n";
+ print cppfile " else par.$param[$i]=false;\n";
+ print cppfile " }\n";
} else {
- if ($convtype[$i] eq "bool") {
- print cppfile " tmpval = $param[$i]_edit->text().stripWhiteSpace();\n";
- print cppfile " if (tmpval == \"true\" || tmpval == \"yes\" ) par.$param[$i] = true;\n";
- print cppfile " else if (tmpval == \"false\" || tmpval == \"no\") par.$param[$i] = false;\n";
- print cppfile " else {\n";
- print cppfile " if (QMessageBox::question(this, \"Syntax error\", tr(\"Value %1 of parameter %2 is not recognized as Boolean.\\nDo you mean TRUE or FALSE?\").arg(tmpval).arg(\"$param[$i]\"),\"True\",\"False\", QString::null, 0, 1)==0) par.$param[$i]=true;\n";
- print cppfile " else par.$param[$i]=false;\n";
- print cppfile " }\n";
+ if ($convtype[$i] eq "char *") {
+ print cppfile " par.$param[$i] = strdup((const char *)$param[$i]_edit->text());\n";
} else {
- if ($convtype[$i] eq "char *") {
- print cppfile " par.$param[$i] = strdup((const char *)$param[$i]_edit->text());\n";
- } else {
- print cppfile " par.$param[$i] = $param[$i]_edit->text().$funname{$convtype[$i]}();\n";
- }
+ print cppfile " par.$param[$i] = $param[$i]_edit->text().$funname{$convtype[$i]}();\n";
}
}
- }
+ }
+}
- print cppfile <) {
- chomp;
- s/\\/\\\\/g;
- s/\"/\\\"/g;
- s/\&/\&/g;
- $str.=$_."\\n";
- }
- $str .= "\";\n";
- return $str;
- }
+ open srcfile, "<$fname";
+ while () {
+ chomp;
+ s/\\/\\\\/g;
+ s/\"/\\\"/g;
+ s/\&/\&/g;
+ $str.=$_."\\n";
+ }
+ $str .= "\";\n";
+ return $str;
+}
- print xmlsrc "xmlChar *sourcecode = (xmlChar *)\"".construct_string_constant_from_file( "$mainsource" );
- print xmlsrc <