Skip to content

Commit

Permalink
Merge pull request sofa-framework#13 from SofaDefrost/fixDuSoir
Browse files Browse the repository at this point in the history
Various FIX in the widget for Data
  • Loading branch information
damienmarchal authored Oct 15, 2019
2 parents 65639d7 + 88ca796 commit fe1a1db
Show file tree
Hide file tree
Showing 16 changed files with 176 additions and 160 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ def createScene(node):
print(sys.argv[1])
print(sys.argv[2])

loader = node.createObject(sys.argv[1], name="loader", filename=sys.argv[2])
vmodel = node.createObject("OglModel", name="vmodel", src=loader.getLinkPath())
loader = node.addObject(sys.argv[1], name="loader", filename=sys.argv[2])
vmodel = node.addObject("OglModel", name="vmodel", src=loader.getLinkPath())
return node
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,11 @@ def buildDataParams(datas, indent, scn):
s += ", " + data.getName() + "=" + repr(data.value)
return s


def saveRec(node, indent, modules, modulepaths, scn, rootNode):
for o in node.objects:
s = buildDataParams(o.getDataFields(), indent, scn)
print('createObject')
scn[0] += indent + getAbsPythonCallPath(node, rootNode) + ".createObject('"
print('addObject')
scn[0] += indent + getAbsPythonCallPath(node, rootNode) + ".addObject('"
scn[0] += o.getClassName() + "', name='" + o.name.value + "'" + s + ")\n"

for child in node.children:
Expand All @@ -124,7 +123,7 @@ def saveRec(node, indent, modules, modulepaths, scn, rootNode):
child.name + " #########################\n")
scn[0] += (indent + child.getData("Prefab type").value +
"(" + getAbsPythonCallPath(node, rootNode) +
".createChild('" + child.name.value + "'))\n")
".addChild('" + child.name.value + "'))\n")
scn[0] += ("\n")
modules.append(child.getData("Defined in").value)
modulepaths.append(child.getData("modulepath").value)
Expand All @@ -133,7 +132,7 @@ def saveRec(node, indent, modules, modulepaths, scn, rootNode):
scn[0] += (indent + "####################### Node: " + child.name.value +
" #########################\n")
scn[0] += (indent + getAbsPythonCallPath(node, rootNode) +
".createChild('" + child.name.value + "')\n")
".addChild('" + child.name.value + "')\n")
saveRec(child, indent, modules, modulepaths, scn, rootNode)
scn[0] += ("\n")

Expand Down Expand Up @@ -227,8 +226,8 @@ def createPrefabFromNode(fileName, node, name, help):


def loadMeshAsset(type, path, node):
loader = node.createObject(type, name="loader", filename=path)
vmodel = node.createObject("OglModel", name="vmodel", src=loader.getLinkPath())
loader = node.addObject(type, name="loader", filename=path)
vmodel = node.addObject("OglModel", name="vmodel", src=loader.getLinkPath())
return node

def getPrefabMetaData(func, node):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,8 +179,8 @@ Item {
{
/// Returns the widget's properties associated with this SofaData
var component = SofaDataWidgetFactory.getWidgetForData(sofaData)
var o = component.createObject(datawidget, {"sofaData": sofaData,
"Layout.fillWidth":true})
var o = component.createObject(datawidget, {"dataObject": sofaData,
"Layout.fillWidth":true})
self.implicitHeight = o.implicitHeight
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,19 +22,20 @@ import QtQuick.Layouts 1.1
import QtQuick.Controls 2.4
import SofaBasics 1.0
import SofaColorScheme 1.0
import Sofa.Core.SofaData 1.0

ColumnLayout {
id: root
spacing: -1

height: 40
implicitHeight: height
property var sofaData: null
property SofaData dataObject: null


property var values: []
onSofaDataChanged: {
var valStrings = sofaData.value.split(' ')
onDataObjectChanged: {
var valStrings = dataObject.value.split(' ')
for (var i = 0 ; i < valStrings.length ; i++) {
values.push(Number(valStrings[i]))
}
Expand All @@ -57,13 +58,13 @@ ColumnLayout {
Layout.fillWidth: true

showIndicators: false
enabled: !sofaData.isReadOnly
enabled: !dataObject.isReadOnly

value: Number(root.values[index])
onValueChanged: {
if(!sofaData.isReadOnly) {
if(!dataObject.isReadOnly) {
root.values[index] = value;
sofaData.value = root.values.join(' ');
dataObject.value = root.values.join(' ');
}
}

Expand All @@ -83,13 +84,13 @@ ColumnLayout {
Layout.fillWidth: true

showIndicators: false
enabled: !sofaData.isReadOnly
enabled: !dataObject.isReadOnly

value: Number(root.values[index])
onValueChanged: {
if(!sofaData.isReadOnly) {
if(!dataObject.isReadOnly) {
root.values[index] = value;
sofaData.value = root.values.join(' ');
dataObject.value = root.values.join(' ');
}
}

Expand All @@ -108,13 +109,13 @@ ColumnLayout {
Layout.fillWidth: true

showIndicators: false
enabled: !sofaData.isReadOnly
enabled: !dataObject.isReadOnly

value: Number(root.values[index])
onValueChanged: {
if(!sofaData.isReadOnly) {
if(!dataObject.isReadOnly) {
root.values[index] = value;
sofaData.value = root.values.join(' ');
dataObject.value = root.values.join(' ');
}
}

Expand Down Expand Up @@ -144,13 +145,13 @@ ColumnLayout {
Layout.fillWidth: true

showIndicators: false
enabled: !sofaData.isReadOnly
enabled: !dataObject.isReadOnly

value: Number(root.values[index])
onValueChanged: {
if(!sofaData.isReadOnly) {
if(!dataObject.isReadOnly) {
root.values[index] = value;
sofaData.value = root.values.join(' ');
dataObject.value = root.values.join(' ');
}
}

Expand All @@ -170,13 +171,13 @@ ColumnLayout {
Layout.fillWidth: true

showIndicators: false
enabled: !sofaData.isReadOnly
enabled: !dataObject.isReadOnly

value: Number(root.values[index])
onValueChanged: {
if(!sofaData.isReadOnly) {
if(!dataObject.isReadOnly) {
root.values[index] = value;
sofaData.value = root.values.join(' ');
dataObject.value = root.values.join(' ');
}
}

Expand All @@ -195,13 +196,13 @@ ColumnLayout {
Layout.fillWidth: true

showIndicators: false
enabled: !sofaData.isReadOnly
enabled: !dataObject.isReadOnly

value: Number(root.values[index])
onValueChanged: {
if(!sofaData.isReadOnly) {
if(!dataObject.isReadOnly) {
root.values[index] = value;
sofaData.value = root.values.join(' ');
dataObject.value = root.values.join(' ');
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ along with sofaqtquick. If not, see <http://www.gnu.org/licenses/>.
import QtQuick 2.0
import QtQuick.Controls 2.4
import SofaBasics 1.0
import Sofa.Core.SofaData 1.0

/***************************************************************************************************
*
Expand All @@ -28,7 +29,7 @@ import SofaBasics 1.0
*************************************************************************************************/
Text {
id: root
property var dataObject: null
property SofaData dataObject: null
enabled:true
text: dataObject===nullptr? "Undefined" : dataObject.value
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ import QtQuick.Controls 2.4
import QtQuick.Dialogs 1.0
import QtQuick.Layouts 1.0
import SofaBasics 1.0

import Sofa.Core.SofaData 1.0
import SofaApplication 1.0

/***************************************************************************************************
*
Expand All @@ -37,7 +38,7 @@ Row {
spacing : -1
width: parent.width

property var dataObject: null
property SofaData dataObject: null

TextField {
id: textField
Expand Down Expand Up @@ -82,20 +83,27 @@ Row {
}
onClicked: {
/// Open the FileDialog at the specified location.
fileDialog.folder = "file://"+dataObject.properties.folderurl
var url = "";
if( dataObject.properties.folderurl !== ""){
url = "file://"+dataObject.properties.folderurl
}else{
url = SofaApplication.currentProject.rootDir
}

fileDialog.folder = url
fileDialog.open()
}
position: cornerPositions["Right"]
}


FileDialog {
id: fileDialog
title: "Please choose a file"
folder: "file://"+dataObject.properties.folderurl
onAccepted: {
/// Get the URL from the file chooser and convert it to a string.
dataObject.value = fileDialog.fileUrl.toString().replace("file://","") ;
dataObject.upload();
textField.text = dataObject.value.toString();
}
}
Expand Down
Loading

0 comments on commit fe1a1db

Please sign in to comment.