13 #include <wx/stattext.h>
14 #include <wx/statbox.h>
15 #include <wx/bmpbuttn.h>
16 #include <wx/checkbox.h>
17 #include <wx/radiobox.h>
18 #include <wx/slider.h>
19 #include <wx/combobox.h>
22 #include <wx/cmndata.h>
23 #include <wx/dirdlg.h>
24 #include <wx/msgdlg.h>
25 #include <wx/artprov.h>
29 #include <wx/statline.h>
42 DEFINE_EVENT_TYPE(wxEVT_TILE_PREVIEW)
60 { -1.0f, 215.9f/279.4f, 210.0f/297.0f};
67 , m_DirSelectButton(
NULL)
68 , m_FileRootName(
NULL)
70 , m_NumberingFormat(
NULL)
73 , m_ImageSaver(img_saver)
80 wxWindowList& children = this->GetChildren();
82 wxWindowList::compatibility_iterator node = children.GetFirst();
85 wxWindow *child = node->GetData();
87 if (child->GetId() == GetAffirmativeId()) {
88 child->SetLabel(
wxT(
"Save"));
91 else if (child->GetId() == wxID_CANCEL) {
92 child->SetLabel(
wxT(
"Close"));
96 else if (child->GetLabel() ==
wxT(
"Printer...")) {
101 node = node->GetNext();
112 int fname_width = 60;
117 wxBoxSizer *file_sizer =
new wxBoxSizer(wxHORIZONTAL);
118 file_sizer->Add(
new wxStaticText(
this,
121 0, wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER,5);
126 wxSize(dir_width, wxDefaultCoord));
127 file_sizer->Add(
m_Directory, 0, wxTOP|wxBOTTOM|wxALIGN_CENTER, 5 );
131 wxArtProvider::GetBitmap(
wxT(
"menu::open")),
136 file_sizer->Add(
m_DirSelectButton, 0, wxTOP|wxBOTTOM|wxRIGHT|wxLEFT|wxALIGN_CENTER, 5 );
138 file_sizer->Add(
new wxStaticText(
this,
141 0,wxTOP|wxBOTTOM|wxALIGN_CENTER,5);
146 wxSize(fname_width, wxDefaultCoord));
148 file_sizer->Add(
m_FileRootName, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER, 5);
151 file_sizer->Add(
new wxStaticText(
this,
154 1,wxTOP|wxBOTTOM|wxALIGN_CENTER,5);
156 int numbering_count = 2;
157 wxString* num_choices =
new wxString[numbering_count];
158 num_choices[0] =
wxT(
"Sequential");
159 num_choices[1] =
wxT(
"Tile Index");
165 wxSize(100, wxDefaultCoord),
166 numbering_count, num_choices);
170 mainsizer->Add( file_sizer, 0, wxALIGN_CENTER);
171 wxBoxSizer *image_opt_sizer =
new wxBoxSizer(wxHORIZONTAL);
173 image_opt_sizer->Add(
new wxStaticText(
this,
176 1,wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER,5);
180 int format_count = 3;
181 wxString* choices =
new wxString[format_count];
182 choices[0] =
wxT(
"jpeg");
183 choices[1] =
wxT(
"png");
191 wxSize(80, wxDefaultCoord),
192 format_count, choices);
193 image_opt_sizer->Add(
m_ImageFormat, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER, 5);
197 std::vector<int> sizes;
199 wxString* size_choices =
NULL;
202 if (sizes.size() > 0) {
203 size_choices =
new wxString[sizes.size()];
204 for (
size_t i=0;
i<sizes.size(); ++
i) {
206 sprintf(
buf,
"%5d", sizes[
i]);
207 size_choices[
i] = wxString(
buf, wxConvUTF8);
209 if (size_choices->size() > 1U)
215 sizes.push_back(256);
216 size_choices =
new wxString[sizes.size()];
218 sprintf(
buf,
"%5d", sizes[0]);
219 size_choices[0] = wxString(
buf, wxConvUTF8);
222 image_opt_sizer->Add(
new wxStaticText(
this,
225 1,wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER,5);
228 size_choices[default_idx],
230 wxSize(80, wxDefaultCoord),
231 (
int)sizes.size(), size_choices);
232 image_opt_sizer->Add(
m_ImageSizes, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER, 5);
234 image_opt_sizer->Add(
new wxStaticText(
this,
236 wxT(
"Proportions:")),
237 1,wxTOP|wxBOTTOM|wxLEFT|wxALIGN_CENTER,5);
240 wxString* ratio_choices =
new wxString[ratio_count];
243 ratio_choices[0] =
wxT(
"Smallest");
244 ratio_choices[1] =
wxT(
"Letter");
245 ratio_choices[2] =
wxT(
"A4");
251 wxSize(100, wxDefaultCoord),
252 ratio_count, ratio_choices);
253 image_opt_sizer->Add(
m_SizeRatio, 0, wxTOP|wxBOTTOM|wxRIGHT|wxALIGN_CENTER, 5);
256 mainsizer->Add( image_opt_sizer, 0, wxALIGN_CENTER);
266 reg_value = view.
GetString(
"ImageDirectory");
267 if (!reg_value.empty())
268 m_Directory->SetValue(wxString(reg_value.c_str(), wxConvUTF8));
270 reg_value = view.
GetString(
"FileRootName");
271 if (!reg_value.empty())
272 m_FileRootName->SetValue(wxString(reg_value.c_str(), wxConvUTF8));
274 reg_value = view.
GetString(
"ImageFormat");
275 if (!reg_value.empty())
276 m_ImageFormat->SetValue(wxString(reg_value.c_str(), wxConvUTF8));
279 reg_value = view.
GetString(
"NumberingFormat");
280 if (!reg_value.empty())
284 wxString wx_reg_value = wxString(reg_value.c_str(), wxConvUTF8);
285 if (!reg_value.empty())
287 for (
int j=0; j<ratio_count; ++j) {
288 if (wx_reg_value == ratio_choices[j]) {
296 wxCommandEvent dummy_evt;
306 if (ratio == -1.0f)
return ratio;
312 if ((ratio < 1.0f && target_ratio > 1.0f) || (ratio > 1.0f && target_ratio < 1.0f))
342 wxDirDialog dlg(
this);
344 if (dlg.ShowModal() == wxID_OK) {
420 SetCursor(*wxHOURGLASS_CURSOR);
464 SetCursor(*wxSTANDARD_CURSOR);
467 wxMessageBox(
wxT(
"Graphics system does not support in-memory image save feature"),
468 wxT(
"Error Saving"), wxOK);
471 wxMessageBox(
wxT(
"File error occured during save. Make sure file and directory names are valid."),
472 wxT(
"Error Saving"), wxOK);
486 SetCursor(*wxHOURGLASS_CURSOR);
515 CVect2<int>(event.GetInt(),
static_cast<int>(event.GetExtraLong())),
519 SetCursor(*wxSTANDARD_CURSOR);
531 SetCursor(*wxHOURGLASS_CURSOR);
564 SetCursor(*wxSTANDARD_CURSOR);
static std::vector< int > checkFramebufferAvailability(int start_size, int count)
Return an arrray of valid image output sizes.
CRegistryWriteView GetWriteView(const string §ion)
get a read-write view at a particular level.
static CGuiRegistry & GetInstance()
access the application-wide singleton
CRegistryReadView GetReadView(const string §ion) const
get a read-only view at a particular level.
void x_InitDialog(CRef< CImage > img)
Layout all controls owned by this class.
virtual void UpdateMargins()
virtual bool TransferDataFromWindow()
CVect2< int > GetPartitions() const
Get the number of image partitions in x and y.
wxStaticText * m_PageCount
wxSlider * m_PageCountSlider
CGlPreviewSetupWidget * m_PreviewSetupWidget
wxRadioBox * m_GuidesRadioBox
virtual bool TransferDataToWindow()
class CRegistryReadView provides a nested hierarchical view at a particular key.
string GetString(const string &key, const string &default_val=kEmptyStr) const
void Set(const string &key, int val)
access a named key at this level, with no recursion
void OnPreview(wxCommandEvent &event)
void OnPrinter(wxCommandEvent &event)
void OnFileTextChange(wxCommandEvent &evt)
Called to update image on screen.
wxTextCtrl * m_Directory
Directory in which to save the image.
wxComboBox * m_SizeRatio
Size ratio derived from ouput format - US Letter, A4, ...
void OnImageTypeChange(wxCommandEvent &event)
wxComboBox * m_ImageSizes
Output size (this will be the size of larger dimension in output images)
wxButton * m_DirSelectButton
IImageGrabber * m_ImageSaver
std::string GetOutputFormat() const
std::string GetDirectoryName() const
void OnDirSelect(wxCommandEvent &event)
std::string GetNumberingFormat() const
std::string GetImageFormat() const
void OnSave(wxCommandEvent &event)
virtual void x_Init(wxBoxSizer *mainsizer, int widget_width)
Provide virtual hook for subclasses to add their own controls below the main controls.
wxTextCtrl * m_FileRootName
Part of file name before image number.
void OnTilePreview(wxCommandEvent &event)
wxComboBox * m_ImageFormat
Image save format (jpeg, png...)
virtual bool TransferDataFromWindow()
float x_getAspectRatio() const
virtual ~CSaveImagesSetupDlg()
virtual bool TransferDataToWindow()
wxComboBox * m_NumberingFormat
How the numbers are included in filenames, e.g. img_{1..n} or img_x_y;.
CSaveImagesSetupDlg(CRef< CImage > img, IImageGrabber *img_saver, wxWindow *parent=NULL)
std::string GetFileRootName() const
static const float s_ImageAspectRatios[3]
Aspect ratios for image sizes (w/h)
void SetPartitions(const CVect2< int > &p)
Set number of desired image partitions.
void SetImageAspectRatio(float ar)
Set aspect ratio for image as a whole.
eCaptureResult PreviewImages(int tex_size, int ref_img_width, int ref_img_height, IImageGrabberProgress *p=NULL)
Grab images to update the on-screen image to approximate final output.
virtual eCaptureResult GrabImages(int tex_size, IImageGrabberProgress *p=NULL)
Grab the requested images.
void SetNumberingFormat(eImageNumberingFormat fmt)
Set the numbering format for sequential image names.
void SetPrintingGuidesEnabled(bool b)
Set to true to put cutting/printing guides on output images.
eCaptureResult GrabImage(int tex_size, CVect2< int > img_idx, IImageGrabberProgress *p=NULL)
Grab a single image for preview purposes.
void SetOutputInfo(const std::string &dir, const std::string &base_name, const std::string &img_format)
Set file output information.
void SetTileAspectRatio(float ar)
Set aspect ratio tiles captured.
IMPLEMENT_CLASS(CFloatingFrame, CFloatingFrameBaseClass) const static long kFloatFrameStyle
CFloatingFrame.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static const string kSaveImagesBaseKey("GBPlugins.SaveImagesDialog")
static const char * str(char *buf, int n)
static void SetTitle(CRef< CSeq_entry > entry, string title)