Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -773,7 +773,7 @@ cisTEM_CPPFLAGS = $(WX_CPPFLAGS)
cisTEM_LDADD = libguicore.a libcore.a $(WX_LIBS) $(MKL_LIBS)
cisTEM_LIBTOOLFLAGS = $(LIBTOOL_FLAGS)

cisTEM_display_SOURCES = programs/cisTEM_display/cisTEM_display.cpp programs/cisTEM_display/display_gui.cpp gui/DisplayPanel.cpp gui/DisplayFrame.cpp
cisTEM_display_SOURCES = programs/cisTEM_display/cisTEM_display.cpp programs/cisTEM_display/display_gui.cpp gui/DisplayPanel.cpp gui/DisplayFrame.cpp programs/cisTEM_display/DisplayServer.cpp
cisTEM_display_CXXFLAGS = $(WX_CPPFLAGS)
cisTEM_display_CPPFLAGS = $(WX_CPPFLAGS)
cisTEM_display_LDADD = libguicore.a libcore.a $(WX_LIBS) $(MKL_LIBS)
Expand Down
405 changes: 405 additions & 0 deletions src/gui/DisplayFrame.cpp

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions src/gui/DisplayFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,22 @@ class DisplayFrame : public DisplayFrameParent {
//Additional functions
void DisableAllToolbarButtons( );
void EnableAllToolbarButtons( );
void OnServerOpenFile(wxCommandEvent& event);

// GUI event functions
void OnCharHook(wxKeyEvent& event);
void OnUpdateUI(wxUpdateUIEvent& event);

// File menu
void OnFileOpenClick(wxCommandEvent& event);
void OnSaveDisplayedImagesClick(wxCommandEvent& event);
void OnSaveDisplayedImagesWithLegendClick(wxCommandEvent& event);
void OnCloseTabClick(wxCommandEvent& event);
void OnExitClick(wxCommandEvent& event);

// Label menu
void OnLocationNumberClick(wxCommandEvent& event);
void OnLabelScaleBarClick(wxCommandEvent& event);

// Select menu
void OnImageSelectionModeClick(wxCommandEvent& event);
Expand All @@ -46,13 +50,16 @@ class DisplayFrame : public DisplayFrameParent {

// Help menu
void OnDocumentationClick(wxCommandEvent& event);
void OnDisplayControlsClick(wxCommandEvent& event);

private:
bool is_fullscreen;
wxString remember_path;
bool LoadCoords(wxString current_line, long& x, long& y, long& image_number);
bool LoadImageSelections(wxString current_line);
void ClearTextFileFromPanel( );
wxBitmap CropImageForSaving( );
void DrawScaleBarOnBitmap(wxBitmap& target_bitmap);
};

#endif
89 changes: 81 additions & 8 deletions src/gui/DisplayPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ void DisplayPanel::OnOpen(wxCommandEvent& WXUNUSED(event)) {
extension is included in this list, which is not robust against the various extensions that
could exist*/
OpenFile(path, this_filename);
ReturnCurrentPanel( )->short_image_filename = this_filename;
}
else
wxMessageBox(wxT("This file is not a compatible type; must be mrc file format."), wxT("Error"), wxOK | wxICON_INFORMATION);
Expand Down Expand Up @@ -855,6 +854,8 @@ void DisplayPanel::OpenFile(wxString wanted_filename, wxString wanted_tab_title,
return;
}

my_panel->short_image_filename = wanted_tab_title;

// which images are we including..

if ( wanted_included_image_numbers == NULL ) {
Expand Down Expand Up @@ -1432,6 +1433,7 @@ DisplayNotebookPanel::DisplayNotebookPanel(wxWindow* parent, wxWindowID id, cons
use_7bit_greys = false;
show_selection_distances = false;
resolution_instead_of_radius = false;
draw_scale_bar = false;

blue_selection_square_location = -1;

Expand Down Expand Up @@ -1570,14 +1572,16 @@ void DisplayNotebookPanel::UpdateImageStatusInfo(int x_pos, int y_pos) {

StatusText += wxT(", Value=") + wxString::Format(wxT("%f"), raw_pixel_value);

//if (selected_distance != 0 && show_selection_distances ) StatusText += wxT(", Dist=") + wxString::Format(wxT("%f"), selected_distance);
if ( selected_distance != 0 && show_selection_distances )
StatusText += wxT(", Dist=") + wxString::Format(wxT("%f"), selected_distance);
//if (image_picking_mode_enabled == INTEGRATE_PICK && integrate_box_x_pos != -1 && integrate_box_y_pos != -1) StatusText += wxT(", Integrated Value =") + wxString::Format(wxT("%f"), integrated_value);
parent_display_panel->StatusText->SetLabel(StatusText);
}
else {
wxString StatusText = wxT("");

//if (selected_distance != 0 && show_selection_distances ) StatusText += wxT("Dist=") + wxString::Format(wxT("%f"), selected_distance);
if ( selected_distance != 0 && show_selection_distances )
StatusText += wxT("Dist=") + wxString::Format(wxT("%f"), selected_distance);
// if (image_picking_mode_enabled == INTEGRATE_PICK && integrate_box_x_pos != -1 && integrate_box_y_pos != -1) StatusText += wxT("Integrated Value =") + wxString::Format(wxT("%f"), integrated_value);
parent_display_panel->StatusText->SetLabel(StatusText);
}
Expand Down Expand Up @@ -1614,22 +1618,25 @@ void DisplayNotebookPanel::UpdateImageStatusInfo(int x_pos, int y_pos) {

StatusText += wxT(", Value=") + wxString::Format(wxT("%f"), raw_pixel_value);

// if (selected_distance != 0 && show_selection_distances ) StatusText += wxT(", Dist=") + wxString::Format(wxT("%f"), selected_distance);
if ( selected_distance != 0 && show_selection_distances )
StatusText += wxT(", Dist=") + wxString::Format(wxT("%f"), selected_distance);
// if (image_picking_mode_enabled == INTEGRATE_PICK && integrate_box_x_pos != -1 && integrate_box_y_pos != -1) StatusText += wxT(", Integrated Value =") + wxString::Format(wxT("%f"), integrated_value);
parent_display_panel->StatusText->SetLabel(StatusText);
}
else {
wxString StatusText = wxT("");

// if (selected_distance != 0 && show_selection_distances ) StatusText += wxT("Dist=") + wxString::Format(wxT("%f"), selected_distance);
if ( selected_distance != 0 && show_selection_distances )
StatusText += wxT("Dist=") + wxString::Format(wxT("%f"), selected_distance);
// if (image_picking_mode_enabled == INTEGRATE_PICK && integrate_box_x_pos != -1 && integrate_box_y_pos != -1) StatusText += wxT("Integrated Value =") + wxString::Format(wxT("%f"), integrated_value);
parent_display_panel->StatusText->SetLabel(StatusText);
}
}
else {
wxString StatusText = wxT("");

// if (selected_distance != 0 && show_selection_distances ) StatusText += wxT("Dist=") + wxString::Format(wxT("%f"), selected_distance);
if ( selected_distance != 0 && show_selection_distances )
StatusText += wxT("Dist=") + wxString::Format(wxT("%f"), selected_distance);
// if (image_picking_mode_enabled == INTEGRATE_PICK && integrate_box_x_pos != -1 && integrate_box_y_pos != -1) StatusText += wxT(" Integrated Value =") + wxString::Format(wxT("%f"), integrated_value);
parent_display_panel->StatusText->SetLabel(StatusText);
}
Expand Down Expand Up @@ -2333,8 +2340,17 @@ void DisplayNotebookPanel::ReDrawPanel(void) {
images_in_x = 1;
images_in_y = 1;
}
else
images_in_current_view = images_in_x * images_in_y;
else {
// Checks if the number of images that will be displayed on the panel will fill the available
// space; if not, then we adjust the images_in_current_view to be accurate.
const int imgs_remaining = ReturnNumberofImages( ) + 1 - current_location;
if ( imgs_remaining < images_in_x * images_in_y ) {
images_in_current_view = imgs_remaining;
}
else {
images_in_current_view = images_in_x * images_in_y;
}
}

if ( current_location != location_on_last_draw || images_in_x != images_in_x_on_last_draw || images_in_y != images_in_y_on_last_draw ) {
//dc.Clear();
Expand Down Expand Up @@ -2893,6 +2909,63 @@ void DisplayNotebookPanel::OnPaint(wxPaintEvent& evt) {
}
}
}

// Scale bar overlay (single-image mode only)
if ( draw_scale_bar && single_image ) {
// Compute the actual screen-pixel extent of the drawn image,
// which may be smaller than the window if the image is small.
int image_screen_width = panel_image->GetWidth( ) - int(single_image_x * actual_scale_factor);
int image_screen_height = panel_image->GetHeight( ) - int(single_image_y * actual_scale_factor);
if ( image_screen_width > window_x_size )
image_screen_width = window_x_size;
if ( image_screen_height > window_y_size )
image_screen_height = window_y_size;

// Å per screen pixel, then *0.1 converts Å→nm in the formula
const float image_in_bitmap_pixel_size = pixel_size / actual_scale_factor;

int scalebar_length;
{
const float bar_must_be_multiple_of = 5.0f; // nm
float ideal_length_in_pixels = float(image_screen_width) * 0.1f;
float ideal_length_in_nm = ideal_length_in_pixels * image_in_bitmap_pixel_size * 0.1f;
ideal_length_in_nm = roundf(ideal_length_in_nm / bar_must_be_multiple_of) * bar_must_be_multiple_of;
if ( ideal_length_in_nm < bar_must_be_multiple_of )
ideal_length_in_nm = bar_must_be_multiple_of;
ideal_length_in_pixels = ideal_length_in_nm * 10.0f / image_in_bitmap_pixel_size;
scalebar_length = myroundint(ideal_length_in_pixels);
}

int scalebar_thickness = int(float(image_screen_height) / 50.0f);
if ( scalebar_thickness < 2 )
scalebar_thickness = 2;

int scalebar_x_start = int(float(image_screen_width) * 0.85f) - scalebar_length / 2;
int scalebar_y_pos = int(float(image_screen_height) * 0.95f) - scalebar_thickness;

// Clamp so the bar never spills outside the image area
if ( scalebar_x_start < 0 )
scalebar_x_start = 0;
if ( scalebar_x_start + scalebar_length > image_screen_width )
scalebar_x_start = image_screen_width - scalebar_length;

wxPen scalebar_pen(*wxWHITE);
dc.SetPen(scalebar_pen);
dc.SetBrush(*wxWHITE_BRUSH);
dc.DrawRectangle(scalebar_x_start, scalebar_y_pos, scalebar_length, scalebar_thickness);

dc.SetTextForeground(*wxWHITE);
int label_font_size = std::max(9, int(float(scalebar_thickness) * 0.75f));
dc.SetFont(wxFont(label_font_size, wxFONTFAMILY_DEFAULT, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_BOLD));

wxString scalebar_label = wxString::Format("%.0f nm", float(scalebar_length) * image_in_bitmap_pixel_size * 0.1f);
int scalebar_label_width;
int scalebar_label_height;
dc.GetTextExtent(scalebar_label, &scalebar_label_width, &scalebar_label_height);
dc.DrawText(scalebar_label,
scalebar_x_start + scalebar_length / 2 - scalebar_label_width / 2,
scalebar_y_pos - scalebar_label_height - scalebar_thickness / 8);
}
}
}

