Grid scale proportional to user's units
The grid lines should be 1 unit apart, where the unit is whatever the user's defaultUnitLength setting is, e.g. 1mm or 1cm or 1in apart.
This commit is contained in:
4
rust/Cargo.lock
generated
4
rust/Cargo.lock
generated
@ -2082,9 +2082,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "kittycad-modeling-cmds"
|
name = "kittycad-modeling-cmds"
|
||||||
version = "0.2.121"
|
version = "0.2.122"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "94ba95c22493d79ec8a1faab963d8903f6de0e373efedf2bc3bb76a0ddbab036"
|
checksum = "643f41fa4bc9c98104d6f0da937024dbb5fce37ffe63c0635b348db74bd78c4f"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"anyhow",
|
"anyhow",
|
||||||
"chrono",
|
"chrono",
|
||||||
|
@ -36,7 +36,7 @@ dashmap = { version = "6.1.0" }
|
|||||||
http = "1"
|
http = "1"
|
||||||
indexmap = "2.9.0"
|
indexmap = "2.9.0"
|
||||||
kittycad = { version = "0.3.37", default-features = false, features = ["js", "requests"] }
|
kittycad = { version = "0.3.37", default-features = false, features = ["js", "requests"] }
|
||||||
kittycad-modeling-cmds = { version = "0.2.120", features = ["ts-rs", "websocket"] }
|
kittycad-modeling-cmds = { version = "0.2.122", features = ["ts-rs", "websocket"] }
|
||||||
lazy_static = "1.5.0"
|
lazy_static = "1.5.0"
|
||||||
miette = "7.5.0"
|
miette = "7.5.0"
|
||||||
pyo3 = { version = "0.24.1" }
|
pyo3 = { version = "0.24.1" }
|
||||||
|
@ -369,13 +369,15 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
|||||||
settings: &crate::ExecutorSettings,
|
settings: &crate::ExecutorSettings,
|
||||||
source_range: SourceRange,
|
source_range: SourceRange,
|
||||||
id_generator: &mut IdGenerator,
|
id_generator: &mut IdGenerator,
|
||||||
|
grid_scale_unit: Option<kcmc::units::UnitLength>,
|
||||||
) -> Result<(), crate::errors::KclError> {
|
) -> Result<(), crate::errors::KclError> {
|
||||||
// Set the edge visibility.
|
// Set the edge visibility.
|
||||||
self.set_edge_visibility(settings.highlight_edges, source_range, id_generator)
|
self.set_edge_visibility(settings.highlight_edges, source_range, id_generator)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// Send the command to show the grid.
|
// Send the command to show the grid.
|
||||||
self.modify_grid(!settings.show_grid, source_range, id_generator)
|
|
||||||
|
self.modify_grid(!settings.show_grid, grid_scale_unit, source_range, id_generator)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
// We do not have commands for changing ssao on the fly.
|
// We do not have commands for changing ssao on the fly.
|
||||||
@ -829,6 +831,7 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
|||||||
async fn modify_grid(
|
async fn modify_grid(
|
||||||
&self,
|
&self,
|
||||||
hidden: bool,
|
hidden: bool,
|
||||||
|
base_unit: Option<kcmc::units::UnitLength>,
|
||||||
source_range: SourceRange,
|
source_range: SourceRange,
|
||||||
id_generator: &mut IdGenerator,
|
id_generator: &mut IdGenerator,
|
||||||
) -> Result<(), KclError> {
|
) -> Result<(), KclError> {
|
||||||
@ -843,6 +846,17 @@ pub trait EngineManager: std::fmt::Debug + Send + Sync + 'static {
|
|||||||
)
|
)
|
||||||
.await?;
|
.await?;
|
||||||
|
|
||||||
|
let grid_scale = if let Some(units) = base_unit {
|
||||||
|
// The grid is 10x10, so setting the value to 10 means that
|
||||||
|
// users whose unit is cm will see each cell as 1cm by 1cm,
|
||||||
|
// which is useful for sketching.
|
||||||
|
ModelingCmd::from(mcmd::SetGridScale { value: 10.0, units })
|
||||||
|
} else {
|
||||||
|
ModelingCmd::from(mcmd::SetGridAutoScale {})
|
||||||
|
};
|
||||||
|
self.batch_modeling_cmd(id_generator.next_uuid(), source_range, &grid_scale)
|
||||||
|
.await?;
|
||||||
|
|
||||||
// Hide/show the grid scale text.
|
// Hide/show the grid scale text.
|
||||||
self.batch_modeling_cmd(
|
self.batch_modeling_cmd(
|
||||||
id_generator.next_uuid(),
|
id_generator.next_uuid(),
|
||||||
|
@ -593,6 +593,12 @@ impl ExecutorContext {
|
|||||||
|
|
||||||
pub async fn run_with_caching(&self, program: crate::Program) -> Result<ExecOutcome, KclErrorWithOutputs> {
|
pub async fn run_with_caching(&self, program: crate::Program) -> Result<ExecOutcome, KclErrorWithOutputs> {
|
||||||
assert!(!self.is_mock());
|
assert!(!self.is_mock());
|
||||||
|
let grid_scale = program
|
||||||
|
.meta_settings()
|
||||||
|
.ok()
|
||||||
|
.flatten()
|
||||||
|
.map(|s| s.default_length_units)
|
||||||
|
.map(kcmc::units::UnitLength::from);
|
||||||
|
|
||||||
let (program, mut exec_state, preserve_mem, cached_body_items, imports_info) = if let Some(OldAstState {
|
let (program, mut exec_state, preserve_mem, cached_body_items, imports_info) = if let Some(OldAstState {
|
||||||
ast: old_ast,
|
ast: old_ast,
|
||||||
@ -623,7 +629,7 @@ impl ExecutorContext {
|
|||||||
if reapply_settings
|
if reapply_settings
|
||||||
&& self
|
&& self
|
||||||
.engine
|
.engine
|
||||||
.reapply_settings(&self.settings, Default::default(), old_state.id_generator())
|
.reapply_settings(&self.settings, Default::default(), old_state.id_generator(), grid_scale)
|
||||||
.await
|
.await
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
@ -647,7 +653,7 @@ impl ExecutorContext {
|
|||||||
if reapply_settings
|
if reapply_settings
|
||||||
&& self
|
&& self
|
||||||
.engine
|
.engine
|
||||||
.reapply_settings(&self.settings, Default::default(), old_state.id_generator())
|
.reapply_settings(&self.settings, Default::default(), old_state.id_generator(), grid_scale)
|
||||||
.await
|
.await
|
||||||
.is_err()
|
.is_err()
|
||||||
{
|
{
|
||||||
@ -697,7 +703,7 @@ impl ExecutorContext {
|
|||||||
CacheResult::NoAction(true) => {
|
CacheResult::NoAction(true) => {
|
||||||
if self
|
if self
|
||||||
.engine
|
.engine
|
||||||
.reapply_settings(&self.settings, Default::default(), old_state.id_generator())
|
.reapply_settings(&self.settings, Default::default(), old_state.id_generator(), grid_scale)
|
||||||
.await
|
.await
|
||||||
.is_ok()
|
.is_ok()
|
||||||
{
|
{
|
||||||
@ -1089,8 +1095,19 @@ impl ExecutorContext {
|
|||||||
let _stats = crate::log::LogPerfStats::new("Interpretation");
|
let _stats = crate::log::LogPerfStats::new("Interpretation");
|
||||||
|
|
||||||
// Re-apply the settings, in case the cache was busted.
|
// Re-apply the settings, in case the cache was busted.
|
||||||
|
let grid_scale = program
|
||||||
|
.meta_settings()
|
||||||
|
.ok()
|
||||||
|
.flatten()
|
||||||
|
.map(|s| s.default_length_units)
|
||||||
|
.map(kcmc::units::UnitLength::from);
|
||||||
self.engine
|
self.engine
|
||||||
.reapply_settings(&self.settings, Default::default(), exec_state.id_generator())
|
.reapply_settings(
|
||||||
|
&self.settings,
|
||||||
|
Default::default(),
|
||||||
|
exec_state.id_generator(),
|
||||||
|
grid_scale,
|
||||||
|
)
|
||||||
.await
|
.await
|
||||||
.map_err(KclErrorWithOutputs::no_outputs)?;
|
.map_err(KclErrorWithOutputs::no_outputs)?;
|
||||||
|
|
||||||
|
@ -256,7 +256,6 @@ impl EngineConnection {
|
|||||||
let entity_ids = generate_repl_uuids(*num_repetitions as usize);
|
let entity_ids = generate_repl_uuids(*num_repetitions as usize);
|
||||||
|
|
||||||
this_response = OkModelingCmdResponse::EntityCircularPattern(kcmc::output::EntityCircularPattern {
|
this_response = OkModelingCmdResponse::EntityCircularPattern(kcmc::output::EntityCircularPattern {
|
||||||
entity_ids: entity_ids.clone(),
|
|
||||||
entity_face_edge_ids: vec![],
|
entity_face_edge_ids: vec![],
|
||||||
});
|
});
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user