Have Print::apply_config() return true if any step was invalidated

master
Alessandro Ranellucci 2014-06-12 09:29:26 +02:00
parent 5e80d7a388
commit 97231327e0
4 changed files with 23 additions and 9 deletions

View File

@ -43,13 +43,17 @@ sub apply_config {
# apply variables to placeholder parser # apply variables to placeholder parser
$self->placeholder_parser->apply_config($config); $self->placeholder_parser->apply_config($config);
my $invalidated = 0;
# handle changes to print config # handle changes to print config
my $print_diff = $self->config->diff($config); my $print_diff = $self->config->diff($config);
if (@$print_diff) { if (@$print_diff) {
$self->config->apply_dynamic($config); $self->config->apply_dynamic($config);
$self->invalidate_all_steps my $res;
$res = $self->invalidate_all_steps
if !$self->invalidate_state_by_config_options($print_diff); if !$self->invalidate_state_by_config_options($print_diff);
$invalidated = 1 if $res;
} }
# handle changes to object config defaults # handle changes to object config defaults
@ -69,8 +73,11 @@ sub apply_config {
my $diff = $object->config->diff($new); my $diff = $object->config->diff($new);
if (@$diff) { if (@$diff) {
$object->config->apply($new); $object->config->apply($new);
$object->invalidate_all_steps
my $res;
$res = $object->invalidate_all_steps
if !$object->invalidate_state_by_config_options($diff); if !$object->invalidate_state_by_config_options($diff);
$invalidated = 1 if $res;
} }
} }
@ -124,8 +131,10 @@ sub apply_config {
if (@$region_config_diff) { if (@$region_config_diff) {
$region->config->apply($new); $region->config->apply($new);
foreach my $o (@{$self->objects}) { foreach my $o (@{$self->objects}) {
$o->invalidate_all_steps my $res;
$res = $o->invalidate_all_steps
if !$o->invalidate_state_by_config_options($region_config_diff); if !$o->invalidate_state_by_config_options($region_config_diff);
$invalidated = 1 if $res;
} }
} }
} }
@ -139,7 +148,10 @@ sub apply_config {
my @model_objects = map $_->model_object, @{$self->objects}; my @model_objects = map $_->model_object, @{$self->objects};
$self->clear_objects; $self->clear_objects;
$self->add_model_object($_) for @model_objects; $self->add_model_object($_) for @model_objects;
$invalidated = 1;
} }
return $invalidated;
} }
sub has_support_material { sub has_support_material {

View File

@ -40,11 +40,13 @@ PrintState<StepClass>::invalidate(StepClass step)
} }
template <class StepClass> template <class StepClass>
void bool
PrintState<StepClass>::invalidate_all() PrintState<StepClass>::invalidate_all()
{ {
bool empty = this->_started.empty();
this->_started.clear(); this->_started.clear();
this->_done.clear(); this->_done.clear();
return !empty; // return true if we invalidated something
} }
template class PrintState<PrintStep>; template class PrintState<PrintStep>;

View File

@ -36,7 +36,7 @@ class PrintState
void set_started(StepType step); void set_started(StepType step);
void set_done(StepType step); void set_done(StepType step);
void invalidate(StepType step); void invalidate(StepType step);
void invalidate_all(); bool invalidate_all();
}; };
// A PrintRegion object represents a group of volumes to print // A PrintRegion object represents a group of volumes to print

View File

@ -87,8 +87,8 @@ _constant()
bool invalidate_state_by_config_options(std::vector<std::string> opt_keys); bool invalidate_state_by_config_options(std::vector<std::string> opt_keys);
void invalidate_step(PrintObjectStep step); void invalidate_step(PrintObjectStep step);
void invalidate_all_steps() bool invalidate_all_steps()
%code%{ THIS->state.invalidate_all(); %}; %code%{ RETVAL = THIS->state.invalidate_all(); %};
bool step_done(PrintObjectStep step) bool step_done(PrintObjectStep step)
%code%{ RETVAL = THIS->state.done(step); %}; %code%{ RETVAL = THIS->state.done(step); %};
void set_step_done(PrintObjectStep step) void set_step_done(PrintObjectStep step)
@ -142,8 +142,8 @@ _constant()
bool invalidate_state_by_config_options(std::vector<std::string> opt_keys); bool invalidate_state_by_config_options(std::vector<std::string> opt_keys);
void invalidate_step(PrintStep step); void invalidate_step(PrintStep step);
void invalidate_all_steps() bool invalidate_all_steps()
%code%{ THIS->state.invalidate_all(); %}; %code%{ RETVAL = THIS->state.invalidate_all(); %};
bool step_done(PrintStep step) bool step_done(PrintStep step)
%code%{ RETVAL = THIS->state.done(step); %}; %code%{ RETVAL = THIS->state.done(step); %};
void set_step_done(PrintStep step) void set_step_done(PrintStep step)