SHARE
TWEET

Untitled

a guest Sep 16th, 2019 111 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import QtQuick 2.12
  2. import QtQuick3D 1.0
  3.  
  4. Model {
  5.     id:panel
  6.  
  7.     property Item panelContents
  8.  
  9.     property real ppm: 250
  10.  
  11.     property int margin: 0
  12.     property int marginTop: margin
  13.     property int marginBottom: margin
  14.     property int marginLeft: margin
  15.     property int marginRight: margin
  16.  
  17.     onMarginTopChanged: panelContents.y = -marginTop
  18.     onMarginLeftChanged: panelContents.x = -marginLeft
  19.  
  20.     property size physicalDimensions: Qt.size(0.4, 0.4)
  21.     property size pixelDimensions: Qt.size(100, 100)
  22.  
  23.     function setPhysicalDimensions(size) {
  24.         physicalDimensions = size;
  25.  
  26.         pixelDimensions.x = size.x*ppm;
  27.         pixelDimensions.y = size.y*ppm;
  28.     }
  29.     function setPixelDimensions(size) {
  30.         pixelDimensions = size;
  31.  
  32.         physicalDimensions.x = size.x/ppm;
  33.         physicalDimensions.y = size.y/ppm;
  34.     }
  35.     panelContents.onWidthChanged: pixelDimensions.x = panelContents.width
  36.     panelContents.onHeightChanged: pixelDimensions.x = panelContents.height
  37.  
  38.     property size croppedDimensions: Qt.size(dimensions.width-marginLeft-marginRight, dimensions.height-marginTop-marginBottom)
  39.  
  40.     source: "#Rect"
  41.  
  42.     scale: Qt.vector3d(croppedDimensions.width/ppm, croppedDimensions.height/ppm, 1)
  43.  
  44.     materials: DefaultMaterial {
  45.         lighting: DefaultMaterial.NoLighting
  46.  
  47.         diffuseMap: Texture {
  48.             sourceItem: panelContents
  49.         }
  50.     }
  51. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top