Commit dd8e9771 authored by Hossain Mahmud's avatar Hossain Mahmud Committed by Christian Schulte zu Berge
Browse files

Squashed various commits:

relocated mscopysegmentation module

relocated alglib library. Compiler warning level raised to w1 to get rid of float-double conversions.

save results into csv
akima spline interpolation using alglib, deleting nearest point

alglib library. extensive trimming required

ctrl+wheel zooming, arrow movement, ctrl+z, atl+click_nearest+click to edit _nearest point

multi object, multi location, multi slide contour point/line painting

draft code for addobject deleteobject

added ContourObject class linked with add and delete button.

added a proxy class of Vec4Property/Widget as colorproperty/widget to control drawing color

Conflicts:
	modules/vis/processors/sliceextractor.cpp

edited DevilImageReader to read multiple files having same name pattern: somePrefix_[number].[extension] given the 1st file name

Worked on DevilImageReader to load single 2d image for 3d rendering

exp_01 commit
parent 97c25b99
......@@ -45,5 +45,8 @@ moc_*.cxx_parameters
# TBB library in ext/
ext/tbb
# alglib library in ext/
#ext/alglib
# SWIG wrapper code
*LUA_wrap.cxx
......@@ -53,6 +53,7 @@ SET(CampvisApplicationToBeMocced
gui/properties/datanamepropertywidget.h
gui/properties/intpropertywidget.h
gui/properties/floatpropertywidget.h
gui/properties/colorpropertywidget.h
gui/properties/geometry1dtransferfunctioneditor.h
gui/properties/geometry2dtransferfunctioneditor.h
gui/properties/metapropertywidget.h
......
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#include "colorpropertywidget.h"
#include "core/properties/colorproperty.h"
namespace campvis {
ColorPropertyWidget::ColorPropertyWidget(ColorProperty* property, DataContainer* dataContainer, QWidget* parent /*= 0*/)
: AbstractPropertyWidget(property, false, dataContainer, parent)
//, _lblColorPicker(0)
, _colorPicker(0)
{
//_lblColorPicker = new QLabel("Change color: ", this);
_colorPicker = new ColorPickerWidget(QtColorTools::toQColor(property->getValue()), this);
addWidget(_colorPicker);
//connect(_colorPicker, SIGNAL(valueChanged(tgt::vec4)), this, SLOT(onColorChanged(tgt::vec4)));
connect(_colorPicker, SIGNAL(colorChanged(const QColor&)), this, SLOT(onColorChanged(const QColor&)));
}
ColorPropertyWidget::~ColorPropertyWidget() {
ColorProperty* property = static_cast<ColorProperty*>(_property);
}
void ColorPropertyWidget::updateWidgetFromProperty() {
ColorProperty* prop = static_cast<ColorProperty*>(_property);
_colorPicker->blockSignals(true);
const tgt::vec4 val = static_cast<ColorProperty*>(_property)->getValue();
_colorPicker->setColor(QtColorTools::toQColor(tgt::vec4(val.x *255, val.y*255, val.z*255, val.w*255)));
_colorPicker->blockSignals(false);
}
void ColorPropertyWidget::onColorChanged(const QColor& value) {
++_ignorePropertyUpdates;
ColorProperty* prop = static_cast<ColorProperty*>(_property);
tgt::vec4 val = QtColorTools::toTgtColor(_colorPicker->color());
prop->setValue(tgt::vec4(val.x/val.w, val.y/val.w, val.z/val.w, val.w/val.w));
--_ignorePropertyUpdates;
}
void ColorPropertyWidget::onPropertyMinMaxChanged(const AbstractProperty* property) {
if (_ignorePropertyUpdates == 0)
emit s_propertyChanged(property);
}
}
// ================================================================================================
//
// This file is part of the CAMPVis Software Framework.
//
// If not explicitly stated otherwise: Copyright (C) 2012-2014, all rights reserved,
// Christian Schulte zu Berge <christian.szb@in.tum.de>
// Chair for Computer Aided Medical Procedures
// Technische Universitaet Muenchen
// Boltzmannstr. 3, 85748 Garching b. Muenchen, Germany
//
// For a full list of authors and contributors, please refer to the file "AUTHORS.txt".
//
// Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
// except in compliance with the License. You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software distributed under the
// License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
// either express or implied. See the License for the specific language governing permissions
// and limitations under the License.
//
// ================================================================================================
#ifndef COLORPROPERTYWIDGET_H__
#define COLORPROPERTYWIDGET_H__
#include "application/gui/adjusterwidgets/doubleadjusterwidget.h"
#include "application/gui/properties/abstractpropertywidget.h"
#include "application/gui/properties/propertywidgetfactory.h"
#include "core/properties/floatingpointproperty.h"
#include "core/properties/colorproperty.h"
#include "application/gui/qtcolortools.h"
namespace campvis {
/**
* Widget for a ColorProperty
*/
class ColorPropertyWidget : public AbstractPropertyWidget {
Q_OBJECT
public:
/**
* Creates a new FloatPropertyWidget for the property \a property.
* \param property The property the widget shall handle
* \param dataContainer DataContainer to use (optional), defaults to nullptr.
* \param parent Parent Qt widget
*/
ColorPropertyWidget(ColorProperty* property, DataContainer* dataContainer, QWidget* parent = 0);
/**
* Destructor
*/
virtual ~ColorPropertyWidget();
protected:
/**
* Gets called when the property has changed, so that widget can update its state.
*/
virtual void updateWidgetFromProperty();
private slots:
/// Slot getting called when the adjuster's value changes
void onColorChanged(const QColor&);
private:
/// Slot getting called when the property's min or max value has changed, so that the widget can be updated.
virtual void onPropertyMinMaxChanged(const AbstractProperty* property);
//QLabel *_lblColorPicker;
ColorPickerWidget * _colorPicker; ///< color picker widget allowing to change color
};
// ================================================================================================
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template class PropertyWidgetRegistrar<ColorPropertyWidget, ColorProperty>;
}
#endif // COLORPROPERTYWIDGET_H__
......@@ -84,4 +84,5 @@ namespace campvis {
if (_ignorePropertyUpdates == 0)
emit s_propertyChanged(property);
}
}
......@@ -30,6 +30,9 @@
#include "application/gui/properties/propertywidgetfactory.h"
#include "core/properties/floatingpointproperty.h"
#include "application/gui/qtcolortools.h"
namespace campvis {
/**
* Widget for a FloatProperty
......@@ -270,7 +273,7 @@ namespace campvis {
void onValueChanged(double value) { onValueChangedImpl(); };
};
// ================================================================================================
// ================================================================================================
class Vec4PropertyWidget : public VecPropertyWidget<4> {
Q_OBJECT
......@@ -287,7 +290,8 @@ namespace campvis {
void onValueChanged(double value) { onValueChangedImpl(); };
};
// ================================================================================================
// ================================================================================================
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
template class PropertyWidgetRegistrar<Vec2PropertyWidget, typename VecPropertyWidgetTraits<2>::PropertyType, 5>;
......
// WARNING: This file is automatically generated by CMake, do not modify!
// Include Converter Headers:
#include "datastructures/imagerepresentationconversioncore.h"
......@@ -51,9 +51,9 @@ namespace campvis {
class CAMPVIS_CORE_API VisualizationProcessor : public AbstractProcessor {
public:
/**
* Utility struct to encapuslate off-screen rendering with this processor using FBOs.
* Utility struct to encapsulate off-screen rendering with this processor using FBOs.
* This guard essentially activates the VisualizationProcessor's FBO and sets the OpenGL
* viewport size. Upon destruction it detaches all texutres and deactivates the FBO again.
* viewport size. Upon destruction it detaches all textures and deactivates the FBO again.
*/
struct CAMPVIS_CORE_API FramebufferActivationGuard {
public:
......
#include "core/properties/colorproperty.h"
namespace campvis {
}
#ifndef COLORPROPERTY_H__
#define COLORPROPERTY_H__
# include "core/properties/floatingpointproperty.h"
namespace campvis {
template <typename T>
class _ColorProperty : public FloatingPointProperty<T> {
public:
/**
* Creates a new FloatingPointProperty.
* \param name Property name
* \param title Property title (e.g. used for GUI)
* \param value Initial value of the property
* \param minValue Minimum value for this property
* \param maxValue Maximum value for this property
* \param stepValue Step value for this property
* \param decimals Number of significant decimal places
*/
_ColorProperty(
const std::string& name,
const std::string& title,
const T& value,
const T& minValue,
const T& maxValue,
const T& stepValue = T(0.01f));
static const std::string loggerCat_;
};
template<typename T>
const std::string campvis::_ColorProperty<T>::loggerCat_ = "CAMPVis.core.properties.ColorProperty";
typedef _ColorProperty<tgt::vec4> ColorProperty;
template<typename T>
_ColorProperty<T>::_ColorProperty(
const std::string& name,
const std::string& title,
const T& value,
const T& minValue,
const T& maxValue,
const T& stepValue = T(0.01f))
: Vec4Property(name, title, value, minValue, maxValue, stepValue)
{
}
}
#endif // COLORPROPERTY_H__
......@@ -67,7 +67,7 @@ namespace campvis {
* FloatingPointProperty extends NumericProperty to control how many decimal places should be
* shown when displaying the property's value.
*
* \tparam T Base type of the property's value.
* \param T Base type of the property's value.
*/
template<typename T>
class FloatingPointProperty : public NumericProperty<T> {
......@@ -133,6 +133,8 @@ namespace campvis {
typedef FloatingPointProperty<tgt::vec3> Vec3Property;
typedef FloatingPointProperty<tgt::vec4> Vec4Property;
//typedef FloatingPointProperty<tgt::vec4> ColorProperty;
// = Template Implementation ======================================================================
template<typename T>
......
......@@ -68,7 +68,7 @@ namespace campvis {
, _title(title)
, _value(value)
{};
std::string _id;
std::string _title;
T _value;
......@@ -161,6 +161,41 @@ namespace campvis {
* \param option Option to set.
*/
void selectByOption(T option);
/**
* Add a new Option
* \param option New option to add
* returns Number of items
*/
size_t addOption(GenericOption<T> option);
/**
* Update current option
* \param copy Data to copy from
* returns Number of items
*/
size_t updateCurrent(GenericOption<T> copy);
size_t updateCurrent(T& copy);
/**
* Remove current copy, except the last one
* returns Number of items
*/
size_t removeCurrent();
/**
* Returns a non-const reference of current option's value
* \param index Position to
* \note With great power comes great responsibility
* returns Number of items
*/
T& getOptionReference(int index = -1);
/**
* Get Option count
* returns Number of items
*/
size_t getOptionCount();
protected:
std::vector< GenericOption<T> > _options;
......@@ -221,9 +256,10 @@ namespace campvis {
LERROR("Could not find option with id '" + id + "'");
}
//TODO: Shouldn't this be index >= 0 ?
template<typename T>
void campvis::GenericOptionProperty<T>::selectByIndex(int index) {
tgtAssert(index > 0 && index < _options.size(), "Index out of bounds.");
tgtAssert(index >= 0 && index < _options.size(), "Index out of bounds.");
setValue(index);
}
......@@ -238,6 +274,49 @@ namespace campvis {
LERROR("Could not find specified option.");
}
template<typename T>
size_t campvis::GenericOptionProperty<T>::addOption(GenericOption<T> option) {
this->_options.push_back(option);
//setMaxValue(this->_options.size());
setMaxValue(static_cast<int>(this->_options.size()) - 1);
return this->_options.size();
}
template<typename T>
size_t campvis::GenericOptionProperty<T>::removeCurrent() {
int index = getValue();
if (index == 0) return 0;
if(index <= this->_options.size()-1)
this->_options.erase(this->_options.begin() + index);
selectByIndex(index <= static_cast<int>(this->_options.size())-1? index : static_cast<int>(this->_options.size())-1);
return index <= static_cast<int>(this->_options.size())-1? index : static_cast<int>(this->_options.size())-1;
}
template<typename T>
size_t campvis::GenericOptionProperty<T>::updateCurrent(GenericOption<T> copy) {
std::vector< GenericOption<T> >::iterator *it = this->_options[getValue()];
it->_id = copy._id;
it->_title = copy._title;
it->_value = copy._value;
return this->_options.size();
}
template<typename T>
size_t campvis::GenericOptionProperty<T>::updateCurrent(T& copy) {
GenericOption<T> *it = &this->_options[getValue()];
it->_value = copy;
return this->_options.size();
}
template<typename T>
T& campvis::GenericOptionProperty<T>::getOptionReference(int index) {
return index == -1? _options[_value]._value : _options[index]._value;
}
template<typename T>
size_t campvis::GenericOptionProperty<T>::getOptionCount() {
return _options.size();
}
}
#endif // OPTIONPROPERTY_H__
......@@ -66,6 +66,17 @@ namespace campvis {
void setDisplayType(DisplayType val) { _displayType = val; }
/**
* Overloads == operator.
* \param rhs Object to compare with.
**/
bool operator==(StringProperty& rhs) {
return this->getValue() == rhs.getValue()
&& this->getName() == rhs.getName()
&& this->getTitle() == rhs.getTitle();
}
protected:
DisplayType _displayType;
......
......@@ -27,6 +27,7 @@
#include <IL/il.h>
#include <cstring>
#include <vector>
#include "tgt/logmanager.h"
#include "tgt/filesystem.h"
......@@ -40,30 +41,41 @@
#include "core/datastructures/genericimagerepresentationlocal.h"
#include "core/tools/quadrenderer.h"
#include "core/tools/stringutils.h"
#include "core/tools/mapping.h"
namespace campvis {
const std::string DevilImageReader::loggerCat_ = "CAMPVis.modules.io.DevilImageReader";
GenericOption<std::string> importOptions[3] = {
GenericOption<std::string> importOptions[4] = {
GenericOption<std::string>("rt", "Render Target"),
GenericOption<std::string>("texture", "OpenGL Texture"),
GenericOption<std::string>("localIntensity", "Local Intensity Image")
GenericOption<std::string>("localIntensity", "Local Intensity Image"),
GenericOption<std::string>("localIntensity3", "Local Intensity Image RGB")
};
DevilImageReader::DevilImageReader(IVec2Property* viewportSizeProp)
: VisualizationProcessor(viewportSizeProp)
, p_url("url", "Image URL", "", StringProperty::OPEN_FILENAME)
, p_targetImageID("targetImageName", "Target Image ID", "DevilImageReader.output", DataNameProperty::WRITE)
, p_importType("ImportType", "Import Type", importOptions, 3)
//, p_url("url", "Image URL", "", StringProperty::OPEN_FILENAME)
//, p_targetImageID("targetImageName", "Target Image ID", "DevilImageReader.output", DataNameProperty::WRITE)
, p_importType("ImportType", "Import Type", importOptions, 4)
, p_importSimilar("ImportSimilar", "Import All Similar Files", false)
, _shader(nullptr)
, _devilTextureReader(nullptr)
{
this->_ext.push_back(".jpg");
this->_ext.push_back(".tif");
this->p_targetImageID.setValue("DevilImageReader.output");
addProperty(p_url);
addProperty(p_targetImageID);
addProperty(p_importType);
addProperty(p_importSimilar);
_devilTextureReader = new tgt::TextureReaderDevil();
p_importType.selectById("localIntensity3");
}
DevilImageReader::~DevilImageReader() {
......@@ -83,10 +95,23 @@ namespace campvis {
}
void DevilImageReader::updateResult(DataContainer& data) {
std::string url = this->p_url.getValue();
std::string base = "", numstr = "", ext = "";
size_t _Pos = url.rfind('_');
size_t dotPos = url.rfind('.');
if (dotPos > _Pos && dotPos != std::string::npos && _Pos != std::string::npos ) {
numstr = url.substr(_Pos+1, dotPos);
base = url.substr(0, _Pos+1);
ext = url.substr(dotPos);
}
int suffix = StringUtils::fromString<int>(numstr);
std::cout << "\nfileName Suffix: "<<suffix <<" count: "<<dotPos-_Pos <<std::endl;
tgt::Texture* tex = _devilTextureReader->loadTexture(p_url.getValue(), tgt::Texture::LINEAR, false, true, true, false);
if (tex != 0) {
if (p_importType.getOptionValue() == "rt") {
ImageData id (2, tex->getDimensions(), tex->getNumChannels());
ImageData id (3, tex->getDimensions(), tex->getNumChannels());
ImageRepresentationGL* image = ImageRepresentationGL::create(&id, tex);
FramebufferActivationGuard fag(this);
......@@ -112,7 +137,7 @@ namespace campvis {
data.addData(p_targetImageID.getValue(), new RenderData(_fbo));
}
else if (p_importType.getOptionValue() == "texture") {
ImageData* id = new ImageData(2, tex->getDimensions(), tex->getNumChannels());
ImageData* id = new ImageData(3, tex->getDimensions(), tex->getNumChannels());
ImageRepresentationGL::create(id, tex);
data.addData(p_targetImageID.getValue(), id);
}
......@@ -121,7 +146,7 @@ namespace campvis {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
tex->downloadTexture();
size_t numElements = tgt::hmul(tex->getDimensions());
ImageData* id = new ImageData(2, tex->getDimensions(), 1);
ImageData* id = new ImageData(3, tex->getDimensions(), 1);
// TODO: use macro magic to switch through the different data types and number of channels
if (tex->getDataType() == GL_UNSIGNED_BYTE && tex->getNumChannels() == 3) {
......@@ -136,6 +161,111 @@ namespace campvis {
delete tex;
data.addData(p_targetImageID.getValue(), id);
}
else if (p_importType.getOptionValue() == "localIntensity33") {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
tex->downloadTexture();
size_t numElements = tgt::hmul(tex->getDimensions());
tgt::ivec3 temp = tex->getDimensions();
temp.z = 100;
ImageData* id = new ImageData(3, temp, 3);
/*if (tex->getDataType() == GL_UNSIGNED_BYTE && tex->getNumChannels() == 3) {
tgt::Vector3<uint8_t>* data = reinterpret_cast<tgt::Vector3<uint8_t>*>(tex->getPixelData());
tgt::Vector3<uint8_t>* data3d = new tgt::Vector3<uint8_t>[numElements];
for (size_t i = 0; i < numElements; ++i) {
data3d[i].x = data[i].x;
data3d[i].y = data[i].y;
data3d[i].z = data[i].z;
}
GenericImageRepresentationLocal<uint8_t, 3>::create(id, data3d);
}*/
if (tex->getDataType() == GL_UNSIGNED_BYTE && tex->getNumChannels() == 3) {
tgt::Vector3<uint8_t>* data = reinterpret_cast<tgt::Vector3<uint8_t>*>(tex->getPixelData());
tgt::Vector3<uint8_t>* data3d = new tgt::Vector3<uint8_t>[temp.y * temp.x*temp.z];
//for(int i =0; i < temp.z; i++)
// data3d[i] = new tgt::Vector3<uint8_t>[temp.y * temp.x];
for (size_t i = 0; i < numElements; ++i) {
for(int k = 0; k < temp.z; k++){
data3d[k*numElements + i].x = data[i].x;
data3d[k*numElements + i].y = data[i].y;
data3d[k*numElements + i].z = data[i].z;}
}
GenericImageRepresentationLocal<uint8_t, 3>::create(id, data3d);
}
delete tex;
data.addData(p_targetImageID.getValue(), id);
}
else if (p_importType.getOptionValue() == "localIntensity3") {
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
tex->downloadTexture();
size_t numElements = tgt::hmul(tex->getDimensions());
tgt::ivec3 temp = tex->getDimensions();
//temp.z = 1;
int zee = 0;
/*if (tex->getDataType() == GL_UNSIGNED_BYTE && tex->getNumChannels() == 3) {
tgt::Vector3<uint8_t>* data = reinterpret_cast<tgt::Vector3<uint8_t>*>(tex->getPixelData());
tgt::Vector3<uint8_t>* data3d = new tgt::Vector3<uint8_t>[numElements];
for (size_t i = 0; i < numElements; ++i) {
data3d[i].x = data[i].x;
data3d[i].y = data[i].y;
data3d[i].z = data[i].z;
}
GenericImageRepresentationLocal<uint8_t, 3>::create(id, data3d);
}*/
//tgt::Vector3<uint8_t>* data3d;
std::vector<tgt::Vector3<uint8_t> > vdata;// = new std::vector<tgt::Vector3<uint8_t> >();
while (nullptr != tex) {
if (tex->getDataType() == GL_UNSIGNED_BYTE && tex->getNumChannels() == 3) {
tgt::Vector3<uint8_t>* data = reinterpre