Commit 6765bb2a authored by Sylvain Thery's avatar Sylvain Thery

duplicate & remove maps in schnapps

parent 13852a54
...@@ -81,8 +81,8 @@ void ControlDock_MapTab::setSelectedMap(const QString& mapName) ...@@ -81,8 +81,8 @@ void ControlDock_MapTab::setSelectedMap(const QString& mapName)
if(!items.empty()) if(!items.empty())
{ {
items[0]->setSelected(false); items[0]->setSelected(false);
m_selectedMap = NULL;
} }
m_selectedMap = NULL;
updateSelectedMapInfo(); updateSelectedMapInfo();
return; return;
} }
...@@ -149,7 +149,7 @@ void ControlDock_MapTab::showBBChanged(bool b) ...@@ -149,7 +149,7 @@ void ControlDock_MapTab::showBBChanged(bool b)
// RECORDING // RECORDING
QTextStream* rec = m_schnapps->pythonStreamRecorder(); QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec) if (rec)
*rec << m_selectedMap->getName() << ".showBB(\"" << b << "\");" << endl; *rec << m_selectedMap->getName() << ".showBB(" << b << ");" << endl;
} }
} }
...@@ -162,11 +162,7 @@ void ControlDock_MapTab::duplicateCurrentMap() ...@@ -162,11 +162,7 @@ void ControlDock_MapTab::duplicateCurrentMap()
{ {
if (m_selectedMap) if (m_selectedMap)
{ {
m_schnapps->duplicateMap(m_selectedMap->getName(),true); /*MapHandlerGen* mhg = */m_schnapps->duplicateMap(m_selectedMap->getName(), true);
// RECORDING
QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec)
*rec << "schnapps.duplicateMap(" << m_selectedMap->getName() << ".getName(),1);" << endl;
} }
} }
} }
...@@ -182,7 +178,6 @@ void ControlDock_MapTab::removeCurrentMap() ...@@ -182,7 +178,6 @@ void ControlDock_MapTab::removeCurrentMap()
QTextStream* rec = m_schnapps->pythonStreamRecorder(); QTextStream* rec = m_schnapps->pythonStreamRecorder();
if (rec) if (rec)
*rec << "schnapps.removeMap(" << m_selectedMap->getName() << ".getName());" << endl; *rec << "schnapps.removeMap(" << m_selectedMap->getName() << ".getName());" << endl;
setSelectedMap("NONE");
} }
} }
} }
......
...@@ -553,6 +553,11 @@ MapHandlerGen* SCHNApps::duplicateMap(const QString& name, bool properties) ...@@ -553,6 +553,11 @@ MapHandlerGen* SCHNApps::duplicateMap(const QString& name, bool properties)
if (m_maps.contains(newName)) if (m_maps.contains(newName))
return NULL; return NULL;
// RECORDING
QTextStream* rec = this->pythonStreamRecorder();
if (rec)
*rec << newName << " = schnapps.duplicateMap(" << name << ".getName(),1);" << endl;
MapHandlerGen* maph = m_maps[name]; MapHandlerGen* maph = m_maps[name];
MapHandlerGen* new_mh; MapHandlerGen* new_mh;
...@@ -564,16 +569,40 @@ MapHandlerGen* SCHNApps::duplicateMap(const QString& name, bool properties) ...@@ -564,16 +569,40 @@ MapHandlerGen* SCHNApps::duplicateMap(const QString& name, bool properties)
PFP2::MAP* map = new PFP2::MAP(); PFP2::MAP* map = new PFP2::MAP();
map->copyFrom(*(maph->getGenericMap())); map->copyFrom(*(maph->getGenericMap()));
new_mh = new MapHandler<PFP2>(newName, this, map); new_mh = new MapHandler<PFP2>(newName, this, map);
for (unsigned int orbit = VERTEX; orbit <= VOLUME; orbit++)
{
AttributeContainer& cont = map->getAttributeContainer(orbit);
std::vector<std::string> names;
std::vector<std::string> types;
cont.getAttributesNames(names);
cont.getAttributesTypes(types);
for (unsigned int i = 0; i < names.size(); ++i)
new_mh->registerAttribute(orbit, QString::fromStdString(names[i]), QString::fromStdString(types[i]));
}
break; break;
} }
case 3: { case 3: {
PFP3::MAP* map = new PFP3::MAP(); PFP3::MAP* map = new PFP3::MAP();
map->copyFrom(*(maph->getGenericMap())); map->copyFrom(*(maph->getGenericMap()));
new_mh = new MapHandler<PFP3>(newName, this, map); new_mh = new MapHandler<PFP3>(newName, this, map);
for (unsigned int orbit = VERTEX; orbit <= VOLUME; orbit++)
{
AttributeContainer& cont = map->getAttributeContainer(orbit);
std::vector<std::string> names;
std::vector<std::string> types;
cont.getAttributesNames(names);
cont.getAttributesTypes(types);
for (unsigned int i = 0; i < names.size(); ++i)
new_mh->registerAttribute(orbit, QString::fromStdString(names[i]), QString::fromStdString(types[i]));
}
break; break;
} }
} }
m_maps.insert(newName, new_mh); m_maps.insert(newName, new_mh);
DEBUG_EMIT("mapAdded"); DEBUG_EMIT("mapAdded");
emit(mapAdded(new_mh)); emit(mapAdded(new_mh));
...@@ -591,6 +620,8 @@ MapHandlerGen* SCHNApps::duplicateMap(const QString& name, bool properties) ...@@ -591,6 +620,8 @@ MapHandlerGen* SCHNApps::duplicateMap(const QString& name, bool properties)
} }
} }
pythonVarDeclare(new_mh->getName());
return new_mh; return new_mh;
} }
...@@ -642,8 +673,9 @@ void SCHNApps::removeMap(const QString& name) ...@@ -642,8 +673,9 @@ void SCHNApps::removeMap(const QString& name)
// unselect map if it is removed // unselect map if it is removed
if (this->getSelectedMap() == map) if (this->getSelectedMap() == map)
{
setSelectedMap(QString("NONE")); setSelectedMap(QString("NONE"));
}
delete map; delete map;
} }
} }
...@@ -905,6 +937,7 @@ void SCHNApps::beginPyRecording() ...@@ -905,6 +937,7 @@ void SCHNApps::beginPyRecording()
m_pyRecording = NULL; m_pyRecording = NULL;
m_pyRecFile = NULL; m_pyRecFile = NULL;
statusbar->showMessage(QString(" Stop recording python"), 2000); statusbar->showMessage(QString(" Stop recording python"), 2000);
action_Python_Recording->setText("Python Recording");
return; return;
} }
...@@ -927,6 +960,7 @@ void SCHNApps::beginPyRecording() ...@@ -927,6 +960,7 @@ void SCHNApps::beginPyRecording()
statusbar->showMessage(QString(" Recording python in ") + fileName); statusbar->showMessage(QString(" Recording python in ") + fileName);
pythonVarsClear(); pythonVarsClear();
action_Python_Recording->setText("Stop Python Recording");
} }
else else
{ {
...@@ -954,6 +988,7 @@ void SCHNApps::appendPyRecording() ...@@ -954,6 +988,7 @@ void SCHNApps::appendPyRecording()
m_pyRecording = NULL; m_pyRecording = NULL;
m_pyRecFile = NULL; m_pyRecFile = NULL;
statusbar->showMessage(QString(" Stop recording python"), 2000); statusbar->showMessage(QString(" Stop recording python"), 2000);
action_Append_Python_Recording->setText("Append Python Recording");
return; return;
} }
...@@ -978,7 +1013,7 @@ void SCHNApps::appendPyRecording() ...@@ -978,7 +1013,7 @@ void SCHNApps::appendPyRecording()
} }
statusbar->showMessage(QString(" Append recording python in ") + fileName); statusbar->showMessage(QString(" Append recording python in ") + fileName);
action_Append_Python_Recording->setText("Stop Append Python Recording");
} }
else else
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment