Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ build_v8a/

node_modules
output

# Copilot instruction files
copilot-instructions.md
1 change: 0 additions & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
"version": "0.2.0",
"configurations": [
{
CreateDmxChannelSet
"preLaunchTask": "build"
},
{
Expand Down
118 changes: 96 additions & 22 deletions src/GDTFManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5274,7 +5274,7 @@ size_t GdtfDmxMode::GetFootPrintForBreak(size_t breakId)
}
void GdtfDmxMode::GetAddressesFromChannel(TDMXAddressArray& addresses, GdtfDmxChannel* channel, DMXAddress offset) const
{
EGdtfChannelBitResolution resolution = channel->GetChannelBitResolution();
EGdtfChannelBitResolution resolution = channel->GetResolution();
if(resolution >= eGdtfChannelBitResolution_8) { addresses.push_back(channel->GetCoarse() + offset);}
if(resolution >= eGdtfChannelBitResolution_16) { addresses.push_back(channel->GetFine() + offset);}
if(resolution >= eGdtfChannelBitResolution_24) { addresses.push_back(channel->GetUltra() + offset);}
Expand All @@ -5293,6 +5293,7 @@ GdtfDmxChannel::GdtfDmxChannel(GdtfDmxMode* parent)
{
fName_AutoGenerated = "";
fDmxBreak = 1;
fResolution = eGdtfChannelBitResolution_8;
fCoarse = 0;
fFine = 0;
fUltra = 0;
Expand Down Expand Up @@ -5321,6 +5322,11 @@ void GdtfDmxChannel::SetDmxBreak(Sint32 dmxBreak)
fDmxBreak = dmxBreak;
}

void GdtfDmxChannel::SetResolution(EGdtfChannelBitResolution resolution)
{
fResolution = resolution;
}

void GdtfDmxChannel::SetDmxCoarse(Sint32 coarse)
{
fCoarse = coarse;
Expand Down Expand Up @@ -5369,12 +5375,11 @@ void GdtfDmxChannel::OnPrintToFile(IXMLFileNodePtr pNode)
// Call the parent
GdtfObject::OnPrintToFile(pNode);

EGdtfChannelBitResolution chanelReso = GetChannelBitResolution();
// ------------------------------------------------------------------------------------
// Print node attributes
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelDMXBreak, GdtfConverter::ConvertDmxBreak(fDmxBreak));
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelOffset, GdtfConverter::ConvertDmxOffset(fCoarse, fFine, fUltra, fUber));
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelHighlight, GdtfConverter::ConvertDMXValue(fHeighlight, chanelReso, fHeighlightNone));
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelHighlight, GdtfConverter::ConvertDMXValue(fHeighlight, fResolution, fHeighlightNone));
if (fGeomRef) { pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelGeometry, fGeomRef->GetNodeReference()); }
if (fInitialFunction) { pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelInitialFunction, fInitialFunction->GetNodeReference()); }

Expand Down Expand Up @@ -5402,19 +5407,21 @@ void GdtfDmxChannel::OnReadFromNode(const IXMLFileNodePtr& pNode)
GdtfConverter::ConvertDmxOffset(offset, pNode, fCoarse, fFine, fUltra, fUber);
}

fResolution = GetCalculatedChannelBitResolution(pNode);

// In GDTF 1.0, default value was in the DMX channel, this is for old files :
TXString defVal;
if (pNode->GetNodeAttributeValue(XML_GDTF_DMXChannelFuntionDefault, defVal) == kVCOMError_NoError)
{
GdtfConverter::ConvertDMXValue(defVal, pNode, this->GetChannelBitResolution(), fDefaultValue_old);
GdtfConverter::ConvertDMXValue(defVal, pNode, this->GetResolution(), fDefaultValue_old);
}
// ------------------------------------------------------------------------------------

//
TXString highlight;
if(VCOM_SUCCEEDED(pNode->GetNodeAttributeValue(XML_GDTF_DMXChannelHighlight, highlight) ))
{
GdtfConverter::ConvertDMXValue(highlight, pNode, this->GetChannelBitResolution(), fHeighlight, fHeighlightNone);
GdtfConverter::ConvertDMXValue(highlight, pNode, this->GetResolution(), fHeighlight, fHeighlightNone);
}

pNode->GetNodeAttributeValue(XML_GDTF_DMXChannelGeometry, fUnresolvedGeomRef);
Expand Down Expand Up @@ -5517,6 +5524,11 @@ Sint32 GdtfDmxChannel::GetDmxBreak() const
return fDmxBreak;
}

