Compare commits
23 Commits
2.11.0-rc10
...
2.11.1
| Author | SHA1 | Date | |
|---|---|---|---|
| d0113532b6 | |||
| 5a1d2ad5f4 | |||
| dfe02f4c74 | |||
| 5349d556b9 | |||
| 7f7d8a501b | |||
| cbee0e465b | |||
| faf00f0b0d | |||
| fa97da5781 | |||
| e7bab546db | |||
| e2f4a30b5b | |||
| ccff1df041 | |||
| 2037cfc25a | |||
| 268a091d8a | |||
| 6b52dfab3e | |||
| 839999851f | |||
| a87470b7b5 | |||
| e76aeb80fd | |||
| 28292e59e2 | |||
| 25dda481b2 | |||
| bbda233fd8 | |||
| 349218f0b5 | |||
| f18d00a69d | |||
| 25ea6504de |
@@ -10,6 +10,7 @@ module SpeckleConnector
|
||||
module Preferences
|
||||
include Immutable::ImmutableUtils
|
||||
DICT_HANDLER = SketchupModel::Dictionary::SpeckleModelDictionaryHandler
|
||||
DEFAULT_PREFERENCES = "('configSketchup', '{\"DarkTheme\":false}');"
|
||||
|
||||
# @param sketchup_model [Sketchup::Model] active model.
|
||||
# rubocop:disable Metrics/MethodLength
|
||||
@@ -17,8 +18,13 @@ module SpeckleConnector
|
||||
# Init sqlite database
|
||||
db = Sqlite3::Database.new(SPECKLE_CONFIG_DB_PATH)
|
||||
|
||||
# Check configSketchup key is valid or not, otherwise init with default settings
|
||||
if db.exec("SELECT content FROM 'objects' WHERE hash = 'configSketchup'").empty?
|
||||
db.exec("INSERT INTO 'objects' VALUES #{DEFAULT_PREFERENCES}")
|
||||
end
|
||||
|
||||
# Select data
|
||||
data = db.exec("SELECT content FROM 'objects' WHERE hash = 'configDUI'").first.first
|
||||
data = db.exec("SELECT content FROM 'objects' WHERE hash = 'configSketchup'").first.first
|
||||
|
||||
# Parse string to hash
|
||||
data_hash = JSON.parse(data).to_h
|
||||
|
||||
@@ -89,8 +89,6 @@ module SpeckleConnector
|
||||
|
||||
# @param face [Sketchup::Face] face to convert mesh
|
||||
# rubocop:disable Style/MultilineTernaryOperator
|
||||
# rubocop:disable Metrics/CyclomaticComplexity
|
||||
# rubocop:disable Metrics/PerceivedComplexity
|
||||
def self.from_face(face, units, model_preferences)
|
||||
dictionaries = {}
|
||||
if model_preferences[:include_entity_attributes]
|
||||
@@ -114,8 +112,6 @@ module SpeckleConnector
|
||||
speckle_mesh
|
||||
end
|
||||
# rubocop:enable Style/MultilineTernaryOperator
|
||||
# rubocop:enable Metrics/CyclomaticComplexity
|
||||
# rubocop:enable Metrics/PerceivedComplexity
|
||||
|
||||
def face_to_mesh(face)
|
||||
mesh = face.loops.count > 1 ? face.mesh : nil
|
||||
@@ -135,7 +131,7 @@ module SpeckleConnector
|
||||
end
|
||||
|
||||
def update_mesh
|
||||
puts "Vertex count on mesh #{vertices.length}"
|
||||
# puts "Vertex count on mesh #{vertices.length}"
|
||||
self['@(31250)vertices'] = vertices_to_array(units)
|
||||
self[:'@(62500)faces'] = polygons
|
||||
end
|
||||
@@ -145,6 +141,7 @@ module SpeckleConnector
|
||||
def face_vertices_to_array(face)
|
||||
face.vertices.each do |v|
|
||||
pt = v.position
|
||||
# FIXME: Enable previous line when viewer supports shared vertices
|
||||
# vertices.push(pt) unless vertices.any? { |point| point == pt }
|
||||
vertices.push(pt)
|
||||
end
|
||||
@@ -155,6 +152,7 @@ module SpeckleConnector
|
||||
polygons.push(face.vertices.count)
|
||||
face.vertices.each do |v|
|
||||
pt = v.position
|
||||
# FIXME: Enable previous line when viewer supports shared vertices
|
||||
# global_vertex_index = vertices.reverse.find_index(pt)
|
||||
global_vertex_index = vertices.length - vertices.reverse.find_index(pt) - 1
|
||||
polygons.push(global_vertex_index)
|
||||
@@ -165,6 +163,7 @@ module SpeckleConnector
|
||||
# @param mesh [Geom::PolygonMesh] mesh to get points.
|
||||
def mesh_points_to_array(mesh)
|
||||
mesh.points.each do |pt|
|
||||
# FIXME: Enable previous line when viewer supports shared vertices
|
||||
# vertices.push(pt) unless vertices.any? { |point| point == pt }
|
||||
vertices.push(pt)
|
||||
end
|
||||
@@ -176,6 +175,7 @@ module SpeckleConnector
|
||||
mesh.polygons.each do |poly|
|
||||
global_polygon_array = [poly.count]
|
||||
poly.each do |index|
|
||||
# FIXME: Enable previous line when viewer supports shared vertices
|
||||
# global_vertex_index = vertices.reverse.find_index(mesh.points[index.abs - 1])
|
||||
global_vertex_index = vertices.length - vertices.reverse.find_index(mesh.points[index.abs - 1]) - 1
|
||||
global_polygon_array.push(global_vertex_index)
|
||||
|
||||
@@ -134,7 +134,7 @@ module SpeckleConnector
|
||||
if preferences[:model][:combine_faces_by_material]
|
||||
mesh_groups = {}
|
||||
definition.entities.grep(Sketchup::Face).collect do |face|
|
||||
group_meshes_by_material(definition, face, mesh_groups, units, preferences[:model])
|
||||
group_meshes_by_material(face, mesh_groups, units, preferences[:model])
|
||||
end
|
||||
# Update mesh overwrites points and polygons into base object.
|
||||
mesh_groups.each { |_, mesh| mesh.update_mesh }
|
||||
@@ -153,29 +153,13 @@ module SpeckleConnector
|
||||
# rubocop:enable Metrics/CyclomaticComplexity
|
||||
# rubocop:enable Metrics/PerceivedComplexity
|
||||
|
||||
# rubocop:disable Metrics/AbcSize
|
||||
def self.group_meshes_by_material(definition, face, mat_groups, units, model_preferences)
|
||||
def self.group_meshes_by_material(face, mat_groups, units, model_preferences)
|
||||
# convert material
|
||||
mat_id = get_mesh_group_id(face, model_preferences)
|
||||
mat_groups[mat_id] = initialise_group_mesh(face, definition.bounds, units) unless mat_groups.key?(mat_id)
|
||||
mat_groups[mat_id] = Geometry::Mesh.from_face(face, units, model_preferences) unless mat_groups.key?(mat_id)
|
||||
mat_group = mat_groups[mat_id]
|
||||
mat_group.face_to_mesh(face)
|
||||
end
|
||||
# rubocop:enable Metrics/AbcSize
|
||||
|
||||
def self.initialise_group_mesh(face, bounds, units)
|
||||
has_any_soften_edge = face.edges.any?(&:soft?)
|
||||
mesh = Geometry::Mesh.new(
|
||||
units: units,
|
||||
render_material: face.material.nil? ? nil : RenderMaterial.from_material(face.material),
|
||||
bbox: Geometry::BoundingBox.from_bounds(bounds, units),
|
||||
vertices: [],
|
||||
faces: [],
|
||||
sketchup_attributes: { is_soften: has_any_soften_edge }
|
||||
)
|
||||
mesh[:pt_count] = 0
|
||||
mesh
|
||||
end
|
||||
|
||||
# Mesh group id helps to determine how to group faces into meshes.
|
||||
# @param face [Sketchup::Face] face to get mesh group id.
|
||||
|
||||
+3
-3
@@ -80,7 +80,7 @@
|
||||
</v-menu>
|
||||
</v-app-bar>
|
||||
|
||||
<create-stream v-if="accounts().length !== 0"/>
|
||||
<create-stream-dialog v-if="accounts().length !== 0"/>
|
||||
|
||||
<v-container v-if="accounts().length !== 0" fluid>
|
||||
<router-view :stream-search-query="streamSearchQuery" />
|
||||
@@ -129,8 +129,8 @@ export default {
|
||||
name: 'App',
|
||||
components: {
|
||||
Login,
|
||||
CreateStream: () => import('@/components/CreateStream'),
|
||||
SettingsDialog: () => import('@/components/SettingsDialog'),
|
||||
CreateStreamDialog: () => import('@/components/dialogs/CreateStreamDialog'),
|
||||
SettingsDialog: () => import('@/components/dialogs/SettingsDialog'),
|
||||
GlobalToast: () => import('@/components/GlobalToast')
|
||||
},
|
||||
props: {
|
||||
|
||||
@@ -60,11 +60,17 @@
|
||||
<v-card-text class="d-flex align-center pb-5 mb-5 -mt-2" style="height: 50px">
|
||||
<v-menu offset-y>
|
||||
<template #activator="{ on, attrs }">
|
||||
<v-slide-x-transition>
|
||||
<div v-show="hover">
|
||||
<create-branch-dialog :stream-name="stream.name" :stream-id="streamId"/>
|
||||
</div>
|
||||
</v-slide-x-transition>
|
||||
<v-chip v-if="stream.branches" small v-bind="attrs" class="mr-1" v-on="on">
|
||||
<v-icon small class="mr-1 float-left">mdi-source-branch</v-icon>
|
||||
{{ branchName }}
|
||||
</v-chip>
|
||||
</template>
|
||||
<!-- Branch list -->
|
||||
<v-list dense>
|
||||
<v-list-item
|
||||
v-for="(branch, index) in stream.branches.items"
|
||||
@@ -73,7 +79,7 @@
|
||||
@click="switchBranch(branch.name)"
|
||||
>
|
||||
<v-list-item-title class="text-caption font-weight-regular">
|
||||
<v-icon v-if="branch.name == branchName" small class="mr-1 float-left">
|
||||
<v-icon v-if="branch.name === branchName" small class="mr-1 float-left">
|
||||
mdi-check
|
||||
</v-icon>
|
||||
<v-icon v-else small class="mr-1 float-left">mdi-source-branch</v-icon>
|
||||
@@ -171,6 +177,9 @@ global.oneClickSend = function (streamId) {
|
||||
|
||||
export default {
|
||||
name: 'StreamCard',
|
||||
components: {
|
||||
CreateBranchDialog: () => import('@/components/dialogs/CreateBranchDialog'),
|
||||
},
|
||||
props: {
|
||||
streamId: {
|
||||
type: String,
|
||||
@@ -261,16 +270,28 @@ export default {
|
||||
},
|
||||
computed: {
|
||||
selectedBranch() {
|
||||
if (this.$apollo.loading) return
|
||||
return this.stream.branches.items.find((branch) => branch.name == this.branchName)
|
||||
if (!this.stream) return
|
||||
return this.stream.branches.items.find((branch) => branch.name === this.branchName)
|
||||
},
|
||||
selectedCommit() {
|
||||
if (this.$apollo.loading) return
|
||||
if (this.commitId == 'latest') return this.selectedBranch.commits.items[0]
|
||||
return this.selectedBranch.commits.items.find((commit) => commit.id == this.commitId)
|
||||
if (!this.selectedBranch) return
|
||||
if (this.commitId === 'latest') return this.selectedBranch.commits.items[0]
|
||||
return this.selectedBranch.commits.items.find((commit) => commit.id === this.commitId)
|
||||
}
|
||||
},
|
||||
mounted() {
|
||||
bus.$on(`refresh-stream-${this.streamId}`, () => {
|
||||
let oldBranchName = this.branchName
|
||||
let oldCommitId = this.commitId
|
||||
this.$apollo.queries.stream.refetch()
|
||||
this.branchName = oldBranchName
|
||||
this.commitId = oldCommitId
|
||||
})
|
||||
bus.$on(`create-branch-${this.streamId}`, (branchName) => {
|
||||
this.$apollo.queries.stream.refetch()
|
||||
this.branchName = branchName
|
||||
this.commitId = 'latest'
|
||||
})
|
||||
bus.$on(`sketchup-objects-${this.streamId}`, async (batches, commitId, totalChildrenCount) => {
|
||||
console.log('>>> SpeckleSketchUp: Received objects from sketchup')
|
||||
|
||||
@@ -376,7 +397,7 @@ export default {
|
||||
await this.sleep(2000)
|
||||
},
|
||||
async createCommit(batches, commitId, totalChildrenCount) {
|
||||
if (batches.length == 0) {
|
||||
if (batches.length === 0) {
|
||||
this.loadingSend = false
|
||||
this.loadingStage = null
|
||||
this.$eventHub.$emit('notification', {
|
||||
|
||||
@@ -0,0 +1,137 @@
|
||||
<template>
|
||||
<!-- DIALOG: Create Branch -->
|
||||
<v-dialog v-model="showCreateBranch">
|
||||
<template #activator="{ on: dialog, attrs }">
|
||||
<v-btn
|
||||
v-tooltip="'Create Branch'"
|
||||
icon x-small class="ml-0 mr-1"
|
||||
v-bind="attrs"
|
||||
v-on="{...dialog}"
|
||||
>
|
||||
<v-icon>
|
||||
mdi-plus-circle
|
||||
</v-icon>
|
||||
</v-btn>
|
||||
</template>
|
||||
<v-card>
|
||||
<v-card-title class="text-h5 mb-1">
|
||||
Create a New Branch
|
||||
</v-card-title>
|
||||
<v-card-subtitle class="py-0 my-0 font-italic">
|
||||
under {{ streamName }} stream
|
||||
</v-card-subtitle>
|
||||
<v-container class="px-6" pb-0>
|
||||
<v-text-field
|
||||
v-model="branchName"
|
||||
xxxclass="small-text-field"
|
||||
hide-details
|
||||
dense
|
||||
flat
|
||||
placeholder="Branch Name"
|
||||
/>
|
||||
<v-text-field
|
||||
v-model="description"
|
||||
xxxclass="small-text-field"
|
||||
hide-details
|
||||
dense
|
||||
flat
|
||||
placeholder="Description (Optional)"
|
||||
/>
|
||||
</v-container>
|
||||
|
||||
<v-card-actions>
|
||||
<v-spacer></v-spacer>
|
||||
<v-btn
|
||||
color="blue darken-1"
|
||||
text
|
||||
@click="showCreateBranch = false"
|
||||
>
|
||||
Cancel
|
||||
</v-btn>
|
||||
<v-btn
|
||||
:disabled="branchName === ''"
|
||||
color="blue darken-1"
|
||||
text
|
||||
@click="createBranch"
|
||||
>
|
||||
Create
|
||||
</v-btn>
|
||||
</v-card-actions>
|
||||
</v-card>
|
||||
</v-dialog>
|
||||
</template>
|
||||
|
||||
<script>
|
||||
import gql from "graphql-tag";
|
||||
import {bus} from "@/main";
|
||||
|
||||
export default {
|
||||
name: "CreateBranchDialog",
|
||||
props: {
|
||||
streamId: {
|
||||
type: String,
|
||||
default: null
|
||||
},
|
||||
streamName: {
|
||||
type: String,
|
||||
default: null
|
||||
}
|
||||
},
|
||||
data() {
|
||||
return {
|
||||
showCreateBranch: false,
|
||||
branchName: "",
|
||||
description: "",
|
||||
defaultDescription: "Stream created from SketchUp",
|
||||
accountToCreateStream: null
|
||||
}
|
||||
},
|
||||
computed: {
|
||||
loggedIn() {
|
||||
return localStorage.getItem('SpeckleSketchup.AuthToken') !== null
|
||||
},
|
||||
accounts() {
|
||||
return JSON.parse(localStorage.getItem('localAccounts'))
|
||||
},
|
||||
},
|
||||
methods: {
|
||||
async createBranch(){
|
||||
let res = await this.$apollo.mutate({
|
||||
mutation: gql`
|
||||
mutation branchCreate($branch: BranchCreateInput!) {
|
||||
branchCreate(branch: $branch)
|
||||
}
|
||||
`,
|
||||
variables: {
|
||||
branch: {
|
||||
streamId: this.streamId,
|
||||
name: this.branchName,
|
||||
description: this.description === '' ? this.defaultDescription : this.description,
|
||||
}
|
||||
}
|
||||
})
|
||||
bus.$emit(`create-branch-${this.streamId}`, this.branchName)
|
||||
this.showCreateBranch = false
|
||||
this.branchName = ""
|
||||
this.description = ""
|
||||
this.$mixpanel.track('Connector Action', { name: 'Create Branch' })
|
||||
return res
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
<style>
|
||||
|
||||
.v-dialog {
|
||||
max-width: 390px
|
||||
}
|
||||
|
||||
.v-text-field >>> input {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
.v-text-field >>> label {
|
||||
font-size: 0.9em;
|
||||
}
|
||||
|
||||
</style>
|
||||
+2
-1
@@ -161,7 +161,7 @@ import {bus} from "@/main";
|
||||
import userQuery from "@/graphql/user.gql";
|
||||
|
||||
export default {
|
||||
name: "CreateStream",
|
||||
name: "CreateStreamDialog",
|
||||
data() {
|
||||
return {
|
||||
showCreateNewStream: false,
|
||||
@@ -216,6 +216,7 @@ export default {
|
||||
this.showCreateNewStream = false
|
||||
this.streamName = ""
|
||||
this.description = ""
|
||||
this.$mixpanel.track('Connector Action', { name: 'Create Stream' })
|
||||
sketchup.exec({name: "save_stream", data: {stream_id: res["data"]["streamCreate"]}})
|
||||
this.refresh()
|
||||
return res
|
||||
@@ -122,14 +122,11 @@ export default {
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
combineFacesByMaterialHandler() {
|
||||
|
||||
},
|
||||
switchTheme() {
|
||||
this.$vuetify.theme.dark = !this.$vuetify.theme.dark
|
||||
sketchup.exec({
|
||||
name: "user_preferences_updated",
|
||||
data: {preference_hash: "configDUI", preference: "DarkTheme", value: this.$vuetify.theme.dark}
|
||||
data: {preference_hash: "configSketchup", preference: "DarkTheme", value: this.$vuetify.theme.dark}
|
||||
})
|
||||
this.$mixpanel.track('Connector Action', { name: 'Toggle Theme' })
|
||||
},
|
||||
@@ -73,7 +73,9 @@ export default {
|
||||
},
|
||||
mounted() {
|
||||
bus.$on('refresh-streams', () => {
|
||||
// TODO: We should remember selected branches and commits before refetch
|
||||
this.$apollo.queries.streams.refetch()
|
||||
// TODO: We should set previously selected branches and commits after refetch
|
||||
})
|
||||
|
||||
bus.$on('set-saved-streams', (streamIds) => {
|
||||
|
||||
Reference in New Issue
Block a user