Commit ef559095 authored by promayon's avatar promayon
Browse files

FIXED crash with MML stopping criteria position without a specified target (introduced in r2282)

FIXED Consequently PhysicalModel::getComponentByName(..) also works with the atoms SC name 
FIXED relax disciplin on PML structural naming
FIXED various comments cleanup (no code change) and of an unwanted std::cout in InteractiveViewer


git-svn-id: svn+ssh://scm.forge.imag.fr/var/lib/gforge/chroot/scmrepos/svn/camitk/trunk/camitk@2283 ec899d31-69d1-42ba-9299-647d76f65fb3
parent d2c08b49
......@@ -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) {
......
......@@ -34,7 +34,13 @@
// -------------------- constructor --------------------
Position::Position(mml::Position* c,MonitoringManager* monitoringManager, MultipleCriterion* parent): Criterion(c,monitoringManager,parent) {
target=c->target().get();
if (c->target().present()) {
target=c->target().get();
}
else {
// if target is not provided, use all atoms
target = monitoringManager->getPml()->getAtoms()->getName();
}
switch (c->unit()) {
case mml::PositionUnit::nm:
......
......@@ -53,6 +53,8 @@ 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;
};
......
......@@ -485,7 +485,7 @@ bool PhysicalModel::parseComponents ( physicalModel::MultiComponent xmlFatherMC,
// Parse the name and unkown properties attribute of the main multiComponent
MultiComponent* fatherMC = ( MultiComponent* ) father;
fatherMC->setName ( xmlFatherMC.name() );
fatherMC->setName ( xmlFatherMC.name().get() );
fatherMC->getProperties()->xmlToFields ( xmlFatherMC.any_attribute() );
// Recursively consider multi component children
......@@ -544,14 +544,20 @@ bool PhysicalModel::parseComponents ( physicalModel::MultiComponent xmlFatherMC,
// ------------------ getComponentByName ------------------
Component * PhysicalModel::getComponentByName ( const std::string n ) {
// look for the component in the informative and exclusive component
//-- look for the component in exclusive component first
Component * foundC;
foundC = exclusiveComponents->getComponentByName ( n );
//-- then look in the informative components
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;
}
......
......@@ -30,7 +30,7 @@
StructuralComponentProperties::StructuralComponentProperties(PhysicalModel * p, physicalModel::StructuralComponent xmlSC) : Properties(p) {
alloc();
setName(xmlSC.name());
setName(xmlSC.name().get());
if (xmlSC.mode().present()) {
if (!xmlSC.mode().get().compare("NONE")) {
......
......@@ -28,7 +28,7 @@
<xsd:element name="atomRef" type="AtomRef" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="mode" type="RenderingMode"/>
<!-- adding any kind of attributes -->
<xsd:anyAttribute namespace="##any" processContents="lax"/>
......
......@@ -23,7 +23,7 @@
<xsd:group ref="MultiComponent"/>
<xsd:group ref="StructuralComponent"/>
</xsd:choice>
<xsd:attribute name="name" use="required" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:anyAttribute namespace="##any" processContents="lax" />
</xsd:complexType>
......
......@@ -34,7 +34,7 @@
<xsd:element name="atomRef" type="AtomRef" minOccurs="0" maxOccurs="unbounded"/>
</xsd:choice>
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string"/>
<xsd:attribute name="name" type="xsd:string"/>
<xsd:attribute name="mode" type="RenderingMode"/>
<!-- adding any kind of attributes -->
<xsd:anyAttribute namespace="##any" processContents="lax"/>
......
......@@ -178,8 +178,6 @@ void Geometry::setPointSet(vtkSmartPointer<vtkPointSet> ps) {
void Geometry::setMeshWorldTransform(vtkSmartPointer<vtkTransform> transform) {
// Do not delete vtkSmartTransform previous transform, but set it to NULL to
// decrement its counter
// worldTransformFilter->GetTransform()->Delete();
worldTransformFilter->SetTransform(transform);
worldTransformFilter->Update();
}
......
......@@ -46,6 +46,7 @@ using namespace std;
namespace camitk {
/* Deprecated constructor */
// -------------------- Deprecated constructor --------------------
Slice::Slice(vtkSmartPointer<vtkImageData> volume, PossibleOrientation orientation, vtkSmartPointer<vtkWindowLevelLookupTable> lookupTable) {
switch (orientation) {
default:
......@@ -73,7 +74,7 @@ Slice::Slice(vtkSmartPointer<vtkImageData> volume, PossibleOrientation orientati
}
/* Constructor */
// -------------------- constructor --------------------
Slice::Slice(vtkSmartPointer<vtkImageData> volume, SliceOrientation orientation, vtkSmartPointer<vtkWindowLevelLookupTable> lookupTable) {
this->sliceOrientation = orientation;
this->lut = lookupTable;
......@@ -83,7 +84,7 @@ Slice::Slice(vtkSmartPointer<vtkImageData> volume, SliceOrientation orientation,
}
/* Destructor */
// -------------------- Destructor --------------------
Slice::~Slice() {
// Let's unreference vtkSmartPointers
......@@ -99,6 +100,7 @@ Slice::~Slice() {
}
// -------------------- init --------------------
void Slice::init() {
currentSliceIndex = 0;
......@@ -138,6 +140,7 @@ void Slice::init() {
}
// -------------------- setOriginalVolume --------------------
void Slice::setOriginalVolume( vtkSmartPointer<vtkImageData> volume ) {
// If there were already a referenced volume,
// de-reference the smart pointer.
......@@ -167,7 +170,7 @@ void Slice::setOriginalVolume( vtkSmartPointer<vtkImageData> volume ) {
initActors();
}
// -------------------- initActors --------------------
void Slice::initActors() {
imgToMapFilter->SetInput(originalVolume);
......@@ -217,50 +220,48 @@ void Slice::initActors() {
}
// -------------------- setImageWorldTransform --------------------
void Slice::setImageWorldTransform(vtkSmartPointer<vtkTransform> transform) {
// image3DActor->GetUserTransform()->Delete();
image3DActor->SetUserTransform(transform);
}
/* Return the vtkImageActor (vtkProp) representing a slice to be displayed in 2D. */
// -------------------- get2DImageActor --------------------
vtkSmartPointer<vtkImageActor> Slice::get2DImageActor() const {
return image2DActor;
}
/* Return the vtkImageActor (vtkProp) representing a slice to be displayed in 2D. */
// -------------------- get3DImageActor --------------------
vtkSmartPointer<vtkImageActor> Slice::get3DImageActor() const {
return image3DActor;
}
/* Return the vtkActor used to pick pixels in the slices. */
// -------------------- getPickPlaneActor --------------------
vtkSmartPointer<vtkActor> Slice::getPickPlaneActor() const {
return pickPlaneActor;
}
/* This method is called when the associated plane has been picked in the InteractiveViewer,
* the given coordinates is position where the plane was picked.
*/
// -------------------- pixelPicked --------------------
void Slice::pixelPicked(double x, double y, double z) {
return;
}
// -------------------- reslicedToVolumeCoords --------------------
void Slice::reslicedToVolumeCoords(const double *ijk, double *xyz) {
xyz[0] = ijk[0] * originalSpacing[0];
xyz[1] = ijk[1] * originalSpacing[1];
xyz[2] = ijk[2] * originalSpacing[2];
}
// -------------------- volumeToReslicedCoords --------------------
void Slice::volumeToReslicedCoords(const double *xyz, double *ijk) {
ijk[0] = xyz[0] / originalSpacing[0];
ijk[1] = xyz[1] / originalSpacing[1];
ijk[2] = xyz[2] / originalSpacing[2];
}
// -------------------- updatePickPlane --------------------
void Slice::updatePickPlane() {
// Be carefull, The center of the first voxel (0,0,0) is displayed at coordinates (0.0, 0.0, 0.0).
// Pixels winthin borders are represented (in 2D) only by their half, quarter or eigth depending on their coordinates.
......@@ -295,7 +296,7 @@ void Slice::updatePickPlane() {
pickPlane->UpdateWholeExtent();
}
/* Return the number of slices in the image data set. */
// -------------------- getNumberOfSlices --------------------
int Slice::getNumberOfSlices() const {
int nbSlices = 0;
......@@ -316,18 +317,12 @@ int Slice::getNumberOfSlices() const {
return nbSlices;
}
/* Return the index of the current displayed slice. */
// -------------------- getSlice --------------------
int Slice::getSlice() const {
return currentSliceIndex;
}
/* Set the current slice index.
* If the slice index is less than the first slice index, the first slice is displayed.
* If the slice index is more than the last slice index, the last slice is displayed.
* @param s the index of the slice to display (base 0). */
// -------------------- setSlice --------------------
void Slice::setSlice(int s) {
// Check if s is inside the volume bounds
if ( s < 0 ) {
......@@ -380,7 +375,7 @@ void Slice::setSlice(int s) {
}
// Set the slice corresponding to the given world coordinates
// -------------------- setSlice --------------------
void Slice::setSlice(double x, double y, double z) {
// At this point, coordinates are expressed in Image coordinate system
......@@ -408,21 +403,17 @@ void Slice::setSlice(double x, double y, double z) {
}
}
/* Return the number of colors in the images.
* If color is coded on 1 byte, the images are on 256 grey level.
* If color is coded on 2 bytes, the images are on 4096 grey level (not 65536). */
// -------------------- getNumberOfColors --------------------
int Slice::getNumberOfColors() const {
return originalVolume->GetScalarTypeMax() - originalVolume->GetScalarTypeMin();
}
// move the pixel selection green indicator (pixelActor) to the given real position
// -------------------- setPixelRealPosition --------------------
void Slice::setPixelRealPosition(double x, double y, double z) {
updatePixelActorPosition(x, y, z);
}
// -------------------- initPixelActor --------------------
void Slice::initPixelActor() {
double xMin = 0.0;
double xMax = originalSize[0];
......@@ -441,7 +432,7 @@ void Slice::initPixelActor() {
void Slice::updatePixelActorPosition(double x, double y, double z) {
// if the interactive viewer is not refreshed/displayed, the pixelActor is null. In this case, no point to update it
if (pixelActor) {
// Create the cloup points used to describe the bounding box around
// Create the cloud points used to describe the bounding box around
vtkSmartPointer<vtkPoints> pixelPoints = vtkSmartPointer<vtkPoints>::New();
pixelPoints->SetNumberOfPoints(4);
// Those points describes the (red / blue / green) cross around the picked pixel.
......@@ -542,14 +533,14 @@ void Slice::updatePixelActorPosition(double x, double y, double z) {
}
/* Create the pixel grid (bounding box) around the pixel picked.
* Returns the actors that has been calculated */
// -------------------- --------------------
vtkSmartPointer<vtkActor> Slice::getPixelActor() {
if (!pixelActor)
initPixelActor();
return pixelActor;
}
// -------------------- --------------------
void Slice::init2DAxesActor() {
axes2DActor = vtkSmartPointer<vtkAxesActor>::New();
axes2DActor->SetShaftTypeToCylinder();
......@@ -590,7 +581,7 @@ void Slice::init2DAxesActor() {
update2DAxesActorPosition();
}
// -------------------- --------------------
void Slice::update2DAxesActorPosition() {
vtkSmartPointer<vtkTransform> transform = vtkSmartPointer<vtkTransform>::New();
transform->Identity();
......@@ -626,6 +617,7 @@ void Slice::update2DAxesActorPosition() {
// else no point to update the pixelActor
}
// -------------------- --------------------
vtkSmartPointer<vtkAxesActor> Slice::get2DAxesActor() {
if (! axes2DActor)
init2DAxesActor();
......
......@@ -468,6 +468,7 @@ SingleImageComponent * ImageComponent::getArbitrarySlices() {
return this->arbitrarySlices;
}
// ---------------- getVolumeRenderingChild -------------------
MeshComponent * ImageComponent::getVolumeRenderingChild() {
return this->volumeRenderingChild;
}
......
......@@ -2177,7 +2177,6 @@ bool InteractiveViewer::eventFilter(QObject *object, QEvent *event) {
// save the settings
QSettings &settings = Application::getSettings();
std::cout << "Current group is:" << settings.group().toStdString() << std::endl;
settings.beginGroup(Application::getName() + ".InteractiveViewer." + objectName().simplified().replace(" ",""));
settings.setValue("highlightMode", highlightMode );
......
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