mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
undo: more fine-grained editing of cylinder
Don't overwrite the full cylinder when editing a single field. Implement three "modes": editing of type, pressure and gasmix. Don't consider individual fields, because some of them are related. E.g. you can change the gasmix by setting the MOD. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
4e8a838f74
commit
2eeb5f4fc2
7 changed files with 64 additions and 22 deletions
|
@ -1151,9 +1151,23 @@ void RemoveCylinder::redo()
|
|||
}
|
||||
}
|
||||
|
||||
static int editCylinderTypeToFlags(EditCylinderType type)
|
||||
{
|
||||
switch (type) {
|
||||
default:
|
||||
case EditCylinderType::TYPE:
|
||||
return SAME_TYPE | SAME_SIZE;
|
||||
case EditCylinderType::PRESSURE:
|
||||
return SAME_PRESS;
|
||||
case EditCylinderType::GASMIX:
|
||||
return SAME_GAS;
|
||||
}
|
||||
}
|
||||
|
||||
// ***** Edit Cylinder *****
|
||||
EditCylinder::EditCylinder(int index, cylinder_t cylIn, bool currentDiveOnly) :
|
||||
EditCylinderBase(index, currentDiveOnly, false, SAME_TYPE | SAME_PRESS | SAME_GAS)
|
||||
EditCylinder::EditCylinder(int index, cylinder_t cylIn, EditCylinderType typeIn, bool currentDiveOnly) :
|
||||
EditCylinderBase(index, currentDiveOnly, false, editCylinderTypeToFlags(typeIn)),
|
||||
type(typeIn)
|
||||
{
|
||||
if (dives.empty())
|
||||
return;
|
||||
|
@ -1184,9 +1198,23 @@ EditCylinder::EditCylinder(int index, cylinder_t cylIn, bool currentDiveOnly) :
|
|||
|
||||
// The base class copied the cylinders for us, let's edit them
|
||||
for (int i = 0; i < (int)indexes.size(); ++i) {
|
||||
free_cylinder(cyl[i]);
|
||||
cyl[i] = cylIn;
|
||||
cyl[i].type.description = copy_qstring(description);
|
||||
switch (type) {
|
||||
case EditCylinderType::TYPE:
|
||||
free((void *)cyl[i].type.description);
|
||||
cyl[i].type = cylIn.type;
|
||||
cyl[i].type.description = copy_qstring(description);
|
||||
cyl[i].cylinder_use = cylIn.cylinder_use;
|
||||
break;
|
||||
case EditCylinderType::PRESSURE:
|
||||
cyl[i].start.mbar = cylIn.start.mbar;
|
||||
cyl[i].end.mbar = cylIn.end.mbar;
|
||||
break;
|
||||
case EditCylinderType::GASMIX:
|
||||
cyl[i].gasmix = cylIn.gasmix;
|
||||
cyl[i].bestmix_o2 = cylIn.bestmix_o2;
|
||||
cyl[i].bestmix_he = cylIn.bestmix_he;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue