Permalink
Browse files

added diagram font to config_parameters and moved labels from the per…

…sistence diagram to the main window
  • Loading branch information...
mlwright84 committed Jun 2, 2017
1 parent c18e437 commit f2dd6caee73ca325a21d3ef58aff2823cd734f4c
@@ -22,24 +22,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
//default values are set here
ConfigParameters::ConfigParameters()
: xi0color(0, 255, 0, 100)
, //green semi-transparent, for xi_0 support dots
xi1color(255, 0, 0, 100)
, //red semi-transparent, for xi_1 support dots
xi2color(255, 255, 0, 100)
, //yellow semi-transparent, for xi_2 support dots
persistenceColor(160, 0, 200, 127)
, //purple semi-transparent, for persistence bars and dots
persistenceHighlightColor(255, 140, 0, 150)
, //orange semi-transparent, for highlighting part of the slice line
sliceLineColor(0, 0, 255, 150)
, //blue semi-transparent, for slice line
sliceLineHighlightColor(0, 200, 200, 150)
, //cyan semi-transparent, for highlighting the slice line on click-and-drag
bettiDotRadius(5)
, //radius of dot representing xi_0 = 1 or xi_1 = 1
persistenceDotRadius(5)
, //radius of dot representing one homology class in persistence diagram
autoDotSize(true) //automatic dot sizing is initially on
: xi0color(0, 255, 0, 100) //green semi-transparent, for xi_0 support dots
, xi1color(255, 0, 0, 100) //red semi-transparent, for xi_1 support dots
, xi2color(255, 255, 0, 100) //yellow semi-transparent, for xi_2 support dots
, persistenceColor(160, 0, 200, 127) //purple semi-transparent, for persistence bars and dots
, persistenceHighlightColor(255, 140, 0, 150) //orange semi-transparent, for highlighting part of the slice line
, sliceLineColor(0, 0, 255, 150) //blue semi-transparent, for slice line
, sliceLineHighlightColor(0, 200, 200, 150) //cyan semi-transparent, for highlighting the slice line on click-and-drag
, bettiDotRadius(5) //radius of dot representing xi_0 = 1 or xi_1 = 1
, persistenceDotRadius(5) //radius of dot representing one homology class in persistence diagram
, autoDotSize(true) //automatic dot sizing is initially on
, diagramFont() //system default font
{
diagramFont.setPointSize(14); // SET DEFAULT FONT SIZE HERE
}
@@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define CONFIG_PARAMETERS_H
#include <QColor>
#include <QFont>
//these parameters control the visualization and are (mostly) user-customizable through the Configure dialog box
struct ConfigParameters {
@@ -39,6 +40,9 @@ struct ConfigParameters {
int persistenceDotRadius;
bool autoDotSize;
//fonts
QFont diagramFont;
//constructor
ConfigParameters();
};
@@ -44,7 +44,7 @@ PersistenceDiagram::PersistenceDiagram(ConfigParameters* params, QObject* parent
}
//simply creates all objects; resize_diagram() handles positioning of objects
void PersistenceDiagram::create_diagram(const QString& filename, int dim)
void PersistenceDiagram::create_diagram()
{
//define pens and brushes
QPen grayPen(QBrush(Qt::darkGray), 2, Qt::DotLine, Qt::RoundCap, Qt::RoundJoin);
@@ -63,25 +63,21 @@ void PersistenceDiagram::create_diagram(const QString& filename, int dim)
//create text objects
inf_text = addSimpleText("inf");
inf_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
inf_text->setFont(config_params->diagramFont);
lt_inf_text = addSimpleText("<inf");
lt_inf_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
lt_inf_text->setFont(config_params->diagramFont);
inf_count_text = addSimpleText("0");
inf_count_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
inf_count_text->setBrush(purpleBrush);
inf_count_text->setFont(config_params->diagramFont);
lt_inf_count_text = addSimpleText("0");
lt_inf_count_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
lt_inf_count_text->setBrush(purpleBrush);
file_text = addSimpleText(filename);
file_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
std::ostringstream sdim;
sdim << "homology dimension: " << dim;
dim_text = addSimpleText(QString(sdim.str().data()));
dim_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
lt_inf_count_text->setFont(config_params->diagramFont);
} //end create_diagram()
//resizes diagram to fill the QGraphicsView; called after every window resize
@@ -140,9 +136,6 @@ void PersistenceDiagram::resize_diagram(double slice_length, double diagram_scal
inf_count_text->setPos(diagram_size + text_padding, inf_text_vpos);
lt_inf_count_text->setPos(diagram_size + text_padding, lt_inf_text_vpos);
file_text->setPos(diagram_size - file_text->boundingRect().width() - text_padding, file_text->boundingRect().height() + text_padding);
dim_text->setPos(diagram_size - dim_text->boundingRect().width() - text_padding, file_text->pos().y() + dim_text->boundingRect().height() + text_padding);
//set scene rectangle (necessary to prevent auto-scrolling)
double scene_rect_x = -lt_inf_text->boundingRect().width() - text_padding;
double scene_rect_y = 0;
@@ -37,7 +37,7 @@ class PersistenceDiagram : public QGraphicsScene {
public:
PersistenceDiagram(ConfigParameters* params, QObject* parent = 0);
void create_diagram(const QString& filename, int dim); //simply creates all objects; resize_diagram() handles positioning of objects
void create_diagram(); //simply creates all objects; resize_diagram() handles positioning of objects
void resize_diagram(double slice_length, double diagram_scale); //resizes diagram to fill the QGraphicsView; called after every window resize
void set_barcode(double zero, const Barcode& bc); //sets the barcode and the zero coordinate
@@ -102,30 +102,36 @@ void SliceDiagram::create_diagram(const QString x_text, const QString y_text, do
s_xmin << data_xmin;
data_xmin_text = addSimpleText(QString(s_xmin.str().data()));
data_xmin_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
data_xmin_text->setFont(config_params->diagramFont);
std::ostringstream s_xmax;
s_xmax.precision(4);
s_xmax << data_xmax;
data_xmax_text = addSimpleText(QString(s_xmax.str().data()));
data_xmax_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
data_xmax_text->setFont(config_params->diagramFont);
std::ostringstream s_ymin;
s_ymin.precision(4);
s_ymin << data_ymin;
data_ymin_text = addSimpleText(QString(s_ymin.str().data()));
data_ymin_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
data_ymin_text->setFont(config_params->diagramFont);
std::ostringstream s_ymax;
s_ymax.precision(4);
s_ymax << data_ymax;
data_ymax_text = addSimpleText(QString(s_ymax.str().data()));
data_ymax_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
data_ymax_text->setFont(config_params->diagramFont);
x_label = addSimpleText(x_text);
x_label->setFlag(QGraphicsItem::ItemIgnoresTransformations);
x_label->setFont(config_params->diagramFont);
y_label = addSimpleText(y_text);
y_label->setTransform(QTransform(0, 1, 1, 0, 0, 0));
y_label->setFont(config_params->diagramFont);
//create rectangles for visualizing homology dimensions
//first, find max dimension
View
@@ -116,6 +116,13 @@ void VisualizationWindow::start_computation()
//start the computation in a new thread
cthread.compute();
//update text items
auto shortName = QString::fromStdString(input_params.shortName);
this->setWindowTitle("RIVET - " + shortName);
ui->filenameLabel->setText( QStringLiteral("Input file: ").append(shortName) );
ui->homdimLabel->setText( QStringLiteral("Homology dimension: %1").arg(input_params.dim) );
} //end start_computation()
//this slot is signaled when the xi support points are ready to be drawn
@@ -169,12 +176,9 @@ void VisualizationWindow::augmented_arrangement_ready(std::shared_ptr<Arrangemen
//TESTING: print arrangement info and verify consistency
// arrangement->print_stats();
// arrangement->test_consistency();
auto shortName = QString::fromStdString(input_params.shortName);
this->setWindowTitle("RIVET - " + shortName);
//inialize persistence diagram
p_diagram.create_diagram(shortName, input_params.dim);
//create persistence diagram
p_diagram.create_diagram();
//get the barcode
BarcodeTemplate dbc = arrangement->get_barcode_template(angle_precise, offset_precise);
View
@@ -376,32 +376,32 @@
<widget class="QGraphicsView" name="pdView"/>
</item>
<item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_pd_controls">
<layout class="QVBoxLayout" name="verticalLayout_for_text">
<item>
<spacer name="horizontalSpacer_4">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QLabel" name="filenameLabel">
<property name="sizePolicy">
<sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<property name="text">
<string>Input file:</string>
</property>
</spacer>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item>
<item>
<spacer name="horizontalSpacer_5">
<property name="orientation">
<enum>Qt::Horizontal</enum>
<widget class="QLabel" name="homdimLabel">
<property name="text">
<string>Homology dimension:</string>
</property>
<property name="sizeHint" stdset="0">
<size>
<width>40</width>
<height>20</height>
</size>
<property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</spacer>
</widget>
</item>
</layout>
</item>

0 comments on commit f2dd6ca

Please sign in to comment.