Commit 09b49a54 authored by Jakob Weiss's avatar Jakob Weiss
Browse files

cleanup and disconnect button

parent e88a4e46
......@@ -22,8 +22,6 @@
//
// ================================================================================================
#define CAMPCOM_FAST_SERIALIZATION
#include "matrixprocessor.h"
#include "core/datastructures/imagedata.h"
......@@ -53,17 +51,17 @@ namespace campvis {
, p_targetMatrixID("TargetMatrixID", "Target Matrix ID", "ProbeToReference", DataNameProperty::WRITE)
, _lastdc(nullptr)
{
addProperty(p_matrixAType, INVALID_PROPERTIES);
addProperty(p_matrixAID, VALID);
addProperty(p_matrixAString, VALID);
addProperty(p_matrixAModifiers, VALID);
addProperty(p_matrixAType, INVALID_PROPERTIES | INVALID_RESULT);
addProperty(p_matrixAID, INVALID_RESULT);
addProperty(p_matrixAString, INVALID_RESULT);
addProperty(p_matrixAModifiers, INVALID_RESULT);
addProperty(p_matrixBType, INVALID_PROPERTIES);
addProperty(p_matrixBID, VALID);
addProperty(p_matrixBString, VALID);
addProperty(p_matrixBModifiers, VALID);
addProperty(p_matrixBType, INVALID_PROPERTIES | INVALID_RESULT);
addProperty(p_matrixBID, INVALID_RESULT);
addProperty(p_matrixBString, INVALID_RESULT);
addProperty(p_matrixBModifiers, INVALID_RESULT);
addProperty(p_targetMatrixID, VALID);
addProperty(p_targetMatrixID, INVALID_RESULT);
invalidate(INVALID_PROPERTIES);
}
......@@ -82,7 +80,9 @@ namespace campvis {
}
void MatrixProcessor::updateResult(DataContainer& data) {
#ifdef MATRIX_PROCESSOR_DEBUGGING
LINFO("Updating Result");
#endif
if (&data != _lastdc) {
if (_lastdc) {
......@@ -115,12 +115,14 @@ namespace campvis {
tgt::mat4 result = matAProcessed * matBProcessed;
#ifdef MATRIX_PROCESSOR_DEBUGGING
LDEBUG("Matrix A: " << std::endl << matA);
LDEBUG("Matrix A':" << std::endl << matAProcessed);
LDEBUG("Matrix B: " << std::endl << matB);
LDEBUG("Matrix B':" << std::endl << matBProcessed);
LDEBUG("Result Matrix: " << std::endl << result);
LDEBUG(std::endl);
#endif
TransformData * td = new TransformData(result);
......@@ -131,7 +133,9 @@ namespace campvis {
void MatrixProcessor::updateProperties(DataContainer& dataContainer)
{
#ifdef MATRIX_PROCESSOR_DEBUGGING
LINFO("Updating Properties");
#endif
if (p_matrixAType.getOptionValue() == "fixed") {
p_matrixAID.setVisible(false);
p_matrixAString.setVisible(true);
......
......@@ -25,6 +25,7 @@
#ifndef MATRIXPROCESSOR_H__
#define MATRIXPROCESSOR_H__
//#define MATRIX_PROCESSOR_DEBUGGING
#include <string>
......
......@@ -43,6 +43,7 @@ namespace campvis {
, p_port("ServerPort", "Server Port", 18944, 1, 65535, 1)
, p_deviceName("ServerDeviceName", "Device Name (empty to accept all)")
, p_connect("Connect", "Connect to Server")
, p_disconnect("Disconnect", "Disconnect from Server")
, p_receiveImages("ReceiveImages", "Receive IMAGE Messages", false)
, p_targetImagePrefix("targetImageName", "Target Image Prefix", "IGTL.image.")
, p_receiveTransforms("ReceiveTransforms", "Receive TRANSFORM Messages", true)
......@@ -57,6 +58,7 @@ namespace campvis {
addProperty(p_deviceName, VALID);
addProperty(p_connect, VALID);
addProperty(p_disconnect, VALID);
addProperty(p_receiveTransforms, INVALID_PROPERTIES);
addProperty(p_receiveImages, INVALID_PROPERTIES);
......@@ -76,6 +78,7 @@ namespace campvis {
void OpenIGTLinkClient::init() {
p_connect.s_clicked.connect(this, &OpenIGTLinkClient::connectToServer);
p_disconnect.setVisible(false);
}
void OpenIGTLinkClient::deinit() {
......@@ -92,8 +95,9 @@ namespace campvis {
TransformData * td = new TransformData(it->second);
data.addData(p_targetTransformPrefix.getValue() + it->first, td);
#ifdef IGTL_CLIENT_DEBUGGING
LDEBUG("Transform data put into container. ");
#endif
}
_receivedTransforms.clear();
_transformMutex.unlock();
......@@ -107,7 +111,9 @@ namespace campvis {
igtl::ImageMessage::Pointer imageMessage = it->second;
WeaklyTypedPointer wtp;
wtp._pointer = new uint8_t[imageMessage->GetImageSize()];
#ifdef IGTL_CLIENT_EBUGGING
LDEBUG("Image has " << imageMessage->GetNumComponents() << " components and is of size " << imageMessage->GetImageSize());
#endif
memcpy(wtp._pointer, imageMessage->GetScalarPointer(), imageMessage->GetImageSize());
wtp._numChannels = imageMessage->GetNumComponents();
......@@ -143,6 +149,7 @@ namespace campvis {
size_t dimensionality = (size_i[2] == 1) ? ((size_i[1] == 1) ? 1 : 2) : 3;
ImageData* image = new ImageData(dimensionality, size, wtp._numChannels);
ImageRepresentationLocal::create(image, wtp);
image->setMappingInformation(ImageMappingInformation(size, p_imageOffset.getValue(), voxelSize * p_voxelSize.getValue()));
data.addData(p_targetImagePrefix.getValue() + it->first, image);
}
......@@ -194,6 +201,8 @@ namespace campvis {
LINFO("Connected to server " << p_address.getValue() << ":" << p_port.getValue());
start(); //start receiving data in a new thread
validate(INVALID_RESULT);
......@@ -355,6 +364,9 @@ namespace campvis {
headerMsg = igtl::MessageHeader::New();
ts = igtl::TimeStamp::New();
p_connect.setVisible(false);
p_disconnect.setVisible(true);
while (!_stopExecution && _socket)
{
// Initialize receive buffer
......@@ -456,5 +468,7 @@ namespace campvis {
if(_socket)
_socket->CloseSocket();
_socket = nullptr;
p_disconnect.setVisible(false);
p_connect.setVisible(true);
}
}
\ No newline at end of file
......@@ -25,6 +25,8 @@
#ifndef OPENIGTLINKCLIENT_H__
#define OPENIGTLINKCLIENT_H__
//#define IGTL_CLIENT_DEBUGGING
#include <string>
#include <map>
......@@ -84,6 +86,7 @@ namespace campvis {
NumericProperty<int> p_port; ///< server port to connect to
StringProperty p_deviceName; ///< IGTL device name (leave empty to accept all)
ButtonProperty p_connect; ///< Connect button
ButtonProperty p_disconnect; ///< Disconnect button
BoolProperty p_receiveImages; ///< toggle receiving IMAGE messages
......
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