acquireView.as 51 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859
  1. import com.adobe.ac.mxeffects.DistortionConstants;
  2. import com.adobe.ac.mxeffects.Flip;
  3. import com.imt.flex.cairngormExtended.event.ChainEvent;
  4. import com.imt.flex.cairngormExtended.event.EventChainFactory;
  5. import com.imt.intimamedia.events.acquire.DeleteImagesEvent;
  6. import com.imt.intimamedia.events.acquire.DeleteMarkersEvent;
  7. import com.imt.intimamedia.events.acquire.GetImagesEvent;
  8. import com.imt.intimamedia.events.acquire.GetMarkersEvent;
  9. import com.imt.intimamedia.events.acquire.GetTypeFromLocationEvent;
  10. import com.imt.intimamedia.events.acquire.SaveImageEvent;
  11. import com.imt.intimamedia.events.acquire.SaveMarkerEvent;
  12. import com.imt.intimamedia.events.patient.UpdateAppointmentEvent;
  13. import com.imt.intimamedia.helpers.FlashHelper;
  14. import com.imt.intimamedia.helpers.HelpUtils;
  15. import com.imt.intimamedia.helpers.ImageCJ;
  16. import com.imt.intimamedia.helpers.Measure;
  17. import com.imt.intimamedia.model.ApplicationModelLocator;
  18. import com.imt.intimamedia.views.common.ImtToaster;
  19. import com.imt.intimamedia.views.common.ShowProgress;
  20. import com.imt.intimamedia.views.menus.PhysicianMenu;
  21. import com.imt.intimamedia.views.physician.acquire.IncidencePopUp;
  22. import com.imt.intimamedia.views.physician.acquire.LoadingPopUp;
  23. import com.imt.intimamedia.views.physician.measure.MeasureView;
  24. import com.imt.intimamedia.views.physician.patient.PatientFile;
  25. import com.imt.intimamedia.vo.DragAndDropVo;
  26. import com.imt.intimamedia.vo.MarkerVo;
  27. import com.imt.intimamedia.vo.ScaleCjVo;
  28. import com.imt.intimamedia.vo.ScaleVo;
  29. import flash.display.Bitmap;
  30. import flash.display.BitmapData;
  31. import flash.display.Loader;
  32. import flash.events.Event;
  33. import flash.events.IEventDispatcher;
  34. import flash.events.KeyboardEvent;
  35. import flash.events.MouseEvent;
  36. import flash.events.ProgressEvent;
  37. import flash.events.TimerEvent;
  38. import flash.geom.Matrix;
  39. import flash.geom.Rectangle;
  40. import flash.media.Camera;
  41. import flash.net.FileFilter;
  42. import flash.net.FileReference;
  43. import flash.net.URLRequest;
  44. import flash.net.URLRequestMethod;
  45. import flash.net.URLVariables;
  46. import flash.system.Security;
  47. import flash.system.SecurityPanel;
  48. import flash.system.System;
  49. import flash.utils.Timer;
  50. import mx.collections.ArrayCollection;
  51. import mx.containers.Canvas;
  52. import mx.containers.HBox;
  53. import mx.controls.Alert;
  54. import mx.controls.Button;
  55. import mx.controls.HSlider;
  56. import mx.controls.Image;
  57. import mx.controls.ProgressBar;
  58. import mx.controls.SWFLoader;
  59. import mx.controls.TileList;
  60. import mx.core.Application;
  61. import mx.core.DragSource;
  62. import mx.events.DragEvent;
  63. import mx.events.EffectEvent;
  64. import mx.events.ResizeEvent;
  65. import mx.managers.CursorManager;
  66. import mx.managers.DragManager;
  67. import mx.managers.PopUpManager;
  68. import mx.resources.ResourceManager;
  69. import mx.rpc.events.FaultEvent;
  70. import mx.rpc.events.ResultEvent;
  71. import mx.rpc.http.HTTPService;
  72. import mx.utils.ObjectUtil;
  73. import org.rockholla.controls.panzoom.PanZoomComponent;
  74. /**
  75. * Référence sur le modèle
  76. */
  77. [Bindable]
  78. private var _model : ApplicationModelLocator = ApplicationModelLocator.getInstance();
  79. /**
  80. * Liste des constantes de glisser/déplacer
  81. */
  82. private const SNAPSHOT : String = "snapshot";
  83. private const LIST_LEFT : String = "listLeft";
  84. private const LIST_RIGHT : String = "listRight";
  85. private const BODY : String = "body";
  86. public const CAROTID_RIGHT : String = "carotidRight";
  87. public const CAROTID_LEFT : String = "carotidLeft";
  88. public const BODY_AORTE : String = "body";
  89. public const ARM_RIGHT : String = "armRight";
  90. public const ARM_LEFT : String = "armLeft";
  91. public const LEG_RIGHT : String = "legRight";
  92. public const LEG_LEFT : String = "legLeft";
  93. public const SWF_STENOSE : String = "stenose";
  94. public const SWF_PLAQUE : String = "plaque";
  95. public const SWF_OCCLUSION : String = "occlusion";
  96. /**
  97. * Liste des constantes de zoom
  98. */
  99. public static const MAX_ZOOM:Number = 2;
  100. public static const MIN_ZOOM:Number = 1;
  101. /**
  102. * Liste des curseurs
  103. */
  104. [Embed(source="images/acquire/plaque.png")]
  105. public var plaque : Class;
  106. [Embed(source="images/acquire/stenose.png")]
  107. public var stenose : Class;
  108. [Embed(source="images/acquire/occlusion.png")]
  109. public var occlusion : Class;
  110. /**
  111. * Liste des collections des miniatures de stockage
  112. */
  113. [Bindable]
  114. public var collectionImagesCarotidLeft : ArrayCollection = new ArrayCollection();
  115. [Bindable]
  116. public var collectionImagesCarotidRight : ArrayCollection = new ArrayCollection();
  117. [Bindable]
  118. public var collectionImagesBody : ArrayCollection = new ArrayCollection();
  119. [Bindable]
  120. public var collectionImagesArmLeft : ArrayCollection = new ArrayCollection();
  121. [Bindable]
  122. public var collectionImagesArmRight : ArrayCollection = new ArrayCollection();
  123. [Bindable]
  124. public var collectionImagesLegLeft : ArrayCollection = new ArrayCollection();
  125. [Bindable]
  126. public var collectionImagesLegRight : ArrayCollection = new ArrayCollection();
  127. [Bindable]
  128. public var collectionDisplay : ArrayCollection = new ArrayCollection();
  129. [Bindable]
  130. public var collectionOfMarkers : ArrayCollection = new ArrayCollection();
  131. /**
  132. * Information sur le côté qui est affiché dans les miniatures sous les SWF
  133. */
  134. public var sideDisplay : String;
  135. /**
  136. * Elément en cours de déplacement
  137. */
  138. public var currentDragAndDropObject : DragAndDropVo;
  139. /**
  140. * Références sur les SWF
  141. */
  142. public var carotidLeftSWF : *;
  143. public var carotidRightSWF : *;
  144. public var bodySWF : *;
  145. public var armLeftSWF : *;
  146. public var armRightSWF : *;
  147. public var legLeftSWF : *;
  148. public var legRightSWF : *;
  149. /**
  150. * Variables locales au composant
  151. */
  152. [Bindable]
  153. private var _man : Boolean = true;
  154. [Bindable]
  155. private var _carotids : Boolean = false;
  156. [Bindable]
  157. private var _arms : Boolean = false;
  158. [Bindable]
  159. private var _body : Boolean = false;
  160. [Bindable]
  161. private var _legs : Boolean = false;
  162. private var _webcam : Camera = null;
  163. [Bindable]
  164. private var _webcamMaxHeight : int = 0;
  165. [Bindable]
  166. private var _webcamMaxWidth : int = 0;
  167. private var _imagesFilter : FileFilter = new FileFilter("Images","*.jpg;*.jpeg;*.png;*.dcm;*.dcim");
  168. private var _fileReference : FileReference = new FileReference();
  169. private var _rollOverElement : *;
  170. private var _cursorID : Number = 0;
  171. private var _cursor : Class = null;
  172. private var _typeCursor : String = null;
  173. private var _offset : int = -7;
  174. private var _canvasActive : Canvas = null;
  175. private var _boxActive : Canvas = null;
  176. public var list : Array = new Array();
  177. private var _timer : Timer;
  178. private var _appointmentId : int = 0;
  179. private var _cameraSelected : Boolean = true;
  180. [Bindable]
  181. private var _flowChoice : Boolean = false;
  182. private var _imagesLoaded : Boolean = false;
  183. [Bindable]
  184. private var _twoSideSelected : Boolean = true;
  185. // used if "saveImage" failed to know on which collectionImagesXX do a removeItem
  186. private var _lastAddedImgCollection : String;
  187. public var isDicomImg : Boolean = false;
  188. public var dicomScale : Number;
  189. private var dicomProgressPopup : ShowProgress;
  190. /**
  191. * Fenêtre d'information lors de la sauvegardes des acquisitions
  192. */
  193. public var loadingPopUp : LoadingPopUp;
  194. /**
  195. * Fonction activée à l'affichage de la vue permettant de récupérer les images
  196. */
  197. private function showView() : void
  198. {
  199. _model.acquireViewLoaded = true;
  200. if( _appointmentId != _model.appointmentSelected.id )
  201. _appointmentId = _model.appointmentSelected.id;
  202. _model.application.menuPhysician.patient.patientFile.updateAppointment();
  203. if (_model.viewPatient)
  204. {
  205. if (!_imagesLoaded)
  206. {
  207. this.loadingPopUp = new LoadingPopUp();
  208. PopUpManager.addPopUp( this.loadingPopUp, this, true );
  209. PopUpManager.centerPopUp( this.loadingPopUp );
  210. this.loadingPopUp.title = ResourceManager.getInstance().getString('labels', 'acquire.loadingAcquisitionDownloadTitle')
  211. this.loadingPopUp.message = ResourceManager.getInstance().getString( 'labels', 'acquire.popUp.get.images' );
  212. this.loadingPopUp.progress.setProgress( 15, 100 );
  213. new GetImagesEvent( _model.appointmentSelected.id, this ).dispatch();
  214. }
  215. var isCameraSelected : Boolean = _cameraSelected;
  216. viewBrowse();
  217. _cameraSelected = isCameraSelected;
  218. }
  219. else
  220. {
  221. if (_cameraSelected)
  222. viewCamera();
  223. }
  224. this.setFocus();
  225. this.addEventListener(KeyboardEvent.KEY_DOWN, keyHandler);
  226. }
  227. private function loadFirstImage(dragAndDropVo : DragAndDropVo) : void
  228. {
  229. var bitmapData : BitmapData = new BitmapData(dragAndDropVo.imageHigh.width,dragAndDropVo.imageHigh.height);
  230. bitmapData.draw(dragAndDropVo.imageHigh,new Matrix());
  231. var bitmap : Bitmap = new Bitmap(bitmapData);
  232. snapshotImage.maintainAspectRatio = true;
  233. snapshotImage.visible = true;
  234. snapshotImage.source = bitmap;
  235. }
  236. /**
  237. * Fonction permettant de préparer la récupération des marqueurs
  238. */
  239. public function getMarkers() : void
  240. {
  241. this.loadingPopUp.action.visible = true;
  242. this.loadingPopUp.message = ResourceManager.getInstance().getString( 'labels', 'acquire.popUp.get.markers' );
  243. this.loadingPopUp.progress.setProgress( 80, 100 );
  244. _timer = new Timer( 500, 1 )
  245. _timer.addEventListener( TimerEvent.TIMER_COMPLETE, getMarkersEvent );
  246. _timer.start();
  247. }
  248. /**
  249. * Fonction permettant de récupérer les marqueurs
  250. */
  251. private function getMarkersEvent( event : TimerEvent ) : void
  252. {
  253. _timer.removeEventListener( TimerEvent.TIMER_COMPLETE, getMarkersEvent );
  254. new GetMarkersEvent( _model.appointmentSelected.id, this ).dispatch();
  255. }
  256. /**
  257. * Changement du slider
  258. */
  259. private function sliderChanged( slider : HSlider , zoom : PanZoomComponent ) : void
  260. {
  261. zoom.zoom( slider.value / 100 );
  262. }
  263. /**
  264. * Changement du zoom
  265. */
  266. private function zoomChanged( slider : HSlider , zoom : PanZoomComponent ) : void
  267. {
  268. if( slider.value/100 != zoom.scale )
  269. {
  270. slider.value = zoom.scale * 100;
  271. }
  272. }
  273. /**
  274. * Création de la vue
  275. */
  276. private function creationCompleteHandler() : void
  277. {
  278. acquireImageSelectionHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/acquireArterySelection.png';
  279. acquireGlobalProcessHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/acquireGlobalProcess.png';
  280. acquireAcquisitionHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/acquireAcquisition.png';
  281. acquireAffectationHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/acquireAffectation.png';
  282. acquireThumbnailHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/acquireThumbnail.png';
  283. acquireLesionsHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/acquireLesions.png';
  284. launchVideoStream();
  285. configureListeners( _fileReference );
  286. }
  287. private function keyHandler( event : KeyboardEvent ) : void
  288. {
  289. if (event.charCode == 32)
  290. togglePlaySnapshot();
  291. else if (event.charCode == 83 || event.charCode == 115)
  292. changeSecurity();
  293. }
  294. private function resetLists() : void
  295. {
  296. _carotids = false;
  297. _arms = false;
  298. _legs = false;
  299. _body = false;
  300. }
  301. /**
  302. * Passage à la vue des carotides
  303. */
  304. private function flipToCarotids() : void
  305. {
  306. _boxActive = carotids;
  307. resetLists();
  308. _carotids = true;
  309. var flip : Flip = new Flip(human);
  310. flip.siblings = [ carotids ];
  311. flip.direction = DistortionConstants.RIGHT;
  312. flip.duration = 750;
  313. flip.addEventListener( EffectEvent.EFFECT_END, hideMan );
  314. flip.play();
  315. }
  316. /**
  317. * Passage à la vue du tronc
  318. */
  319. private function flipToBody() : void
  320. {
  321. _boxActive = body;
  322. resetLists();
  323. _body = true;
  324. var flip : Flip = new Flip(human);
  325. flip.siblings = [ body ];
  326. flip.direction = DistortionConstants.RIGHT;
  327. flip.duration = 750;
  328. flip.addEventListener( EffectEvent.EFFECT_END, hideMan );
  329. flip.play();
  330. }
  331. /**
  332. * Passage à la vue des jambes
  333. */
  334. private function flipToLegs() : void
  335. {
  336. _boxActive = legs;
  337. resetLists();
  338. _legs = true;
  339. var flip : Flip = new Flip(human);
  340. flip.siblings = [ legs ];
  341. flip.direction = DistortionConstants.RIGHT;
  342. flip.duration = 750;
  343. flip.addEventListener( EffectEvent.EFFECT_END, hideMan );
  344. flip.play();
  345. }
  346. /**
  347. * Passage à la vue des bras
  348. */
  349. private function flipToArms() : void
  350. {
  351. _boxActive = arms;
  352. resetLists();
  353. _arms = true;
  354. var flip : Flip = new Flip(human);
  355. flip.siblings = [ arms ];
  356. flip.direction = DistortionConstants.RIGHT;
  357. flip.duration = 750;
  358. flip.addEventListener( EffectEvent.EFFECT_END, hideMan );
  359. flip.play();
  360. }
  361. /**
  362. * Passage à la vue de la silhouette
  363. */
  364. private function flipToHuman() : void
  365. {
  366. var flip : Flip = new Flip(_boxActive);
  367. flip.siblings = [ human ];
  368. flip.direction = DistortionConstants.LEFT;
  369. flip.duration = 750;
  370. flip.addEventListener( EffectEvent.EFFECT_END, showMan );
  371. flip.play();
  372. }
  373. /**
  374. * Masquer la silhouette (fin d'événement)
  375. */
  376. private function hideMan( event : EffectEvent ) : void
  377. {
  378. _man = false;
  379. // load help if needed
  380. if (ApplicationModelLocator.getInstance().connectedUser.help)
  381. {
  382. HelpUtils.loadHelp(HelpUtils.buildAcquireHelpPages(), 0);
  383. }
  384. }
  385. /**
  386. * Afficher la silhouette (fin d'événement)
  387. */
  388. private function showMan( event : EffectEvent ) : void
  389. {
  390. _man = true;
  391. collectionDisplay.removeAll();
  392. }
  393. /**
  394. * Activation du champ parcourir sur le disque
  395. */
  396. private function viewBrowse() : void
  397. {
  398. snapshotVideo.removeEventListener( MouseEvent.MOUSE_DOWN, beginDragFromVideoOrBrowse );
  399. snapshotImage.addEventListener( MouseEvent.MOUSE_DOWN, beginDragFromVideoOrBrowse );
  400. cameraViews.selectedIndex = 1;
  401. _cameraSelected = false;
  402. _flowChoice = true;
  403. if (!_model.viewPatient)
  404. browse();
  405. }
  406. /**
  407. * Activation du flux vidéo
  408. */
  409. private function viewCamera() : void
  410. {
  411. snapshotVideo.addEventListener( MouseEvent.MOUSE_DOWN, beginDragFromVideoOrBrowse );
  412. snapshotImage.removeEventListener( MouseEvent.MOUSE_DOWN, beginDragFromVideoOrBrowse );
  413. cameraViews.selectedIndex = 0;
  414. _cameraSelected = true;
  415. _flowChoice = true;
  416. //flowChoice.includeInLayout = false;
  417. //flowChoice.visible = false;
  418. }
  419. /**
  420. * Lancement du flux vidéo
  421. */
  422. public function launchVideoStream() : void
  423. {
  424. try {
  425. _webcam = Camera.getCamera();
  426. _webcam.setQuality(0, 100);
  427. //_webcam.setMode(10240, 7680, 30, true);
  428. _webcam.setMode(640, 480, 25, true);
  429. _webcamMaxWidth = _webcam.width;
  430. _webcamMaxHeight = _webcam.height;
  431. video.attachCamera( _webcam );
  432. videoHD.attachCamera( _webcam );
  433. }
  434. catch ( error : * ) {
  435. var toastMessage : ImtToaster = new ImtToaster();
  436. toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'error.camera.title');
  437. toastMessage.message = ResourceManager.getInstance().getString('labels', 'error.camera');
  438. toastMessage.level = ImtToaster.ERROR;
  439. _model.toaster.toast( toastMessage );
  440. return;
  441. }
  442. }
  443. /**
  444. * Lancement de source vidéo
  445. */
  446. private function changeCamera() : void
  447. {
  448. Security.showSettings(SecurityPanel.CAMERA);
  449. launchVideoStream();
  450. }
  451. /**
  452. * Affichage du paramètrage de la sécurité
  453. */
  454. private function changeSecurity() : void
  455. {
  456. Security.showSettings(SecurityPanel.PRIVACY);
  457. }
  458. /**
  459. * Réalisation d'une capture d'écran de la vidéo
  460. */
  461. private function snapshot() : void
  462. {
  463. var bitmapData : BitmapData = new BitmapData(_webcamMaxWidth, _webcamMaxHeight);
  464. bitmapData.draw( videoHD );
  465. var bitmapDataHD : BitmapData = new BitmapData(_webcamMaxWidth, _webcamMaxHeight)
  466. bitmapDataHD.draw( videoHD );
  467. var bitmap : Bitmap = new Bitmap( bitmapData );
  468. var bitmapHD : Bitmap = new Bitmap( bitmapDataHD );
  469. snapshotVideo.source = bitmap;
  470. snapshotVideoHD.source = bitmapHD;
  471. snapshotVideo.visible = true;
  472. snapshotVideo.includeInLayout = true;
  473. playButton.visible = true;
  474. playButton.includeInLayout = true;
  475. video.visible = false;
  476. video.includeInLayout = false;
  477. snapshotButton.visible = false;
  478. snapshotButton.includeInLayout = false;
  479. if (_model.dragAndDropExplanation)
  480. {
  481. _model.dragAndDropExplanation = false;
  482. var toastMessage : ImtToaster = new ImtToaster();
  483. toastMessage = new ImtToaster();
  484. toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'title.dragAndDrop');
  485. toastMessage.message = ResourceManager.getInstance().getString('labels', 'dragAndDropHowTo');
  486. toastMessage.timeToLive = 15;
  487. toastMessage.level = ImtToaster.INFORMATION;
  488. _model.toaster.toast( toastMessage );
  489. }
  490. this.setFocus();
  491. }
  492. /**
  493. * Diffusion du flux vidéo
  494. */
  495. private function play() : void
  496. {
  497. snapshotVideo.visible = false;
  498. snapshotVideo.includeInLayout = false;
  499. playButton.visible = false;
  500. playButton.includeInLayout = false;
  501. video.visible = true;
  502. video.includeInLayout = true;
  503. snapshotButton.visible = true;
  504. snapshotButton.includeInLayout = true;
  505. this.setFocus();
  506. }
  507. private function togglePlaySnapshot() : void
  508. {
  509. if (snapshotVideo.visible == true)
  510. play();
  511. else
  512. snapshot();
  513. }
  514. /**
  515. * Début du déplacement de la capture ou de la photo chargée
  516. */
  517. private function beginDragFromVideoOrBrowse( mouseEvent : MouseEvent ) : void
  518. {
  519. var dragInitiator : Image = mouseEvent.currentTarget as Image;
  520. dragInitiator.maintainAspectRatio = true;
  521. var dragSource : DragSource = new DragSource();
  522. dragSource.addData( ObjectUtil.copy( dragInitiator ), SNAPSHOT );
  523. var bitmapDataDragView : BitmapData = new BitmapData(660, 494);
  524. bitmapDataDragView.draw( dragInitiator, new Matrix() );
  525. var bitmapDragView : Bitmap = new Bitmap( bitmapDataDragView );
  526. var dragView : Image = new Image();
  527. dragView.maintainAspectRatio = true;
  528. dragView.width = 450;
  529. dragView.height = 337;
  530. dragView.source = bitmapDragView;
  531. DragManager.doDrag( dragInitiator, dragSource, mouseEvent, dragView, -( dragInitiator.mouseX + 5 ), -( dragInitiator.mouseY + 5) );
  532. }
  533. /**
  534. * Accepter le coller sur les deux listes
  535. */
  536. private function allowDropToTileList( dragEvent : DragEvent ) : void
  537. {
  538. var dropTarget : TileList = dragEvent.currentTarget as TileList;
  539. if( dragEvent.dragSource.formats[ 0 ] == SNAPSHOT )
  540. {
  541. DragManager.acceptDragDrop( dropTarget );
  542. DragManager.showFeedback(DragManager.COPY);
  543. } else {
  544. DragManager.showFeedback(DragManager.NONE);
  545. }
  546. }
  547. /**
  548. * Survol d'un segment sur les éléments Flash
  549. */
  550. private function rollOverSegment( event : MouseEvent, type : String, canvas : Canvas ) : void
  551. {
  552. _canvasActive = canvas;
  553. if( event.target is Loader )
  554. {
  555. //Focus sur le loader et non le movieclip
  556. } else {
  557. if( ObjectUtil.compare( event.target.parent, event.target.root, 0) == 0 )
  558. {
  559. //Le Focus est sur l'objet MainTimeLine de Flash
  560. switch( type )
  561. {
  562. case CAROTID_RIGHT :
  563. carotidRightSWF = event.target.parent;
  564. break;
  565. case CAROTID_LEFT :
  566. carotidLeftSWF = event.target.parent;
  567. break;
  568. case BODY_AORTE :
  569. bodySWF = event.target.parent;
  570. break;
  571. case ARM_RIGHT :
  572. armRightSWF = event.target.parent;
  573. break;
  574. case ARM_LEFT :
  575. armLeftSWF = event.target.parent;
  576. break;
  577. case LEG_RIGHT :
  578. legRightSWF = event.target.parent;
  579. break;
  580. case LEG_LEFT :
  581. legLeftSWF = event.target.parent;
  582. break;
  583. }
  584. }
  585. }
  586. _rollOverElement = event.target;
  587. if( _cursor != null )
  588. _cursorID = CursorManager.setCursor( _cursor, 2, _offset, _offset );
  589. }
  590. /**
  591. * Ajout du curseur au déplacement pour compenser le composant zoom qui supprime les curseurs
  592. */
  593. private function addCursor() : void
  594. {
  595. if( _cursor != null )
  596. _cursorID = CursorManager.setCursor( _cursor, 2, _offset, _offset );
  597. }
  598. /**
  599. * Survol hors d'un segment sur les éléments Flash
  600. */
  601. private function rollOutSegment( event : MouseEvent ) : void
  602. {
  603. CursorManager.removeAllCursors();
  604. }
  605. /**
  606. * Accepter le coller sur la liste de gauche
  607. */
  608. private function allowDropFromLeftList( dragEvent : DragEvent ) : void
  609. {
  610. var dropTarget : SWFLoader = dragEvent.currentTarget as SWFLoader;
  611. if( dragEvent.dragSource.formats[ 0 ] == LIST_LEFT )
  612. {
  613. DragManager.acceptDragDrop( dropTarget );
  614. DragManager.showFeedback(DragManager.LINK);
  615. } else if( dragEvent.dragSource.formats[ 0 ] == SNAPSHOT ) {
  616. DragManager.acceptDragDrop( dropTarget );
  617. DragManager.showFeedback(DragManager.LINK);
  618. } else {
  619. DragManager.showFeedback(DragManager.NONE);
  620. }
  621. }
  622. /**
  623. * Accepter le coller sur la liste de droite
  624. */
  625. private function allowDropFromRightList( dragEvent : DragEvent ) : void
  626. {
  627. var dropTarget : SWFLoader = dragEvent.currentTarget as SWFLoader;
  628. if( dragEvent.dragSource.formats[ 0 ] == LIST_RIGHT )
  629. {
  630. DragManager.acceptDragDrop( dropTarget );
  631. DragManager.showFeedback(DragManager.LINK);
  632. } else if( dragEvent.dragSource.formats[ 0 ] == SNAPSHOT ) {
  633. DragManager.acceptDragDrop( dropTarget );
  634. DragManager.showFeedback(DragManager.LINK);
  635. } else {
  636. DragManager.showFeedback(DragManager.NONE);
  637. }
  638. }
  639. /**
  640. * Accepter le coller sur la liste de droite
  641. */
  642. private function allowDropFromBodyList( dragEvent : DragEvent ) : void
  643. {
  644. var dropTarget : SWFLoader = dragEvent.currentTarget as SWFLoader;
  645. if( dragEvent.dragSource.formats[ 0 ] == BODY )
  646. {
  647. DragManager.acceptDragDrop( dropTarget );
  648. DragManager.showFeedback(DragManager.LINK);
  649. } else if( dragEvent.dragSource.formats[ 0 ] == SNAPSHOT ) {
  650. DragManager.acceptDragDrop( dropTarget );
  651. DragManager.showFeedback(DragManager.LINK);
  652. } else {
  653. DragManager.showFeedback(DragManager.NONE);
  654. }
  655. }
  656. /**
  657. * Réalisation du coller de l'image sur un tronçon des éléments Flash et modification du Flash
  658. */
  659. private function dropOnSWF( event : DragEvent, flash : String ) : void
  660. {
  661. var previousType : String;
  662. if (_model.viewPatient)
  663. {
  664. var toastMessage : ImtToaster = new ImtToaster();
  665. toastMessage = new ImtToaster();
  666. toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'warning.use');
  667. toastMessage.message = ResourceManager.getInstance().getString('labels', 'acquire.updateImgInVisualMode');
  668. toastMessage.level = ImtToaster.WARNING;
  669. _model.toaster.toast( toastMessage );
  670. return;
  671. }
  672. if( event.dragSource.formats[ 0 ] == SNAPSHOT )
  673. {
  674. if( currentDragAndDropObject != null )
  675. {
  676. previousType = currentDragAndDropObject.type;
  677. }
  678. else
  679. {
  680. currentDragAndDropObject = new DragAndDropVo();
  681. }
  682. _rollOverElement.gotoAndStop( 2 );
  683. //création du DragAndDropObject à inserer dans la bonne liste
  684. var dragSource : DragSource = event.dragSource;
  685. var dragInitiator : Image = event.dragInitiator as Image;
  686. dragInitiator.maintainAspectRatio = true;
  687. var bitmapDataSmall : BitmapData = new BitmapData(450, 337);
  688. bitmapDataSmall.draw( dragInitiator, new Matrix() );
  689. var bitmapDataHigh : BitmapData;
  690. if( _cameraSelected )
  691. {
  692. bitmapDataHigh = ( snapshotVideoHD.content as Bitmap ).bitmapData;
  693. bitmapDataHigh.draw( snapshotVideoHD, new Matrix() );
  694. }
  695. else
  696. {
  697. bitmapDataHigh = ( snapshotImageHD.content as Bitmap ).bitmapData;
  698. bitmapDataHigh.draw( snapshotImageHD, new Matrix() );
  699. var dragAndDropObject : DragAndDropVo = new DragAndDropVo();
  700. dragAndDropObject.imageSmall = new Bitmap( bitmapDataSmall );
  701. dragAndDropObject.imageHigh = new Bitmap( bitmapDataHigh );
  702. if( isDicomImg )
  703. {
  704. if (!dragAndDropObject.scale)
  705. dragAndDropObject.scale = new ScaleVo();
  706. dragAndDropObject.scale.value = dicomScale;
  707. dragAndDropObject.isDicom = true;
  708. }
  709. dragAndDropObject.type = _rollOverElement.name;
  710. dragAndDropObject.width = dragAndDropObject.imageHigh.bitmapData.width;
  711. dragAndDropObject.height = dragAndDropObject.imageHigh.bitmapData.height;
  712. switch( flash )
  713. {
  714. case CAROTID_RIGHT:
  715. dragAndDropObject.collection = "CR";
  716. collectionImagesCarotidRight.addItem( dragAndDropObject );
  717. break;
  718. case CAROTID_LEFT:
  719. dragAndDropObject.collection = "CL";
  720. collectionImagesCarotidLeft.addItem( dragAndDropObject );
  721. break;
  722. case BODY_AORTE:
  723. dragAndDropObject.collection = "BO";
  724. collectionImagesBody.addItem( dragAndDropObject );
  725. break;
  726. case ARM_RIGHT:
  727. dragAndDropObject.collection = "AR";
  728. collectionImagesArmRight.addItem( dragAndDropObject );
  729. break;
  730. case ARM_LEFT:
  731. dragAndDropObject.collection = "AL";
  732. collectionImagesArmLeft.addItem( dragAndDropObject );
  733. break;
  734. case LEG_RIGHT:
  735. dragAndDropObject.collection = "LR";
  736. collectionImagesLegRight.addItem( dragAndDropObject );
  737. break;
  738. case LEG_LEFT:
  739. dragAndDropObject.collection = "LL";
  740. collectionImagesLegLeft.addItem( dragAndDropObject );
  741. break;
  742. }
  743. _lastAddedImgCollection = dragAndDropObject.collection;
  744. currentDragAndDropObject = dragAndDropObject;
  745. play();
  746. }
  747. }
  748. else
  749. {
  750. previousType = currentDragAndDropObject.type;
  751. deleteImage();
  752. currentDragAndDropObject.type = _rollOverElement.name;
  753. _rollOverElement.gotoAndStop( 2 );
  754. _lastAddedImgCollection = "";
  755. currentDragAndDropObject = (event.dragInitiator as Image).data as DragAndDropVo;
  756. }
  757. switch( flash )
  758. {
  759. case CAROTID_RIGHT:
  760. if (_lastAddedImgCollection == "")
  761. currentDragAndDropObject.collection = "CR";
  762. FlashHelper.refreshCarotidRight( previousType, this );
  763. break;
  764. case CAROTID_LEFT:
  765. if (_lastAddedImgCollection == "")
  766. currentDragAndDropObject.collection = "CL";
  767. FlashHelper.refreshCarotidLeft( previousType, this );
  768. break;
  769. case BODY_AORTE:
  770. if (_lastAddedImgCollection == "")
  771. currentDragAndDropObject.collection = "BO";
  772. FlashHelper.refreshBody( previousType, this );
  773. break;
  774. case ARM_RIGHT:
  775. if (_lastAddedImgCollection == "")
  776. currentDragAndDropObject.collection = "AR";
  777. FlashHelper.refreshArmRight( previousType, this );
  778. break;
  779. case ARM_LEFT:
  780. if (_lastAddedImgCollection == "")
  781. currentDragAndDropObject.collection = "AL";
  782. FlashHelper.refreshArmLeft( previousType, this );
  783. break;
  784. case LEG_RIGHT:
  785. if (_lastAddedImgCollection == "")
  786. currentDragAndDropObject.collection = "LR";
  787. FlashHelper.refreshLegRight( previousType, this );
  788. break;
  789. case LEG_LEFT:
  790. if (_lastAddedImgCollection == "")
  791. currentDragAndDropObject.collection = "LL";
  792. FlashHelper.refreshLegLeft( previousType, this );
  793. break;
  794. }
  795. if (currentDragAndDropObject.type == 'COMD' || currentDragAndDropObject.type == 'COMG')
  796. {
  797. var incidencePopUp : IncidencePopUp = new IncidencePopUp();
  798. incidencePopUp.parentAcquire = this;
  799. PopUpManager.addPopUp( incidencePopUp, this, true );
  800. PopUpManager.centerPopUp( incidencePopUp );
  801. }
  802. else
  803. {
  804. saveImage();
  805. }
  806. }
  807. private function removeImageFromCollection() : void
  808. {
  809. switch( currentDragAndDropObject.collection )
  810. {
  811. case "CR":
  812. if (_lastAddedImgCollection)
  813. collectionImagesCarotidRight.removeItemAt(collectionImagesCarotidRight.length - 1);
  814. FlashHelper.removeSelectionForRightCarotid( currentDragAndDropObject.type );
  815. break;
  816. case "CL":
  817. if (_lastAddedImgCollection)
  818. collectionImagesCarotidLeft.removeItemAt(collectionImagesCarotidLeft.length - 1);
  819. FlashHelper.removeSelectionForLeftCarotid( currentDragAndDropObject.type );
  820. break;
  821. case "BO":
  822. if (_lastAddedImgCollection)
  823. collectionImagesBody.removeItemAt(collectionImagesBody.length - 1);
  824. FlashHelper.removeSelectionForBody( currentDragAndDropObject.type );
  825. break;
  826. case "AR":
  827. if (_lastAddedImgCollection)
  828. collectionImagesArmRight.removeItemAt(collectionImagesArmRight.length - 1);
  829. FlashHelper.removeSelectionForRightArm( currentDragAndDropObject.type );
  830. break;
  831. case "AL":
  832. if (_lastAddedImgCollection)
  833. collectionImagesArmLeft.removeItemAt(collectionImagesArmLeft.length - 1);
  834. FlashHelper.removeSelectionForLeftArm( currentDragAndDropObject.type );
  835. break;
  836. case "LR":
  837. if (_lastAddedImgCollection)
  838. collectionImagesLegRight.removeItemAt(collectionImagesLegRight.length - 1);
  839. FlashHelper.removeSelectionForRightLeg( currentDragAndDropObject.type );
  840. break;
  841. case "LL":
  842. if (_lastAddedImgCollection)
  843. collectionImagesLegLeft.removeItemAt(collectionImagesLegLeft.length - 1);
  844. FlashHelper.removeSelectionForLeftLeg( currentDragAndDropObject.type );
  845. break;
  846. default:
  847. break;
  848. }
  849. _lastAddedImgCollection = "";
  850. }
  851. /**
  852. * Conversion de l'image en Base64 et déclenchement de l'événement de sauvegarde
  853. */
  854. private function saveImage() : void
  855. {
  856. this.loadingPopUp = new LoadingPopUp();
  857. PopUpManager.addPopUp( this.loadingPopUp, this, true );
  858. PopUpManager.centerPopUp( this.loadingPopUp );
  859. this.loadingPopUp.message = ResourceManager.getInstance().getString( 'labels', 'acquire.popUp.convert' );
  860. this.loadingPopUp.action.visible = true;
  861. this.loadingPopUp.progress.setProgress( 50, 100 );
  862. new SaveImageEvent( currentDragAndDropObject, _model.appointmentSelected.id, this ).dispatch();
  863. }
  864. public function saveImageEnded(id : int) : void
  865. {
  866. currentDragAndDropObject.id = id;
  867. _model.measuresList.addItem( currentDragAndDropObject );
  868. if (_model.measuresList.length == 1)
  869. _model.appointmentSelected.type = currentDragAndDropObject.collection;
  870. saveEnding();
  871. _model.enabledMeasure = true;
  872. }
  873. public function removeImageFromError() : void
  874. {
  875. this.loadingPopUp.closeHandler();
  876. removeImageFromCollection();
  877. }
  878. /**
  879. * Déclenchement de l'événement de suppression d'image
  880. */
  881. public function deleteImage() : void
  882. {
  883. new DeleteImagesEvent( currentDragAndDropObject, _model.appointmentSelected.id, this ).dispatch() ;
  884. var index : int = 0;
  885. for each( var elementToDelete : DragAndDropVo in _model.measuresList )
  886. {
  887. if( ObjectUtil.compare( elementToDelete, currentDragAndDropObject, 0) == 0 )
  888. _model.measuresList.removeItemAt( index );
  889. index++;
  890. }
  891. switch( currentDragAndDropObject.collection )
  892. {
  893. case "CR":
  894. FlashHelper.removeSelectionForRightCarotid(currentDragAndDropObject.type);
  895. break;
  896. case "CL":
  897. FlashHelper.removeSelectionForLeftCarotid(currentDragAndDropObject.type);
  898. break;
  899. case "AR":
  900. FlashHelper.removeSelectionForRightArm(currentDragAndDropObject.type);
  901. break;
  902. case "AL":
  903. FlashHelper.removeSelectionForLeftArm(currentDragAndDropObject.type);
  904. break;
  905. case "LR":
  906. FlashHelper.removeSelectionForRightLeg(currentDragAndDropObject.type);
  907. break;
  908. case "LL":
  909. FlashHelper.removeSelectionForLeftLeg(currentDragAndDropObject.type);
  910. break;
  911. case "BO":
  912. FlashHelper.removeSelectionForBody(currentDragAndDropObject.type);
  913. break;
  914. }
  915. if (_model.measuresList.length == 0)
  916. {
  917. _model.enabledMeasure = false;
  918. _model.enabledReport = false;
  919. }
  920. // remove image from measures page
  921. Application.application.menuPhysician.generalMeasure.measures.imageZoom.removeAllChildren();
  922. Application.application.menuPhysician.generalMeasure.measures.selectedZoneLabel.text = "";
  923. }
  924. /**
  925. * Déclenchement de l'événement de sauvegarde des marqueurs
  926. */
  927. public function saveMarker() : void
  928. {
  929. this.loadingPopUp.message = ResourceManager.getInstance().getString( 'labels', 'acquire.popUp.trasnfert.lesions' );
  930. this.loadingPopUp.progress.setProgress( 85, 100 );
  931. new SaveMarkerEvent( collectionOfMarkers.source, _model.appointmentSelected.id, this ).dispatch();
  932. }
  933. /**
  934. * Déclenchement de l'événement de suppression des marqueurs
  935. */
  936. public function deleteMarkersEvent() : void
  937. {
  938. new DeleteMarkersEvent( collectionOfMarkers.source, _model.appointmentSelected.id, this ).dispatch();
  939. }
  940. /**
  941. * Déclenchement de l'événement de sauvegarde des marqueurs
  942. */
  943. public function saveEnding() : void
  944. {
  945. this.loadingPopUp.message = ResourceManager.getInstance().getString( "labels", "acquire.popUp.save.done");
  946. this.loadingPopUp.progress.setProgress( 100, 100 );
  947. this.loadingPopUp.closeHandler();
  948. panzoomCarotidRight.zoom( 1 );
  949. panzoomCarotidLeft.zoom( 1 );
  950. panzoomArmRight.zoom( 1 );
  951. panzoomArmLeft.zoom( 1 );
  952. panzoomLegRight.zoom( 1 );
  953. panzoomLegLeft.zoom( 1 );
  954. panzoomBody.zoom( 1 );
  955. _timer = new Timer( 1000, 1 );
  956. _timer.addEventListener( TimerEvent.TIMER_COMPLETE, buildSegments );
  957. _timer.start();
  958. }
  959. /**
  960. * Construction des differents segments (conversion swf en bitmap)
  961. */
  962. private function buildSegments( event : TimerEvent ) : void
  963. {
  964. FlashHelper.buildSegmentSelected( panzoomCarotidRight, "CR" );
  965. FlashHelper.buildSegmentSelected( panzoomCarotidLeft, "CL" );
  966. FlashHelper.buildSegmentSelected( panzoomArmRight, "AR" );
  967. FlashHelper.buildSegmentSelected( panzoomArmLeft, "AL" );
  968. FlashHelper.buildSegmentSelected( panzoomLegRight, "LR" );
  969. FlashHelper.buildSegmentSelected( panzoomLegLeft, "LL" );
  970. FlashHelper.buildSegmentSelected( panzoomBody, "BO" );
  971. }
  972. /**
  973. * Convertisseur de SWF en bitmap pour les mesures
  974. */
  975. private function convertSWFToBitmap( swf : PanZoomComponent, bitmap : String ) : void
  976. {
  977. var bitmapData : BitmapData = new BitmapData( swf.width - 15, swf.height - 14 );
  978. var matrix : Matrix = new Matrix(1,0,0,1,2,2);
  979. var rectangle : Rectangle = new Rectangle( 5, 5, swf.width - 15, swf.height - 14 );
  980. bitmapData.draw( swf, matrix, null, null, rectangle );
  981. switch( bitmap )
  982. {
  983. case "CR":
  984. _model.carotidRight = new Bitmap( bitmapData );
  985. _model.carotidRight.smoothing = true;
  986. break;
  987. case "CL":
  988. _model.carotidLeft = new Bitmap( bitmapData );
  989. _model.carotidLeft.smoothing = true;
  990. break;
  991. case "AR":
  992. _model.armRight = new Bitmap( bitmapData );
  993. _model.armRight.smoothing = true;
  994. break;
  995. case "AL":
  996. _model.armLeft = new Bitmap( bitmapData );
  997. _model.armLeft.smoothing = true;
  998. break;
  999. case "LR":
  1000. _model.legRight = new Bitmap( bitmapData );
  1001. _model.legRight.smoothing = true;
  1002. break;
  1003. case "LL":
  1004. _model.legLeft = new Bitmap( bitmapData );
  1005. _model.legLeft.smoothing = true;
  1006. break;
  1007. case "BO":
  1008. _model.body = new Bitmap( bitmapData );
  1009. _model.body.smoothing = true;
  1010. break;
  1011. }
  1012. }
  1013. /**
  1014. * Acceptation du copier de l'image provenant de l'acquisition (flux vidéo ou champ parcourir)
  1015. */
  1016. private function acceptDropToTileList( dragEvent : DragEvent ) : void
  1017. {
  1018. var dragSource : DragSource = dragEvent.dragSource;
  1019. var dragInitiator : Image = dragEvent.dragInitiator as Image;
  1020. var dropTarget : TileList = dragEvent.currentTarget as TileList;
  1021. var bitmapDataSmall : BitmapData = new BitmapData(400, 300);
  1022. bitmapDataSmall.draw( dragInitiator, new Matrix() );
  1023. var bitmapDataHigh : BitmapData;
  1024. if( _cameraSelected )
  1025. {
  1026. bitmapDataHigh = ( snapshotVideoHD.content as Bitmap ).bitmapData;
  1027. bitmapDataHigh.draw( snapshotVideoHD, new Matrix() );
  1028. }
  1029. else
  1030. {
  1031. bitmapDataHigh = ( snapshotImageHD.content as Bitmap ).bitmapData;
  1032. bitmapDataHigh.draw( snapshotImageHD, new Matrix() );
  1033. }
  1034. var dragAndDropObject : DragAndDropVo = new DragAndDropVo();
  1035. dragAndDropObject.imageSmall = new Bitmap( bitmapDataSmall );
  1036. dragAndDropObject.imageHigh = new Bitmap( bitmapDataHigh );
  1037. if( isDicomImg )
  1038. {
  1039. if (!dragAndDropObject.scale)
  1040. dragAndDropObject.scale = new ScaleVo();
  1041. dragAndDropObject.scale.value = dicomScale;
  1042. dragAndDropObject.isDicom = true;
  1043. }
  1044. if( dragSource.formats[ 0 ] == SNAPSHOT )
  1045. {
  1046. dropTarget.dataProvider.addItem( dragAndDropObject );
  1047. }
  1048. play();
  1049. }
  1050. /**
  1051. * Création d'écouteurs lors de la création du composant
  1052. */
  1053. private function configureListeners( dispatcher : IEventDispatcher ) : void
  1054. {
  1055. snapshotVideo.addEventListener( MouseEvent.MOUSE_DOWN, beginDragFromVideoOrBrowse );
  1056. }
  1057. /**
  1058. * Ouverture de la fenêtre parcourir
  1059. */
  1060. private function browse() : void
  1061. {
  1062. _fileReference = new FileReference();
  1063. _fileReference.addEventListener(Event.SELECT, imageSelected);
  1064. _fileReference.addEventListener(Event.COMPLETE, imageLoaded);
  1065. _fileReference.browse( [_imagesFilter] );
  1066. }
  1067. private function imagesDownload() : void
  1068. {
  1069. _fileReference = new FileReference();
  1070. _fileReference.download(new URLRequest(_model.ipProtocol + "://" + _model.ipAddress + "/images/images.zip"));
  1071. }
  1072. /**
  1073. * Image séléctionnée depuis le champ parcourir
  1074. */
  1075. private function imageSelected( event : Event ) : void
  1076. {
  1077. var _fileReference : FileReference = FileReference(event.target);
  1078. _fileReference.load();
  1079. }
  1080. /**
  1081. * Image chargée depuis le champ parcourir
  1082. */
  1083. private function imageLoaded( event : Event ) : void
  1084. {
  1085. var toastMessage : ImtToaster;
  1086. var _fileReference : FileReference = FileReference(event.target);
  1087. var filename : String = event.target.name;
  1088. var extension : String = filename.substr(filename.lastIndexOf(".") + 1);
  1089. if (extension == "jpg" || extension == "jpeg" || extension == "png"
  1090. || extension == "JPG" || extension == "JPEG" || extension == "PNG")
  1091. {
  1092. isDicomImg = false;
  1093. snapshotImage.source = _fileReference.data;
  1094. snapshotImageHD.source = _fileReference.data;
  1095. // var imageCJ : ImageCJ = new ImageCJ();
  1096. // imageCJ.toQuatreTiers( ( snapshotImageHD.content as Bitmap ).bitmapData.width, ( snapshotImageHD.content as Bitmap ).bitmapData.height, ( snapshotImageHD.content as Bitmap ).bitmapData );
  1097. // bitmapDataHigh = ( snapshotImageHD.content as Bitmap ).bitmapData;
  1098. // bitmapDataHigh.draw( snapshotImageHD, new Matrix() );
  1099. }
  1100. else if (extension == "dcm" || extension == "dcim" || extension == "DCM" || extension == "DCIM")
  1101. {
  1102. isDicomImg = true
  1103. snapshotImage.source = null;
  1104. snapshotImageHD.source = null;
  1105. dicomProgressPopup = ShowProgress(PopUpManager.createPopUp(this, ShowProgress, true));
  1106. dicomProgressPopup.progress.label = "Uploading...";
  1107. PopUpManager.centerPopUp(dicomProgressPopup);
  1108. _fileReference.removeEventListener(Event.COMPLETE, imageLoaded);
  1109. _fileReference.removeEventListener(Event.SELECT, imageSelected);
  1110. _fileReference.addEventListener(Event.COMPLETE, uploadCompleteHandler);
  1111. var request : URLRequest = new URLRequest();
  1112. request.url = _model.ipProtocol + "://" + _model.ipAddress + "/services/common/dicom/upload.php";
  1113. request.method = URLRequestMethod.POST;
  1114. _fileReference.upload( request, "filename" );
  1115. }
  1116. if (_model.dragAndDropExplanation)
  1117. {
  1118. // one time by connection : display drag and drop howto
  1119. _model.dragAndDropExplanation = false;
  1120. toastMessage = new ImtToaster();
  1121. toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'title.dragAndDrop');
  1122. toastMessage.message = ResourceManager.getInstance().getString('labels', 'dragAndDropHowTo');
  1123. toastMessage.timeToLive = 12;
  1124. toastMessage.level = ImtToaster.INFORMATION;
  1125. _model.toaster.toast( toastMessage );
  1126. }
  1127. }
  1128. private function uploadCompleteHandler(event:Event):void
  1129. {
  1130. PopUpManager.removePopUp(dicomProgressPopup);
  1131. var service : HTTPService = new HTTPService();
  1132. _fileReference.removeEventListener(Event.COMPLETE, uploadCompleteHandler);
  1133. service.url = _model.ipProtocol + "://" + _model.ipAddress + "/services/common/dicom/dicomProcessing.php";
  1134. service.method = URLRequestMethod.GET;
  1135. service.resultFormat = "text";
  1136. var parameters : Object = new Object();
  1137. parameters.filename = event.target.name;
  1138. parameters.idpatient = _model.connectedUser.id;
  1139. parameters.lastname = _model.connectedUser.person.lastName;
  1140. parameters.firstname = _model.connectedUser.person.firstName;
  1141. parameters.sex = "";
  1142. parameters.birthdate = "";
  1143. service.request = parameters;
  1144. service.addEventListener(ResultEvent.RESULT, onDicomOK );
  1145. service.addEventListener(FaultEvent.FAULT, onDicomFault );
  1146. dicomProgressPopup = ShowProgress(PopUpManager.createPopUp(this, ShowProgress, true));
  1147. dicomProgressPopup.progress.label = "Downloading...";
  1148. PopUpManager.centerPopUp(dicomProgressPopup);
  1149. service.send();
  1150. }
  1151. /**
  1152. * Changement d'affichage du curseur
  1153. */
  1154. private function changeCursor( icon : Class, swf : String, event : Event, buttons : Array ) : void
  1155. {
  1156. if( event.currentTarget.selected )
  1157. {
  1158. _cursor = icon;
  1159. _typeCursor = "swf/" + swf + ".swf";
  1160. for each( var button : Button in buttons )
  1161. button.selected = false;
  1162. } else {
  1163. _cursor = null;
  1164. }
  1165. }
  1166. /**
  1167. * Ajout d'un marqueur
  1168. */
  1169. private function addMarkerOrDisplayPictures( event : MouseEvent, flash : String, canvas : Canvas ) : void
  1170. {
  1171. if( _cursor != null )
  1172. {
  1173. var markerVo : MarkerVo = new MarkerVo();
  1174. var marker : SWFLoader = new SWFLoader();
  1175. marker.source = _typeCursor;
  1176. if( _typeCursor == "swf/" + SWF_STENOSE + ".swf" )
  1177. markerVo.type = MarkerVo.STENOSE;
  1178. if( _typeCursor == "swf/" + SWF_PLAQUE + ".swf" )
  1179. markerVo.type = MarkerVo.PLAQUE;
  1180. if( _typeCursor == "swf/" + SWF_OCCLUSION + ".swf" )
  1181. markerVo.type = MarkerVo.OCCLUSION;
  1182. canvas.addChild( marker );
  1183. marker.x = canvas.contentMouseX + _offset;
  1184. marker.y = canvas.contentMouseY + _offset;
  1185. switch( flash )
  1186. {
  1187. case CAROTID_RIGHT :
  1188. markerVo.location = MarkerVo.CAROTID;
  1189. markerVo.side = MarkerVo.RIGHT;
  1190. break;
  1191. case CAROTID_LEFT :
  1192. markerVo.location = MarkerVo.CAROTID;
  1193. markerVo.side = MarkerVo.LEFT;
  1194. break;
  1195. case ARM_RIGHT :
  1196. markerVo.location = MarkerVo.ARM;
  1197. markerVo.side = MarkerVo.RIGHT;
  1198. break;
  1199. case ARM_LEFT :
  1200. markerVo.location = MarkerVo.ARM;
  1201. markerVo.side = MarkerVo.LEFT;
  1202. break;
  1203. case LEG_RIGHT :
  1204. markerVo.location = MarkerVo.LEG;
  1205. markerVo.side = MarkerVo.RIGHT;
  1206. break;
  1207. case LEG_LEFT :
  1208. markerVo.location = MarkerVo.LEG;
  1209. markerVo.side = MarkerVo.LEFT;
  1210. break;
  1211. case BODY :
  1212. markerVo.location = MarkerVo.BODY;
  1213. markerVo.side = MarkerVo.CENTER;
  1214. break;
  1215. }
  1216. markerVo.xPosition = marker.x;
  1217. markerVo.yPosition = marker.y;
  1218. markerVo.uidDisplayObject = marker.uid;
  1219. collectionOfMarkers.addItem( markerVo );
  1220. marker.addEventListener( MouseEvent.CLICK, removeMarker );
  1221. for each( var button : Button in [ buttonPlaque, buttonStenosis, buttonOcclusion ] )
  1222. button.selected = false;
  1223. _cursor = null;
  1224. saveMarker();
  1225. }
  1226. else
  1227. refreshDisplayList( event, flash );
  1228. }
  1229. /**
  1230. * Suppression d'un marqueur
  1231. */
  1232. private function removeMarker( event : MouseEvent ) : void
  1233. {
  1234. _canvasActive.removeChild( event.currentTarget as SWFLoader );
  1235. var index : int = 0;
  1236. for each( var item : MarkerVo in collectionOfMarkers )
  1237. {
  1238. if( ObjectUtil.compare( item.uidDisplayObject, ( event.currentTarget.uid as String ), 0) == 0 )
  1239. {
  1240. collectionOfMarkers.removeItemAt( index );
  1241. break;
  1242. }
  1243. index++;
  1244. }
  1245. saveMarker();
  1246. }
  1247. /**
  1248. * Rafraichissement de la collection d'affichage
  1249. */
  1250. private function refreshDisplayList( event : Event, flash : String ) : void
  1251. {
  1252. collectionDisplay.removeAll();
  1253. var item : DragAndDropVo;
  1254. for each( item in collectionImagesCarotidRight )
  1255. {
  1256. item.segment = false
  1257. }
  1258. for each( item in collectionImagesCarotidLeft )
  1259. {
  1260. item.segment = false
  1261. }
  1262. for each( item in collectionImagesBody )
  1263. {
  1264. item.segment = false
  1265. }
  1266. for each( item in collectionImagesLegRight )
  1267. {
  1268. item.segment = false
  1269. }
  1270. for each( item in collectionImagesLegLeft )
  1271. {
  1272. item.segment = false
  1273. }
  1274. for each( item in collectionImagesArmRight )
  1275. {
  1276. item.segment = false
  1277. }
  1278. for each( item in collectionImagesArmLeft )
  1279. {
  1280. item.segment = false
  1281. }
  1282. switch( flash )
  1283. {
  1284. case CAROTID_RIGHT:
  1285. for each( item in collectionImagesCarotidRight )
  1286. {
  1287. if( item.type == event.target.name )
  1288. {
  1289. collectionDisplay.addItem( item );
  1290. item.segment = true
  1291. } else {
  1292. item.segment = false
  1293. }
  1294. }
  1295. sideDisplay = CAROTID_RIGHT;
  1296. break;
  1297. case CAROTID_LEFT:
  1298. for each( item in collectionImagesCarotidLeft )
  1299. {
  1300. if( item.type == event.target.name )
  1301. {
  1302. collectionDisplay.addItem( item );
  1303. item.segment = true
  1304. } else {
  1305. item.segment = false
  1306. }
  1307. }
  1308. sideDisplay = CAROTID_LEFT;
  1309. break;
  1310. case BODY_AORTE:
  1311. for each( item in collectionImagesBody )
  1312. {
  1313. if( item.type == event.target.name )
  1314. {
  1315. collectionDisplay.addItem( item );
  1316. item.segment = true
  1317. } else {
  1318. item.segment = false
  1319. }
  1320. }
  1321. sideDisplay = BODY_AORTE;
  1322. break;
  1323. case LEG_RIGHT:
  1324. for each( item in collectionImagesLegRight )
  1325. {
  1326. if( item.type == event.target.name )
  1327. {
  1328. collectionDisplay.addItem( item );
  1329. item.segment = true
  1330. } else {
  1331. item.segment = false
  1332. }
  1333. }
  1334. sideDisplay = LEG_RIGHT;
  1335. break;
  1336. case LEG_LEFT:
  1337. for each( item in collectionImagesLegLeft )
  1338. {
  1339. if( item.type == event.target.name )
  1340. {
  1341. collectionDisplay.addItem( item );
  1342. item.segment = true
  1343. } else {
  1344. item.segment = false
  1345. }
  1346. }
  1347. sideDisplay = LEG_LEFT;
  1348. break;
  1349. case ARM_RIGHT:
  1350. for each( item in collectionImagesArmRight )
  1351. {
  1352. if( item.type == event.target.name )
  1353. {
  1354. collectionDisplay.addItem( item );
  1355. item.segment = true
  1356. } else {
  1357. item.segment = false
  1358. }
  1359. }
  1360. sideDisplay = ARM_RIGHT;
  1361. break;
  1362. case ARM_LEFT:
  1363. for each( item in collectionImagesArmLeft )
  1364. {
  1365. if( item.type == event.target.name )
  1366. {
  1367. collectionDisplay.addItem( item );
  1368. item.segment = true
  1369. } else {
  1370. item.segment = false
  1371. }
  1372. }
  1373. sideDisplay = ARM_LEFT;
  1374. break;
  1375. }
  1376. }
  1377. /**
  1378. * Lors de la sélection d'une zone du corps on charge les éléments qui lui sont liés depuis la base.
  1379. * Au 10/05/2011 cette collection n'est plus utilisée pour des raisons de lisibilité.
  1380. */
  1381. private function selectZone( event : MouseEvent ) : void
  1382. {
  1383. _twoSideSelected = true;
  1384. switch( event.target.name )
  1385. {
  1386. case "neck":
  1387. flipToCarotids();
  1388. new GetTypeFromLocationEvent( "CL" ).dispatch();
  1389. new GetTypeFromLocationEvent( "CR" ).dispatch();
  1390. break;
  1391. case "armL":
  1392. case "armR":
  1393. flipToArms();
  1394. new GetTypeFromLocationEvent( "AL" ).dispatch();
  1395. new GetTypeFromLocationEvent( "AR" ).dispatch();
  1396. break;
  1397. case "body":
  1398. flipToBody();
  1399. _twoSideSelected = false;
  1400. new GetTypeFromLocationEvent( "BO" ).dispatch();
  1401. break;
  1402. case "legs":
  1403. flipToLegs();
  1404. new GetTypeFromLocationEvent( "LL" ).dispatch();
  1405. new GetTypeFromLocationEvent( "LR" ).dispatch();
  1406. break;
  1407. }
  1408. }
  1409. /**
  1410. * Affichage des contrôles vidéos
  1411. */
  1412. private function displayControls( box : HBox ) : void
  1413. {
  1414. box.alpha = 1;
  1415. }
  1416. /**
  1417. * Disparition des contrôles vidéos
  1418. */
  1419. private function hideControls( box : HBox ) : void
  1420. {
  1421. box.alpha = 0;
  1422. }
  1423. public function setImagesLoaded( type : String ) : void
  1424. {
  1425. _imagesLoaded = true;
  1426. if (_model.viewPatient)
  1427. {
  1428. var dragAndDropVo : DragAndDropVo = null;
  1429. switch( type )
  1430. {
  1431. case "CR":
  1432. case "CL":
  1433. if (collectionImagesCarotidRight)
  1434. dragAndDropVo = collectionImagesCarotidRight.getItemAt(0) as DragAndDropVo;
  1435. else if (collectionImagesCarotidLeft)
  1436. dragAndDropVo = collectionImagesCarotidLeft.getItemAt(0) as DragAndDropVo;
  1437. flipToCarotids();
  1438. break;
  1439. case "AR":
  1440. case "AL":
  1441. if (collectionImagesArmRight)
  1442. dragAndDropVo = collectionImagesArmRight.getItemAt(0) as DragAndDropVo;
  1443. else if (collectionImagesArmLeft)
  1444. dragAndDropVo = collectionImagesArmLeft.getItemAt(0) as DragAndDropVo;
  1445. flipToArms();
  1446. break;
  1447. case "LR":
  1448. case "LL":
  1449. if (collectionImagesLegRight)
  1450. dragAndDropVo = collectionImagesLegRight.getItemAt(0) as DragAndDropVo;
  1451. else if (collectionImagesLegLeft)
  1452. dragAndDropVo = collectionImagesLegLeft.getItemAt(0) as DragAndDropVo;
  1453. flipToLegs();
  1454. break;
  1455. case "BO":
  1456. if (collectionImagesBody)
  1457. dragAndDropVo = collectionImagesBody.getItemAt(0) as DragAndDropVo;
  1458. flipToBody();
  1459. break;
  1460. }
  1461. if (dragAndDropVo)
  1462. loadFirstImage(dragAndDropVo);
  1463. }
  1464. }
  1465. public function clearPage() : void
  1466. {
  1467. collectionImagesCarotidLeft.removeAll();
  1468. collectionImagesCarotidRight.removeAll();
  1469. collectionImagesBody.removeAll();
  1470. collectionImagesArmLeft.removeAll();
  1471. collectionImagesArmRight.removeAll();
  1472. collectionImagesLegLeft.removeAll();
  1473. collectionImagesLegRight.removeAll();
  1474. collectionDisplay.removeAll();
  1475. collectionOfMarkers.removeAll();
  1476. _imagesLoaded = false;
  1477. _model.measuresList.removeAll();
  1478. _model.listMarkers.removeAll();
  1479. snapshotImage.source = null;
  1480. snapshotImageHD.source = null;
  1481. cameraViews.selectedIndex = 0;
  1482. for each( var button : Button in [ buttonPlaque, buttonStenosis, buttonOcclusion ] )
  1483. button.selected = false;
  1484. var stenose : String = "swf/" + SWF_STENOSE + ".swf";
  1485. var occlusion : String = "swf/" + SWF_OCCLUSION + ".swf";
  1486. var plaque : String = "swf/" + SWF_PLAQUE + ".swf";
  1487. for each ( var theCanvas : Canvas in [ canvasArmLeft, canvasArmRight, canvasBody, canvasCarotidLeft, canvasCarotidRight, canvasLegLeft, canvasLegRight ] )
  1488. for each ( var itsChild : SWFLoader in theCanvas.getChildren() )
  1489. {
  1490. if ( itsChild.source == stenose
  1491. || itsChild.source == occlusion
  1492. || itsChild.source == plaque )
  1493. {
  1494. theCanvas.removeChild(itsChild);
  1495. }
  1496. }
  1497. _cursor = null;
  1498. if( _boxActive != null )
  1499. {
  1500. _boxActive.visible = false;
  1501. human.visible = true;
  1502. _man = true;
  1503. }
  1504. FlashHelper.resetAll();
  1505. }
  1506. public function setImageIncidence(incidence : String) : void
  1507. {
  1508. currentDragAndDropObject.incidence = incidence;
  1509. saveImage();
  1510. }
  1511. public function showHelp(image : Image) : void
  1512. {
  1513. HelpUtils.showHelp(this, image, zoomHelpAdd, zoomHelpRemove);
  1514. }
  1515. /************
  1516. * DICOM PHP
  1517. */
  1518. private function onDicomFault(event:FaultEvent):void
  1519. {
  1520. PopUpManager.removePopUp(dicomProgressPopup);
  1521. var toastMessage : ImtToaster = new ImtToaster();
  1522. toastMessage = new ImtToaster();
  1523. toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'error.title');
  1524. toastMessage.message = ResourceManager.getInstance().getString('labels', 'error.dicom');
  1525. toastMessage.level = ImtToaster.ERROR;
  1526. _model.toaster.toast( toastMessage );
  1527. }
  1528. private function onDicomOK(event:ResultEvent):void
  1529. {
  1530. PopUpManager.removePopUp(dicomProgressPopup);
  1531. // Récupère les Tags sous forme de chaine
  1532. var vStr:String = event.result.toString();
  1533. var tagsDicom:Array = vStr.split(/_TAG_/, 8);
  1534. snapshotImage.source = _model.ipProtocol + "://" + _model.ipAddress + "/services/common/dicom/upload/" + tagsDicom[0];
  1535. snapshotImageHD.source = _model.ipProtocol + "://" + _model.ipAddress + "/services/common/dicom/upload/" + tagsDicom[0];
  1536. var physicalDeltaX : Number = tagsDicom[1];
  1537. var physicalDeltaY : Number = tagsDicom[2];
  1538. var pixelSpacingX : Number = tagsDicom[3];
  1539. var pixelSpacingY : Number = tagsDicom[4];
  1540. if ((pixelSpacingX == 0) && (pixelSpacingY == 0))
  1541. {
  1542. dicomScale = physicalDeltaX < physicalDeltaY ? (physicalDeltaX * 10) : (physicalDeltaY * 10);
  1543. }
  1544. else
  1545. {
  1546. dicomScale = pixelSpacingX < pixelSpacingY ? pixelSpacingX : pixelSpacingY;
  1547. }
  1548. }
  1549. /******************************
  1550. * Fin DICOM PHP
  1551. */