1 |
/* |
/* |
2 |
Copyright (c) 2014 Christian Schoenebeck |
Copyright (c) 2014-2015 Christian Schoenebeck |
3 |
|
|
4 |
This file is part of "gigedit" and released under the terms of the |
This file is part of "gigedit" and released under the terms of the |
5 |
GNU General Public License version 2. |
GNU General Public License version 2. |
20 |
#include <string.h> |
#include <string.h> |
21 |
|
|
22 |
#include <glibmm/ustring.h> |
#include <glibmm/ustring.h> |
|
#include <gtkmm/stock.h> |
|
23 |
#include <gtkmm/messagedialog.h> |
#include <gtkmm/messagedialog.h> |
24 |
#include <gtkmm/label.h> |
#include <gtkmm/label.h> |
25 |
|
|
96 |
* found with a range member point >= iStart |
* found with a range member point >= iStart |
97 |
*/ |
*/ |
98 |
static int findLowestRegionPoint(std::vector<gig::Instrument*>& instruments, int iStart) { |
static int findLowestRegionPoint(std::vector<gig::Instrument*>& instruments, int iStart) { |
99 |
DLS::range_t searchRange = { iStart, 127 }; |
DLS::range_t searchRange = { uint16_t(iStart), 127 }; |
100 |
int result = -1; |
int result = -1; |
101 |
for (uint i = 0; i < instruments.size(); ++i) { |
for (uint i = 0; i < instruments.size(); ++i) { |
102 |
gig::Instrument* instr = instruments[i]; |
gig::Instrument* instr = instruments[i]; |
118 |
* with a range end >= iStart |
* with a range end >= iStart |
119 |
*/ |
*/ |
120 |
static int findFirstRegionEnd(std::vector<gig::Instrument*>& instruments, int iStart) { |
static int findFirstRegionEnd(std::vector<gig::Instrument*>& instruments, int iStart) { |
121 |
DLS::range_t searchRange = { iStart, 127 }; |
DLS::range_t searchRange = { uint16_t(iStart), 127 }; |
122 |
int result = -1; |
int result = -1; |
123 |
for (uint i = 0; i < instruments.size(); ++i) { |
for (uint i = 0; i < instruments.size(); ++i) { |
124 |
gig::Instrument* instr = instruments[i]; |
gig::Instrument* instr = instruments[i]; |
194 |
iStart = findLowestRegionPoint(instruments, iStart); |
iStart = findLowestRegionPoint(instruments, iStart); |
195 |
if (iStart < 0) break; |
if (iStart < 0) break; |
196 |
const int iEnd = findFirstRegionEnd(instruments, iStart); |
const int iEnd = findFirstRegionEnd(instruments, iStart); |
197 |
DLS::range_t range = { iStart, iEnd }; |
DLS::range_t range = { uint16_t(iStart), uint16_t(iEnd) }; |
198 |
intersections.push_back(range); |
intersections.push_back(range); |
199 |
iStart = iEnd + 1; |
iStart = iEnd + 1; |
200 |
} |
} |
265 |
itNums != it->second.end(); ++itNums) |
itNums != it->second.end(); ++itNums) |
266 |
{ |
{ |
267 |
const int iUpperLimit = *itNums; |
const int iUpperLimit = *itNums; |
268 |
DLS::range_t range = { iLow, iUpperLimit }; |
DLS::range_t range = { uint16_t(iLow), uint16_t(iUpperLimit) }; |
269 |
dims[type].push_back(range); |
dims[type].push_back(range); |
270 |
iLow = iUpperLimit + 1; |
iLow = iUpperLimit + 1; |
271 |
} |
} |
382 |
gig::DimensionRegion* dimRgn2 = |
gig::DimensionRegion* dimRgn2 = |
383 |
rgn->pDimensionRegions[ (iDimRgn & mask) | ( z << iBaseBits) ]; |
rgn->pDimensionRegions[ (iDimRgn & mask) | ( z << iBaseBits) ]; |
384 |
int iHigh = dimRgn2->DimensionUpperLimits[iDimension]; |
int iHigh = dimRgn2->DimensionUpperLimits[iDimension]; |
385 |
DLS::range_t range = { iLow, iHigh}; |
DLS::range_t range = { uint16_t(iLow), uint16_t(iHigh) }; |
386 |
#if DEBUG_COMBINE_INSTRUMENTS |
#if DEBUG_COMBINE_INSTRUMENTS |
387 |
printf("%d..%d, ", iLow, iHigh); |
printf("%d..%d, ", iLow, iHigh); |
388 |
fflush(stdout); |
fflush(stdout); |
468 |
#if DEBUG_COMBINE_INSTRUMENTS |
#if DEBUG_COMBINE_INSTRUMENTS |
469 |
printf("dst "); fflush(stdout); |
printf("dst "); fflush(stdout); |
470 |
#endif |
#endif |
471 |
fillDimValues(dstDimValues, dstDimCase, outRgn, true); |
fillDimValues(dstDimValues, dstDimCase, outRgn, false); |
472 |
gig::DimensionRegion* srcDimRgn = inRgn->GetDimensionRegionByValue(srcDimValues); |
gig::DimensionRegion* srcDimRgn = inRgn->GetDimensionRegionByValue(srcDimValues); |
473 |
gig::DimensionRegion* dstDimRgn = outRgn->GetDimensionRegionByValue(dstDimValues); |
gig::DimensionRegion* dstDimRgn = outRgn->GetDimensionRegionByValue(dstDimValues); |
474 |
#if DEBUG_COMBINE_INSTRUMENTS |
#if DEBUG_COMBINE_INSTRUMENTS |
504 |
printf("dst velocity value = %d\n", dstDimCase[gig::dimension_velocity]); |
printf("dst velocity value = %d\n", dstDimCase[gig::dimension_velocity]); |
505 |
printf("dst refilled "); fflush(stdout); |
printf("dst refilled "); fflush(stdout); |
506 |
#endif |
#endif |
507 |
fillDimValues(dstDimValues, dstDimCase, outRgn, true); |
fillDimValues(dstDimValues, dstDimCase, outRgn, false); |
508 |
dstDimRgn = outRgn->GetDimensionRegionByValue(dstDimValues); |
dstDimRgn = outRgn->GetDimensionRegionByValue(dstDimValues); |
509 |
#if DEBUG_COMBINE_INSTRUMENTS |
#if DEBUG_COMBINE_INSTRUMENTS |
510 |
printf("reselected dstDimRgn=%lx\n", (uint64_t)dstDimRgn); |
printf("reselected dstDimRgn=%lx\n", (uint64_t)dstDimRgn); |
659 |
iTotalZones += (def) ? def->zones : 1; |
iTotalZones += (def) ? def->zones : 1; |
660 |
} |
} |
661 |
#if DEBUG_COMBINE_INSTRUMENTS |
#if DEBUG_COMBINE_INSTRUMENTS |
662 |
printf("Required total zones: %d\n", iTotalZones); |
printf("Required total zones: %d, vertical regions: %d\n", iTotalZones, itGroup->second.size()); |
663 |
#endif |
#endif |
664 |
|
|
665 |
// create all required dimensions for this output region |
// create all required dimensions for this output region |
721 |
#if DEBUG_COMBINE_INSTRUMENTS |
#if DEBUG_COMBINE_INSTRUMENTS |
722 |
std::cout << "OK" << std::endl << std::flush; |
std::cout << "OK" << std::endl << std::flush; |
723 |
#endif |
#endif |
724 |
|
} else { |
725 |
|
dims.erase(mainDimension); |
726 |
} |
} |
727 |
|
|
728 |
// for the next task we need to have the current RegionGroup to be |
// for the next task we need to have the current RegionGroup to be |
806 |
CombineInstrumentsDialog::CombineInstrumentsDialog(Gtk::Window& parent, gig::File* gig) |
CombineInstrumentsDialog::CombineInstrumentsDialog(Gtk::Window& parent, gig::File* gig) |
807 |
: Gtk::Dialog(_("Combine Instruments"), parent, true), |
: Gtk::Dialog(_("Combine Instruments"), parent, true), |
808 |
m_gig(gig), m_fileWasChanged(false), m_newCombinedInstrument(NULL), |
m_gig(gig), m_fileWasChanged(false), m_newCombinedInstrument(NULL), |
809 |
m_cancelButton(Gtk::Stock::CANCEL), m_OKButton(Gtk::Stock::OK), |
m_cancelButton(_("_Cancel"), true), m_OKButton(_("_OK"), true), |
810 |
m_descriptionLabel(), m_tableDimCombo(2, 2), m_comboDimType(), |
m_descriptionLabel(), m_tableDimCombo(2, 2), m_comboDimType(), |
811 |
m_labelDimType(Glib::ustring(_("Combine by Dimension:")) + " ", Gtk::ALIGN_END) |
m_labelDimType(Glib::ustring(_("Combine by Dimension:")) + " ", Gtk::ALIGN_END) |
812 |
{ |
{ |
813 |
|
m_scrolledWindow.add(m_treeView); |
814 |
|
m_scrolledWindow.set_policy(Gtk::POLICY_AUTOMATIC, Gtk::POLICY_AUTOMATIC); |
815 |
|
|
816 |
get_vbox()->pack_start(m_descriptionLabel, Gtk::PACK_SHRINK); |
get_vbox()->pack_start(m_descriptionLabel, Gtk::PACK_SHRINK); |
817 |
get_vbox()->pack_start(m_tableDimCombo, Gtk::PACK_SHRINK); |
get_vbox()->pack_start(m_tableDimCombo, Gtk::PACK_SHRINK); |
818 |
get_vbox()->pack_start(m_treeView); |
get_vbox()->pack_start(m_scrolledWindow); |
819 |
get_vbox()->pack_start(m_buttonBox, Gtk::PACK_SHRINK); |
get_vbox()->pack_start(m_buttonBox, Gtk::PACK_SHRINK); |
820 |
|
|
821 |
#if GTKMM_MAJOR_VERSION >= 3 |
#if GTKMM_MAJOR_VERSION >= 3 |