test
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 //
12 
13 // system include files
14 #include <stdexcept>
15 #include <iostream>
16 #include "TGFileDialog.h"
17 
18 // user include files
20 
21 
22 //
23 // constants, enums and typedefs
24 //
25 
26 //
27 // static data member definitions
28 //
29 
30 //
31 // constructors and destructor
32 //
35  m_type(type)
36 {
37 }
38 
39 // FWViewBase::FWViewBase(const FWViewBase& rhs)
40 // {
41 // // do actual copying here;
42 // }
43 
45 {
46 }
47 
48 //
49 // assignment operators
50 //
51 // const FWViewBase& FWViewBase::operator=(const FWViewBase& rhs)
52 // {
53 // //An exception safe implementation is
54 // FWViewBase temp(rhs);
55 // swap(rhs);
56 //
57 // return *this;
58 // }
59 
60 //
61 // member functions
62 //
63 void
65 {
66  beingDestroyed_(this);
67 }
68 
69 //
70 // const member functions
71 //
72 void
73 FWViewBase::promptForSaveImageTo(TGFrame* iParent) const
74 {
75  if (typeId() < FWViewType::kTable)
76  {
77  try {
78  static TString dir(".");
79  const char * kImageExportTypes[] = {"PNG", "*.png",
80  "GIF", "*.gif",
81  "JPEG", "*.jpg",
82  "PDF", "*.pdf",
83  "Encapsulated PostScript", "*.eps",
84  0, 0};
85 
86  TGFileInfo fi;
87  fi.fFileTypes = kImageExportTypes;
88  fi.fIniDir = StrDup(dir);
89  new TGFileDialog(gClient->GetDefaultRoot(), iParent,
90  kFDSave,&fi);
91  dir = fi.fIniDir;
92  if (fi.fFilename != 0) {
93  std::string name = fi.fFilename;
94  // fi.fFileTypeIdx points to the name of the file type
95  // selected in the drop-down menu, so fi.fFileTypeIdx gives us
96  // the extension
97  std::string ext = kImageExportTypes[fi.fFileTypeIdx + 1] + 1;
98  if (name.find(ext) == name.npos)
99  name += ext;
100  saveImageTo(name);
101  }
102  }
103  catch (std::runtime_error &e) { std::cout << e.what() << std::endl; }
104  }
105  else
106  {
107  saveImageTo("dummy");
108  }
109 }
110 
113  return 0;
114 }
115 
116 //
117 // static member functions
118 //
119 const std::string&
121 {
122  return m_type.name();
123 }
type
Definition: HCALResponse.h:21
sigc::signal< void, const FWViewBase * > beingDestroyed_
Definition: FWViewBase.h:55
const std::string & typeName() const
Definition: FWViewBase.cc:120
const std::string & name() const
Definition: FWViewType.cc:74
virtual FWViewContextMenuHandlerBase * contextMenuHandler() const
Definition: FWViewBase.cc:112
FWViewType m_type
Definition: FWViewBase.h:60
virtual ~FWViewBase()
Definition: FWViewBase.cc:44
virtual void saveImageTo(const std::string &iName) const =0
tuple cout
Definition: gather_cfg.py:145
void destroy()
Definition: FWViewBase.cc:64
dbl *** dir
Definition: mlp_gen.cc:35
void promptForSaveImageTo(TGFrame *) const
Definition: FWViewBase.cc:73
FWViewBase(FWViewType::EType, unsigned int iVersion=1)
Definition: FWViewBase.cc:33
FWViewType::EType typeId() const
Definition: FWViewBase.h:41