[f96f56]: src / hugin1 / hugin / PanoOperationTree.cpp  Maximize  Restore  History

Download this file

181 lines (162 with data), 6.2 kB

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
// -*- c-basic-offset: 4 -*-
/** @file PanoOperationTree.cpp
*
* @brief Implementation of PanoOperationTreeCtrl and PanoOperationTreeCtrlXmlHandler class
*
* @author T. Modes
*
*/
/* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public
* License along with this software; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
#include "hugin/PanoOperationTree.h"
#include "hugin/PanoOperation.h"
BEGIN_EVENT_TABLE(PanoOperationTreeCtrl,wxTreeCtrl)
EVT_LEFT_DCLICK(PanoOperationTreeCtrl::OnLeftDblClick)
END_EVENT_TABLE()
void PanoOperationTreeCtrl::GenerateTree()
{
wxTreeItemId root=AddRoot(wxT("root"));
m_images=AppendItem(root,_("Images"));
PanoOperation* op=new AddImageOperation();
AppendItem(m_images,_("Add individual images..."),-1,-1,(wxTreeItemData*)op);
op=new AddImagesSeriesOperation();
AppendItem(m_images,_("Add time-series of images..."),-1,-1,(wxTreeItemData*)op);
op=new RemoveImageOperation();
AppendItem(m_images,_("Remove selected image(s)"),-1,-1,(wxTreeItemData*)op);
op=new ChangeAnchorImageOperation();
AppendItem(m_images,_("Anchor this image for position"),-1,-1,(wxTreeItemData*)op);
op=new ChangeColorAnchorImageOperation();
AppendItem(m_images,_("Anchor this image for exposure"),-1,-1,(wxTreeItemData*)op);
Expand(m_images);
m_stacks=AppendItem(root,_("Stacks"));
op=new NewStackOperation();
AppendItem(m_stacks,_("New stack"),-1,-1,(wxTreeItemData*)op);
op=new ChangeStackOperation();
AppendItem(m_stacks,_("Change stack..."),-1,-1,(wxTreeItemData*)op);
m_cp=AppendItem(root,_("Control points"));
m_cpDetectors=AppendItem(m_cp,_("Control point detectors"));
op=new RemoveControlPointsOperation();
AppendItem(m_cp,_("Remove control points"),-1,-1,(wxTreeItemData*)op);
op=new CelesteOperation();
AppendItem(m_cp,_("Run Celeste"),-1,-1,(wxTreeItemData*)op);
op=new CleanControlPointsOperation();
AppendItem(m_cp,_("Clean control points"),-1,-1,(wxTreeItemData*)op);
};
void PanoOperationTreeCtrl::UpdateCPDetectorItems(CPDetectorConfig& config)
{
DeleteChildren(m_cpDetectors);
if(config.GetCount()>0)
{
for(size_t i=0;i<config.GetCount();i++)
{
CPDetectorSetting setting=config.settings[i];
PanoOperation* op=new GenerateControlPointsOperation(setting);
AppendItem(m_cpDetectors,setting.GetCPDetectorDesc(),-1,-1,(wxTreeItemData*)op);
};
};
Expand(m_cpDetectors);
};
#if defined HUGIN_HSI
void PanoOperationTreeCtrl::GeneratePythonTree(PluginItems items)
{
for(PluginItems::const_iterator it=items.begin();it!=items.end();it++)
{
wxTreeItemId id;
switch((*it).GetPluginType())
{
case PluginItem::DefaultPlugin:
continue;
break;
case PluginItem::ImagePlugin:
id=m_images;
break;
case PluginItem::StackPlugin:
id=m_stacks;
break;
case PluginItem::ControlpointPlugin:
id=m_cp;
break;
};
PanoOperation* op=new PythonOperation((*it).GetFilename());
AppendItem(id,(*it).GetName(),-1,-1,(wxTreeItemData*)op);
};
};
#endif
void PanoOperationTreeCtrl::OnLeftDblClick(wxMouseEvent & e)
{
wxCommandEvent ev(wxEVT_COMMAND_BUTTON_CLICKED,XRCID("images_execute_operation"));
GetParent()->GetEventHandler()->AddPendingEvent(ev);
};
void PanoOperationTreeCtrl::UpdateState(PT::Panorama & pano,HuginBase::UIntSet images)
{
wxTreeItemId item=GetRootItem();
if(item.IsOk())
{
Freeze();
wxColour color1=wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
wxColour color2=wxSystemSettings::GetColour(wxSYS_COLOUR_GRAYTEXT);
UpdateStateRecursivly(item,pano,images,color1,color2);
Thaw();
};
};
void PanoOperationTreeCtrl::UpdateStateRecursivly(wxTreeItemId startItem,PT::Panorama & pano,HuginBase::UIntSet images,const wxColour colorActive, const wxColour colorInactive)
{
if(HasChildren(startItem))
{
wxTreeItemIdValue cookie;
wxTreeItemId item=GetFirstChild(startItem,cookie);
while(item.IsOk())
{
PanoOperation* op=(PanoOperation*)(GetItemData(item));
if(op!=NULL)
{
if(op->IsEnabled(pano,images))
{
SetItemTextColour(item,colorActive);
}
else
{
SetItemTextColour(item,colorInactive);
};
};
UpdateStateRecursivly(item,pano,images,colorActive,colorInactive);
item=GetNextChild(startItem,cookie);
};
};
};
IMPLEMENT_DYNAMIC_CLASS(PanoOperationTreeCtrl, wxTreeCtrl)
IMPLEMENT_DYNAMIC_CLASS(PanoOperationTreeCtrlXmlHandler, wxTreeCtrlXmlHandler)
wxObject *PanoOperationTreeCtrlXmlHandler::DoCreateResource()
{
XRC_MAKE_INSTANCE(tree, PanoOperationTreeCtrl)
tree->Create(m_parentAsWindow,
GetID(),
GetPosition(), GetSize(),
GetStyle(wxT("style"), wxTR_DEFAULT_STYLE),
wxDefaultValidator,
GetName());
#if wxCHECK_VERSION(2,9,0)
wxImageList *imagelist = GetImageList();
if ( imagelist )
tree->AssignImageList(imagelist);
#endif
SetupWindow(tree);
return tree;
}
bool PanoOperationTreeCtrlXmlHandler::CanHandle(wxXmlNode *node)
{
return IsOfClass(node, wxT("PanoOperationTree"));
}

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks