Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Commit

Permalink
Merge pull request #806 from pypeclub/bugfix/harmony-fixes
Browse files Browse the repository at this point in the history
Harmony: fix palette and image sequence loader
  • Loading branch information
mkolar authored Dec 11, 2020
2 parents 8bd4460 + aec53f4 commit 364a52b
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 22 deletions.
5 changes: 5 additions & 0 deletions pype/hosts/harmony/js/PypeHarmony.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
/* global include */
// ***************************************************************************
// * Pype Harmony Host *
// ***************************************************************************

var LD_OPENHARMONY_PATH = System.getenv('LIB_OPENHARMONY_PATH');
include(LD_OPENHARMONY_PATH + '/openHarmony.js');
this.__proto__['$'] = $;


/**
* @namespace
Expand Down
64 changes: 43 additions & 21 deletions pype/hosts/harmony/js/loaders/ImageSequenceLoader.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,42 @@ var ImageSequenceLoader = function() {
};


ImageSequenceLoader.getCurrentGroup = function () {
var doc = $.scn;
var nodeView = '';
for (var i = 0; i < 200; i++) {
nodeView = 'View' + (i);
if (view.type(nodeView) == 'Node View') {
break;
}
}

if (!nodeView) {
$.alert('You must have a Node View open!',
'No Node View is currently open!\n' +
'Open a Node View and Try Again.',
'OK!');
return;
}

var currentGroup;
if (!nodeView) {
currentGroup = doc.root;
} else {
currentGroup = doc.$node(view.group(nodeView));
}

return currentGroup.path;
};


/**
* Get unique column name.
* @function
* @param {string} columnPrefix Column name.
* @return {string} Unique column name.
*/
ImageSequenceLoader.prototype.getUniqueColumnName = function(columnPrefix) {
ImageSequenceLoader.getUniqueColumnName = function(columnPrefix) {
var suffix = 0;
// finds if unique name for a column
var columnName = columnPrefix;
Expand Down Expand Up @@ -63,6 +92,12 @@ ImageSequenceLoader.prototype.getUniqueColumnName = function(columnPrefix) {
* ];
*/
ImageSequenceLoader.prototype.importFiles = function(args) {
var PNGTransparencyMode = 0; // Premultiplied wih Black
var TGATransparencyMode = 0; // Premultiplied wih Black
var SGITransparencyMode = 0; // Premultiplied wih Black
var LayeredPSDTransparencyMode = 1; // Straight
var FlatPSDTransparencyMode = 2; // Premultiplied wih White

var doc = $.scn;
var files = args[0];
var asset = args[1];
Expand All @@ -78,28 +113,15 @@ ImageSequenceLoader.prototype.importFiles = function(args) {
}

// Get the current group
var nodeViewWidget = $.app.getWidgetByName('Node View');
if (!nodeViewWidget) {
$.alert('You must have a Node View open!', 'No Node View!', 'OK!');
return;
}
var currentGroup = doc.$node(ImageSequenceLoader.getCurrentGroup());

nodeViewWidget.setFocus();
var nodeView = view.currentView();
var currentGroup = null;
if (!nodeView) {
currentGroup = doc.root;
} else {
currentGroup = doc.$node(view.group(nodeView));
}
// Get a unique iterative name for the container read node
var num = 0;
var name = '';
do {
name = asset + '_' + (num++) + '_' + subset;
} while (currentGroup.getNodeByName(name) != null);


extension = filename.substr(pos+1).toLowerCase();
if (extension == 'jpeg') {
extension = 'jpg';
Expand All @@ -123,7 +145,7 @@ ImageSequenceLoader.prototype.importFiles = function(args) {
return null; // no read to add.
}

var uniqueColumnName = this.getUniqueColumnName(name);
var uniqueColumnName = ImageSequenceLoader.getUniqueColumnName(name);
column.add(uniqueColumnName, 'DRAWING');
column.setElementIdOfDrawing(uniqueColumnName, elemId);
var read = node.add(currentGroup, name, 'READ', 0, 0, 0);
Expand All @@ -139,19 +161,19 @@ ImageSequenceLoader.prototype.importFiles = function(args) {
read, frame.current(), 'applyMatteToColor'
);
if (extension === 'png') {
transparencyModeAttr.setValue(this.PNGTransparencyMode);
transparencyModeAttr.setValue(PNGTransparencyMode);
}
if (extension === 'tga') {
transparencyModeAttr.setValue(this.TGATransparencyMode);
transparencyModeAttr.setValue(TGATransparencyMode);
}
if (extension === 'sgi') {
transparencyModeAttr.setValue(this.SGITransparencyMode);
transparencyModeAttr.setValue(SGITransparencyMode);
}
if (extension === 'psd') {
transparencyModeAttr.setValue(this.FlatPSDTransparencyMode);
transparencyModeAttr.setValue(FlatPSDTransparencyMode);
}
if (extension === 'jpg') {
transparencyModeAttr.setValue(this.LayeredPSDTransparencyMode);
transparencyModeAttr.setValue(LayeredPSDTransparencyMode);
}

var drawingFilePath;
Expand Down
2 changes: 1 addition & 1 deletion pype/plugins/harmony/load/load_palette.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
class ImportPaletteLoader(api.Loader):
"""Import palettes."""

families = ["palette"]
families = ["palette", "harmony.palette"]
representations = ["plt"]
label = "Import Palette"

Expand Down

0 comments on commit 364a52b

Please sign in to comment.