Skip to content
Permalink
Browse files

Merge pull request #144 from hackerde/window

Implement Load New Data Feature
  • Loading branch information...
mlesnick committed Jun 19, 2019
2 parents 821493d + 62bfafe commit 51356c687828fddbb05e8669c09dc7dbead957d9
@@ -66,8 +66,10 @@ void DataSelectDialog::closeEvent(QCloseEvent* event)
{
event->accept();

if (!data_selected)
if (!data_selected) {
qobject_cast<QWidget*>(this->parent())->close();
exit(0);
}
}

void DataSelectDialog::on_computeButton_clicked()
@@ -34,7 +34,7 @@ extern "C" RivetComputationResult read_rivet_computation(const char* bytes, size
extern "C" void free_rivet_computation_result(RivetComputationResult result)
{
if (result.computation != nullptr) {
delete reinterpret_cast<ComputationResult *>(result.computation);
delete reinterpret_cast<ComputationResult*>(result.computation);
} else {
delete[] result.error;
}
@@ -67,7 +67,7 @@ extern "C" BarCodesResult barcodes_from_computation(RivetComputation* rivet_comp
barcodes[i].angle = angles[i];
barcodes[i].offset = offsets[i];
}
// Bounds bounds = compute_bounds(*computation);
// Bounds bounds = compute_bounds(*computation);
result.barcodes = barcodes;
result.length = query_results.size();
result.error = nullptr;
@@ -108,8 +108,7 @@ extern "C" void free_barcodes_result(BarCodesResult result)
}
}


