mirror of
https://git.mirrors.martin98.com/https://github.com/SoftFever/OrcaSlicer.git
synced 2025-04-18 12:10:10 +08:00
init
This commit is contained in:
parent
0f3fbd4390
commit
6a922ea913
@ -220,6 +220,9 @@ function SortUI()
|
||||
//------
|
||||
if(SelectNumber==0)
|
||||
ChooseDefaultFilament();
|
||||
|
||||
// After building the UI, setup filament click handlers
|
||||
SetupFilamentClickHandlers();
|
||||
}
|
||||
|
||||
|
||||
@ -253,7 +256,7 @@ function ChooseAllFilament()
|
||||
{
|
||||
let bCheck=$("#FilatypeList input:first").prop("checked");
|
||||
$("#FilatypeList input").prop("checked",bCheck);
|
||||
|
||||
|
||||
SortFilament();
|
||||
}
|
||||
|
||||
@ -429,6 +432,12 @@ function ChooseDefaultFilament()
|
||||
$(OneFF).prop("checked",true);
|
||||
}
|
||||
|
||||
// Keep this part since we're checking filaments
|
||||
let currentPrinters = GetSelectedPrinters();
|
||||
$("#ItemBlockArea input:checked").each(function() {
|
||||
$(this).data("selectedPrinters", currentPrinters);
|
||||
});
|
||||
|
||||
ShowNotice(0);
|
||||
}
|
||||
|
||||
@ -436,11 +445,16 @@ function SelectAllFilament( nShow )
|
||||
{
|
||||
if( nShow==0 )
|
||||
{
|
||||
$('#ItemBlockArea .MItem:visible input').prop("checked",false);
|
||||
$('#ItemBlockArea .MItem:visible input').prop("checked",false).each(function() {
|
||||
$(this).removeData("selectedPrinters");
|
||||
});
|
||||
}
|
||||
else
|
||||
{
|
||||
$('#ItemBlockArea .MItem:visible input').prop("checked",true);
|
||||
let currentPrinters = GetSelectedPrinters();
|
||||
$('#ItemBlockArea .MItem:visible input').prop("checked",true).each(function() {
|
||||
$(this).data("selectedPrinters", currentPrinters);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@ -471,16 +485,33 @@ function ResponseFilamentResult()
|
||||
}
|
||||
|
||||
let FilaArray=new Array();
|
||||
let FilaInfo = {};
|
||||
|
||||
for(let n=0;n<nAll;n++)
|
||||
{
|
||||
let sName=FilaSelectedList[n].getAttribute("name");
|
||||
let filaElement = FilaSelectedList[n];
|
||||
let sName=filaElement.getAttribute("name");
|
||||
|
||||
// Get the specific printers that were selected when this filament was checked
|
||||
let selectedPrinters = $(filaElement).data("selectedPrinters");
|
||||
if (!selectedPrinters) {
|
||||
// Fallback to current printer selection if no data was stored
|
||||
selectedPrinters = GetSelectedPrinters();
|
||||
}
|
||||
|
||||
for( let key in m_ProfileItem['filament'] )
|
||||
{
|
||||
let FName=GetFilamentShortname(key);
|
||||
|
||||
if(FName==sName)
|
||||
{
|
||||
FilaArray.push(key);
|
||||
|
||||
// Store printer info with the filament
|
||||
FilaInfo[key] = {
|
||||
selectedPrinters: selectedPrinters
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -489,6 +520,7 @@ function ResponseFilamentResult()
|
||||
tSend['command']="save_userguide_filaments";
|
||||
tSend['data']={};
|
||||
tSend['data']['filament']=FilaArray;
|
||||
tSend['data']['filamentInfo'] = FilaInfo;
|
||||
|
||||
SendWXMessage( JSON.stringify(tSend) );
|
||||
|
||||
@ -615,4 +647,43 @@ function CFEdit( fid )
|
||||
SendWXMessage( JSON.stringify(tSend) );
|
||||
}
|
||||
|
||||
// Get selected printers as an array of objects with model and nozzle info
|
||||
function GetSelectedPrinters() {
|
||||
let selectedPrinters = [];
|
||||
let pModel = $("#MachineList input:checked");
|
||||
let nModel = pModel.length;
|
||||
|
||||
for (let n = 0; n < nModel; n++) {
|
||||
let oneModel = pModel[n];
|
||||
let modelName = oneModel.getAttribute("mode");
|
||||
|
||||
if (modelName !== 'all') {
|
||||
selectedPrinters.push(modelName);
|
||||
}
|
||||
}
|
||||
|
||||
return selectedPrinters;
|
||||
}
|
||||
|
||||
// Add click handlers for filament checkboxes
|
||||
function SetupFilamentClickHandlers() {
|
||||
// Remove any existing handler to avoid duplicates
|
||||
$("#ItemBlockArea").off("change", "input[type='checkbox']");
|
||||
|
||||
// Add click handler for filament checkboxes
|
||||
$("#ItemBlockArea").on("change", "input[type='checkbox']", function() {
|
||||
// Only associate printer data when the filament is being checked
|
||||
if ($(this).prop("checked")) {
|
||||
// Get currently selected printers when a filament is checked
|
||||
let selectedPrinters = GetSelectedPrinters();
|
||||
$(this).data("selectedPrinters", selectedPrinters);
|
||||
|
||||
console.log("Filament selected: " + $(this).attr("name") + " with printers:", selectedPrinters);
|
||||
} else {
|
||||
// Clear printer data when unchecked
|
||||
$(this).removeData("selectedPrinters");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
|
@ -132,6 +132,8 @@ GuideFrame::GuideFrame(GUI_App *pGUI, long style)
|
||||
}
|
||||
m_browser->Hide();
|
||||
m_browser->SetSize(0, 0);
|
||||
m_browser->EnableAccessToDevTools();
|
||||
|
||||
|
||||
SetSizer(topsizer);
|
||||
|
||||
@ -447,11 +449,25 @@ void GuideFrame::OnScriptMessage(wxWebViewEvent &evt)
|
||||
for (int m = 0; m < nF; m++)
|
||||
{
|
||||
std::string fName = fSelected[m];
|
||||
|
||||
m_ProfileJson["filament"][fName]["selected"] = 1;
|
||||
// check if fNmae is in j["data"]["filamentInfo"][fName]["selectedPrinters"]
|
||||
if (m_ProfileJson["filament"].find(fName) != m_ProfileJson["filament"].end())
|
||||
m_ProfileJson["filament"][fName]["selected"] = 1;
|
||||
m_ProfileJson["filament"][fName]["enabled_printers"] = j["data"]["filamentInfo"][fName]["selectedPrinters"];
|
||||
}
|
||||
|
||||
// Save profile json to file (for debugging purposes)
|
||||
boost::filesystem::path profile_path = boost::filesystem::path(Slic3r::data_dir()) / "cached_profile.json";
|
||||
|
||||
try {
|
||||
std::ofstream profile_file(profile_path.string());
|
||||
if (profile_file.is_open()) {
|
||||
profile_file << m_ProfileJson.dump(4);
|
||||
profile_file.close();
|
||||
BOOST_LOG_TRIVIAL(debug) << __FUNCTION__ << ": Saved profile to " << profile_path.string();
|
||||
}
|
||||
} catch (const std::exception& e) {
|
||||
BOOST_LOG_TRIVIAL(error) << __FUNCTION__ << ": Failed to save profile: " << e.what();
|
||||
}
|
||||
}
|
||||
else if (strCmd == "user_guide_finish") {
|
||||
SaveProfile();
|
||||
|
||||
std::string oldregion = m_ProfileJson["region"];
|
||||
|
Loading…
x
Reference in New Issue
Block a user