Commit 75440a67 authored by Emmanuel Promayon's avatar Emmanuel Promayon
Browse files

FIXED coding covention simple spacing (using astyle)



This is the result of running a basic
astyle --style=java -R *.cpp *.h
Signed-off-by: Emmanuel Promayon's avatarEmmanuel Promayon <Emmanuel.Promayon@imag.fr>
parent df40af82
......@@ -211,7 +211,7 @@ vtkSmartPointer<vtkImageData> Derivative::itkProcess(vtkSmartPointer<vtkImageDat
resultImage->GetExtent(extent);
result->SetExtent(extent);
result->DeepCopy(resultImage);
// Set CamiTK progress bar back to zero (the processing filter is over)
observer->Reset();
......
......@@ -174,7 +174,7 @@ void MMLComponent::connectPml() {
pmlComponent = new PMLComponent( mmlGUI->getMonitoringManager()->takePml(), mmlGUI->getMonitoringManager()->getPmlFileName().c_str());
addChild(pmlComponent);
refreshInterfaceNode();
// This is forced refresh (bad, breaking rules)
// TODO: refresh should be called in the MMLDisplay connectPml() method instead)
pmlComponent->refresh();
......
......@@ -171,7 +171,7 @@ public:
/// Warning: this methods contains a forced/active refresh (breaking CamiTK programming guidelines)
/// DO NOT CALL this method from a component, this method SHOULD ONLY be called from an action
/// Raison d'être : this method force the vtk pipeline updates (needed when, for example, the points moved)
/// and then refresh the 3D viewer. The later is against CamiTK programming guidelines.
/// and then refresh the 3D viewer. The later is against CamiTK programming guidelines.
/// It is written here (in the component) because it is a helper method for actions
/// that would need to refresh the mesh.
void refreshDisplay();
......
......@@ -43,186 +43,186 @@ using namespace camitk;
// --------------- getName -------------------
QString PMLComponentExtension::getName() const {
return "PML Component";
return "PML Component";
}
// --------------- getDescription -------------------
QString PMLComponentExtension::getDescription() const {
return "<b>New PML COMPONENT!</b>";// Manage Physical Model <em>.pml</em> files in <b>CamiTK</b>.<br/>CamiTK was initially mainly developed to support this format. Lots of things are possible with a physical model!";
return "<b>New PML COMPONENT!</b>";// Manage Physical Model <em>.pml</em> files in <b>CamiTK</b>.<br/>CamiTK was initially mainly developed to support this format. Lots of things are possible with a physical model!";
}
// --------------- getFileExtensions -------------------
QStringList PMLComponentExtension::getFileExtensions() const {
QStringList ext;
ext << "pml";
return ext;
QStringList ext;
ext << "pml";
return ext;
}
// --------------- open -------------------
camitk::Component * PMLComponentExtension::open(const QString & fileName) throw(AbortException) {
Application::showStatusBarMessage("Loading " + fileName + "...");
Application::showStatusBarMessage("Loading " + fileName + "...");
// instanciate the component
PMLComponent * pmlComponent = new PMLComponent(fileName);
// instanciate the component
PMLComponent * pmlComponent = new PMLComponent(fileName);
// reset the progress bar
Application::resetProgressBar();
// reset the progress bar
Application::resetProgressBar();
return pmlComponent;
return pmlComponent;
}
// --------------- save -------------------
bool PMLComponentExtension::save(camitk::Component * component) const {
PMLComponent * comp = dynamic_cast<PMLComponent *>(component);
if (comp) {
// easy!
// Just generate an ostream from the filename and then xmlPrint pop
std::ofstream outputFile(comp->getFileName().toStdString().c_str());
comp->getPhysicalModel()->xmlPrint(outputFile);
outputFile.close();
comp->setModified(false);
return true;
} else {
// save from generic MeshComponent
MeshComponent * meshComp = dynamic_cast<MeshComponent *>(component);
if (meshComp && meshComp->getPointSet()->GetNumberOfPoints() > 0) {
//-- create a new physical model
PhysicalModel * newPM = new PhysicalModel();
// extract the atoms from the Geometry
vtkSmartPointer<vtkPoints> thePoints = vtkSmartPointer<vtkPoints>::New();
thePoints->DeepCopy(meshComp->getPointSet()->GetPoints());
//-- create the structural components for the atoms
StructuralComponent * theAtoms = new StructuralComponent(newPM, "All Atoms");
double pos[3];
// create the atom structures
for (int i = 0; i < thePoints->GetNumberOfPoints(); i++) {
thePoints->GetPoint(i, pos);
theAtoms->addStructure(new Atom(newPM, pos), false);
}
// set the atom sc
newPM->setAtoms(theAtoms);
//-- create the unique structural components containing all the vtkCell, this is an exclusive component
unsigned int nrOfCells = meshComp->getPointSet()->GetNumberOfCells();
StructuralComponent * sc = new StructuralComponent(newPM, "All Cells");
// fill in this new structural component with all vtk cells
for (vtkIdType i = 0; i < (vtkIdType) nrOfCells; i++) {
// create a cell for each cell
vtkCell * theCell = meshComp->getPointSet()->GetCell(i);
// translate cell type
StructureProperties::GeometricType cellType;
switch (theCell->GetCellType()) {
case VTK_TETRA:
cellType = StructureProperties::TETRAHEDRON;
break;
case VTK_HEXAHEDRON:
cellType = StructureProperties::HEXAHEDRON;
break;
case VTK_WEDGE:
cellType = StructureProperties::WEDGE;
break;
case VTK_PYRAMID:
cellType = StructureProperties::PYRAMID;
break;
case VTK_LINE:
cellType = StructureProperties::LINE;
break;
case VTK_POLY_LINE:
cellType = StructureProperties::POLY_LINE;
break;
case VTK_POLY_VERTEX:
cellType = StructureProperties::POLY_VERTEX;
break;
case VTK_TRIANGLE:
cellType = StructureProperties::TRIANGLE;
break;
case VTK_QUAD:
cellType = StructureProperties::QUAD;
break;
default:
cellType = StructureProperties::INVALID;
break;
}
// create the corresponding PML cell
Cell * c = new Cell(newPM, cellType);
// fill-in the cell structures (atoms)
for (int i = 0; i < theCell->GetNumberOfPoints(); i++) {
// get the corresponding atom
Atom * a = newPM->getAtom(theCell->GetPointId(i)); // dynamic_cast<Atom *>(theAtoms->getStructure(theCell->GetPointId(i)));
// set the corresponding atom as a structure composing the cell
c->addStructure(a, false);
}
// insert the cell in the structure
sc->addStructure(c, false);
}
// create the exclusive multi-component
MultiComponent * exclusiveComponents = new MultiComponent(newPM);
// insert all the cells (i.e. the sc component)
exclusiveComponents->addSubComponent(sc);
exclusiveComponents->setName("Exclusive Components");
// insert this exclusive component into the pm
newPM->setExclusiveComponents(exclusiveComponents);
// create the informative components from the selection
MultiComponent * informativeComponents =
new MultiComponent(newPM, "Informative Components");
newPM->setInformativeComponents(informativeComponents);
StructuralComponent* scinf;
vtkSmartPointer<vtkAbstractArray> idArray;
std::string selName;
for (int i=0; i<meshComp->getNumberOfSelections(); i++) {
// TODO : test if it is a cell selection
selName = meshComp->getSelectionAt(i)->GetSelectionList()->GetName();
scinf = new StructuralComponent(newPM, selName);
idArray = meshComp->getSelectionAt(i)->GetSelectionList();
for (int j=0; j<idArray->GetNumberOfTuples(); j++) {
Cell* c = sc->getCell(idArray->GetVariantValue(j).ToInt());
// TODO : this don't work with the Explore PML Component
// since it use cellRef that are not managed
scinf->addStructure(c, false);
}
// add the selection component to the informative components.
newPM->getInformativeComponents()->addSubComponent(scinf);
}
// save it!
std::ofstream outputFile(meshComp->getFileName().toStdString().c_str());
newPM->xmlPrint(outputFile);
meshComp->setModified(false);
outputFile.close();
return true;
PMLComponent * comp = dynamic_cast<PMLComponent *>(component);
if (comp) {
// easy!
// Just generate an ostream from the filename and then xmlPrint pop
std::ofstream outputFile(comp->getFileName().toStdString().c_str());
comp->getPhysicalModel()->xmlPrint(outputFile);
outputFile.close();
comp->setModified(false);
return true;
} else {
// save from generic MeshComponent
MeshComponent * meshComp = dynamic_cast<MeshComponent *>(component);
if (meshComp && meshComp->getPointSet()->GetNumberOfPoints() > 0) {
//-- create a new physical model
PhysicalModel * newPM = new PhysicalModel();
// extract the atoms from the Geometry
vtkSmartPointer<vtkPoints> thePoints = vtkSmartPointer<vtkPoints>::New();
thePoints->DeepCopy(meshComp->getPointSet()->GetPoints());
//-- create the structural components for the atoms
StructuralComponent * theAtoms = new StructuralComponent(newPM, "All Atoms");
double pos[3];
// create the atom structures
for (int i = 0; i < thePoints->GetNumberOfPoints(); i++) {
thePoints->GetPoint(i, pos);
theAtoms->addStructure(new Atom(newPM, pos), false);
}
// set the atom sc
newPM->setAtoms(theAtoms);
//-- create the unique structural components containing all the vtkCell, this is an exclusive component
unsigned int nrOfCells = meshComp->getPointSet()->GetNumberOfCells();
StructuralComponent * sc = new StructuralComponent(newPM, "All Cells");
// fill in this new structural component with all vtk cells
for (vtkIdType i = 0; i < (vtkIdType) nrOfCells; i++) {
// create a cell for each cell
vtkCell * theCell = meshComp->getPointSet()->GetCell(i);
// translate cell type
StructureProperties::GeometricType cellType;
switch (theCell->GetCellType()) {
case VTK_TETRA:
cellType = StructureProperties::TETRAHEDRON;
break;
case VTK_HEXAHEDRON:
cellType = StructureProperties::HEXAHEDRON;
break;
case VTK_WEDGE:
cellType = StructureProperties::WEDGE;
break;
case VTK_PYRAMID:
cellType = StructureProperties::PYRAMID;
break;
case VTK_LINE:
cellType = StructureProperties::LINE;
break;
case VTK_POLY_LINE:
cellType = StructureProperties::POLY_LINE;
break;
case VTK_POLY_VERTEX:
cellType = StructureProperties::POLY_VERTEX;
break;
case VTK_TRIANGLE:
cellType = StructureProperties::TRIANGLE;
break;
case VTK_QUAD:
cellType = StructureProperties::QUAD;
break;
default:
cellType = StructureProperties::INVALID;
break;
}
// create the corresponding PML cell
Cell * c = new Cell(newPM, cellType);
// fill-in the cell structures (atoms)
for (int i = 0; i < theCell->GetNumberOfPoints(); i++) {
// get the corresponding atom
Atom * a = newPM->getAtom(theCell->GetPointId(i)); // dynamic_cast<Atom *>(theAtoms->getStructure(theCell->GetPointId(i)));
// set the corresponding atom as a structure composing the cell
c->addStructure(a, false);
}
// insert the cell in the structure
sc->addStructure(c, false);
}
// create the exclusive multi-component
MultiComponent * exclusiveComponents = new MultiComponent(newPM);
// insert all the cells (i.e. the sc component)
exclusiveComponents->addSubComponent(sc);
exclusiveComponents->setName("Exclusive Components");
// insert this exclusive component into the pm
newPM->setExclusiveComponents(exclusiveComponents);
// create the informative components from the selection
MultiComponent * informativeComponents =
new MultiComponent(newPM, "Informative Components");
newPM->setInformativeComponents(informativeComponents);
StructuralComponent* scinf;
vtkSmartPointer<vtkAbstractArray> idArray;
std::string selName;
for (int i=0; i<meshComp->getNumberOfSelections(); i++) {
// TODO : test if it is a cell selection
selName = meshComp->getSelectionAt(i)->GetSelectionList()->GetName();
scinf = new StructuralComponent(newPM, selName);
idArray = meshComp->getSelectionAt(i)->GetSelectionList();
for (int j=0; j<idArray->GetNumberOfTuples(); j++) {
Cell* c = sc->getCell(idArray->GetVariantValue(j).ToInt());
// TODO : this don't work with the Explore PML Component
// since it use cellRef that are not managed
scinf->addStructure(c, false);
}
// add the selection component to the informative components.
newPM->getInformativeComponents()->addSubComponent(scinf);
}
// save it!
std::ofstream outputFile(meshComp->getFileName().toStdString().c_str());
newPM->xmlPrint(outputFile);
meshComp->setModified(false);
outputFile.close();
return true;
}
}
}
return false;
return false;
}
......@@ -32,7 +32,7 @@ AtomIterator::AtomIterator(PhysicalModel* pml, std::string targetList) {
for(unsigned int i=0; i<tlist.getNumberOfTargets(); i++) {
atoms.push_back(pml->getAtom(tlist.getIndexedTarget(i)));
}
} else {
} else {
for(unsigned int i=0; i<tlist.getNumberOfTargets(); i++) {
StructuralComponent *sc = dynamic_cast<StructuralComponent *>(pml->getComponentByName(tlist.getNamedTarget(i)));
if (sc) {
......
......@@ -58,8 +58,8 @@ std::string MonitorVolume::getTypeName() {
}
// -------------------- write --------------------
void MonitorVolume::write(){
// write data
void MonitorVolume::write() {
// write data
std::string s = "";
for (unsigned int i = 0; i < values.size(); i++) {
std::ostringstream ss;
......
......@@ -51,7 +51,7 @@ public:
/// return a string relative to monitor type
std::string getTypeName();
virtual void write();
};
......
......@@ -33,15 +33,14 @@
// -------------------- constructor --------------------
Position::Position(mml::Position* c,MonitoringManager* monitoringManager, MultipleCriterion* parent): Criterion(c,monitoringManager,parent) {
if (c->target().present()) {
target=c->target().get();
}
else {
} else {
// if target is not provided, use all atoms
target = monitoringManager->getPml()->getAtoms()->getName();
}
switch (c->unit()) {
case mml::PositionUnit::nm:
factor = 1000000;
......
......@@ -53,7 +53,7 @@ public:
private:
/// calculate stopping criteria data and store it into values vector
void calculate();
/// the monitor targets describe as an LML TargetList string (e.g. "1-4,5"), @see TargetList
std::string target;
};
......
......@@ -40,7 +40,7 @@ bool TimePeriodThreshold::individualTest(double tested) {
if (tested <= value) {
increment--;
} else {
increment = iterations;
increment = iterations;
}
return (increment == 0);
}
......
......@@ -57,13 +57,13 @@ public:
private:
/// value of the threshold
double value;
/// number of iterations defining the time period
int iterations;
/// Needed to keep an eye on consecutive win
int increment;
/// the xsdcxx object representing TimePeriodThreshold, used for serialization
mml::TimePeriodThreshold* mappedObject;
......
......@@ -552,12 +552,12 @@ Component * PhysicalModel::getComponentByName ( const std::string n ) {
if ( !foundC && informativeComponents ) {
foundC = informativeComponents->getComponentByName ( n );
}
//-- at last, just in case, look if this is not the name of the atoms SC
if ( !foundC && getAtoms()->getName() == n) {
foundC = getAtoms();
}
return foundC;
}
......
......@@ -40,7 +40,7 @@ OpenAction::OpenAction (ActionExtension * extension) : Action (extension) {
setEmbedded (false);
setDescription (tr("Open data (component) from a file"));
setComponent ("");
// Setting classification family and tags
setFamily ("Application");
addTag (tr("Open"));
......
......@@ -223,7 +223,7 @@ Action::ApplyStatus EditFrame::apply() {
//--------------- save ------------
void EditFrame::save() {
QString filename = QFileDialog::getSaveFileName(NULL, tr("Save Frame File"), "/home/myFrame.frame", tr("Frames (*.frame)"));
QString filename = QFileDialog::getSaveFileName(NULL, tr("Save Frame File"), "/home/myFrame.frame", tr("Frames (*.frame)"));
QFile file(filename);
if (file.open(QIODevice::WriteOnly)) {
QTextStream stream(&file);
......@@ -278,7 +278,7 @@ void EditFrame::save() {
void EditFrame::load() {
// choose the file to open
QString fileName = QFileDialog::getOpenFileName(NULL, tr("Open Frame File"), "/home", tr("Frames (*.frame)"));
QString fileName = QFileDialog::getOpenFileName(NULL, tr("Open Frame File"), "/home", tr("Frames (*.frame)"));
QFile file(fileName);
if(file.open(QIODevice::ReadOnly)) {
QDomDocument doc("frame");
......
......@@ -130,7 +130,7 @@ void MultiPickingWidget::updateTable() {
header = headerString.split(",");
ui.pointsTableWidget->setHorizontalHeaderLabels (header);
createItems (pPM->getPixelIndexList(), pPM->getPixelValueList());
} else if (ui.coordinatesRadioButton->isChecked()){
} else if (ui.coordinatesRadioButton->isChecked()) {
// case of image coordinates
headerString = QString(HEADER_TABLE_IMG);
header = headerString.split(",");
......@@ -316,35 +316,35 @@ void MultiPickingWidget::manuallyModified(int i, int j) {
int iPick = ui.pointsTableWidget->item(i, X_TABLE_INDEX)->text().toInt();
int jPick = ui.pointsTableWidget->item(i, Y_TABLE_INDEX)->text().toInt();
int kPick = ui.pointsTableWidget->item(i, Z_TABLE_INDEX)->text().toInt();
// Exceptionnally, we do not make this calculation by image picking and use image voxel size
// to mimick a picking from the axial slice.
double x = iPick * voxSize.x();
double y = jPick * voxSize.y();
double z = kPick * voxSize.z();
// check that this point is within image dimensions
if (((x < 0) || (x > imageDims[0]*voxSize.x())) ||
((y < 0) || (y > imageDims[1]*voxSize.y())) ||
((z < 0) || (z > imageDims[2]*voxSize.z()))) {
((y < 0) || (y > imageDims[1]*voxSize.y())) ||
((z < 0) || (z > imageDims[2]*voxSize.z()))) {
QString msg = "The point (" + QString::number(x) + ", " + QString::number(y) + ", " + QString::number(z) + "), does not belong to the image " + img->getName() + ". Sorry...";
QMessageBox::warning(this, "Impossible Operation", msg);
updateTable();
return;
}
// If right pixel, pick the image at this point
// Cheat ! Say that your are its axial slice...
img->getAxialSlices()->setSlice(z);
img->pixelPicked(x, y, z, img->getAxialSlices());
Application::refresh();
pPM->modifyPixel(i);
updateTable();
} else{ // Image Coordinates
} else { // Image Coordinates
int * imageDims = img->getImageData()->GetDimensions();
QVector3D voxSize = img->getVoxelSize();
// Change the pixel index at this row
......@@ -354,26 +354,26 @@ void MultiPickingWidget::manuallyModified(int i, int j) {
double x = ui.pointsTableWidget->item(i, X_TABLE_INDEX)->text().toDouble();
double y = ui.pointsTableWidget->item(i, Y_TABLE_INDEX)->text().toDouble();
double z = ui.pointsTableWidget->item(i, Z_TABLE_INDEX)->text().toDouble();
// check that this point is within image dimensions
if (((x < 0) || (x > imageDims[0]*voxSize.x())) ||
((y < 0) || (y > imageDims[1]*voxSize.y())) ||
((z < 0) || (z > imageDims[2]*voxSize.z()))) {
((y < 0) || (y > imageDims[1]*voxSize.y())) ||
((z < 0) || (z > imageDims[2]*voxSize.z()))) {
QString msg = "The point (" + QString::number(x) + ", " + QString::number(y) + ", " + QString::number(z) + "), does not belong to the image " + img->getName() + ". Sorry...";
QMessageBox::warning(this, "Impossible Operation", msg);
updateTable();
return;
}