Expand Down
1 change: 1 addition & 0 deletions src/gui/DisplayPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ class
bool show_label;
bool show_crosshair;
bool single_image;
bool draw_scale_bar;

bool txt_is_saved;
bool have_txt_filename;
Expand Down
24 changes: 22 additions & 2 deletions src/gui/MyRefinementResultsPanel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,15 @@ MyRefinementResultsPanel::MyRefinementResultsPanel(wxWindow* parent)

#include "icons/show_angles.cpp"
#include "icons/show_text.cpp"
#include "icons/small_save_icon.cpp"

wxBitmap angles_popup_bmp = wxBITMAP_PNG_FROM_DATA(show_angles);
wxBitmap parameters_popup_bmp = wxBITMAP_PNG_FROM_DATA(show_text);
wxBitmap angles_popup_bmp = wxBITMAP_PNG_FROM_DATA(show_angles);
wxBitmap parameters_popup_bmp = wxBITMAP_PNG_FROM_DATA(show_text);
wxBitmap binned_angles_save_bmp = wxBITMAP_PNG_FROM_DATA(small_save_icon);
AngularPlotDetailsButton->SetBitmap(angles_popup_bmp);
ParametersDetailButton->SetBitmap(parameters_popup_bmp);
SaveBinnedAngularPlotButton->SetBitmap(binned_angles_save_bmp);
Layout( );

