Skip to content

Commit

Permalink
Merge pull request #18 from marcelluethi/load-scalar-mesh-fields-gui
Browse files Browse the repository at this point in the history
Added option to load scalarMeshFields from context menu
  • Loading branch information
Dennis Madsen authored Dec 5, 2017
2 parents 6580a75 + a06dd23 commit c600875
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion project/Build.scala
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ object Creds {

object Dependencies {

val scalismo = "ch.unibas.cs.gravis" %% "scalismo" % "0.16.0-RC1"
val scalismo = "ch.unibas.cs.gravis" %% "scalismo" % "0.16.0-RC2"
val scalismoNative = "ch.unibas.cs.gravis" % "scalismo-native-all" % "4.0.0"
val scalatest = "org.scalatest" %% "scalatest" % "3.0.1" % "test"
val swingPlus = "de.sciss" %% "swingplus" % "0.2.2"
Expand Down
20 changes: 17 additions & 3 deletions src/main/scala/scalismo/ui/model/ScalarMeshFieldNode.scala
Original file line number Diff line number Diff line change
Expand Up @@ -24,18 +24,32 @@ import scalismo.io.MeshIO
import scalismo.mesh.ScalarMeshField
import scalismo.ui.model.capabilities._
import scalismo.ui.model.properties._
import scalismo.ui.util.FileIoMetadata
import scalismo.ui.util.{ FileIoMetadata, FileUtil }

import scala.util.Try
import scala.util.{ Failure, Success, Try }

class ScalarMeshFieldsNode(override val parent: GroupNode) extends SceneNodeCollection[ScalarMeshFieldNode] with Loadable {

override def loadMetadata: FileIoMetadata = FileIoMetadata.ScalarMeshField

class ScalarMeshFieldsNode(override val parent: GroupNode) extends SceneNodeCollection[ScalarMeshFieldNode] {
override val name: String = "Scalar Mesh Fields"

def add(scalarMeshField: ScalarMeshField[Float], name: String): ScalarMeshFieldNode = {
val node = new ScalarMeshFieldNode(this, scalarMeshField, name)
add(node)
node
}

override def load(file: File): Try[Unit] = {
val r = MeshIO.readScalarMeshFieldAsType[Float](file)
r match {
case Failure(ex) => Failure(ex)
case Success(scalarMeshField) =>
add(scalarMeshField, FileUtil.basename(file))
Success(())
}
}

}

class ScalarMeshFieldNode(override val parent: ScalarMeshFieldsNode, override val source: ScalarMeshField[Float], initialName: String) extends Transformable[ScalarMeshField[Float]] with InverseTransformation with Saveable with Removeable with Renameable with HasOpacity with HasLineWidth with HasScalarRange {
Expand Down

0 comments on commit c600875

Please sign in to comment.