CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
FWViewBase.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Core
4 // Class : FWViewBase
5 //
6 // Implementation:
7 // <Notes on implementation>
8 //
9 // Original Author: Chris Jones
10 // Created: Thu Feb 21 14:43:19 EST 2008
11 // $Id: FWViewBase.cc,v 1.13 2009/11/03 00:05:01 chrjones Exp $
12 //
13 
14 // system include files
15 #include <stdexcept>
16 #include <iostream>
17 #include "TGFileDialog.h"
18 
19 // user include files
21 
22 
23 //
24 // constants, enums and typedefs
25 //
26 
27 //
28 // static data member definitions
29 //
30 
31 //
32 // constructors and destructor
33 //
36  m_type(type)
37 {
38 }
39 
40 // FWViewBase::FWViewBase(const FWViewBase& rhs)
41 // {
42 // // do actual copying here;
43 // }
44 
46 {
47 }
48 
49 //
50 // assignment operators
51 //
52 // const FWViewBase& FWViewBase::operator=(const FWViewBase& rhs)
53 // {
54 // //An exception safe implementation is
55 // FWViewBase temp(rhs);
56 // swap(rhs);
57 //
58 // return *this;
59 // }
60 
61 //
62 // member functions
63 //
64 void
66 {
67  beingDestroyed_(this);
68 }
69 
70 //
71 // const member functions
72 //
73 void
74 FWViewBase::promptForSaveImageTo(TGFrame* iParent) const
75 {
76  try {
77  static TString dir(".");
78  const char * kImageExportTypes[] = {"PNG", "*.png",
79  "GIF", "*.gif",
80  "JPEG", "*.jpg",
81  "PDF", "*.pdf",
82  "Encapsulated PostScript", "*.eps",
83  0, 0};
84 
85  TGFileInfo fi;
86  fi.fFileTypes = kImageExportTypes;
87  fi.fIniDir = StrDup(dir);
88  new TGFileDialog(gClient->GetDefaultRoot(), iParent,
89  kFDSave,&fi);
90  dir = fi.fIniDir;
91  if (fi.fFilename != 0) {
92  std::string name = fi.fFilename;
93  // fi.fFileTypeIdx points to the name of the file type
94  // selected in the drop-down menu, so fi.fFileTypeIdx gives us
95  // the extension
96  std::string ext = kImageExportTypes[fi.fFileTypeIdx + 1] + 1;
97  if (name.find(ext) == name.npos)
98  name += ext;
99  saveImageTo(name);
100  }
101  }
102  catch (std::runtime_error &e) { std::cout << e.what() << std::endl; }
103 }
104 
107  return 0;
108 }
109 
110 //
111 // static member functions
112 //
113 const std::string&
115 {
116  return m_type.name();
117 }
type
Definition: HCALResponse.h:22
sigc::signal< void, const FWViewBase * > beingDestroyed_
Definition: FWViewBase.h:56
const std::string & typeName() const
Definition: FWViewBase.cc:114
const std::string & name() const
Definition: FWViewType.cc:74
virtual FWViewContextMenuHandlerBase * contextMenuHandler() const
Definition: FWViewBase.cc:106
FWViewType m_type
Definition: FWViewBase.h:61
virtual ~FWViewBase()
Definition: FWViewBase.cc:45
virtual void saveImageTo(const std::string &iName) const =0
tuple cout
Definition: gather_cfg.py:41
void destroy()
Definition: FWViewBase.cc:65
dbl *** dir
Definition: mlp_gen.cc:35
void promptForSaveImageTo(TGFrame *) const
Definition: FWViewBase.cc:74
FWViewBase(FWViewType::EType, unsigned int iVersion=1)
Definition: FWViewBase.cc:34