Skip to content

Commit

Permalink
Merge branch 'feature-grm-custom-axes' into 'develop'
Browse files Browse the repository at this point in the history
added new structure which includes all axis changes made by the user so they...

See merge request Scientific-IT-Systems/gr!1313
  • Loading branch information
IngoMeyer441 committed Jul 18, 2024
2 parents bcc8387 + 3cbd4a3 commit 516ad3f
Show file tree
Hide file tree
Showing 8 changed files with 556 additions and 160 deletions.
1 change: 0 additions & 1 deletion lib/grm/grplot/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,6 @@ Valid keys are:
7. `phi_lim`, `r_lim`: defines which part of the specific polar axis should be displayed
8. `x_lim`, `y_lim`, `z_lim`: defines which part of the respective axis should be displayed
9. `x_range`, `y_range`, `z_range`: defines the range of the values on the respective axis
10. `x_tick_labels`, `y_tick_labels`: sets the custom labels for the x-, y-axis ticks
Values are seperated through commas (`,`), e.g. `3, 5`.
Expand Down
34 changes: 31 additions & 3 deletions lib/grm/grplot/grplot_widget.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ GRPlotWidget::GRPlotWidget(QMainWindow *parent, int argc, char **argv)

combo_box_attr = QStringList{
"algorithm",
"axis_type",
"colormap",
"font",
"font_precision",
Expand All @@ -121,6 +122,7 @@ GRPlotWidget::GRPlotWidget(QMainWindow *parent, int argc, char **argv)
"orientation",
"projection_type",
"resample_method",
"scientific_format",
"size_x_type",
"size_y_type",
"size_x_unit",
Expand All @@ -142,11 +144,15 @@ GRPlotWidget::GRPlotWidget(QMainWindow *parent, int argc, char **argv)
"adjust_z_lim",
"disable_x_trans",
"disable_y_trans",
"draw_grid",
"grplot",
"hide",
"is_major",
"is_mirrored",
"keep_aspect_ratio",
"keep_window",
"marginal_heatmap_side_plot",
"mirrored_axis",
"movable",
"only_quadratic_aspect_ratio",
"phi_flip",
Expand Down Expand Up @@ -519,6 +525,10 @@ void GRPlotWidget::attributeComboBoxHandler(const std::string &cur_attr_name, st
model_list.push_back(i.c_str());
}

QStringList axis_type_list{
"x",
"y",
};
QStringList orientation_list{
"vertical",
"horizontal",
Expand Down Expand Up @@ -570,12 +580,17 @@ void GRPlotWidget::attributeComboBoxHandler(const std::string &cur_attr_name, st
"low",
"high",
};
QStringList scientific_format_list{
"textex",
"mathtex",
};
QStringList tick_orientation_list{
"up",
"down",
};
QStringList side_region_location_list{"top", "right", "bottom", "left"};
static std::map<std::string, QStringList> attributeToList{
{"axis_type", axis_type_list},
{"size_x_unit", size_unit_list},
{"size_y_unit", size_unit_list},
{"colormap", colormap_list},
Expand All @@ -592,6 +607,7 @@ void GRPlotWidget::attributeComboBoxHandler(const std::string &cur_attr_name, st
{"plot_type", plot_type_list},
{"projection_type", projection_type_list},
{"resample_method", resample_method_list},
{"scientific_format", scientific_format_list},
{"size_x_type", size_type_list},
{"size_y_type", size_type_list},
{"style", style_list},
Expand Down Expand Up @@ -781,6 +797,11 @@ void GRPlotWidget::advancedAttributeComboBoxHandler(const std::string &cur_attr_
{
current_text = lineTypeIntToString(static_cast<int>(current_selection->get_ref()->getAttribute(cur_attr_name)));
}
else if (cur_attr_name == "scientific_format" && current_selection->get_ref()->getAttribute(cur_attr_name).isInt())
{
current_text =
scientificFormatIntToString(static_cast<int>(current_selection->get_ref()->getAttribute(cur_attr_name)));
}
else if (cur_attr_name == "tick_orientation" && current_selection->get_ref()->getAttribute(cur_attr_name).isInt())
{
current_text =
Expand Down Expand Up @@ -852,6 +873,10 @@ void GRPlotWidget::attributeSetForComboBox(const std::string &attr_type, std::sh
{
element->setAttribute(label, tickOrientationStringToInt(value));
}
else if (label == "scientific_format")
{
element->setAttribute(label, scientificFormatStringToInt(value));
}
else
{
element->setAttribute(label, std::stoi(value));
Expand Down Expand Up @@ -1212,7 +1237,10 @@ void GRPlotWidget::AttributeEditEvent()
amount_scrolled = 0;
tree_update = true;
clicked.clear();
std::cerr << GRM::toXML(grm_get_document_root()) << std::endl;
if (getenv("GRM_DEBUG"))
{
std::cerr << toXML(grm_get_document_root(), GRM::SerializerOptions{std::string(2, ' '), true}) << "\n";
}
reset_pixmap();
}
else
Expand Down Expand Up @@ -2520,7 +2548,7 @@ void GRPlotWidget::show_bounding_boxes_slot()

void GRPlotWidget::load_file_slot()
{
if (enable_editor)
if (getenv("GRDISPLAY") && strcmp(getenv("GRDISPLAY"), "edit") == 0)
{
#ifndef NO_LIBXML2
std::string path =
Expand Down Expand Up @@ -2552,7 +2580,7 @@ void GRPlotWidget::load_file_slot()

void GRPlotWidget::save_file_slot()
{
if (enable_editor)
if (getenv("GRDISPLAY") && strcmp(getenv("GRDISPLAY"), "edit") == 0)
{
if (grm_get_render() == nullptr)
{
Expand Down
14 changes: 6 additions & 8 deletions lib/grm/include/grm/dom_render/render.hxx
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ EXPORT int locationStringToInt(const std::string &location_str);
EXPORT int markerTypeStringToInt(const std::string &marker_type_str);
EXPORT int projectionTypeStringToInt(const std::string &projection_type_str);
EXPORT int modelStringToInt(const std::string &model_str);
EXPORT int scientificFormatStringToInt(const std::string &scientific_format_str);
EXPORT int textAlignHorizontalStringToInt(const std::string &text_align_horizontal_str);
EXPORT int textAlignVerticalStringToInt(const std::string &text_align_vertical_str);
EXPORT int textEncodingStringToInt(const std::string &text_encoding_str);
Expand All @@ -136,6 +137,7 @@ EXPORT std::string locationIntToString(int location);
EXPORT std::string markerTypeIntToString(int marker_type);
EXPORT std::string projectionTypeIntToString(int projection_type);
EXPORT std::string modelIntToString(int model);
EXPORT std::string scientificFormatIntToString(int scientific_format);
EXPORT std::string textAlignHorizontalIntToString(int text_align_horizontal);
EXPORT std::string textAlignVerticalIntToString(int text_align_vertical);
EXPORT std::string textEncodingIntToString(int text_encoding);
Expand Down Expand Up @@ -494,14 +496,6 @@ public:

void setSubplot(const std::shared_ptr<Element> &element, double xmin, double xmax, double ymin, double ymax);

void setXTickLabels(const std::shared_ptr<GRM::Element> &element, const std::string &key,
std::optional<std::vector<std::string>> x_tick_labels,
const std::shared_ptr<GRM::Context> &extContext = nullptr);

void setYTickLabels(const std::shared_ptr<GRM::Element> &element, const std::string &key,
std::optional<std::vector<std::string>> y_tick_labels,
const std::shared_ptr<GRM::Context> &extContext = nullptr);

void setOriginPosition(const std::shared_ptr<GRM::Element> &element, const std::string &x_org_pos,
const std::string &y_org_pos);

Expand All @@ -523,6 +517,10 @@ public:

static void getFigureSize(int *pixel_width, int *pixel_height, double *metric_width, double *metric_height);

std::map<int, std::map<double, std::map<std::string, GRM::Value>>> *getTickModificationMap();

int getAxisId();

void render(); // render doc and render context
void render(const std::shared_ptr<Context> &extContext); // render doc and external context
void render(const std::shared_ptr<Document> &document); // external doc and render context
Expand Down
59 changes: 32 additions & 27 deletions lib/grm/src/grm/dom_render/graphics_tree/schema.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,27 @@
</xs:complexType>
</xs:element>

<!-- definition of marginal_heatmap_plot -->
<xs:element name="marginal_heatmap_plot">
<xs:complexType>
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element ref="central_region" minOccurs="0" maxOccurs="1"/>
<xs:element ref="side_region" minOccurs="0" maxOccurs="4"/>
<xs:element ref="text" minOccurs="0" maxOccurs="1"/> <!-- title -->
</xs:choice>
<xs:attributeGroup ref="move_xform_ndc"/>
<xs:attributeGroup ref="ranges"/>
<xs:attribute name="algorithm" type="xs:string"/>
<xs:attribute name="kind" type="xs:string"/>
<xs:attribute name="marginal_heatmap_kind" type="xs:string" use="required"/>
<xs:attribute name="x" type="xs:string" use="required"/>
<xs:attribute name="x_ind" type="xs:integer"/>
<xs:attribute name="y" type="xs:string" use="required"/>
<xs:attribute name="y_ind" type="xs:integer"/>
<xs:attribute name="z" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>

<!-- definition of central_region -->
<xs:element name="central_region">
<xs:complexType>
Expand Down Expand Up @@ -360,7 +381,7 @@
<xs:attribute name="pos" type="xs:double"/>
<xs:attribute name="org" type="xs:double"/>
<xs:attribute name="scale" type="xs:integer"/>
<xs:attribute name="scientific_format" type="xs:integer"/>
<xs:attribute name="scientific_format" type="strint"/>
<xs:attribute name="tick" type="xs:double"/>
<xs:attribute name="tick_orientation" type="xs:integer"/>
<xs:attribute name="tick_size" type="xs:double"/>
Expand All @@ -382,9 +403,14 @@
</xs:choice>
<xs:attributeGroup ref="move_xform_ndc"/>
<xs:attribute name="is_major" type="xs:integer"/>
<xs:attribute name="line_color_ind" type="xs:integer"/>
<xs:attribute name="line_spec" type="xs:string"/>
<xs:attribute name="line_type" type="strint"/>
<xs:attribute name="line_width" type="xs:double"/>
<xs:attribute name="text_align_horizontal" type="strint"/>
<xs:attribute name="text_align_vertical" type="strint"/>
<xs:attribute name="tick_label" type="xs:string"/>
<xs:attribute name="tick_size" type="xs:double"/>
<xs:attribute name="value" type="xs:double"/>
<xs:attribute name="width" type="xs:double"/>
</xs:complexType>
Expand All @@ -394,10 +420,10 @@
<xs:element name="tick">
<xs:complexType>
<xs:attributeGroup ref="move_xform_wc"/>
<xs:attribute name="is_major" type="xs:integer"/>
<xs:attribute name="is_mirrored" type="xs:integer"/>
<xs:attribute name="value" type="xs:double"/>
<xs:attribute name="z_index" type="xs:integer"/>
<xs:attribute name="is_major" type="xs:integer"/>
<xs:attribute name="is_mirrored" type="xs:integer"/>
<xs:attribute name="value" type="xs:double"/>
<xs:attribute name="z_index" type="xs:integer"/>
</xs:complexType>
</xs:element>

Expand Down Expand Up @@ -437,7 +463,7 @@
<xs:attribute name="line_color_ind" type="xs:integer"/>
<xs:attribute name="line_width" type="xs:double"/>
<xs:attribute name="name" type="xs:string"/>
<xs:attribute name="scientific_format" type="xs:integer"/>
<xs:attribute name="scientific_format" type="strint"/>
<xs:attribute name="set_text_color_for_background" type="xs:integer"/>
<xs:attribute name="space" type="xs:integer"/>
<xs:attribute name="text" type="xs:string" use="required"/>
Expand Down Expand Up @@ -770,27 +796,6 @@
</xs:complexType>
</xs:element>

<!-- definition of marginal_heatmap_plot -->
<xs:element name="marginal_heatmap_plot">
<xs:complexType>
<xs:choice minOccurs="1" maxOccurs="unbounded">
<xs:element ref="central_region" minOccurs="0" maxOccurs="1"/>
<xs:element ref="side_region" minOccurs="0" maxOccurs="4"/>
<xs:element ref="text" minOccurs="0" maxOccurs="1"/> <!-- title -->
</xs:choice>
<xs:attributeGroup ref="move_xform_ndc"/>
<xs:attributeGroup ref="ranges"/>
<xs:attribute name="algorithm" type="xs:string"/>
<xs:attribute name="kind" type="xs:string"/>
<xs:attribute name="marginal_heatmap_kind" type="xs:string" use="required"/>
<xs:attribute name="x" type="xs:string" use="required"/>
<xs:attribute name="x_ind" type="xs:integer"/>
<xs:attribute name="y" type="xs:string" use="required"/>
<xs:attribute name="y_ind" type="xs:integer"/>
<xs:attribute name="z" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>

<!-- ||||||||||||||||||||||||||||| Plottypes |||||||||||||||||||||||||||||||||||||||| -->

<!-- definition of barplot -->
Expand Down
Loading

0 comments on commit 516ad3f

Please sign in to comment.