Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

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

clean up

parent 1e080477
......@@ -56,8 +56,6 @@
#include <QFileDialog>
#include <QScrollArea>
#include "scripting/luagen/properties/propertyluafactory.h"
namespace campvis {
const std::string DataContainerInspectorWidget::loggerCat_ = "CAMPVis.application.DataContainerInspectorWidget";
......@@ -216,10 +214,6 @@ namespace campvis {
_pcWidget->updatePropCollection(_canvas, _dataContainer);
_pipelinePropertiesScrollArea->setWidget(_pcWidget);
PropertyCollectionLua *_pcLua = new PropertyCollectionLua();
_pcLua->updatePropCollection(_canvas, _dataContainer);
std::cout << _pcLua->getLuaScript("", "proc:");
_infoWidgetLayout->addWidget(_pipelinePropertiesScrollArea, 6, 0, 1, 2);
_mainLayout->addWidget(_infoWidget, 0, 1, 3, 1);
......
......@@ -33,8 +33,6 @@
#include "application/gui/datacontainerinspectorcanvas.h"
#include "application/gui/properties/propertycollectionwidget.h"
#include "scripting/luagen/properties/propertycollectionlua.h"
#include <QLabel>
#include <QWidget>
#include <QVBoxLayout>
......
......@@ -43,7 +43,7 @@
#include <fstream>
#include "scripting/luagen/properties/propertycollectionlua.h"
#include "scripting/luagen/properties/propertycollectionluascriptgenerator.h"
#include "scripting/luagen/properties/abstractpropertylua.h"
......@@ -296,25 +296,6 @@ namespace campvis {
QString filename = QFileDialog::getOpenFileName(QWidget::parentWidget(), dialogCaption, directory, fileFilter);
if (filename != nullptr && _application->getLuaVmState() != nullptr) {
_application->getLuaVmState()->execFile(filename.toStdString());
//std::ifstream file;
//file.open(filename.toStdString());
//if (!file.fail()) {
// _application->getLuaVmState()->execString("proc = pipelines[\"" +_selectedPipeline->getName()+"\"]");
//
// std::string script;
// while (!file.eof()) {
// script = "";
// std::getline(file, script);
// if (script == "")
// continue;
//
// printf("%s\n", script.c_str());
// //if (_application->getLuaVmState() != nullptr) {
// _application->getLuaVmState()->execString(script.c_str());
// //}
// }
// printf("Load lua script");
//}
}
#endif
}
......@@ -329,24 +310,22 @@ namespace campvis {
if (filename != nullptr) {
if (_selectedProcessor != 0 && _selectedPipeline != 0) {
PropertyCollectionLua *_pcLua = new PropertyCollectionLua();
PropertyCollectionLuaScriptGenerator* _pcLua = new PropertyCollectionLuaScriptGenerator();
std::string pipeScript = "pipeline = pipelines[\"" + _selectedPipeline->getName()+"\"]\n\n";
for (int i = 1; i < _selectedPipeline->getProcessors().size(); i++) {
pipeScript += "proc = pipeline:getProcessor(" + StringUtils::toString(i) + ")\n";
AbstractProcessor *proc = _selectedPipeline->getProcessor(i);
AbstractProcessor* proc = _selectedPipeline->getProcessor(i);
_pcLua->updatePropCollection(proc, &_selectedPipeline->getDataContainer());
std::string res = _pcLua->getLuaScript("", "proc:");
std::string res = _pcLua->getLuaScript(std::string(""), std::string("proc:"));
pipeScript += res;
std::cout << "\n\n" + pipeScript + "\n\n";
}
if (pipeScript != "pipeline = pipelines[\"" + _selectedPipeline->getName()+"\"]\n\n") {
std::ofstream file;
file.open(filename.toStdString());
file << pipeScript.c_str();
file.close();
printf("Saved Lua script");
}
delete _pcLua;
......
......@@ -191,25 +191,10 @@ namespace campvis {
float pos = static_cast<float>(e->x()) / static_cast<float>(_canvas->width());
cgt::col4 col = cgt::col4(255);
// add a control point on CTRL+Click
//std::vector<TFGeometry1D::KeyPoint>& kpts = g->getKeyPoints();
//TFGeometry1D::KeyPoint kp(static_cast<float>(e->x()) / static_cast<float>(_canvas->width()), cgt::col4(255));
//std::vector<TFGeometry1D::KeyPoint>::iterator lb = std::upper_bound(kpts.begin(), kpts.end(), kp);
//if (lb != kpts.end()) {
// kp._color = lb->_color;
// col = lb->_color;
//}
//else {
// kp._color = kpts.back()._color;
// col = kpts.back()._color;
//}
float alpha = cgt::clamp(static_cast<float>(_canvas->height() - e->y()) / static_cast<float>(_canvas->height()), 0.f, 1.f);
//kp._color.a = static_cast<uint8_t>(alpha * 255.f);
col.a = static_cast<uint8_t>(alpha * 255.f);
//kpts.insert(lb, kp);
g->addKeyPoint(pos, alpha);
//g->addKeyPoint(pos, col);
}
updateManipulators();
......
......@@ -91,8 +91,8 @@ namespace campvis {
property->s_BeforeTFReplace.connect(this, &TransferFunctionPropertyWidget::onBeforeTFReplace);
property->s_AfterTFReplace.connect(this, &TransferFunctionPropertyWidget::onAfterTFReplace);
bool b = connect(this, SIGNAL(s_beforeTFReplace(AbstractTransferFunction*)), this, SLOT(execBeforeTFReplace(AbstractTransferFunction*)));
b = connect(this, SIGNAL(s_afterTFReplace(AbstractTransferFunction*)), this, SLOT(execAfterTFReplace(AbstractTransferFunction*)));
connect(this, SIGNAL(s_beforeTFReplace(AbstractTransferFunction*)), this, SLOT(execBeforeTFReplace(AbstractTransferFunction*)));
connect(this, SIGNAL(s_afterTFReplace(AbstractTransferFunction*)), this, SLOT(execAfterTFReplace(AbstractTransferFunction*)));
property->s_autoFitWindowToDataChanged.connect(this, &TransferFunctionPropertyWidget::onTransferFunctionAutoFitWindowToDataChanged);
wasVisible = false;
......@@ -181,10 +181,6 @@ namespace campvis {
delete _editor;
_editor = nullptr;
}
if (_dockWidget) {
//delete _dockWidget;
//_dockWidget = nullptr;
}
}
void TransferFunctionPropertyWidget::execAfterTFReplace(AbstractTransferFunction *tf ) {
......@@ -194,11 +190,9 @@ namespace campvis {
TransferFunctionProperty* prop = static_cast<TransferFunctionProperty*>(_property);
_editor = TransferFunctionEditorFactory::createEditor(prop);
//_dockWidget = new QDockWidget("Transfer Function Editor");
_dockWidget->setWidget(_editor);
_dockWidget->setVisible(wasVisible);
//static_cast<CampVisApplication*>(qApp)->registerDockWidget(Qt::BottomDockWidgetArea, _dockWidget);
} else {
_dockWidget->setVisible(true);
}
......
......@@ -116,7 +116,7 @@ namespace campvis {
}
return _texture;
}
cgt::svec3 AbstractTransferFunction::getSize() {
const cgt::svec3& AbstractTransferFunction::getSize() {
return _size;
}
}
\ No newline at end of file
......@@ -124,7 +124,7 @@ namespace campvis {
/// Signal emitted when the intensity domain has changed
sigslot::signal0 s_intensityDomainChanged;
cgt::svec3 getSize();
const cgt::svec3& getSize();
protected:
/**
* Computes the intensity histogram;
......
......@@ -151,9 +151,8 @@ namespace campvis {
}
void TFGeometry1D::addKeyPoint( float position, const cgt::col4& color ) {
TFGeometry1D::KeyPoint kp(position, cgt::col4(255));
TFGeometry1D::KeyPoint kp(position, color);
std::vector<TFGeometry1D::KeyPoint>::iterator lb = std::upper_bound(_keyPoints.begin(), _keyPoints.end(), kp);
kp._color = color; // Check implementation of upper_bound to set this in constructor
_keyPoints.insert(lb, kp);
}
......
......@@ -135,13 +135,19 @@ namespace campvis {
* \return _options[_value]
*/
const GenericOption<T>& getOption() const;
/**
* Returns the value of the currently selected option.
* \return _options[_value]._value
*/
T getOptionValue() const;
/**
* Returns the id of the currently selected option.
* \return _options[_value]._id
*/
std::string& getOptionId() const;
/**
* Sets the selected option to the first option with the given id.
......@@ -245,6 +251,11 @@ namespace campvis {
return _options[_value]._value;
}
template<typename T>
std::string& campvis::GenericOptionProperty<T>::getOptionId() const {
return _options[_value]._id;
}
template<typename T>
void campvis::GenericOptionProperty<T>::selectById(const std::string& id) {
for (size_t i = 0; i < _options.size(); ++i) {
......
......@@ -3,17 +3,14 @@
// Add property luas to ensure build
// TODO: find a better way
#include "scripting/luagen/properties/boolpropertylua.h"
#include "scripting/luagen/properties/buttonpropertylua.h"
#include "scripting/luagen/properties/floatpropertylua.h"
#include "scripting/luagen/properties/intpropertylua.h"
#include "scripting/luagen/properties/optionpropertylua.h"
#include "scripting/luagen/properties/stringpropertylua.h"
#include "scripting/luagen/properties/camerapropertylua.h"
#include "scripting/luagen/properties/colorpropertylua.h"
#include "scripting/luagen/properties/datanamepropertylua.h"
#include "scripting/luagen/properties/metapropertylua.h"
#include "scripting/luagen/properties/propertycollectionlua.h"
#include "scripting/luagen/properties/propertycollectionluascriptgenerator.h"
#include "scripting/luagen/properties/transferfunctionpropertylua.h"
namespace campvis {
......
......@@ -26,9 +26,8 @@
#include "core/properties/abstractproperty.h"
namespace campvis {
AbstractPropertyLua::AbstractPropertyLua(AbstractProperty* property, DataContainer* dataContainer)
AbstractPropertyLua::AbstractPropertyLua(AbstractProperty* property)
: _property(property)
, _dataContainer(dataContainer)
{
}
......
......@@ -37,28 +37,26 @@ namespace campvis {
/**
* Abstract base class for property luas.
*/
class AbstractPropertyLua : public sigslot::has_slots {
class AbstractPropertyLua {
public:
/**
* Creates a new PropertyWidget for the property \a property.
* Creates a new Lua Property for the property \a property.
*
* If displayBoxed is true, the lua is displayed vertically in a QGroupBox.
*
* \param property The property the lua shall handle.
* \param dataContainer DataContainer to use (optional), defaults to nullptr. However, some derived classed might need a valid pointer here!
*/
AbstractPropertyLua(AbstractProperty* property, DataContainer* dataContainer = nullptr);
AbstractPropertyLua(AbstractProperty* property);
/**
* Destructor
*/
virtual ~AbstractPropertyLua();
public:
virtual std::string getLuaScript(std::string propNamePrefix, std::string luaProc) = 0;
virtual std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc) = 0;
protected:
AbstractProperty* _property; ///< The property this lua handles
DataContainer* _dataContainer; ///< DataContainer to use (e.g. to populate GUI), may be 0!
};
}
......
......@@ -26,15 +26,15 @@
#include "core/tools/stringutils.h"
namespace campvis {
BoolPropertyLua::BoolPropertyLua(BoolProperty* property, DataContainer* dataContainer)
: AbstractPropertyLua(property, dataContainer)
BoolPropertyLua::BoolPropertyLua(BoolProperty* property)
: AbstractPropertyLua(property)
{
}
BoolPropertyLua::~BoolPropertyLua() {
}
std::string BoolPropertyLua::getLuaScript(std::string propNamePrefix, std::string luaProc) {
std::string BoolPropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
std::string ret = "";
ret += luaProc;
ret += "getNestedProperty(\"" + propNamePrefix +_property->getName() + "\"):setValue("
......
......@@ -39,14 +39,14 @@ namespace campvis {
* Creates a new BoolPropertyLua for the property \a property.
* \param property The property the widget shall handle
*/
BoolPropertyLua(BoolProperty* property, DataContainer* dataContainer = nullptr);
BoolPropertyLua(BoolProperty* property);
/**
* Destructor
*/
virtual ~BoolPropertyLua();
std::string getLuaScript(std::string propNamePrefix, std::string luaProc);
std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc);
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
......
// ================================================================================================
//
// 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 "buttonpropertylua.h"
#include <QPushButton>
namespace campvis {
ButtonPropertyLua::ButtonPropertyLua(ButtonProperty* property, DataContainer* dataContainer)
: AbstractPropertyLua(property, dataContainer)
{
}
ButtonPropertyLua::~ButtonPropertyLua() {
}
std::string ButtonPropertyLua::getLuaScript(std::string propNamePrefix, std::string luaProc) {
return "-- Not necessary ButtonProperty";
}
}
\ No newline at end of file
// ================================================================================================
//
// 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 BUTTONPROPERTYLUA_H__
#define BUTTONPROPERTYLUA_H__
#include "abstractpropertylua.h"
#include "propertyluafactory.h"
#include "core/properties/buttonproperty.h"
namespace campvis {
/**
* Lua generator for a ButtonProperty.
* For now just offering read-access.
*/
class ButtonPropertyLua : public AbstractPropertyLua {
public:
/**
* Creates a new ButtonPropertyLua for the property \a property.
* \param property The property the lua shall handle
*/
ButtonPropertyLua(ButtonProperty* property, DataContainer* dataContainer = nullptr);
/**
* Destructor
*/
virtual ~ButtonPropertyLua();
std::string getLuaScript(std::string propNamePrefix, std::string luaProc);
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
//template class PropertyLuaRegistrar<ButtonPropertyLua, ButtonProperty>;
}
#endif // BUTTONPROPERTYLUA_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 "camerapropertylua.h"
#include "core/tools/stringutils.h"
namespace campvis {
//CameraPropertyLua::CameraPropertyLua(CameraProperty* property, DataContainer* dataContainer)
// : AbstractPropertyLua(property, dataContainer)
//{
//}
CameraPropertyLua::~CameraPropertyLua() {
}
//void CameraPropertyLua::updateLuaFromProperty() {
// CameraProperty* prop = static_cast<CameraProperty*>(_property);
// _lblCameraPosition->setText("Position: " + QString::fromStdString(StringUtils::toString(prop->getValue().getPosition())));
// _lblFocusPosition->setText("Focus: " + QString::fromStdString(StringUtils::toString(prop->getValue().getFocus())));
// _lblLookDirection->setText("Look Direction: " + QString::fromStdString(StringUtils::toString(prop->getValue().getLook())));
// _lblUpVector->setText("Up Vector: " + QString::fromStdString(StringUtils::toString(prop->getValue().getUpVector())));
//}
std::string CameraPropertyLua::getLuaScript(std::string propNamePrefix, std::string luaProc) {
std::string ret = "";
// cgt::Camera cam = static_cast<CameraProperty*>(_property)->getValue();
// cgt::vec3 pos = cam.getPosition();
// cgt::vec3 focus = cam.getFocus();
// cgt::vec3 up = cam.getUpVector();
// float fovy = cam.getFovy();
// float ratio = cam.getRatio();
// float distn = cam.getNearDist();
// float distf = cam.getFarDist();
// int pm = cam.getProjectionMode();
// ret += "getNestedProperty(\"" + propNamePrefix+ _property->getName() + "\"):setValue(cgt.Camera("
// + "cgt.vec3(" + StringUtils::toString(pos.x) + "," + StringUtils::toString(pos.y) + "," + StringUtils::toString(pos.z) + ")"
// + "," + "cgt.vec3(" + StringUtils::toString(focus.x) + "," + StringUtils::toString(focus.y) + "," + StringUtils::toString(focus.z) + ")"
// + "," + "cgt.vec3(" + StringUtils::toString(up.x) + "," + StringUtils::toString(up.y) + "," + StringUtils::toString(up.z) + ")"
// + "," + StringUtils::toString(fovy)
// + "," + StringUtils::toString(ratio)
// + "," + StringUtils::toString(distn)
// + "," + StringUtils::toString(distf)
// + "," + StringUtils::toString(pm)
// +"))";
// //ret = "-- If required need to implement lua interface for cgt:Camera";
return ret;
}
}
\ No newline at end of file
// ================================================================================================
//
// 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 CAMERAPROPERTYLUA_H__
#define CAMERAPROPERTYLUA_H__
#include "abstractpropertylua.h"
#include "propertyluafactory.h"
namespace campvis {
/**
* Lua generator for a Camera.
* For now just offering read-access.
*/
class CameraPropertyLua : public AbstractPropertyLua {
public:
/**
* Creates a new CameraPropertyLua for the property \a property.
* \param property The property the lua shall handle
* \param dataContainer DataContainer to use (optional), defaults to nullptr.
*/
//CameraPropertyLua(CameraProperty* property, DataContainer* dataContainer);
/**
* Destructor
*/
virtual ~CameraPropertyLua();
std::string getLuaScript(std::string propNamePrefix, std::string luaProc);
};
// explicitly instantiate template, so that it gets registered also over DLL boundaries.
//template class PropertyLuaRegistrar<CameraPropertyLua, CameraProperty>;
}
#endif // CAMERAPROPERTYLUA_H__
......@@ -27,15 +27,15 @@
#include "core/tools/stringutils.h"
namespace campvis {
ColorPropertyLua::ColorPropertyLua(ColorProperty* property, DataContainer* dataContainer)
: AbstractPropertyLua(property, dataContainer)
ColorPropertyLua::ColorPropertyLua(ColorProperty* property)
: AbstractPropertyLua(property)
{
}
ColorPropertyLua::~ColorPropertyLua() {
}
std::string ColorPropertyLua::getLuaScript(std::string propNamePrefix, std::string luaProc) {
std::string ColorPropertyLua::getLuaScript(std::string& propNamePrefix, std::string& luaProc) {
cgt::vec4 value = static_cast<ColorProperty*>(_property)->getValue();
std::string ret = "";
ret += luaProc;
......
......@@ -40,16 +40,15 @@ namespace campvis {
/**
* Creates a new FloatPropertyLua for the property \a property.
* \param property The property the lua shall handle
* \param dataContainer DataContainer to use (optional), defaults to nullptr.
*/
ColorPropertyLua(ColorProperty* property, DataContainer* dataContainer);
ColorPropertyLua(ColorProperty* property);
/**
* Destructor
*/
virtual ~ColorPropertyLua();
std::string getLuaScript(std::string propNamePrefix, std::string luaProc);
std::string getLuaScript(std::string& propNamePrefix, std::string& luaProc);
};
// ================================================================================================
......