Skip to content

Commit

Permalink
Finished up adding the 3'|5' customized marker at the bottom of the d…
Browse files Browse the repository at this point in the history
…iagram window
  • Loading branch information
Maxie D. Schmidt committed Mar 2, 2019
1 parent 6e9b44c commit 109126e
Show file tree
Hide file tree
Showing 5 changed files with 361 additions and 51 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion scripts/BuildTargetInfo.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
#define FLTK_USE_CAIRO 1
#define FLTK_HAVE_CAIRO 1

#define RNASTRUCTVIZ_VSTRING ("RNAStructViz v1.3.8-production -- CT File Viewer and Structure Comparison Tool")
#define RNASTRUCTVIZ_VSTRING ("RNAStructViz v1.3.9-production -- CT File Viewer and Structure Comparison Tool")

#define GIT_COMMIT_HASH ("##__GIT_COMMITREV_HASHNUM__##")
#define GIT_COMMIT_HASH_SHORT ("##__GIT_COMMITREV_HASHNUM_SHORT__##")
Expand Down
94 changes: 45 additions & 49 deletions src/DiagramWindow.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@
#include "ConfigOptions.h"
#include "ConfigParser.h"

#include "pixmaps/DiagramWindowIcon.xbm"
#include "pixmaps/FivePrimeThreePrimeStrandEdgesMarker.c"