EGdtfChannelBitResolution GdtfDmxChannel::GetResolution() const
{
return fResolution;
}

Sint32 GdtfDmxChannel::GetCoarse() const
{
return fCoarse;
Expand Down Expand Up @@ -5587,10 +5599,10 @@ const TGdtfDmxLogicalChannelArray GdtfDmxChannel::GetLogicalChannelArray()
return fLogicalChannels;
}

EGdtfChannelBitResolution SceneData::GdtfDmxChannel::GetChannelBitResolution()
EGdtfChannelBitResolution SceneData::GdtfDmxChannel::GetCalculatedChannelBitResolution(const IXMLFileNodePtr& pNode)
{
// 0 is false, everything else is true
if ((!fCoarse) && !fFine && !fUltra && !fUber) { return EGdtfChannelBitResolution::eGdtfChannelBitResolution_32; }
if ((!fCoarse) && !fFine && !fUltra && !fUber) { return ExtractResolutionFromDMXFrom(pNode); }
else if (( fCoarse) && !fFine && !fUltra && !fUber) { return EGdtfChannelBitResolution::eGdtfChannelBitResolution_8; }
else if (( fCoarse) &&( fFine) && !fUltra && !fUber ) { return EGdtfChannelBitResolution::eGdtfChannelBitResolution_16; }
else if (( fCoarse) &&( fFine) && ( fUltra) && !fUber ) { return EGdtfChannelBitResolution::eGdtfChannelBitResolution_24; }
Expand All @@ -5601,9 +5613,71 @@ EGdtfChannelBitResolution SceneData::GdtfDmxChannel::GetChannelBitResolution()
return EGdtfChannelBitResolution::eGdtfChannelBitResolution_8;
}

EGdtfChannelBitResolution SceneData::GdtfDmxChannel::ExtractResolutionFromDMXFrom(const IXMLFileNodePtr& pNode)
{
auto extractFromDMXValue = [](const TXString& dmxValue) -> EGdtfChannelBitResolution {
if (dmxValue.IsEmpty()) {
return EGdtfChannelBitResolution::eGdtfChannelBitResolution_8;//Invalid
}

ptrdiff_t splitPos = dmxValue.Find("/");
if (splitPos == -1) {
return EGdtfChannelBitResolution::eGdtfChannelBitResolution_8;//Invalid
}

TXString resolutionPart = dmxValue.Mid(splitPos + 1);
resolutionPart.Trim();

if (!resolutionPart.IsCompleteNumber()) {
return EGdtfChannelBitResolution::eGdtfChannelBitResolution_8;//Invalid
}

Sint32 byteSpecifier = resolutionPart.atoi();

switch (byteSpecifier) {
case 1: return EGdtfChannelBitResolution::eGdtfChannelBitResolution_8;
case 2: return EGdtfChannelBitResolution::eGdtfChannelBitResolution_16;
case 3: return EGdtfChannelBitResolution::eGdtfChannelBitResolution_24;
case 4: return EGdtfChannelBitResolution::eGdtfChannelBitResolution_32;
default: return EGdtfChannelBitResolution::eGdtfChannelBitResolution_8;//Invalid
}
};

EGdtfChannelBitResolution foundResolution = EGdtfChannelBitResolution::eGdtfChannelBitResolution_8;
bool found = false;

GdtfConverter::TraverseNodes(pNode, "", XML_GDTF_DMXLogicalChannelNodeName, [&](IXMLFileNodePtr logicalChannelNode) -> void {
if (CheckAbort() || found) return;

GdtfConverter::TraverseNodes(logicalChannelNode, "", XML_GDTF_DMXChannelFuntionNodeName, [&](IXMLFileNodePtr functionNode) -> void {
if (CheckAbort() || found) return;

TXString dmxFrom;
if (functionNode->GetNodeAttributeValue(XML_GDTF_DMXChannelFuntionDMXFrom, dmxFrom) == kVCOMError_NoError) {

if (dmxFrom.Find("/") != -1) {
EGdtfChannelBitResolution result = extractFromDMXValue(dmxFrom);

if (result != EGdtfChannelBitResolution::eGdtfChannelBitResolution_8 || dmxFrom.Find("/1") != -1) {
foundResolution = result;
found = true;
return;
}
}
}
});
});

if (found) {
return foundResolution;
}

return EGdtfChannelBitResolution::eGdtfChannelBitResolution_32;
}

DmxValue SceneData::GdtfDmxChannel::GetChannelMaxDmx()
{
return GdtfConverter::GetChannelMaxDmx(this->GetChannelBitResolution());
return GdtfConverter::GetChannelMaxDmx(this->GetResolution());
}

bool SceneData::GdtfDmxChannel::IsVirtual() const
Expand Down Expand Up @@ -5988,7 +6062,7 @@ void GdtfDmxChannelFunction::OnPrintToFile(IXMLFileNodePtr pNode)
// Call the parent
GdtfObject::OnPrintToFile(pNode);

EGdtfChannelBitResolution chanelReso = GetParentDMXChannel()->GetChannelBitResolution();
EGdtfChannelBitResolution chanelReso = GetParentDMXChannel()->GetResolution();

// ------------------------------------------------------------------------------------
// Print node attributes
Expand Down Expand Up @@ -6020,16 +6094,16 @@ void GdtfDmxChannelFunction::OnPrintToFile(IXMLFileNodePtr pNode)
ASSERTN(kEveryone, (fModeMaster_Function == nullptr));

pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelFuntionModeMaster, fModeMaster_Channel->GetNodeReference());
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelFuntionModeFrom, GdtfConverter::ConvertDMXValue(fDmxModeStart, fModeMaster_Channel->GetChannelBitResolution()));
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelFuntionModeTo, GdtfConverter::ConvertDMXValue(fDmxModeEnd, fModeMaster_Channel->GetChannelBitResolution()));
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelFuntionModeFrom, GdtfConverter::ConvertDMXValue(fDmxModeStart, fModeMaster_Channel->GetResolution()));
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelFuntionModeTo, GdtfConverter::ConvertDMXValue(fDmxModeEnd, fModeMaster_Channel->GetResolution()));
}
if(fModeMaster_Function)
{
ASSERTN(kEveryone, (fModeMaster_Channel == nullptr));

pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelFuntionModeMaster, fModeMaster_Function->GetNodeReference());
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelFuntionModeFrom, GdtfConverter::ConvertDMXValue(fDmxModeStart, fModeMaster_Function->GetParentDMXChannel()->GetChannelBitResolution()));
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelFuntionModeTo, GdtfConverter::ConvertDMXValue(fDmxModeEnd, fModeMaster_Function->GetParentDMXChannel()->GetChannelBitResolution()));
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelFuntionModeFrom, GdtfConverter::ConvertDMXValue(fDmxModeStart, fModeMaster_Function->GetParentDMXChannel()->GetResolution()));
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelFuntionModeTo, GdtfConverter::ConvertDMXValue(fDmxModeEnd, fModeMaster_Function->GetParentDMXChannel()->GetResolution()));
}

// ------------------------------------------------------------------------------------
Expand Down Expand Up @@ -6117,7 +6191,7 @@ void GdtfDmxChannelFunction::OnReadFromNode(const IXMLFileNodePtr& pNode)

// ------------------------------------------------------------------------------------
// Print node attributes
EGdtfChannelBitResolution channelReso = fParentLogicalChannel->GetParentDMXChannel()->GetChannelBitResolution();
EGdtfChannelBitResolution channelReso = fParentLogicalChannel->GetParentDMXChannel()->GetResolution();

pNode->GetNodeAttributeValue(XML_GDTF_DMXChannelFuntionName, fName);
pNode->GetNodeAttributeValue(XML_GDTF_DMXChannelFuntionOriginalAttribute, fOrignalAttribute);
Expand Down Expand Up @@ -6637,7 +6711,7 @@ void GdtfDmxChannelSet::OnPrintToFile(IXMLFileNodePtr pNode)
// Call the parent
GdtfObject::OnPrintToFile(pNode);

EGdtfChannelBitResolution chanelReso = GetParentDMXChannel()->GetChannelBitResolution();
EGdtfChannelBitResolution chanelReso = GetParentDMXChannel()->GetResolution();
// ------------------------------------------------------------------------------------
// Print node attributes
pNode->SetNodeAttributeValue(XML_GDTF_DMXChannelSetName, fUniqueName);
Expand All @@ -6663,7 +6737,7 @@ void GdtfDmxChannelSet::OnReadFromNode(const IXMLFileNodePtr& pNode)
// Print node attributes
pNode->GetNodeAttributeValue(XML_GDTF_DMXChannelSetName, fUniqueName);