// FSCPlotPanel->ClassComboBox->Connect( wxEVT_COMMAND_COMBOBOX_SELECTED, wxCommandEventHandler( MyRefinementResultsPanel::OnClassComboBoxChange ), NULL, this );
}
Expand Down Expand Up @@ -329,6 +333,22 @@ void MyRefinementResultsPanel::AngularPlotPopupClick(wxCommandEvent& event) {
}
}

void MyRefinementResultsPanel::SaveBinnedPlotClick(wxCommandEvent& event) {
ProperOverwriteCheckSaveDialog* saveFileDialog;
saveFileDialog = new ProperOverwriteCheckSaveDialog(this, _("Save png image"), "PNG files (*.png)|*.png", ".png");
if ( saveFileDialog->ShowModal( ) == wxID_CANCEL ) {
saveFileDialog->Destroy( );
return;
}

// save the file then..

// TODO: this would likely be the only difference; change the source of data
// for the saving of the file
AngularPlotPanel->buffer_bitmap.SaveFile(saveFileDialog->ReturnProperPath( ), wxBITMAP_TYPE_PNG);
saveFileDialog->Destroy( );
}

void MyRefinementResultsPanel::PopupParametersClick(wxCommandEvent& event) {
if ( RefinementPackageComboBox->GetSelection( ) >= 0 && OrthPanel->my_notebook->GetPageCount( ) > 0 ) {
UpdateBufferedFullRefinement( );
Expand Down
1 change: 1 addition & 0 deletions src/gui/MyRefinementResultsPanel.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ class MyRefinementResultsPanel : public RefinementResultsPanel {
void OnClassComboBoxChange(wxCommandEvent& event);
void AngularPlotPopupClick(wxCommandEvent& event);
void PopupParametersClick(wxCommandEvent& event);
void SaveBinnedPlotClick(wxCommandEvent& event);

void UpdateCachedRefinement( );
void UpdateBufferedFullRefinement( );
Expand Down
9 changes: 7 additions & 2 deletions src/gui/ProjectX_gui_refine3d.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,15 @@ RefinementResultsPanel::RefinementResultsPanel( wxWindow* parent, wxWindowID id,
ParametersDetailButton = new NoFocusBitmapButton( m_panel125, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );

ParametersDetailButton->SetDefault();
bSizer497->Add( ParametersDetailButton, 0, wxLEFT|wxTOP, 5 );
bSizer497->Add( ParametersDetailButton, 0, wxEXPAND|wxTOP, 5 );

AngularPlotDetailsButton = new NoFocusBitmapButton( m_panel125, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );

AngularPlotDetailsButton->SetDefault();
bSizer497->Add( AngularPlotDetailsButton, 0, wxRIGHT|wxTOP, 5 );
bSizer497->Add( AngularPlotDetailsButton, 0, wxEXPAND|wxTOP, 5 );

SaveBinnedAngularPlotButton = new NoFocusBitmapButton( m_panel125, wxID_ANY, wxNullBitmap, wxDefaultPosition, wxDefaultSize, wxBU_AUTODRAW|0 );
bSizer497->Add( SaveBinnedAngularPlotButton, 0, wxEXPAND|wxTOP, 5 );


bSizer495->Add( bSizer497, 0, wxEXPAND, 5 );
Expand Down Expand Up @@ -614,6 +617,7 @@ RefinementResultsPanel::RefinementResultsPanel( wxWindow* parent, wxWindowID id,
this->Connect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( RefinementResultsPanel::OnUpdateUI ) );
ParametersDetailButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( RefinementResultsPanel::PopupParametersClick ), NULL, this );
AngularPlotDetailsButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( RefinementResultsPanel::AngularPlotPopupClick ), NULL, this );
SaveBinnedAngularPlotButton->Connect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( RefinementResultsPanel::SaveBinnedPlotClick ), NULL, this );
JobDetailsToggleButton->Connect( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler( RefinementResultsPanel::OnJobDetailsToggle ), NULL, this );
}

