Skip to content

Commit

Permalink
Improvement: Disable generate gcode button when models are all hidden (
Browse files Browse the repository at this point in the history
  • Loading branch information
jane-rose authored Nov 30, 2020
1 parent 6606c81 commit 6e8128e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
4 changes: 4 additions & 0 deletions src/app/models/ModelGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ class ModelGroup extends EventEmitter {
return this.selectedModelArray.length === 1 && this.selectedModelArray[0].changeShowOrigin();
}

hasAnyModelVisible() {
return this.models.some((model) => model.visible);
}

hideSelectedModel() {
const models = this.getSelectedModelArray();
models.forEach((model) => {
Expand Down
6 changes: 4 additions & 2 deletions src/app/widgets/PrintingOutput/Output.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ class Output extends PureComponent {
gcodeLine: PropTypes.object,
gcodeFile: PropTypes.object,
hasModel: PropTypes.bool.isRequired,
hasAnyModelVisible: PropTypes.bool.isRequired,
stage: PropTypes.number.isRequired,
isAnyModelOverstepped: PropTypes.bool.isRequired,
generateGcode: PropTypes.func.isRequired,
Expand Down Expand Up @@ -119,7 +120,7 @@ class Output extends PureComponent {
render() {
const state = this.state;
const actions = this.actions;
const { workflowState, stage, gcodeLine, hasModel } = this.props;
const { workflowState, stage, gcodeLine, hasModel, hasAnyModelVisible } = this.props;

const isSlicing = stage === PRINTING_STAGE.SLICING;
const { isAnyModelOverstepped } = this.props;
Expand All @@ -131,7 +132,7 @@ class Output extends PureComponent {
type="button"
className="sm-btn-large sm-btn-default"
onClick={actions.onClickGenerateGcode}
disabled={!hasModel || isSlicing || isAnyModelOverstepped}
disabled={!hasModel || !hasAnyModelVisible || isSlicing || isAnyModelOverstepped}
style={{ display: 'block', width: '100%' }}
>
{i18n._('Generate G-code')}
Expand Down Expand Up @@ -214,6 +215,7 @@ const mapStateToProps = (state) => {
workflowState,
stage,
modelGroup,
hasAnyModelVisible: modelGroup.hasAnyModelVisible(),
boundingBox,
hasModel,
isAnyModelOverstepped,
Expand Down

0 comments on commit 6e8128e

Please sign in to comment.