EGdtfChannelBitResolution channelReso = fParentChnlFunction->GetParentDMXChannel()->GetChannelBitResolution();
EGdtfChannelBitResolution channelReso = fParentChnlFunction->GetParentDMXChannel()->GetResolution();

TXString dmxfrom; pNode->GetNodeAttributeValue(XML_GDTF_DMXChannelSetDMXFrom, dmxfrom); fValid = GdtfConverter::ConvertDMXValue (dmxfrom, pNode, channelReso, fDmxStart);
TXString wheelId; pNode->GetNodeAttributeValue(XML_GDTF_DMXChannelSetWheelSlotIndexRef, wheelId); GdtfConverter::ConvertInteger(wheelId, pNode, fWheelSlotIdx);
Expand Down Expand Up @@ -8366,7 +8440,7 @@ void GdtfFixture::ResolveMacroRefs(GdtfDmxModePtr dmxMode)
{

DmxValue dmxVal = 0;
GdtfConverter::ConvertDMXValue(value->GetUnresolvedDMXValue(), node, value->GetDMXChannel()->GetChannelBitResolution(), dmxVal);
GdtfConverter::ConvertDMXValue(value->GetUnresolvedDMXValue(), node, value->GetDMXChannel()->GetResolution(), dmxVal);
value->SetValue(dmxVal);
}
else
Expand Down Expand Up @@ -8403,7 +8477,7 @@ void GdtfFixture::ResolveMacroRefs(GdtfDmxModePtr dmxMode)
value->GetNode(node);

DmxValue dmxVal = 0;
GdtfConverter::ConvertDMXValue(value->GetUnresolvedDMXValue(), node, channelFunction->GetParentDMXChannel()->GetChannelBitResolution(), dmxVal);
GdtfConverter::ConvertDMXValue(value->GetUnresolvedDMXValue(), node, channelFunction->GetParentDMXChannel()->GetResolution(), dmxVal);
value->SetDmxValue(dmxVal);
}
}
Expand Down Expand Up @@ -8489,15 +8563,15 @@ void GdtfFixture::ResolveDMXModeMasters()
{
function->SetModeMaster_Channel(channelPtr);
resolved = true;
resolution = channelPtr->GetChannelBitResolution();
resolution = channelPtr->GetResolution();
}

GdtfDmxChannelFunctionPtr functionPtr = getDmxFunctionByRef(unresolvedModeMaster, mode);
if(! resolved && functionPtr)
{
function->SetModeMaster_Function(functionPtr);
resolved = true;
resolution = functionPtr->GetParentDMXChannel()->GetChannelBitResolution();
resolution = functionPtr->GetParentDMXChannel()->GetResolution();
}

ASSERTN(kEveryone, resolved);
Expand Down Expand Up @@ -11355,7 +11429,7 @@ void SceneData::GdtfMacroDMXValue::OnPrintToFile(IXMLFileNodePtr pNode)
ASSERTN(kEveryone, fDMXChannel != nullptr);
if(fDMXChannel)
{
resolution = fDMXChannel->GetChannelBitResolution();
resolution = fDMXChannel->GetResolution();
}

//------------------------------------------------------------------------------------
Expand Down Expand Up @@ -11668,7 +11742,7 @@ void SceneData::GdtfMacroVisualValue::OnPrintToFile(IXMLFileNodePtr pNode)

EGdtfChannelBitResolution resolution = EGdtfChannelBitResolution::eGdtfChannelBitResolution_8;
ASSERTN(kEveryone, fChannelFunctionRef != nullptr);
if(fChannelFunctionRef) {resolution = fChannelFunctionRef->GetParentDMXChannel()->GetChannelBitResolution(); }
if(fChannelFunctionRef) {resolution = fChannelFunctionRef->GetParentDMXChannel()->GetResolution(); }

//------------------------------------------------------------------------------------
// Print the attributes
Expand Down
8 changes: 7 additions & 1 deletion src/GDTFManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -1748,6 +1748,7 @@ namespace SceneData
private:
TXString fName_AutoGenerated;
Sint32 fDmxBreak;
EGdtfChannelBitResolution fResolution;
DMXAddress fCoarse;
DMXAddress fFine;
DMXAddress fUltra;
Expand All @@ -1771,6 +1772,7 @@ namespace SceneData