Expand All @@ -623,6 +627,7 @@ RefinementResultsPanel::~RefinementResultsPanel()
this->Disconnect( wxEVT_UPDATE_UI, wxUpdateUIEventHandler( RefinementResultsPanel::OnUpdateUI ) );
ParametersDetailButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( RefinementResultsPanel::PopupParametersClick ), NULL, this );
AngularPlotDetailsButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( RefinementResultsPanel::AngularPlotPopupClick ), NULL, this );
SaveBinnedAngularPlotButton->Disconnect( wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( RefinementResultsPanel::SaveBinnedPlotClick ), NULL, this );
JobDetailsToggleButton->Disconnect( wxEVT_COMMAND_TOGGLEBUTTON_CLICKED, wxCommandEventHandler( RefinementResultsPanel::OnJobDetailsToggle ), NULL, this );

}
Expand Down
2 changes: 2 additions & 0 deletions src/gui/ProjectX_gui_refine3d.h
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ class RefinementResultsPanel : public wxPanel
virtual void OnUpdateUI( wxUpdateUIEvent& event ) { event.Skip(); }
virtual void PopupParametersClick( wxCommandEvent& event ) { event.Skip(); }
virtual void AngularPlotPopupClick( wxCommandEvent& event ) { event.Skip(); }
virtual void SaveBinnedPlotClick( wxCommandEvent& event ) { event.Skip(); }
virtual void OnJobDetailsToggle( wxCommandEvent& event ) { event.Skip(); }


Expand All @@ -177,6 +178,7 @@ class RefinementResultsPanel : public wxPanel
RefinementPickerComboPanel* InputParametersComboBox;
NoFocusBitmapButton* ParametersDetailButton;
NoFocusBitmapButton* AngularPlotDetailsButton;
NoFocusBitmapButton* SaveBinnedAngularPlotButton;

RefinementResultsPanel( wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxSize( 1007,587 ), long style = wxTAB_TRAVERSAL, const wxString& name = wxEmptyString );

Expand Down
Loading
Loading