Commit b6cee752 authored by Mike Kremer's avatar Mike Kremer

Integrated scripting functions and key shortcuts.

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13909 383ad7c9-94d9-4d36-a494-682f7c89f535
parent d22d922e
......@@ -561,16 +561,16 @@ VolumeMeshSelectionPlugin::HFPair VolumeMeshSelectionPlugin::getCommonFace(const
void VolumeMeshSelectionPlugin::loadSelection(int _objId, const QString& _filename) {
// // Load ini file
// INIFile file;
//
// if(!file.connect(_filename, false)) {
// emit log(LOGERR, QString("Could not read file '%1'!").arg(_filename));
// return;
// }
//
// // Load selection from file
// loadIniFile(file, _objId);
// // Load ini file
// INIFile file;
//
// if(!file.connect(_filename, false)) {
// emit log(LOGERR, QString("Could not read file '%1'!").arg(_filename));
// return;
// }
//
// // Load selection from file
// loadIniFile(file, _objId);
}
//==============================================================================================
......@@ -591,54 +591,73 @@ void VolumeMeshSelectionPlugin::saveIniFile(INIFile& _ini, int _id) {
void VolumeMeshSelectionPlugin::slotLoadSelection(const INIFile& _file) {
// // Iterate over all volumemesh objects in the scene and save
// // the selections for all supported entity types
// for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DataType(DATA_POLY_VOLUME_MESH | DATA_HEX_VOLUME_MESH));
// o_it != PluginFunctions::objectsEnd(); ++o_it) {
//
// // Read section for each object
// // Append object name to section identifier
// QString section = QString("VolumeMeshSelection") + "//" + o_it->name();
// if(!_file.section_exists(section)) {
// continue;
// }
//
// std::vector<int> ids;
// // Load vertex selection:
// _file.get_entry(ids, section, "VertexSelection");
// selectVertices(o_it->id(), ids);
// ids.clear();
// // Load edge selection:
// _file.get_entry(ids, section, "EdgeSelection");
// selectEdges(o_it->id(), ids);
// ids.clear();
//
// emit updatedObject(o_it->id(), UPDATE_SELECTION);
// }
// Iterate over all polyhedral mesh objects in the scene and save
// the selections for all supported entity types
for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DataType(DATA_POLYHEDRAL_MESH | DATA_HEXAHEDRAL_MESH));
o_it != PluginFunctions::objectsEnd(); ++o_it) {
// Read section for each object
// Append object name to section identifier
QString section = QString("PolyhedralMeshSelection") + "//" + o_it->name();
if(!_file.section_exists(section)) {
continue;
}
std::vector<int> ids;
// Load vertex selection:
_file.get_entry(ids, section, "VertexSelection");
selectVertices(o_it->id(), ids);
ids.clear();
// Load edge selection:
_file.get_entry(ids, section, "EdgeSelection");
selectEdges(o_it->id(), ids);
ids.clear();
// Load half-edge selection:
_file.get_entry(ids, section, "HalfEdgeSelection");
selectHalfEdges(o_it->id(), ids);
ids.clear();
// Load face selection:
_file.get_entry(ids, section, "FaceSelection");
selectFaces(o_it->id(), ids);
ids.clear();
// Load half-face selection:
_file.get_entry(ids, section, "HalfFaceSelection");
selectHalfFaces(o_it->id(), ids);
ids.clear();
// Load cell selection:
_file.get_entry(ids, section, "CellSelection");
selectCells(o_it->id(), ids);
ids.clear();
}
}
//==============================================================================================
void VolumeMeshSelectionPlugin::slotSaveSelection(INIFile& _file) {
// // Iterate over all volumemesh objects in the scene and save
// // the selections for all vertices
// for (PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS, DataType(DATA_POLY_VOLUME_MESH | DATA_HEX_VOLUME_MESH));
// o_it != PluginFunctions::objectsEnd(); ++o_it) {
//
// // Create section for each object
// // Append object name to section identifier
// QString section = QString("VolumeMeshSelection") + "//" + o_it->name();
// if(!_file.section_exists(section)) {
// _file.add_section(section);
// } else {
// continue;
// }
//
// // Store vertex selection:
// _file.add_entry(section, "VertexSelection", getVertexSelection(o_it->id()));
// _file.add_entry(section, "EdgeSelection", getEdgeSelection(o_it->id()));
// }
// Iterate over all volumemesh objects in the scene and save
// the selections for all vertices
for(PluginFunctions::ObjectIterator o_it(PluginFunctions::ALL_OBJECTS,
DataType(DATA_POLYHEDRAL_MESH | DATA_HEXAHEDRAL_MESH));
o_it != PluginFunctions::objectsEnd(); ++o_it) {
// Create section for each object
// Append object name to section identifier
QString section = QString("PolyhedralMeshSelection") + "//" + o_it->name();
if(!_file.section_exists(section)) {
_file.add_section(section);
} else {
continue;
}
// Store vertex selection:
_file.add_entry(section, "VertexSelection", getVertexSelection(o_it->id()));
_file.add_entry(section, "EdgeSelection", getEdgeSelection(o_it->id()));
_file.add_entry(section, "HalfEdgeSelection", getHalfEdgeSelection(o_it->id()));
_file.add_entry(section, "FaceSelection", getFaceSelection(o_it->id()));
_file.add_entry(section, "HalfFaceSelection", getHalfFaceSelection(o_it->id()));
_file.add_entry(section, "CellSelection", getCellSelection(o_it->id()));
}
}
//==============================================================================================
......@@ -660,48 +679,66 @@ void VolumeMeshSelectionPlugin::slotKeyShortcutEvent(int _key, Qt::KeyboardModif
PluginFunctions::IteratorRestriction restriction = (targetsOnly ? PluginFunctions::TARGET_OBJECTS
: PluginFunctions::ALL_OBJECTS);
// if(_key == Qt::Key_A && _modifiers == Qt::ControlModifier) {
// // Select all vertices
// for (PluginFunctions::ObjectIterator o_it(restriction, DataType(DATA_POLY_VOLUME_MESH | DATA_HEX_VOLUME_MESH));
// o_it != PluginFunctions::objectsEnd(); ++o_it) {
// if (o_it->visible()) {
// if(type & vertexType_)
// selectAllVertices(o_it->id());
// if(type & edgeType_)
// selectAllEdges(o_it->id());
// }
// emit updatedObject(o_it->id(), UPDATE_SELECTION);
// }
// } else if(_key == Qt::Key_C && _modifiers == Qt::NoModifier) {
// // Deselect all vertices
// for (PluginFunctions::ObjectIterator o_it(restriction, DataType(DATA_POLY_VOLUME_MESH | DATA_HEX_VOLUME_MESH));
// o_it != PluginFunctions::objectsEnd(); ++o_it) {
// if (o_it->visible()) {
// if(type & vertexType_)
// deselectAllVertices(o_it->id());
// if(type & edgeType_)
// deselectAllEdges(o_it->id());
// }
// emit updatedObject(o_it->id(), UPDATE_SELECTION);
// }
// } else if(_key == Qt::Key_I && _modifiers == Qt::NoModifier) {
// // Invert vertex selection
// for (PluginFunctions::ObjectIterator o_it(restriction, DataType(DATA_POLY_VOLUME_MESH | DATA_HEX_VOLUME_MESH));
// o_it != PluginFunctions::objectsEnd(); ++o_it) {
// if (o_it->visible()) {
// if(type & vertexType_)
// invertVertexSelection(o_it->id());
// if(type & edgeType_)
// invertEdgeSelection(o_it->id());
// }
// emit updatedObject(o_it->id(), UPDATE_SELECTION);
// }
if(_key == Qt::Key_Delete && _modifiers == Qt::NoModifier) {
// Delete selected vertices and its children
for(PluginFunctions::ObjectIterator o_it(restriction, DataType(DATA_POLYHEDRAL_MESH | DATA_HEXAHEDRAL_MESH)); o_it
!= PluginFunctions::objectsEnd(); ++o_it) {
if(_key == Qt::Key_A && _modifiers == Qt::ControlModifier) {
// Select all entities
for (PluginFunctions::ObjectIterator o_it(restriction, DataType(DATA_POLYHEDRAL_MESH | DATA_HEXAHEDRAL_MESH));
o_it != PluginFunctions::objectsEnd(); ++o_it) {
if (o_it->visible()) {
if(type & vertexType_)
selectAllVertices(o_it->id());
if(type & edgeType_)
selectAllEdges(o_it->id());
if(type & faceType_)
selectAllFaces(o_it->id());
if(type & cellType_)
selectAllCells(o_it->id());
}
emit updatedObject(o_it->id(), UPDATE_SELECTION);
}
} else if(_key == Qt::Key_C && _modifiers == Qt::NoModifier) {
// Deselect all entities
for (PluginFunctions::ObjectIterator o_it(restriction, DataType(DATA_POLYHEDRAL_MESH | DATA_HEXAHEDRAL_MESH));
o_it != PluginFunctions::objectsEnd(); ++o_it) {
if (o_it->visible()) {
if(type & vertexType_)
deselectAllVertices(o_it->id());
if(type & edgeType_)
deselectAllEdges(o_it->id());
if(type & faceType_)
deselectAllFaces(o_it->id());
if(type & cellType_)
deselectAllCells(o_it->id());
}
emit updatedObject(o_it->id(), UPDATE_SELECTION);
}
} else if(_key == Qt::Key_I && _modifiers == Qt::NoModifier) {
// Invert entity selection
for (PluginFunctions::ObjectIterator o_it(restriction, DataType(DATA_POLYHEDRAL_MESH | DATA_HEXAHEDRAL_MESH));
o_it != PluginFunctions::objectsEnd(); ++o_it) {
if (o_it->visible()) {
if(type & vertexType_)
invertVertexSelection(o_it->id());
if(type & edgeType_)
invertEdgeSelection(o_it->id());
if(type & faceType_)
invertFaceSelection(o_it->id());
if(type & cellType_)
invertCellSelection(o_it->id());
}
emit updatedObject(o_it->id(), UPDATE_SELECTION);
}
} else if(_key == Qt::Key_Delete && _modifiers == Qt::NoModifier) {
// Delete selected entities and its children
for(PluginFunctions::ObjectIterator o_it(restriction, DataType(DATA_POLYHEDRAL_MESH | DATA_HEXAHEDRAL_MESH));
o_it != PluginFunctions::objectsEnd(); ++o_it) {
if(o_it->visible()) {
if(type & vertexType_)
deleteSelectedVertices(o_it->id());
if(type & edgeType_)
deleteSelectedEdges(o_it->id());
if(type & faceType_)
deleteSelectedFaces(o_it->id());
if(type & cellType_)
deleteSelectedCells(o_it->id());
}
......
......@@ -176,74 +176,117 @@ public slots:
* @{ */
//===========================================================================
// /// Select all vertices of a volume mesh
// void selectAllVertices(int _objectId);
//
// /// Deselect all vertices of a volume mesh
// void deselectAllVertices(int _objectId);
//
// /// Invert vertex selection
// void invertVertexSelection(int _objectId);
//
// /// Select specific vertices of a volume mesh
// void selectVertices(int _objectId, const IdList _ids, bool _deselect = false);
//
// /// Get current vertex selection
// IdList getVertexSelection(int _objectId);
//
// //===========================================================================
//
// /// Select all edges of a volume mesh
// void selectAllEdges(int _objectId);
//
// /// Deselect all edges of a volume mesh
// void deselectAllEdges(int _objectId);
//
// /// Invert edge selection
// void invertEdgeSelection(int _objectId);
//
// /// Select specific edges of a volume mesh
// void selectEdges(int _objectId, const IdList _ids, bool _deselect = false);
//
// /// Get current edge selection
// IdList getEdgeSelection(int _objectId);
//
// //===========================================================================
//
// /// Select all faces of a volume mesh
// void selectAllFaces(int _objectId);
//
// /// Deselect all faces of a volume mesh
// void deselectAllFaces(int _objectId);
//
// /// Invert face selection
// void invertFaceSelection(int _objectId);
//
// /// Select specific faces of a volume mesh
// void selectFaces(int _objectId, const IdList _ids, bool _deselect = false);
//
// /// Get current face selection
// IdList getFaceSelection(int _objectId);
//
// //===========================================================================
//
// /// Select all cells of a volume mesh
// void selectAllCells(int _objectId);
//
// /// Deselect all cells of a volume mesh
// void deselectAllCells(int _objectId);
//
// /// Invert cell selection
// void invertCellSelection(int _objectId);
//
// /// Select specific cells of a volume mesh
// void selectCells(int _objectId, const IdList _ids, bool _deselect = false);
//
// /// Get current cell selection
// IdList getCellSelection(int _objectId);
/// Select all vertices of a volume mesh
void selectAllVertices(int _objectId);
/// Deselect all vertices of a volume mesh
void deselectAllVertices(int _objectId);
/// Invert vertex selection
void invertVertexSelection(int _objectId);
/// Select specific vertices of a volume mesh
void selectVertices(int _objectId, const IdList _ids, bool _deselect = false);
/// Get current vertex selection
IdList getVertexSelection(int _objectId);
/// Delete selected vertices from mesh
void deleteSelectedVertices(int _objectId, bool _preserveManifoldness = true);
//===========================================================================
/// Select all edges of a volume mesh
void selectAllEdges(int _objectId);
/// Deselect all edges of a volume mesh
void deselectAllEdges(int _objectId);
/// Invert edge selection
void invertEdgeSelection(int _objectId);
/// Select specific edges of a volume mesh
void selectEdges(int _objectId, const IdList _ids, bool _deselect = false);
/// Get current edge selection
IdList getEdgeSelection(int _objectId);
/// Delete selected edges from mesh
void deleteSelectedEdges(int _objectId, bool _preserveManifoldness = true);
//===========================================================================
/// Select all half-edges of a volume mesh
void selectAllHalfEdges(int _objectId);
/// Deselect all half-edges of a volume mesh
void deselectAllHalfEdges(int _objectId);
/// Invert half-edge selection
void invertHalfEdgeSelection(int _objectId);
/// Select specific half-edges of a volume mesh
void selectHalfEdges(int _objectId, const IdList _ids, bool _deselect = false);
/// Get current half-edge selection
IdList getHalfEdgeSelection(int _objectId);
//===========================================================================
/// Select all faces of a volume mesh
void selectAllFaces(int _objectId);
/// Deselect all faces of a volume mesh
void deselectAllFaces(int _objectId);
/// Invert face selection
void invertFaceSelection(int _objectId);
/// Select specific faces of a volume mesh
void selectFaces(int _objectId, const IdList _ids, bool _deselect = false);
/// Get current face selection
IdList getFaceSelection(int _objectId);
/// Delete selected faces from mesh
void deleteSelectedFaces(int _objectId, bool _preserveManifoldness = true);
//===========================================================================
/// Select all half-faces of a volume mesh
void selectAllHalfFaces(int _objectId);
/// Deselect all half-faces of a volume mesh
void deselectAllHalfFaces(int _objectId);
/// Invert half-face selection
void invertHalfFaceSelection(int _objectId);
/// Select specific half-faces of a volume mesh
void selectHalfFaces(int _objectId, const IdList _ids, bool _deselect = false);
/// Get current half-face selection
IdList getHalfFaceSelection(int _objectId);
//===========================================================================
/// Select all cells of a volume mesh
void selectAllCells(int _objectId);
/// Deselect all cells of a volume mesh
void deselectAllCells(int _objectId);
/// Invert cell selection
void invertCellSelection(int _objectId);
/// Select specific cells of a volume mesh
void selectCells(int _objectId, const IdList _ids, bool _deselect = false);
/// Get current cell selection
IdList getCellSelection(int _objectId);
/// Delete selected cells from mesh
void deleteSelectedCells(int _objectId);
void deleteSelectedCells(int _objectId, bool _preserveManifoldness = true);
/** @} */
......
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