Skip to content

Commit

Permalink
added diagram font to config_parameters and moved labels from the per…
Browse files Browse the repository at this point in the history
…sistence diagram to the main window
  • Loading branch information
mlwright84 committed Jun 6, 2017
1 parent c18e437 commit f2dd6ca
Show file tree
Hide file tree
Showing 7 changed files with 56 additions and 56 deletions.
31 changes: 12 additions & 19 deletions interface/config_parameters.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,24 +22,17 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.


//default values are set here //default values are set here
ConfigParameters::ConfigParameters() ConfigParameters::ConfigParameters()
: xi0color(0, 255, 0, 100) : xi0color(0, 255, 0, 100) //green semi-transparent, for xi_0 support dots
, //green semi-transparent, for xi_0 support dots , xi1color(255, 0, 0, 100) //red semi-transparent, for xi_1 support dots
xi1color(255, 0, 0, 100) , xi2color(255, 255, 0, 100) //yellow semi-transparent, for xi_2 support dots
, //red semi-transparent, for xi_1 support dots , persistenceColor(160, 0, 200, 127) //purple semi-transparent, for persistence bars and dots
xi2color(255, 255, 0, 100) , persistenceHighlightColor(255, 140, 0, 150) //orange semi-transparent, for highlighting part of the slice line
, //yellow semi-transparent, for xi_2 support dots , sliceLineColor(0, 0, 255, 150) //blue semi-transparent, for slice line
persistenceColor(160, 0, 200, 127) , sliceLineHighlightColor(0, 200, 200, 150) //cyan semi-transparent, for highlighting the slice line on click-and-drag
, //purple semi-transparent, for persistence bars and dots , bettiDotRadius(5) //radius of dot representing xi_0 = 1 or xi_1 = 1
persistenceHighlightColor(255, 140, 0, 150) , persistenceDotRadius(5) //radius of dot representing one homology class in persistence diagram
, //orange semi-transparent, for highlighting part of the slice line , autoDotSize(true) //automatic dot sizing is initially on
sliceLineColor(0, 0, 255, 150) , diagramFont() //system default font
, //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.setPointSize(14); // SET DEFAULT FONT SIZE HERE
} }
4 changes: 4 additions & 0 deletions interface/config_parameters.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#define CONFIG_PARAMETERS_H #define CONFIG_PARAMETERS_H


#include <QColor> #include <QColor>
#include <QFont>


//these parameters control the visualization and are (mostly) user-customizable through the Configure dialog box //these parameters control the visualization and are (mostly) user-customizable through the Configure dialog box
struct ConfigParameters { struct ConfigParameters {
Expand All @@ -39,6 +40,9 @@ struct ConfigParameters {
int persistenceDotRadius; int persistenceDotRadius;
bool autoDotSize; bool autoDotSize;


//fonts
QFont diagramFont;

//constructor //constructor
ConfigParameters(); ConfigParameters();
}; };
Expand Down
17 changes: 5 additions & 12 deletions interface/persistence_diagram.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ PersistenceDiagram::PersistenceDiagram(ConfigParameters* params, QObject* parent
} }


//simply creates all objects; resize_diagram() handles positioning of objects //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 //define pens and brushes
QPen grayPen(QBrush(Qt::darkGray), 2, Qt::DotLine, Qt::RoundCap, Qt::RoundJoin); QPen grayPen(QBrush(Qt::darkGray), 2, Qt::DotLine, Qt::RoundCap, Qt::RoundJoin);
Expand All @@ -63,25 +63,21 @@ void PersistenceDiagram::create_diagram(const QString& filename, int dim)
//create text objects //create text objects
inf_text = addSimpleText("inf"); inf_text = addSimpleText("inf");
inf_text->setFlag(QGraphicsItem::ItemIgnoresTransformations); inf_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
inf_text->setFont(config_params->diagramFont);


lt_inf_text = addSimpleText("<inf"); lt_inf_text = addSimpleText("<inf");
lt_inf_text->setFlag(QGraphicsItem::ItemIgnoresTransformations); lt_inf_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
lt_inf_text->setFont(config_params->diagramFont);


inf_count_text = addSimpleText("0"); inf_count_text = addSimpleText("0");
inf_count_text->setFlag(QGraphicsItem::ItemIgnoresTransformations); inf_count_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
inf_count_text->setBrush(purpleBrush); inf_count_text->setBrush(purpleBrush);
inf_count_text->setFont(config_params->diagramFont);


lt_inf_count_text = addSimpleText("0"); lt_inf_count_text = addSimpleText("0");
lt_inf_count_text->setFlag(QGraphicsItem::ItemIgnoresTransformations); lt_inf_count_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
lt_inf_count_text->setBrush(purpleBrush); lt_inf_count_text->setBrush(purpleBrush);

lt_inf_count_text->setFont(config_params->diagramFont);
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);
} //end create_diagram() } //end create_diagram()


//resizes diagram to fill the QGraphicsView; called after every window resize //resizes diagram to fill the QGraphicsView; called after every window resize
Expand Down Expand Up @@ -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); inf_count_text->setPos(diagram_size + text_padding, inf_text_vpos);
lt_inf_count_text->setPos(diagram_size + text_padding, lt_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) //set scene rectangle (necessary to prevent auto-scrolling)
double scene_rect_x = -lt_inf_text->boundingRect().width() - text_padding; double scene_rect_x = -lt_inf_text->boundingRect().width() - text_padding;
double scene_rect_y = 0; double scene_rect_y = 0;
Expand Down
2 changes: 1 addition & 1 deletion interface/persistence_diagram.h
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ class PersistenceDiagram : public QGraphicsScene {
public: public:
PersistenceDiagram(ConfigParameters* params, QObject* parent = 0); 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 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 void set_barcode(double zero, const Barcode& bc); //sets the barcode and the zero coordinate
Expand Down
6 changes: 6 additions & 0 deletions interface/slice_diagram.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -102,30 +102,36 @@ void SliceDiagram::create_diagram(const QString x_text, const QString y_text, do
s_xmin << data_xmin; s_xmin << data_xmin;
data_xmin_text = addSimpleText(QString(s_xmin.str().data())); data_xmin_text = addSimpleText(QString(s_xmin.str().data()));
data_xmin_text->setFlag(QGraphicsItem::ItemIgnoresTransformations); data_xmin_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
data_xmin_text->setFont(config_params->diagramFont);


std::ostringstream s_xmax; std::ostringstream s_xmax;
s_xmax.precision(4); s_xmax.precision(4);
s_xmax << data_xmax; s_xmax << data_xmax;
data_xmax_text = addSimpleText(QString(s_xmax.str().data())); data_xmax_text = addSimpleText(QString(s_xmax.str().data()));
data_xmax_text->setFlag(QGraphicsItem::ItemIgnoresTransformations); data_xmax_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
data_xmax_text->setFont(config_params->diagramFont);


std::ostringstream s_ymin; std::ostringstream s_ymin;
s_ymin.precision(4); s_ymin.precision(4);
s_ymin << data_ymin; s_ymin << data_ymin;
data_ymin_text = addSimpleText(QString(s_ymin.str().data())); data_ymin_text = addSimpleText(QString(s_ymin.str().data()));
data_ymin_text->setFlag(QGraphicsItem::ItemIgnoresTransformations); data_ymin_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
data_ymin_text->setFont(config_params->diagramFont);


std::ostringstream s_ymax; std::ostringstream s_ymax;
s_ymax.precision(4); s_ymax.precision(4);
s_ymax << data_ymax; s_ymax << data_ymax;
data_ymax_text = addSimpleText(QString(s_ymax.str().data())); data_ymax_text = addSimpleText(QString(s_ymax.str().data()));
data_ymax_text->setFlag(QGraphicsItem::ItemIgnoresTransformations); data_ymax_text->setFlag(QGraphicsItem::ItemIgnoresTransformations);
data_ymax_text->setFont(config_params->diagramFont);


x_label = addSimpleText(x_text); x_label = addSimpleText(x_text);
x_label->setFlag(QGraphicsItem::ItemIgnoresTransformations); x_label->setFlag(QGraphicsItem::ItemIgnoresTransformations);
x_label->setFont(config_params->diagramFont);


y_label = addSimpleText(y_text); y_label = addSimpleText(y_text);
y_label->setTransform(QTransform(0, 1, 1, 0, 0, 0)); y_label->setTransform(QTransform(0, 1, 1, 0, 0, 0));
y_label->setFont(config_params->diagramFont);


//create rectangles for visualizing homology dimensions //create rectangles for visualizing homology dimensions
//first, find max dimension //first, find max dimension
Expand Down
14 changes: 9 additions & 5 deletions visualizationwindow.cpp
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -116,6 +116,13 @@ void VisualizationWindow::start_computation()
//start the computation in a new thread //start the computation in a new thread
cthread.compute(); 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() } //end start_computation()


//this slot is signaled when the xi support points are ready to be drawn //this slot is signaled when the xi support points are ready to be drawn
Expand Down Expand Up @@ -169,12 +176,9 @@ void VisualizationWindow::augmented_arrangement_ready(std::shared_ptr<Arrangemen
//TESTING: print arrangement info and verify consistency //TESTING: print arrangement info and verify consistency
// arrangement->print_stats(); // arrangement->print_stats();
// arrangement->test_consistency(); // arrangement->test_consistency();
auto shortName = QString::fromStdString(input_params.shortName);

this->setWindowTitle("RIVET - " + shortName);


//inialize persistence diagram //create persistence diagram
p_diagram.create_diagram(shortName, input_params.dim); p_diagram.create_diagram();


//get the barcode //get the barcode
BarcodeTemplate dbc = arrangement->get_barcode_template(angle_precise, offset_precise); BarcodeTemplate dbc = arrangement->get_barcode_template(angle_precise, offset_precise);
Expand Down
38 changes: 19 additions & 19 deletions visualizationwindow.ui
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -376,32 +376,32 @@
<widget class="QGraphicsView" name="pdView"/> <widget class="QGraphicsView" name="pdView"/>
</item> </item>
<item row="2" column="1"> <item row="2" column="1">
<layout class="QHBoxLayout" name="horizontalLayout_pd_controls"> <layout class="QVBoxLayout" name="verticalLayout_for_text">
<item> <item>
<spacer name="horizontalSpacer_4"> <widget class="QLabel" name="filenameLabel">
<property name="orientation"> <property name="sizePolicy">
<enum>Qt::Horizontal</enum> <sizepolicy hsizetype="Ignored" vsizetype="Preferred">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="text">
<size> <string>Input file:</string>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</spacer> <property name="alignment">
<set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
</property>
</widget>
</item> </item>
<item> <item>
<spacer name="horizontalSpacer_5"> <widget class="QLabel" name="homdimLabel">
<property name="orientation"> <property name="text">
<enum>Qt::Horizontal</enum> <string>Homology dimension:</string>
</property> </property>
<property name="sizeHint" stdset="0"> <property name="alignment">
<size> <set>Qt::AlignRight|Qt::AlignTrailing|Qt::AlignVCenter</set>
<width>40</width>
<height>20</height>
</size>
</property> </property>
</spacer> </widget>
</item> </item>
</layout> </layout>
</item> </item>
Expand Down

0 comments on commit f2dd6ca

Please sign in to comment.