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.16 2013/04/05 21:04:18 amraktad 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  if (typeId() < FWViewType::kTable)
77  {
78  try {
79  static TString dir(".");
80  const char * kImageExportTypes[] = {"PNG", "*.png",
81  "GIF", "*.gif",
82  "JPEG", "*.jpg",
83  "PDF", "*.pdf",
84  "Encapsulated PostScript", "*.eps",
85  0, 0};
86 
87  TGFileInfo fi;
88  fi.fFileTypes = kImageExportTypes;
89  fi.fIniDir = StrDup(dir);
90  new TGFileDialog(gClient->GetDefaultRoot(), iParent,
91  kFDSave,&fi);
92  dir = fi.fIniDir;
93  if (fi.fFilename != 0) {
94  std::string name = fi.fFilename;
95  // fi.fFileTypeIdx points to the name of the file type
96  // selected in the drop-down menu, so fi.fFileTypeIdx gives us
97  // the extension
98  std::string ext = kImageExportTypes[fi.fFileTypeIdx + 1] + 1;
99  if (name.find(ext) == name.npos)
100  name += ext;
101  saveImageTo(name);
102  }
103  }
104  catch (std::runtime_error &e) { std::cout << e.what() << std::endl; }
105  }
106  else
107  {
108  saveImageTo("dummy");
109  }
110 }
111 
114  return 0;
115 }
116 
117 //
118 // static member functions
119 //
120 const std::string&
122 {
123  return m_type.name();
124 }
type
Definition: HCALResponse.h:21
sigc::signal< void, const FWViewBase * > beingDestroyed_
Definition: FWViewBase.h:56
const std::string & typeName() const
Definition: FWViewBase.cc:121
const std::string & name() const
Definition: FWViewType.cc:75
virtual FWViewContextMenuHandlerBase * contextMenuHandler() const
Definition: FWViewBase.cc:113
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:121
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
FWViewType::EType typeId() const
Definition: FWViewBase.h:42