#include <FL/x.H>
Expand Down Expand Up @@ -94,15 +93,6 @@ DiagramWindow::DiagramWindow(int w, int h, const char *label,
m_redrawStructures(true), imageData(NULL), crSurface(NULL) {
copy_label(label);

//#ifndef __APPLE__
//fl_open_display();
//Pixmap iconPixmap = XCreateBitmapFromData(fl_display,
// DefaultRootWindow(fl_display),
// DiagramWindowIcon_bits, DiagramWindowIcon_width,
// DiagramWindowIcon_height);
//this->icon((const void *) iconPixmap);
//#endif

Construct(w + WINW_EXTENSION, h, structures);
}

Expand Down Expand Up @@ -191,20 +181,21 @@ void DiagramWindow::exportToPNGButtonPressHandler(Fl_Widget *, void *v) {
cairo_rectangle(crImageOutput, 0, 0, IMAGE_WIDTH, IMAGE_HEIGHT +
STRAND_MARKER_IMAGE_HEIGHT + PNG_FOOTER_HEIGHT);
cairo_fill(crImageOutput);
thisWindow->RedrawStrandEdgeMarker(crImageOutput);
// now draw the footer data:
thisWindow->SetCairoColor(crImageOutput, CR_SOLID_WHITE);
cairo_rectangle(crImageOutput, 0, IMAGE_HEIGHT,
IMAGE_WIDTH + STRAND_MARKER_IMAGE_HEIGHT, PNG_FOOTER_HEIGHT);
cairo_rectangle(crImageOutput, 0, IMAGE_HEIGHT + STRAND_MARKER_IMAGE_HEIGHT,
IMAGE_WIDTH, PNG_FOOTER_HEIGHT);
cairo_fill(crImageOutput);
thisWindow->SetCairoColor(crImageOutput, CR_SOLID_BLACK);
cairo_set_line_width(crImageOutput, 2);
cairo_move_to(crImageOutput, 0, IMAGE_HEIGHT);
cairo_move_to(crImageOutput, 0, IMAGE_HEIGHT + STRAND_MARKER_IMAGE_HEIGHT);
cairo_line_to(crImageOutput, IMAGE_WIDTH, IMAGE_HEIGHT + STRAND_MARKER_IMAGE_HEIGHT);
cairo_stroke(crImageOutput);
cairo_select_font_face(crImageOutput, "Courier New",
CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_BOLD);
cairo_set_font_size(crImageOutput, 12);
int offsetY = IMAGE_HEIGHT + 25;
int offsetY = IMAGE_HEIGHT + STRAND_MARKER_IMAGE_HEIGHT + 25;
for(int s = 0; s < 3; s++) {
char curStructLabel[MAX_BUFFER_SIZE];
int menuChoiceIdx = thisWindow->m_menus[s]->value();
Expand Down Expand Up @@ -340,12 +331,6 @@ bool DiagramWindow::computeDrawKeyParams(RNAStructure **sequences, int *numToDra
void DiagramWindow::Draw(Fl_Cairo_Window *thisCairoWindow, cairo_t *cr) {

DiagramWindow *thisWindow = (DiagramWindow *) thisCairoWindow;
//cairo_set_source_rgb(cr,
// GetRed(GUI_WINDOW_BGCOLOR) / 255.0f,
// GetGreen(GUI_WINDOW_BGCOLOR) / 255.0f,
// GetBlue(GUI_WINDOW_BGCOLOR) / 255.0f);
//cairo_rectangle(cr, 0, 0, thisWindow->w(), thisWindow->h());
//cairo_fill(cr);
thisWindow->drawWidgets(true);

Fl_Color priorColor = fl_color();
Expand Down Expand Up @@ -387,41 +372,13 @@ void DiagramWindow::Draw(Fl_Cairo_Window *thisCairoWindow, cairo_t *cr) {
thisWindow->SetCairoColor(thisWindow->crDraw, CR_BLACK);
cairo_stroke(thisWindow->crDraw);
thisWindow->m_redrawStructures = false;

// __Give the 5' | 3' distinction note below the diagram:__
// NOTE: to mark this distinction and avoid "ugly" artifacts
// around the curvature of the circle drawing with pure cairo,
// we have just constructed the raw bits for a custom
// image we have constructed to distinguish this marker.
// Here, we just load up these C-struct-style formatted bits
// (with transparency) and copy them over top of the image:
unsigned int markerImageWidth = FivePrimeThreePrimeEdgeMarker.width;
unsigned int markerImageHeight = FivePrimeThreePrimeEdgeMarker.height;
int markerImageStride = cairo_format_stride_for_width(
CAIRO_FORMAT_ARGB32,
markerImageWidth
);
cairo_surface_t *strandEdgeMarkerSurface = cairo_image_surface_create_for_data(
FivePrimeThreePrimeEdgeMarker.pixel_data,
CAIRO_FORMAT_ARGB32,
markerImageWidth,
markerImageHeight,
markerImageStride
);
unsigned int markerImageDrawX = 0; //IMAGE_WIDTH / 2 - (markerImageWidth - 15.0f)/ 2;
unsigned int markerImageDrawY = 0; //IMAGE_HEIGHT;
cairo_set_source_surface(thisWindow->crDraw, strandEdgeMarkerSurface,
markerImageDrawX + GLWIN_TRANSLATEX,
markerImageDrawY + GLWIN_TRANSLATEY);
cairo_rectangle(thisWindow->crDraw, 0, 0, markerImageWidth, markerImageHeight);
cairo_fill(thisWindow->crDraw);
cairo_surface_destroy(strandEdgeMarkerSurface); strandEdgeMarkerSurface = NULL;
}
cairo_set_source_surface(cr, cairo_get_target(thisWindow->crDraw),
GLWIN_TRANSLATEX, GLWIN_TRANSLATEY);
cairo_rectangle(cr, GLWIN_TRANSLATEX, GLWIN_TRANSLATEY,
IMAGE_WIDTH, IMAGE_HEIGHT);
cairo_fill(cr);
thisWindow->RedrawStrandEdgeMarker(cr);
thisWindow->RedrawCairoZoomBuffer(cr);

fl_color(priorColor);
Expand Down Expand Up @@ -1399,6 +1356,45 @@ void DiagramWindow::HandleUserZoomAction() {

}

void DiagramWindow::RedrawStrandEdgeMarker(cairo_t *curWinContext) {

if(curWinContext == NULL) {
return;
}
// __Give the 5' | 3' distinction note below the diagram:__
// NOTE: to mark this distinction and avoid "ugly" artifacts
// around the curvature of the circle drawing with pure cairo,
// we have just constructed the raw bits for a custom
// image we have constructed to distinguish this marker.
// Here, we just load up these C-struct-style formatted bits
// (with transparency) and copy them over top of the image:
unsigned int markerImageWidth = FivePrimeThreePrimeEdgeMarker.width;
unsigned int markerImageHeight = FivePrimeThreePrimeEdgeMarker.height;
int markerImageStride = cairo_format_stride_for_width(
CAIRO_FORMAT_ARGB32,
markerImageWidth
);
cairo_surface_t *strandEdgeMarkerSurface = cairo_image_surface_create_for_data(
FivePrimeThreePrimeEdgeMarker.pixel_data,
CAIRO_FORMAT_ARGB32,
markerImageWidth,
markerImageHeight,
markerImageStride
);
unsigned int markerImageDrawX = (IMAGE_WIDTH - markerImageWidth) / 2;
unsigned int markerImageDrawY = IMAGE_HEIGHT - 14.f;
cairo_reset_clip(curWinContext);
SetCairoColor(curWinContext, CR_TRANSPARENT);
cairo_set_source_surface(curWinContext, strandEdgeMarkerSurface,
GLWIN_TRANSLATEX + markerImageDrawX,
GLWIN_TRANSLATEY + markerImageDrawY);
cairo_paint_with_alpha(curWinContext, 0.67f);
cairo_surface_flush(strandEdgeMarkerSurface);
cairo_surface_flush(cairo_get_target(curWinContext));
cairo_surface_destroy(strandEdgeMarkerSurface); strandEdgeMarkerSurface = NULL;

}

void DiagramWindow::WarnUserDrawingConflict() {
if (!userConflictAlerted && m_drawBranchesIndicator->value()) {
fl_message_title("User Warning ... ");
Expand Down
4 changes: 3 additions & 1 deletion src/DiagramWindow.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#define PNG_FOOTER_HEIGHT (100)

#define GLWIN_TRANSLATEX (35)
#define GLWIN_TRANSLATEY (110)
#define GLWIN_TRANSLATEY (90)

#define WIDGET_SPACING (35)
#define EXPORT_BUTTON_WIDTH (115)
Expand Down Expand Up @@ -215,6 +215,8 @@ class DiagramWindow : public Fl_Cairo_Window
void RedrawCairoZoomBuffer(cairo_t *curWinContext);
void HandleUserZoomAction();

void RedrawStrandEdgeMarker(cairo_t *curWinContext);

void WarnUserDrawingConflict();
void CairoSetRGB(cairo_t *cr, unsigned short R, unsigned short G,
unsigned short B, unsigned short A = 0x99);
Expand Down
Loading

0 comments on commit 109126e

Please sign in to comment.