MarlinFirmware / Marlin

Marlin is an optimized firmware for RepRap 3D printers based on the Arduino platform. Many commercial 3D printers come with Marlin installed. Check with your vendor if you need source code for your specific machine.
https://marlinfw.org
GNU General Public License v3.0
16.28k stars 19.24k forks source link

[FR] Adding the option to have two types of Mesh Viewers #24710

Closed classicrocker883 closed 1 year ago

classicrocker883 commented 2 years ago

Is your feature request related to a problem? Please describe.

20220831_011731
20220831_011809

Adding Mesh Viewer - change how the mesh is viewed

enables both options on how the mesh is viewed with USE_UBL_VIEWER enabled, this gives a check box to alternate type of view for mesh



adding Menu Item FILE--> dwin.cpp under Draw AdvancedSettings Menu

  ```MENU_ITEM(ICON_MeshViewer, MSG_MESH_VIEW, onDrawSubMenu, DWIN_MeshViewer);  
  #if ENABLED(USE_UBL_VIEWER)
    EDIT_ITEM_F(ICON_PrintSize, "Change Mesh Viewer", onDrawChkbMenu, SetViewMesh, &BedLevelTools.view_mesh); 
  #endif```



//the function
FILE--> meshviewer.cpp

void MeshViewerClass::Draw(bool withsave /*= false*/) {
  Title.ShowCaption(GET_TEXT_F(MSG_MESH_VIEWER));
  #if ENABLED(USE_UBL_VIEWER)
  if(BedLevelTools.view_mesh) {
    DWINUI::ClearMainArea();
    BedLevelTools.viewer_print_value = true;
    BedLevelTools.Draw_Bed_Mesh(-1, 1, 8, 10 + TITLE_HEIGHT);}
    else
      DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y);
  #else
    DrawMesh(bedlevel.z_values, GRID_MAX_POINTS_X, GRID_MAX_POINTS_Y);
  #endif
  if (withsave) {
    DWINUI::Draw_Button(BTN_Save, 26, 305);
    DWINUI::Draw_Button(BTN_Continue, 146, 305);
    Draw_Select_Highlight(HMI_flag.select_flag, 305);
  }
  else
    DWINUI::Draw_Button(BTN_Continue, 86, 305);

  #if ENABLED(USE_UBL_VIEWER)
    if(BedLevelTools.view_mesh) {
      BedLevelTools.Set_Mesh_Viewer_Status();}
    else {
    char str_1[6], str_2[6] = "";
    ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"),
      dtostrf(min, 1, 2, str_1),
      dtostrf(max, 1, 2, str_2)
    );}
  #else
    char str_1[6], str_2[6] = "";
    ui.status_printf(0, F("Mesh minZ: %s, maxZ: %s"),
      dtostrf(min, 1, 2, str_1),
      dtostrf(max, 1, 2, str_2)
    );
  #endif



FILE--> settings.cpp

  #if ENABLED(USE_UBL_VIEWER)
    bool view_mesh;
  #endif

//under MarlinSettings::save()

  #if ENABLED(USE_UBL_VIEWER)
    EEPROM_WRITE(BedLevelTools.view_mesh);
  #endif

//under MarlinSettings:_load()

  #if ENABLED(USE_UBL_VIEWER)
    _FIELD_TEST(view_mesh);
    EEPROM_READ(BedLevelTools.view_mesh);
  #endif      

//under MarlinSettings:reset()

  #if ENABLED(USE_UBL_VIEWER)
    BedLevelTools.view_mesh = ENABLED(USE_UBL_VIEWER); //added mesh viewer option
  #endif 



FILE--> bedlevel_tools.cpp

//under


  #if ENABLED(USE_UBL_VIEWER)
    static bool viewer_asymmetric_range;
    static bool viewer_print_value;
    static bool view_mesh;
  #endif



FILE--> bedlevel_tools.h

  class BedLevelToolsClass {
public:
  #if ENABLED(USE_UBL_VIEWER)
    static bool viewer_asymmetric_range;
    static bool viewer_print_value;
    static bool view_mesh;
  #endif

Are you looking for hardware support?

No response

Describe the feature you want

This enabled two options of how the mesh is viewed for ProUI

Additional context

If this can somehow be simplified so it doesnt take so much memory having it duplicate the code

DerAndere1 commented 2 years ago

For accessible data visualization, a continuous color ramp is often preferable. See e.g. https://eagereyes.org/basics/rainbow-color-map . Some good diverging color maps can be found at https://www.kennethmoreland.com/color-maps/

thisiskeithb commented 1 year ago

Implemented in https://github.com/MarlinFirmware/Marlin/pull/26181

github-actions[bot] commented 1 year ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.