Isis 3 Programmer Reference
SetActiveControlWorkOrder.cpp
Go to the documentation of this file.
1 
22 
23 #include <QMessageBox>
24 #include <QtDebug>
25 
26 #include "Control.h"
27 #include "Directory.h"
28 #include "IException.h"
29 #include "Project.h"
30 #include "ProjectItem.h"
31 #include "ProjectItemModel.h"
32 
33 namespace Isis {
34 
40  WorkOrder(project) {
41 
42  // This workorder is not undoable
43  m_isUndoable = false;
44 
45  QAction::setText(tr("Set Active Control Network") );
46  QUndoCommand::setText(tr("Set Active Control Network"));
47  }
48 
49 
55  WorkOrder(other) {
56  }
57 
58 
63  }
64 
65 
71  return new SetActiveControlWorkOrder(*this);
72  }
73 
74 
82 
83  // Return false if more than 1 control was selected or if selected is already active
84  if (controls) {
85  if (controls->size() != 1 || project()->activeControl() == controls->at(0)) {
86  return false;
87  }
88  return true;
89  }
90  return false;
91  }
92 
93 
100 
101  bool success = WorkOrder::setupExecution();
102  if (success) {
103  if (!project()->activeImageList()) {
104 
105  QMessageBox::critical(NULL, tr("Unable to set active control."),
106  tr("You must first choose an active Image List before setting "
107  "the active control net."));
108  success = false;
109  }
110  // So far, so good, set the command text
111  else {
112  QUndoCommand::setText(tr("Set Active Control Network to [%1]").arg(
113  controlList()->at(0)->displayProperties()->displayName()));
114  }
115  }
116 
117  return success;
118  }
119 
120 
129  try {
130  project()->setActiveControl(controlList()->at(0)->displayProperties()->displayName());
131  }
132  catch (IException &e) {
133  m_status = WorkOrderFinished;
134  QMessageBox::critical(NULL, tr("Error"), tr(e.what()));
135  }
136  }
137 }
SetActiveControlWorkOrder.h
Unless noted otherwise, the portions of Isis written by the USGS are public domain.
Isis::WorkOrder::setupExecution
virtual bool setupExecution()
This sets up the state for the work order.
Definition: WorkOrder.cpp:1261
Isis::SetActiveControlWorkOrder::execute
void execute()
Set the active control net for the project.
Definition: SetActiveControlWorkOrder.cpp:128
Isis::WorkOrder
Provide Undo/redo abilities, serialization, and history for an operation.
Definition: WorkOrder.h:311
Project.h
Isis::SetActiveControlWorkOrder::clone
virtual SetActiveControlWorkOrder * clone() const
Returns a copy of this SetActiveControlWorkOrder instance.
Definition: SetActiveControlWorkOrder.cpp:70
Isis::WorkOrder::controlList
QPointer< ControlList > controlList()
Returns the Control List for this WorkOrder (a list of control networks).
Definition: WorkOrder.cpp:706
Isis::ControlList
Maintains a list of Controls so that control nets can easily be copied from one Project to another,...
Definition: ControlList.h:44
Isis::SetActiveControlWorkOrder::~SetActiveControlWorkOrder
~SetActiveControlWorkOrder()
The Destructor.
Definition: SetActiveControlWorkOrder.cpp:62
Isis::SetActiveControlWorkOrder
This is a child of class WorkOrder which is used for anything that performs an action in a Project.
Definition: SetActiveControlWorkOrder.h:49
Isis::SetActiveControlWorkOrder::isExecutable
virtual bool isExecutable(ControlList *controls)
Determines if we can set this control as active.
Definition: SetActiveControlWorkOrder.cpp:81
Isis::SetActiveControlWorkOrder::SetActiveControlWorkOrder
SetActiveControlWorkOrder(Project *project)
Creates a WorkOrder that will set the active Control in the project.
Definition: SetActiveControlWorkOrder.cpp:39
Isis::IException::what
const char * what() const
Returns a string representation of this exception in its current state.
Definition: IException.cpp:375
Isis::Project
The main project for ipce.
Definition: Project.h:289
Isis::Project::setActiveControl
void setActiveControl(QString displayName)
Set the Active Control (control network)
Definition: Project.cpp:1819
Isis::WorkOrder::m_isUndoable
bool m_isUndoable
Set the workorder to be undoable/redoable This is defaulted to true - his will allow the workorder to...
Definition: WorkOrder.h:523
Isis::WorkOrder::project
Project * project() const
Returns the Project this WorkOrder is attached to.
Definition: WorkOrder.cpp:1300
Isis::IException
Isis exception class.
Definition: IException.h:91
Isis::SetActiveControlWorkOrder::setupExecution
bool setupExecution()
Make sure an active ImageList has been chosen.
Definition: SetActiveControlWorkOrder.cpp:99
Isis::WorkOrder::WorkOrderFinished
@ WorkOrderFinished
This is used for work orders that will not undo or redo (See createsCleanState())
Definition: WorkOrder.h:331
Isis
This is free and unencumbered software released into the public domain.
Definition: Apollo.h:16