Commit ff14d163 authored by Hossain Mahmud's avatar Hossain Mahmud
Browse files

[merged commit]clean ups, fixes for g++ errors and warnings, and edits for...

[merged commit]clean ups, fixes for g++ errors and warnings, and edits for cppcheck errors (except for the 480+ in the external library AlgLib)
parent b1404d05
......@@ -42,11 +42,9 @@ namespace campvis {
}
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)));
......@@ -57,7 +55,7 @@ namespace campvis {
++_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));
prop->setValue(tgt::vec4(val.x/val.w, val.y/val.w, val.z/val.w, 1));
--_ignorePropertyUpdates;
}
......
......@@ -35,8 +35,6 @@ namespace campvis {
typedef _ColorProperty<tgt::vec4> ColorProperty;
template<typename T>
_ColorProperty<T>::_ColorProperty(
const std::string& name,
......@@ -44,7 +42,7 @@ namespace campvis {
const T& value,
const T& minValue,
const T& maxValue,
const T& stepValue = T(0.01f))
const T& stepValue)
: Vec4Property(name, title, value, minValue, maxValue, stepValue)
{
......
......@@ -36,6 +36,12 @@ namespace campvis {
MetaProperty::~MetaProperty() {
}
void MetaProperty::deinit() {
for (size_t i = 0; i < _properties.size(); ++i) {
removeProperty(*_properties[i]);
}
}
void MetaProperty::onPropertyChanged(const AbstractProperty* prop) {
s_changed.emitSignal(this);
}
......
......@@ -53,6 +53,8 @@ namespace campvis {
**/
virtual ~MetaProperty();
/// \see AbstractProperty::deinit
virtual void deinit();
/// \see HasPropertyCollection::onPropertyChanged
virtual void onPropertyChanged(const AbstractProperty* prop);
......
......@@ -258,7 +258,7 @@ namespace campvis {
template<typename T>
void campvis::GenericOptionProperty<T>::selectByIndex(int index) {
tgtAssert(index >= 0 && index < _options.size(), "Index out of bounds.");
tgtAssert(index >= 0 && index < static_cast<int>(_options.size()), "Index out of bounds.");
setValue(index);
}
......@@ -282,17 +282,17 @@ namespace campvis {
template<typename T>
size_t campvis::GenericOptionProperty<T>::removeCurrent() {
int index = getValue();
size_t 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);
selectByIndex((index <= this->_options.size() - 1) ? static_cast<int>(index) : static_cast<int>(this->_options.size() - 1));
return (index <= this->_options.size() - 1) ? index : 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()];
GenericOption<T>* it = &this->_options[getValue()];
it->_id = copy._id;
it->_title = copy._title;
it->_value = copy._value;
......
......@@ -160,80 +160,24 @@ 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> >();
std::vector<tgt::Vector3<uint8_t> > vdata;
while (nullptr != tex) {
if (tex->getDataType() == GL_UNSIGNED_BYTE && tex->getNumChannels() == 3) {
tgt::Vector3<uint8_t>* data = reinterpret_cast<tgt::Vector3<uint8_t>*>(tex->getPixelData());
//data3d = new tgt::Vector3<uint8_t>[temp.y * temp.x*temp.z];
for (size_t i = 0; i < numElements*1; ++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;
vdata.push_back(data[i % numElements]);
}
}
//std::vector<tgt::Vector3<uint8_t> > x(data, data+numElements);
//vdata->push_back(x);
zee+=1;
//GenericImageRepresentationLocal<uint8_t, 3>::create(id, data3d);
}
delete tex;
if (this->p_importSimilar.getValue() == true) {
......@@ -246,20 +190,13 @@ namespace campvis {
else {
break;
}
//break;
} //while
}
temp.z = zee;
ImageData* id = new ImageData(3, temp, 3);
//uint8_t* data3d = new uint8_t[temp.x * temp.y * temp.z+100];
//for (size_t i = 0; i < temp.x*temp.y*temp.z; ++i) {
// data3d[i] = vdata->at(i).x;
//}
//GenericImageRepresentationLocal<uint8_t, 1>::create(id, data3d);
tgt::Vector3<uint8_t>* data3d = new tgt::Vector3<uint8_t>[temp.x * temp.y * temp.z];
memcpy_s(data3d, temp.x*temp.y*temp.z *3, &vdata.front(), temp.x*temp.y*temp.z*3);
memcpy(data3d, &vdata.front(), temp.x*temp.y*temp.z *3);
GenericImageRepresentationLocal<uint8_t, 3>::create(id, data3d);
id->setMappingInformation(ImageMappingInformation(id->getSize(), id->getMappingInformation().getOffset(), id->getMappingInformation().getVoxelSize() * tgt::vec3(1, 1, 1) ));
......
......@@ -56,6 +56,10 @@ namespace campvis {
}
GenericImageReader::~GenericImageReader() {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); ++it) {
delete it->second;
delete it->first;
}
}
void GenericImageReader::init() {
......@@ -64,8 +68,14 @@ namespace campvis {
void GenericImageReader::deinit() {
for(std::map<AbstractImageReader*, MetaProperty*>::iterator it = this->_readers.begin(); it != this->_readers.end(); ++it) {
if (nullptr != it->first) delete it->first;
if (nullptr != it->second) delete it->second;
// deinit MetaProperty first!
if (nullptr != it->second) {
it->second->deinit();
}
// then we can delete the reader!
if (nullptr != it->first) {
dynamic_cast<AbstractProcessor*>(it->first)->deinit();
}
}
}
......
......@@ -12,12 +12,12 @@
project(alglib CXX C)
cmake_minimum_required(VERSION 2.6.2)
# Where Google Test's .h files can be found.
# Where .h files can be found.
include_directories(
${alglib_SOURCE_DIR}
${alglib_SOURCE_DIR})
# Where Google Test's libraries can be found.
# Where libraries can be found.
link_directories(${gtest_BINARY_DIR})
LIST(APPEND AlglibHeaders
......@@ -54,13 +54,9 @@ LIST(APPEND AlglibSources
########################################################################
#
# Defines the alglib & gtest_main libraries. User tests should link
# with one of them.
# Google Test libraries. We build them using more strict warnings than what
# are used for other targets, to ensure that alglib can be compiled by a user
# aggressive about warnings.
# Defines the alglib librarie.
ADD_LIBRARY(alglib STATIC
${AlglibSources} ${AlglibHeaders} )
#cxx_library(gtest_main "${cxx_strict}" src/gtest_main.cc)
......@@ -70,9 +66,11 @@ ADD_LIBRARY(alglib STATIC
if ( CMAKE_COMPILER_IS_GNUCC )
# This is tested
set_property( TARGET alglib APPEND_STRING PROPERTY COMPILE_FLAGS -Wall )
SET(CMAKE_CXX_FLAGS "-fPIC -fno-strict-aliasing")
endif ( CMAKE_COMPILER_IS_GNUCC )
if ( MSVC )
# This is untested
set_property( TARGET alglib APPEND_STRING PROPERTY COMPILE_FLAGS /W1 )
set_property( TARGET alglib APPEND_STRING PROPERTY COMPILE_FLAGS "/W1 /EHsc" )
SET(CMAKE_CXX_FLAGS "-fno-strict-aliasing")
endif ( MSVC )
......@@ -139,9 +139,9 @@ __declspec(align(AE_LOCK_ALIGNMENT)) volatile ae_int64_t _ae_dbg_lock_yields = 0
* you can remove them, if you want - they are not used anywhere.
*
*/
static char _ae_int32_t_must_be_32_bits_wide[1-2*((int)(sizeof(ae_int32_t))-4)*((int)(sizeof(ae_int32_t))-4)];
static char _ae_int64_t_must_be_64_bits_wide[1-2*((int)(sizeof(ae_int64_t))-8)*((int)(sizeof(ae_int64_t))-8)];
static char _ae_int_t_must_be_pointer_sized [1-2*((int)(sizeof(ae_int_t))-(int)sizeof(void*))*((int)(sizeof(ae_int_t))-(int)(sizeof(void*)))];
// static char _ae_int32_t_must_be_32_bits_wide[1-2*((int)(sizeof(ae_int32_t))-4)*((int)(sizeof(ae_int32_t))-4)];
// static char _ae_int64_t_must_be_64_bits_wide[1-2*((int)(sizeof(ae_int64_t))-8)*((int)(sizeof(ae_int64_t))-8)];
// static char _ae_int_t_must_be_pointer_sized [1-2*((int)(sizeof(ae_int_t))-(int)sizeof(void*))*((int)(sizeof(ae_int_t))-(int)(sizeof(void*)))];
/*
* This variable is used to prevent some tricky optimizations which may degrade multithreaded performance.
......
......@@ -7071,8 +7071,8 @@ bool rmatrixschur(real_2d_array &a, const ae_int_t n, real_2d_array &s)
/////////////////////////////////////////////////////////////////////////
namespace alglib_impl
{
static ae_int_t ablas_rgemmparallelsize = 64;
static ae_int_t ablas_cgemmparallelsize = 64;
// static ae_int_t ablas_rgemmparallelsize = 64;
// static ae_int_t ablas_cgemmparallelsize = 64;
static void ablas_ablasinternalsplitlength(ae_int_t n,
ae_int_t nb,
ae_int_t* n1,
......@@ -26936,15 +26936,15 @@ static void rcond_cmatrixestimatenorm(ae_int_t n,
{
ae_int_t itmax;
ae_int_t i;
ae_int_t iter;
ae_int_t j;
ae_int_t jlast;
ae_int_t iter = 0;
ae_int_t j=0;
ae_int_t jlast = 0;
ae_int_t jump;
double absxi;
double altsgn;
double estold;
double absxi = 0;
double altsgn = 0;
double estold = 0;
double safmin;
double temp;
double temp = 0;
 
 
......@@ -42,7 +42,6 @@ namespace campvis {
{
addProcessor(&_lsp);
//_ve.getProperty()->addSharedProperty(_imageReader.getProperty("imgReaderViewport"));
addProcessor(&_imageReader);
addProcessor(&_ve);
......@@ -58,20 +57,15 @@ namespace campvis {
_ve.p_outputImage.setValue("mscopy");
_renderTargetID.setValue("mscopy");
//_imageReader.setURL(CAMPVIS_SOURCE_DIR "/modules/vis/sampledata/smallHeart.mhd");
_imageReader.p_url.setValue(CAMPVIS_SOURCE_DIR "/../lymph/LymphP1_0086.tif");
_imageReader.setURL(CAMPVIS_SOURCE_DIR "/../lymph/LymphP1_0086.tif");
MetaProperty *metaProp = dynamic_cast<MetaProperty*>(_imageReader.getProperty("DevilImageReaderMetaProp"));
tgtAssert(nullptr != metaProp, "This should not happen.");
BoolProperty *bp = dynamic_cast<BoolProperty*>(metaProp->getProperty("ImportSimilar"));
tgtAssert(nullptr != bp, "This should not happen.");
bp->setValue(true);
_imageReader.setTargetImageId("mscopy.output");
_imageReader.setTargetImageIdSharedProperty(&_ve.p_inputVolume);
//_imageReader.p_importType.selectById("localIntensity3");//selectByIndex(2);
//_imageReader.p_targetImageID.setValue("reader.output");
//_imageReader.p_targetImageID.addSharedProperty(&_ve.p_inputVolume);
_imageReader.setTargetImageId("mscopy.output");
_imageReader.setTargetImageIdSharedProperty(&_ve.p_inputVolume);
Geometry1DTransferFunction* dvrTF = new Geometry1DTransferFunction(128, tgt::vec2(0.f, .05f));
dvrTF->addGeometry(TFGeometry1D::createQuad(tgt::vec2(.12f, .15f), tgt::col4(85, 0, 0, 128), tgt::col4(255, 0, 0, 128)));
......@@ -84,9 +78,4 @@ namespace campvis {
void MicroscopyImageSegmentationDemo::deinit() {
AutoEvaluationPipeline::deinit();
}
//void MicroscopyImageSegmentation::updateProperties(DataContainer &dc) {
//}
}
\ No newline at end of file
}
......@@ -95,19 +95,19 @@ namespace campvis {
, _zSliceHandler(&_sliceExtractor.p_zSliceNumber)
, _windowingHandler(&_sliceExtractor.p_transferFunction)
, _trackballEH(0)
, _mousePressedInRaycaster(false)
, p_paintColor("PaintColor", "Change Color", tgt::vec4(255), tgt::vec4(0.0f), tgt::vec4(255))
, p_axisScaling("AxisScaling", "Axis Scale", tgt::vec3(1), tgt::vec3(1), tgt::vec3(25), tgt::vec3(1))
, p_objectList(0)
, p_fitToWindow("FitToWindow", "Fit to Window", true)
, p_scalingFactor("ScalingFactor", "Scaling Factor", 1.f, 0.f, 10.f, .1f, 2)
, p_offset("Offset", "Offset", tgt::ivec2(0), tgt::ivec2(0), tgt::ivec2(100))
, p_addObject("addObjectButton", "Add Object")
, p_deleteObject("deleteObjectButton", "Delete Current Object")
, p_csvPath("csvPath", "File Name", "", StringProperty::SAVE_FILENAME)
, p_saveCSV("saveCSV", "Save")
, p_objectList(0)
, _mousePressedInRaycaster(false)
, _objectNamePrefix("Object ")
, _objectNameSuffix(0)
, p_fitToWindow("FitToWindow", "Fit to Window", true)
, p_scalingFactor("ScalingFactor", "Scaling Factor", 1.f, 0.f, 10.f, .1f, 2)
, p_offset("Offset", "Offset", tgt::ivec2(0), tgt::ivec2(0), tgt::ivec2(100))
{
addProperty(p_inputVolume, INVALID_PROPERTIES);
......@@ -254,7 +254,7 @@ namespace campvis {
float pos = 0;
vertices.clear();
colors.clear();
for (int gg = 0; gg < selectedObject._points.size() * 5; gg++ ) {
for (size_t gg = 0; gg < selectedObject._points.size() * 5; gg++ ) {
double x, y, z = selectedObject._points[0].z;
alglib::pspline2calc(p, pos, x, y);
pos += stepSize;
......@@ -292,7 +292,7 @@ namespace campvis {
float pos = 0;
vertices.clear();
colors.clear();
for (int gg= 0; gg < it.size() * 5; gg++ ) {
for (size_t gg= 0; gg < it.size() * 5; gg++ ) {
double x, y, z = it[0].z;
alglib::pspline2calc(p, pos, x, y);
pos += stepSize;
......@@ -556,7 +556,7 @@ namespace campvis {
}
// lock this processor, so that the slice orientation's setting does not change
AbstractProcessor::ScopedLock lock(this, false);
AbstractProcessor::ScopedLock lock(this);
if (me->y() <= blockSize.y * 2 && me->x() >= leftPane.x) {
_sliceExtractor.p_sliceOrientation.selectByOption(SliceExtractor::XZ_PLANE);//xz
......@@ -632,10 +632,10 @@ namespace campvis {
return;
}
for (int i = 0; i < selectedObject._points.size(); i++) {
for (size_t i = 0; i < selectedObject._points.size(); i++) {
unsigned long dist2 = distanceSqr(selectedObject._points[i], voxel);
if (dist > dist2) {
insertNextVoxelAt = i;
insertNextVoxelAt = static_cast<int>(i);
dist = dist2;
}
}
......@@ -672,14 +672,14 @@ namespace campvis {
}
void MicroscopyImageSegmentation::onPaintColorChanged(const AbstractProperty *prop) {
ContourObject &obj = this->p_objectList->getOptionValue();
ContourObject &obj = this->p_objectList->getOptionReference();
obj._color.setValue(p_paintColor.getValue());
this->p_objectList->updateCurrent(obj);
invalidate(INVALID_RESULT | SCRIBBLE_INVALID);
}
void MicroscopyImageSegmentation::onObjectSelectionChanged (const AbstractProperty *prop) {
ContourObject &obj = this->p_objectList->getOptionValue();
const ContourObject &obj = this->p_objectList->getOptionValue();
this->p_paintColor.setValue(obj._color.getValue());
invalidate(INVALID_RESULT | SCRIBBLE_INVALID);
......
......@@ -182,6 +182,12 @@ namespace campvis {
IVec2Property p_leftPaneSize; ///< Used to define space for zslice
IVec2Property p_zSize; ///< Actual size for zslice
MWheelToNumericPropertyEventListener _xSliceHandler;
MWheelToNumericPropertyEventListener _ySliceHandler;
MWheelToNumericPropertyEventListener _zSliceHandler;
TransFuncWindowingEventListener _windowingHandler;
TrackballNavigationEventListener* _trackballEH;
ColorProperty p_paintColor; ///< Color picker for active object
Vec3Property p_axisScaling; ///< Asis ratio. Used to change ImageMappingInformation
tgt::vec3 _oldScaling;
......@@ -195,12 +201,6 @@ namespace campvis {
StringProperty p_csvPath; ///< Filepath to save CSV
ButtonProperty p_saveCSV; ///< Save changes in CSV
GenericOptionProperty<ContourObject> *p_objectList; ///< List of drawn contours
MWheelToNumericPropertyEventListener _xSliceHandler;
MWheelToNumericPropertyEventListener _ySliceHandler;
MWheelToNumericPropertyEventListener _zSliceHandler;
TransFuncWindowingEventListener _windowingHandler;
TrackballNavigationEventListener* _trackballEH;
bool _mousePressedInRaycaster; ///< Flag whether mouse was pressed in raycaster
static const std::string loggerCat_;
......
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