const TXString& GetName();
Sint32 GetDmxBreak() const;
EGdtfChannelBitResolution GetResolution() const;
Sint32 GetCoarse() const;
Sint32 GetFine() const;
Sint32 GetUltra() const;
Expand All @@ -1783,12 +1785,13 @@ namespace SceneData
TXString GetUnresolvedGeomRef() const;
GdtfDmxChannelFunctionPtr GetInitialFunction();
TXString GetUnresolvedInitialFunction() const;
EGdtfChannelBitResolution GetChannelBitResolution();
EGdtfChannelBitResolution GetCalculatedChannelBitResolution(const IXMLFileNodePtr& pNode);
DmxValue GetChannelMaxDmx();
bool IsVirtual() const;

void SetName(const TXString& name);
void SetDmxBreak(Sint32 dmxBreak);
void SetResolution(EGdtfChannelBitResolution resolution);
void SetDmxCoarse(Sint32 coarse);
void SetDmxFine(Sint32 fine);
void SetDmxUltra(Sint32 ultra);
Expand All @@ -1802,6 +1805,9 @@ namespace SceneData
// Get Parent
GdtfDmxMode* GetParentMode();

// Resolution extraction from ChannelFunction's DMXFrom value
EGdtfChannelBitResolution ExtractResolutionFromDMXFrom(const IXMLFileNodePtr& pNode);

protected:
virtual TXString GetNodeName();
virtual void OnPrintToFile(IXMLFileNodePtr pNode);
Expand Down
12 changes: 11 additions & 1 deletion src/Implementation/CGdtfDmxChannel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ VectorworksMVR::VCOMError VectorworksMVR::CGdtfDmxChannelImpl::GetResolution(Gdt
// Check Pointer
if ( ! fChannel) { return kVCOMError_NotInitialized; }

resolution = fChannel->GetChannelBitResolution();
resolution = fChannel->GetResolution();

return kVCOMError_NoError;
}
Expand Down Expand Up @@ -234,6 +234,16 @@ VectorworksMVR::VCOMError VectorworksMVR::CGdtfDmxChannelImpl::SetGeometry(IGdtf
return kVCOMError_NoError;
}

VectorworksMVR::VCOMError VectorworksMVR::CGdtfDmxChannelImpl::SetResolution(GdtfDefines::EGdtfChannelBitResolution resolution)
{
// Check Pointer
if ( ! fChannel) { return kVCOMError_NotInitialized; }

fChannel->SetResolution(resolution);

return kVCOMError_NoError;
}

VectorworksMVR::VCOMError VectorworksMVR::CGdtfDmxChannelImpl::GetLogicalChannelCount(size_t &count)
{
// Check Pointer
Expand Down
1 change: 1 addition & 0 deletions src/Implementation/CGdtfDmxChannel.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace VectorworksMVR
virtual VCOMError VCOM_CALLTYPE SetUber(Sint32 uber);
virtual VCOMError VCOM_CALLTYPE SetHighlight(DmxValue highlight);
virtual VCOMError VCOM_CALLTYPE SetGeometry(IGdtfGeometry* model);
virtual VCOMError VCOM_CALLTYPE SetResolution(GdtfDefines::EGdtfChannelBitResolution resolution);

virtual VCOMError VCOM_CALLTYPE GetLogicalChannelCount(size_t& count);
virtual VCOMError VCOM_CALLTYPE GetLogicalChannelAt(size_t at, IGdtfDmxLogicalChannel** channel);
Expand Down
2 changes: 1 addition & 1 deletion src/Implementation/CGdtfDmxChannelFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ VectorworksMVR::VCOMError VectorworksMVR::CGdtfDmxChannelFunctionImpl::GetResolu
// Check Pointer
if ( ! fFunction) { return kVCOMError_NotInitialized; }

resolution = fFunction->GetParentDMXChannel()->GetChannelBitResolution();
resolution = fFunction->GetParentDMXChannel()->GetResolution();

return kVCOMError_NoError;
}
Expand Down
1 change: 1 addition & 0 deletions src/Include/IMediaRessourceVectorInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -1148,6 +1148,7 @@ namespace VectorworksMVR

// 0.3.20
virtual VCOMError VCOM_CALLTYPE GetResolution(GdtfDefines::EGdtfChannelBitResolution& resolution) = 0;
virtual VCOMError VCOM_CALLTYPE SetResolution(GdtfDefines::EGdtfChannelBitResolution resolution) = 0;

// GDTF 1.1
virtual VCOMError VCOM_CALLTYPE GetInitialFunction(IGdtfDmxChannelFunction** function) = 0;
Expand Down
Loading
Loading