extern "C" StructurePoints * structure_from_computation(RivetComputation* rivet_computation)
extern "C" StructurePoints* structure_from_computation(RivetComputation* rivet_computation)
{
ComputationResult* computation = reinterpret_cast<ComputationResult*>(rivet_computation);
auto x_exact = new Ratio[computation->arrangement->x_exact.size()];
@@ -146,7 +145,8 @@ extern "C" StructurePoints * structure_from_computation(RivetComputation* rivet_
return result;
}

void free_structure_points(StructurePoints *points) {
void free_structure_points(StructurePoints* points)
{
delete[] points->grades->x_grades;
delete[] points->grades->y_grades;
delete points->grades;
@@ -40,7 +40,7 @@ typedef struct {
typedef struct {
BarCode* barcodes;
size_t length;
char * error;
char* error;
size_t error_length;
} BarCodesResult;

@@ -80,9 +80,9 @@ typedef struct {
} Ratio;

typedef struct {
Ratio *x_grades;
Ratio* x_grades;
size_t x_length;
Ratio *y_grades;
Ratio* y_grades;
size_t y_length;
} ExactGrades;

@@ -95,15 +95,14 @@ typedef struct {
} StructurePoint;

typedef struct {
ExactGrades *grades;
StructurePoint *points;
ExactGrades* grades;
StructurePoint* points;
size_t length;
} StructurePoints;

StructurePoints * structure_from_computation(RivetComputation* rivet_computation);

void free_structure_points(StructurePoints *points);
StructurePoints* structure_from_computation(RivetComputation* rivet_computation);

void free_structure_points(StructurePoints* points);
}

#endif //RIVET_CONSOLE_C_API_H
@@ -119,6 +119,12 @@ ConfigureDialog::~ConfigureDialog()
delete ui;
}

void ConfigureDialog::closeEvent(QCloseEvent* event)
{
emit window_closed(); // tells visualization window to check for changes and redraw
QDialog::closeEvent(event);
}

void ConfigureDialog::on_cancelButton_clicked()
{
close();
@@ -41,6 +41,10 @@ class ConfigureDialog : public QDialog {
public:
explicit ConfigureDialog(ConfigParameters& c_params, InputParameters& i_params, QWidget* parent = 0);
~ConfigureDialog();
void closeEvent(QCloseEvent* event);

signals:
void window_closed();

private slots:
void on_cancelButton_clicked();
@@ -56,11 +56,9 @@ void ControlDot::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*unus
QRectF rect = boundingRect();
QBrush brush(config_params->sliceLineColor);

if(!slice_line->is_inside_view())
{
if (!slice_line->is_inside_view()) {
brush.setColor(Qt::gray);
}
else if (pressed) {
} else if (pressed) {
brush.setColor(config_params->sliceLineHighlightColor);
}

@@ -74,8 +72,7 @@ QVariant ControlDot::itemChange(GraphicsItemChange change, const QVariant& value
{
if (change == QGraphicsItem::ItemPositionChange && !update_lock) {


if(!slice_line->is_inside_view()){
if (!slice_line->is_inside_view()) {
//then don't allow the user to drag the dot
return pos();
}
@@ -165,7 +162,7 @@ void ControlDot::set_position(const QPointF& newpos)

void ControlDot::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
if(!slice_line->is_inside_view()){
if (!slice_line->is_inside_view()) {
return;
}
pressed = true;
@@ -177,7 +174,7 @@ void ControlDot::mousePressEvent(QGraphicsSceneMouseEvent* event)

void ControlDot::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
if(!slice_line->is_inside_view()){
if (!slice_line->is_inside_view()) {
return;
}
pressed = false;
@@ -48,6 +48,16 @@ PersistenceDiagram::PersistenceDiagram(ConfigParameters* params, QObject* parent
setItemIndexMethod(NoIndex); //not sure why, but this seems to fix the dot update issue (#7 in the issue tracker)
}

// resets data structures and variables to draw new diagram
void PersistenceDiagram::reset()
{
clear();
all_dots.clear();
dots_by_bc_index.clear();
selected = NULL;
barcode = new Barcode();
}

//simply creates all objects; resize_diagram() handles positioning of objects
void PersistenceDiagram::create_diagram()
{
@@ -541,7 +551,7 @@ void PersistenceDiagram::update_diagram(double slice_length_pix, double diagram_
if (is_visible) {
line_size = slice_length_pix / sqrt(2); //divide by sqrt(2) because the line is drawn at a 45-degree angle
} else {
line_size=0;
line_size = 0;
}
dist_to_origin = slice_dist_dat;
scale = diagram_scale / sqrt(2); //similarly to line_size, divide by sqrt(2)
@@ -52,6 +52,7 @@ class PersistenceDiagram : public QGraphicsScene {
void deselect_dot(); //remove selection and propagate to the slice diagram

void receive_parameter_change(); //updates the diagram after a change in the configuration parameters
void reset(); // clears up data structures and variable values

public slots:
void receive_dot_selection(unsigned index); //highlight the specified dot, which has been selected externally
@@ -85,8 +85,7 @@ void ProgressDialog::updateProgress(unsigned current)
void ProgressDialog::setComputationFinished()
{
computation_finished = true;
QThread::msleep(200); //seems to prevent ProgressDialog from sticking around after it is supposed to have been closed
done(0);
close();
}

void ProgressDialog::closeEvent(QCloseEvent* event)
@@ -58,6 +58,27 @@ SliceDiagram::~SliceDiagram()
clear(); //removes and deletes all items from the QGraphicsScene
}

// resets data structures and variables to draw new diagram
void SliceDiagram::reset()
{
clear();
xi0_dots.clear();
xi1_dots.clear();
xi2_dots.clear();
bars.clear();
primary_selected.clear();
secondary_selected.clear();
points.clear();
hom_dim_rects.resize(boost::extents[0][0]);
dot_left = nullptr;
dot_right = nullptr;
slice_line = nullptr;
max_xi_value = 0;
line_visible = true;
created = false;
control_dot_moved = false;
}

//receives an xi support point, which will be drawn when create_diagram() is called
void SliceDiagram::add_point(double x_coord, double y_coord, int xi0m, int xi1m, int xi2m)
{
@@ -536,7 +557,7 @@ void SliceDiagram::zoom_diagram(double angle, double offset, double distance_to_
if (line_vert) {
double relative_intercept_horz = (-offset - data_xmin) / (data_xmax - data_xmin); //vertical line has negative offset
x = relative_intercept_horz * diagram_width;
line_visible = (0 <= relative_intercept_horz && relative_intercept_horz <= 1+float(padding)/diagram_width);
line_visible = (0 <= relative_intercept_horz && relative_intercept_horz <= 1 + float(padding) / diagram_width);
slice_line->update_position(x, y, line_vert, 0);
slice_line->set_visibility(line_visible); //don't plot the line if it lies outisde of the viewing window
line_pos = -1 * relative_intercept_horz;
@@ -550,12 +571,12 @@ void SliceDiagram::zoom_diagram(double angle, double offset, double distance_to_
double relative_intercept_horz = -data_xmin + (data_ymin - intrinsic_y_int) / (intrinsic_slope);
relative_intercept_horz /= data_xmax - data_xmin;
x = relative_intercept_horz * diagram_width;
line_visible = relative_intercept_horz < 1+float(padding)/diagram_width;
line_visible = relative_intercept_horz < 1 + float(padding) / diagram_width;
line_pos = -1 * relative_intercept_horz;
} else //then left-bottom endpoint is along left edge of box
{
y = relative_intercept_vert * diagram_height;
line_visible = relative_intercept_vert < 1+float(padding)/diagram_height;
line_visible = relative_intercept_vert < 1 + float(padding) / diagram_height;
line_pos = relative_intercept_vert;
}

@@ -689,7 +710,7 @@ void SliceDiagram::update_line(double angle, double offset, double distance_to_o
line_vert = true;
line_pos = offset / (data_xmax - data_xmin); //relative units

line_visible = (-1 <= line_pos && line_pos <= float(padding)/diagram_width); //vertical line has negative offset
line_visible = (-1 <= line_pos && line_pos <= float(padding) / diagram_width); //vertical line has negative offset

//update the SliceLine

@@ -703,7 +724,7 @@ void SliceDiagram::update_line(double angle, double offset, double distance_to_o
line_vert = false;
line_slope = 0;
line_pos = offset / (data_ymax - data_ymin); //relative units
line_visible = (0 <= line_pos && line_pos <= 1+float(padding)/diagram_height);
line_visible = (0 <= line_pos && line_pos <= 1 + float(padding) / diagram_height);

//update the SliceLine
int ypos = (offset - data_ymin) * scale_y; //pixel units
@@ -721,14 +742,14 @@ void SliceDiagram::update_line(double angle, double offset, double distance_to_o
if (y_coord >= data_ymin) //then slice line intersects left edge of box
{
line_pos = (y_coord - data_ymin) / (data_ymax - data_ymin); //relative units
line_visible = line_pos < 1+float(padding)/diagram_height;
line_visible = line_pos < 1 + float(padding) / diagram_height;
slice_line->update_position(0, (y_coord - data_ymin) * scale_y, false, line_slope * scale_y / scale_x);

} else //then slice line intersects bottom of box
{
double x_coord = (data_ymin - offset / cos(radians)) / line_slope; //x-coordinate of slice line at y=data_ymin; data units
line_pos = -1 * (x_coord - data_xmin) / (data_xmax - data_xmin); //relative units
line_visible = -1 -float(padding)/diagram_width< line_pos;
line_visible = -1 - float(padding) / diagram_width < line_pos;

slice_line->update_position((x_coord - data_xmin) * scale_x, 0, false, line_slope * scale_y / scale_x);
}
@@ -903,7 +924,7 @@ std::pair<double, double> SliceDiagram::compute_endpoint(double coordinate, unsi
if (coordinate == std::numeric_limits<double>::infinity() || coordinate * std::min(scale_x, scale_y) > pow(10.0, 7.0)) {
//set coordinate so that it will be outside the viewable window
//the finite cutoff seems to patch over the issue with phantom barcodes-not sure why
coordinate = dist_to_origin+view_length / std::min(scale_x, scale_y);
coordinate = dist_to_origin + view_length / std::min(scale_x, scale_y);
}

//find (x,y) along the line
@@ -105,6 +105,8 @@ class SliceDiagram : public QGraphicsScene {
int get_diagram_width() { return diagram_width; }; //the width of the above region corresponding to the displayed window bounds
int get_diagram_height() { return diagram_height; };

void reset(); // clears up data structures and variable values

public slots:
void receive_bar_selection(std::vector<unsigned> indexes); //highlight the specified class of bars, which has been selected externally
void receive_bar_secondary_selection(std::vector<unsigned> indexes); //secondary highlight, used for persistence dots that represent multiple classes of bars
@@ -67,10 +67,9 @@ void SliceLine::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*unuse
QPen pen(config_params->sliceLineColor);
pen.setWidth(config_params->sliceLineWidth);

if(!inside_view){
if (!inside_view) {
pen.setColor(Qt::gray);
}
else if (pressed) {
} else if (pressed) {
pen.setColor(config_params->sliceLineHighlightColor);
}

@@ -101,8 +100,7 @@ void SliceLine::paint(QPainter* painter, const QStyleOptionGraphicsItem* /*unuse
//left-click and drag to move line, maintaining the same slope
QVariant SliceLine::itemChange(GraphicsItemChange change, const QVariant& value)
{
if(!inside_view)
{//then don't allow the line to be moved
if (!inside_view) { //then don't allow the line to be moved
return QGraphicsItem::itemChange(change, value);
}
if (change == QGraphicsItem::ItemPositionChange && !update_lock) {
@@ -308,7 +306,7 @@ void SliceLine::update_position(double xpos, double ypos, bool vert, double pixe

void SliceLine::mousePressEvent(QGraphicsSceneMouseEvent* event)
{
if(!inside_view){
if (!inside_view) {
return;
}
if (event->button() == Qt::RightButton) {
@@ -325,7 +323,7 @@ void SliceLine::mousePressEvent(QGraphicsSceneMouseEvent* event)

void SliceLine::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
{
if(!inside_view){
if (!inside_view) {
return;
}
if (event->button() == Qt::RightButton) {
@@ -343,7 +341,7 @@ void SliceLine::mouseReleaseEvent(QGraphicsSceneMouseEvent* event)
//right-click and drag to change slope, left/bottom endpoint stays fixed
void SliceLine::mouseMoveEvent(QGraphicsSceneMouseEvent* event)
{
if(!inside_view){
if (!inside_view) {
return;
}
if (rotating) {
@@ -419,7 +417,5 @@ bool SliceLine::is_inside_view()

void SliceLine::set_visibility(bool visible)
{
inside_view=visible;


inside_view = visible;
}
@@ -63,6 +63,7 @@ class SliceLine : public QGraphicsItem {

void set_visibility(bool visible);
bool is_inside_view();

protected:
void mousePressEvent(QGraphicsSceneMouseEvent* event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent* event);
@@ -87,7 +88,7 @@ class SliceLine : public QGraphicsItem {
SliceDiagram* sdgm;
ConfigParameters* config_params;

bool inside_view=true;
bool inside_view = true;
void compute_right_point(); //sets correct position of right_point, given slope of line and position of left point
};

@@ -371,9 +371,9 @@ void Presentation::minimize(int verbosity)
//mark pivot_i for removal from row indices
new_row_indices[pivot_i] = -1;

//zero out the part of the row pivot_i to the right of i.
//The part of the row to the left is already zero.
#pragma omp parallel for
//zero out the part of the row pivot_i to the right of i.
//The part of the row to the left is already zero.
#pragma omp parallel for
for (unsigned j = i + 1; j < mat.width(); j++) {

if (mat.entry_sorted(pivot_i, j)) {

0 comments on commit 51356c6

Please sign in to comment.
You can’t perform that action at this time.