| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196 |
- import com.imt.containers.BlankPaperWrapper;
- import com.imt.events.PolygonEvent;
- import com.imt.intimamedia.events.measures.GetCTPAEvent;
- import com.imt.intimamedia.events.measures.GetUltraSoundScannerEvent;
- import com.imt.intimamedia.events.measures.SaveMeasuresEvent;
- import com.imt.intimamedia.events.measures.majCptMesuresEvent;
- import com.imt.intimamedia.helpers.AlchemyCaller;
- import com.imt.intimamedia.helpers.CustomCursor;
- import com.imt.intimamedia.helpers.FlashHelper;
- import com.imt.intimamedia.helpers.HelpUtils;
- import com.imt.intimamedia.helpers.ImageCJ;
- import com.imt.intimamedia.helpers.Measure;
- import com.imt.intimamedia.helpers.ScaleCJ;
- import com.imt.intimamedia.helpers.ScaleCursor;
- import com.imt.intimamedia.helpers.ScaleDetection;
- import com.imt.intimamedia.model.ApplicationModelLocator;
- import com.imt.intimamedia.views.common.ImtToaster;
- import com.imt.intimamedia.views.physician.measure.DistanceTypePopUp;
- import com.imt.intimamedia.views.physician.measure.GeneralMeasureView;
- import com.imt.intimamedia.views.physician.measure.ScalePopUp;
- import com.imt.intimamedia.vo.AreaVo;
- import com.imt.intimamedia.vo.DistanceVo;
- import com.imt.intimamedia.vo.DragAndDropVo;
- import com.imt.intimamedia.vo.ImtResultVo;
- import com.imt.intimamedia.vo.MarkerVo;
- import com.imt.intimamedia.vo.MeasuresVo;
- import com.imt.intimamedia.vo.ScaleCjVo;
- import com.imt.paperClasses.LineTool;
- import com.imt.paperClasses.PolygonTool;
- import com.imt.paperClasses.RectangleTool;
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.display.DisplayObject;
- import flash.display.Graphics;
- import flash.display.Sprite;
- import flash.events.MouseEvent;
- import flash.events.TimerEvent;
- import flash.geom.Matrix;
- import flash.geom.Point;
- import flash.geom.Rectangle;
- import flash.ui.Mouse;
- import flash.utils.ByteArray;
- import flash.utils.Timer;
- import mx.collections.ArrayCollection;
- import mx.containers.Box;
- import mx.containers.Canvas;
- import mx.controls.Alert;
- import mx.controls.Image;
- import mx.controls.SWFLoader;
- import mx.controls.dataGridClasses.DataGridColumn;
- import mx.core.Application;
- import mx.effects.Fade;
- import mx.events.CloseEvent;
- import mx.events.EffectEvent;
- import mx.managers.CursorManager;
- import mx.managers.PopUpManager;
- import mx.resources.ResourceManager;
- import mx.states.RemoveChild;
- import mx.utils.ObjectUtil;
- import org.rockholla.skins.BlankDividerSkin;
- import com.imt.intimamedia.vo.UserVo;
- import com.imt.intimamedia.events.user.UpdateUserEvent;
- /**
- * Référence sur le modèle
- */
- [Bindable]
- private var _model : ApplicationModelLocator = ApplicationModelLocator.getInstance();
- [Bindable]
- public var canvas : Canvas;
- [Bindable]
- public var nwImtResult : ImtResultVo;
- [Bindable]
- public var fwImtResult : ImtResultVo;
- [Bindable]
- public var imtResults : ArrayCollection = new ArrayCollection();
- public var imtResultVo : ImtResultVo;
- public var timer : Timer = new Timer( 1200, 3 );
- public var scaleVo : ScaleCjVo;
- private var _blankPaper : BlankPaperWrapper = new BlankPaperWrapper();
- private var _moveEnabled : Boolean = true;
- private var _drawEnabled : Boolean = false;
- private const LEFT_SIDE : int = 1;
- private const RIGHT_SIDE : int = 2;
- private var _currentSide : int;
- private var _measureImage : Image;
- private var _currentDragAndDropVo : DragAndDropVo = null;
- public var pointA : Point = null;
- public var pointB : Point = null;
- public var sprite: Sprite = new Sprite();
- public var graph : Graphics = sprite.graphics;
- public var scaleMode : Boolean = true;
- public var scale : ScaleCJ;
- public var imageCJ : ImageCJ;
- public var m_imageResizee : ImageCJ;
- [Bindable]
- public var affCTPA : Boolean = false;
- private function creationCompleteHandler() : void
- {
- measuresThumbnailHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/measuresImageSelection.png';
- measuresHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/measuresGlobalProcess.png';
- measuresCalibrationHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/measuresCalibration.png';
- measuresEndingCalibrationHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/measuresEndingCalibration.png';
- measuresImtButtonHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/measuresImtButton.png';
- measuresDistanceButtonHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/measuresDistanceButton.png';
- measuresAreaButtonHelp.source = 'images/help/' + ResourceManager.getInstance().getString('labels', 'lang') + '/measuresAreaButton.png';
- }
- /**
- * Réinitialisation de la vue lors de la visualisation
- */
- public function showView() : void
- {
- if( _model.measureViewFlip )
- _model.measureViewFlip = false;
- }
- /**
- * Comment by C. Wallet
- * Demande de changement d'échelle, travail complexe en peu de temps,
- * intégration de l'échelle de CJ dans ce projet.
- */
- public function saveClicks( event : MouseEvent ) : void
- {
- if( scaleMode )
- {
- if( pointA == null )
- {
- pointA = new Point();
- pointA.x = event.localX;
- pointA.y = event.localY;
-
- Mouse.hide();
-
- CursorManager.removeAllCursors();
-
- graph.moveTo(pointA.x, pointA.y);
-
- // Dessin du pointeur
- // 2 lignes verticales
- graph.lineStyle(1, 0xf98d00);
- graph.moveTo(pointA.x - 4, pointA.y - 5);
- graph.lineTo(pointA.x - 4, pointA.y + 6);
- graph.moveTo(pointA.x + 4, pointA.y - 5);
- graph.lineTo(pointA.x + 4, pointA.y + 6);
-
- // 3 lignes horizontales
- graph.moveTo(pointA.x - 4, pointA.y - 4);
- graph.lineTo(pointA.x + 4, pointA.y - 4);
-
- graph.moveTo(pointA.x - 4, pointA.y);
- graph.lineTo(pointA.x + 4, pointA.y);
-
- graph.moveTo(pointA.x - 4, pointA.y + 4);
- graph.lineTo(pointA.x + 4, pointA.y + 4);
-
- graph.moveTo(pointA.x, pointA.y - 4);
- graph.lineTo(pointA.x, pointA.y + 21);
-
- event.target.addChild(sprite);
- }
- else
- {
- pointB = new Point();
- pointB.x = pointA.x;
- pointB.y = event.localY + 10;
-
- imageCJ = new ImageCJ();
-
- imageCJ.setBitmapData( ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData );
- var startX:int;
- var startY:int;
- var endX:int;
- var endY:int;
-
- startX = pointxResizeToOriginal(pointA.x,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh);
- startY = pointyResizeToOriginal(pointA.y,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimv);
-
- endX = pointxResizeToOriginal(pointB.x,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh);
- endY = pointyResizeToOriginal(pointB.y,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimv);
- scale = new ScaleCJ();
- // On calcul l'échelle sur l'image d'origine
- scale.setClickPoints( startX, startY, endX, endY );
- /// scale.setClickPoints( pointA.x, pointA.y, pointB.x, pointB.y );
- scale.calculation( imageCJ );
-
- graph.clear();
-
- if( scale.m_nbPoints > 1 )
- {
- canvas = new Canvas();
-
- canvas.width = imageZoom.width;
- canvas.height = imageZoom.height;
- canvas.name = "SCALE";
-
- removeChildren();
-
- imageZoom.addChild( canvas );
- scale.onDraw( ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width, ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh, m_imageResizee.dimv, canvas.graphics );
-
- addPopUp();
- }
- else
- {
- var toastMessage : ImtToaster = new ImtToaster();
- toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'measures.label.scale');
- toastMessage.message = ResourceManager.getInstance().getString('labels', 'measures.no.calibration.detected');
- toastMessage.level = ImtToaster.WARNING;
- _model.toaster.toast( toastMessage );
- }
-
- pointA = null;
- pointB = null;
- }
- }
- }
- public function mouseMoveCursor( event : MouseEvent ) : void
- {
- if( pointA != null )
- {
- graph.clear();
-
- CursorManager.removeAllCursors();
- Mouse.hide();
-
- graph.lineStyle(1,0x00ff00,1);
-
- var ny : int = 0;
- graph.moveTo(pointA.x, pointA.y);
-
- if( (event.target as Image) != null )
- {
- graph.lineTo(pointA.x, (event.target as Image).mouseY);
-
- // 2 lignes verticales
- graph.lineStyle(1, 0xf98d00);
- graph.moveTo(pointA.x - 4, (event.target as Image).mouseY - 5);
- graph.lineTo(pointA.x - 4, (event.target as Image).mouseY + 6);
- graph.moveTo(pointA.x + 4, (event.target as Image).mouseY - 5);
- graph.lineTo(pointA.x + 4, (event.target as Image).mouseY + 6);
-
- // 3 lignes horizontales
- graph.moveTo(pointA.x - 4, (event.target as Image).mouseY - 4);
- graph.lineTo(pointA.x + 4, (event.target as Image).mouseY - 4);
-
- graph.moveTo(pointA.x - 4, (event.target as Image).mouseY);
- graph.lineTo(pointA.x + 4, (event.target as Image).mouseY);
-
- graph.moveTo(pointA.x - 4, (event.target as Image).mouseY + 4);
- graph.lineTo(pointA.x + 4, (event.target as Image).mouseY + 4);
-
- graph.moveTo(pointA.x, (event.target as Image).mouseY - 4);
- graph.lineTo(pointA.x, (event.target as Image).mouseY + 21);
-
- event.target.addChild(sprite);
- }
- }
- }
- /**
- * Création d'une échelle manuelle (affichage ou suppression de la zone)
- */
- private function manualScaleAction() : void
- {
- distanceButton.selected = false;
- areaButton.selected = false;
- imtButton.selected = false;
- var imtLineObject : BlankPaperWrapper = imageZoom.getChildByName("IMTLINE") as BlankPaperWrapper;
- if (imtLineObject)
- imageZoom.removeChild(imtLineObject);
-
- if ( manualScale.selected )
- {
- scaleMode = true;
- _moveEnabled = true;
- _drawEnabled = false;
-
- deleteGraphicMeasures();
-
- graph.clear();
- removeChildren();
- sprite.removeChildAt(0);
- }
- else
- {
- scaleMode = false;
- _moveEnabled = false;
- _drawEnabled = false;
- }
-
- changeCursor();
- }
- /**
- * Suppression des enfants superflus
- */
- public function removeChildren() : void
- {
- for( var index : int = imageZoom.numChildren - 1; index > 0; index-- )
- {
- imageZoom.removeChildAt( index );
- }
- }
- /**
- * Création d'une échelle manuelle (suppression de la zone de recherche)
- */
- private function zoneSelected( event : MouseEvent ) : void
- {
- if( _blankPaper != null && ObjectUtil.compare( event.target, event.currentTarget, 1 ) != 0 )
- {
- var width : int = event.target.endX - event.target.startX;
- var height : int = event.target.endY - event.target.startY;
-
- var bitmapData : BitmapData = new BitmapData( width, height );
- var matrix : Matrix = new Matrix(1,0,0,1,0,0);
-
- matrix.translate( -event.target.startX, -event.target.startY );
-
- var rectangle : Rectangle = new Rectangle( 0, 0, width, height );
- bitmapData.draw( listImages.selectedItem.imageHigh.bitmapData, matrix, null, null, rectangle );
-
- var scaleDetection : ScaleDetection = new ScaleDetection();
- scaleVo = scaleDetection.findScale( bitmapData ) as ScaleCjVo;
- manualScale.selected = false;
-
- _moveEnabled = true;
- _drawEnabled = false;
-
- if (scaleVo)
- {
- if( imageZoom.numChildren > 1 )
- imageZoom.removeChildAt( 1 );
-
- canvas = new Canvas();
-
- canvas.width = imageZoom.width;
- canvas.height = imageZoom.height;
- canvas.name = "SCALE";
-
- removeChildren();
-
- imageZoom.addChild( canvas );
-
- canvas.graphics.lineStyle( 2, 0xd3031c);
-
- var startX:int;
- var startY:int;
- var endX:int;
- var endY:int;
- canvas.graphics.moveTo( scaleVo.start.x + event.target.startX, scaleVo.start.y + event.target.startY );
- canvas.graphics.lineTo( scaleVo.start.x + event.target.startX - 10, scaleVo.start.y + event.target.startY );
-
- canvas.graphics.lineStyle( 2, 0xd3031c);
- canvas.graphics.moveTo( scaleVo.end.x + event.target.startX, scaleVo.end.y + event.target.startY );
- canvas.graphics.lineTo( scaleVo.end.x + event.target.startX - 10, scaleVo.end.y + event.target.startY );
-
- canvas.graphics.lineStyle( 2, 0xd3031c);
- canvas.graphics.moveTo( scaleVo.start.x + event.target.startX - 5, scaleVo.start.y + event.target.startY );
- canvas.graphics.lineTo( scaleVo.end.x + event.target.startX - 5, scaleVo.end.y + event.target.startY );
-
- timer.reset();
- timer.addEventListener( TimerEvent.TIMER, glowOnScale );
- timer.addEventListener( TimerEvent.TIMER_COMPLETE, displayScaleQuestion );
- timer.start();
-
- addPopUp();
- }
- else
- {
- var toastMessage : ImtToaster = new ImtToaster();
- toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'measures.label.scale');
- toastMessage.message = ResourceManager.getInstance().getString('labels', 'measures.no.calibration.detected');
- toastMessage.level = ImtToaster.WARNING;
- _model.toaster.toast( toastMessage );
- }
- }
- }
- /**
- * Ajout de la fenêtre de détermination de l'échelle
- */
- private function addPopUp() : void
- {
- var scalePopUp : ScalePopUp = new ScalePopUp();
-
- scalePopUp.element = listImages.selectedItem as DragAndDropVo;
- scalePopUp.imtButton = imtButton;
- scalePopUp.distanceButton = distanceButton;
- scalePopUp.areaButton = areaButton;
- scalePopUp.parentMeasure = this;
- scalePopUp.moveEnabled = _moveEnabled;
- scalePopUp.drawEnabled = _drawEnabled;
-
- new GetUltraSoundScannerEvent( _model.connectedUser.login ).dispatch();
-
- PopUpManager.addPopUp( scalePopUp, this, true );
- PopUpManager.centerPopUp( scalePopUp );
- }
- /**
- * Préparation d'une ligne pour le calcul de la distance
- */
- private function distanceMeasure() : void
- {
- areaButton.selected = false;
- manualScale.selected = false;
- imtButton.selected = false;
- if( distanceButton.selected )
- {
- deleteGraphicMeasures();
-
- _moveEnabled = false;
- _drawEnabled = true;
-
- _blankPaper = new BlankPaperWrapper();
-
- _blankPaper.name = "DISTANCE";
- _blankPaper.selectedTool = LineTool;
- _blankPaper.multiple = false;
-
- _blankPaper.addEventListener( MouseEvent.MOUSE_UP, lineCreated );
-
- imageZoom.addChild( _blankPaper );
- }
- else
- adjustGraphicMeasures();
- }
- private function areaMeasure() : void
- {
- if ((areaValue.text != "") && (areaValue2.text == ""))
- {
- Alert.show(ResourceManager.getInstance().getString( 'labels', 'measures.label.newsurface' ), "", Alert.YES | Alert.NO, null, alertNewSurfaceListener1, null, Alert.NO);
- }
- else if ((areaValue.text == "") && (areaValue2.text == ""))
- {
- areaMeasureBase(1);
- }
- else if ((areaValue.text != "") && (areaValue2.text != ""))
- {
- Alert.show(ResourceManager.getInstance().getString( 'labels', 'measures.label.newsurface' ), "", Alert.YES | Alert.NO, null, alertNewSurfaceListener2, null, Alert.NO);
- }
- }
- // Message Box : Do you want to erase the last measure
- // Cas 1 : La Surface 1 est remplie et la surface 2 est vide
- private function alertNewSurfaceListener1(event:CloseEvent):void
- {
- if (event.detail == Alert.YES) // Si on veux effacer la surface 1
- {
- areaMeasureBase(1);
- }
- else
- {
- areaMeasureBase(2);
- }
- }
- // Message Box : Do you want to erase the last measure
- // Cas 2 : La Surface 1 est remplie et la surface 2 est remplie
- private function alertNewSurfaceListener2(event:CloseEvent):void
- {
- if (event.detail == Alert.YES) // On veux effacer la surface 2
- {
- areaMeasureBase(2);
- }
- else
- {
- }
- }
- /**
- * Préparation d'une zone pour le calcul de la surface
- */
- private function areaMeasureBase(indiceArea:int):void
- {
- distanceButton.selected = false;
- manualScale.selected = false;
- imtButton.selected = false;
-
- if( areaButton.selected )
- {
- if (indiceArea == 1)
- {
- deleteGraphicMeasures();
-
- _moveEnabled = false;
- _drawEnabled = true;
-
- _blankPaper = new BlankPaperWrapper();
-
- _blankPaper.name = "AREA";
- _blankPaper.selectedTool = PolygonTool;
- _blankPaper.multiple = true;
-
- _blankPaper.addEventListener( PolygonEvent.POLYGON_END, areaCreated );
-
- imageZoom.addChild( _blankPaper );
- }
- else if (indiceArea == 2)
- {
- deleteGraphicMeasures();
- _moveEnabled = false;
- _drawEnabled = true;
- _blankPaper = new BlankPaperWrapper();
- _blankPaper.name = "AREA2";
- _blankPaper.selectedTool = PolygonTool;
- _blankPaper.multiple = true;
- _blankPaper.addEventListener( PolygonEvent.POLYGON_END, area2Created );
- imageZoom.addChild( _blankPaper );
- }
- }
- else
- adjustGraphicMeasures();
- }
- private function MAJArea(): void
- {
- saveMeasures();
- getCTPAValue();
- }
- /**
- * Création d'une ligne pour le calcul de la distance
- */
- private function lineCreated( event : MouseEvent ) : void
- {
- var pstartX:int;
- var pstartY:int;
- var pendX:int;
- var pendY:int;
-
- if( ObjectUtil.compare( event.target, event.currentTarget, 1 ) != 0 )
- {
- pstartX = pointxResizeToOriginal(event.target.startX,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh);
- pstartY = pointyResizeToOriginal(event.target.startY,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimv);
-
- pendX = pointxResizeToOriginal(event.target.endX,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh);
- pendY = pointyResizeToOriginal(event.target.endY,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimv);
- var x : Number = ( pendX - pstartX ) * ( listImages.selectedItem as DragAndDropVo ).scale.value;
- var y : Number = ( pendY - pstartY ) * ( listImages.selectedItem as DragAndDropVo ).scale.value;
-
- if (!( listImages.selectedItem as DragAndDropVo ).distance)
- ( listImages.selectedItem as DragAndDropVo ).distance = new DistanceVo();
-
- ( listImages.selectedItem as DragAndDropVo ).distance.value = Math.sqrt( (x * x) + (y * y) );
- ( listImages.selectedItem as DragAndDropVo ).distance.xFirstPoint = pstartX ;
- ( listImages.selectedItem as DragAndDropVo ).distance.yFirstPoint = pstartY;
- ( listImages.selectedItem as DragAndDropVo ).distance.xLastPoint = pendX;
- ( listImages.selectedItem as DragAndDropVo ).distance.yLastPoint = pendY;
-
- distanceValue.text = ( formatNumber.format( ( listImages.selectedItem as DragAndDropVo ).distance.value ) ) + " mm";
- }
-
- var distanceTypePopUp : DistanceTypePopUp = new DistanceTypePopUp();
-
- distanceTypePopUp.parentMeasure = this;
- PopUpManager.addPopUp( distanceTypePopUp, this, true );
- PopUpManager.centerPopUp( distanceTypePopUp );
- }
- /*
- */
- /**
- * Création d'une aire pour le calcul de la surface
- */
- private function areaCreated( event : PolygonEvent ) : void
- {
- var points : Array = event.points;
- var pstartX:int;
- var pstartY:int;
- var pendX:int;
- var pendY:int;
-
- var i : int;
- var j : int;
- var area : Number = 0;
- // Alert.show("areaCreated");
-
- for( i = 0; i < points.length; i++ )
- {
- j = ( i + 1 ) % points.length;
-
- points[i].x = pointxResizeToOriginal(points[i].x,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh);
- points[i].y = pointyResizeToOriginal(points[i].y,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimv);
-
- points[j].x = pointxResizeToOriginal(points[j].x,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh);
- points[j].y = pointyResizeToOriginal(points[j].y,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimv);
-
- area += points[i].x * points[j].y;
- area -= points[i].y * points[j].x;
- }
-
- if (!( listImages.selectedItem as DragAndDropVo ).area)
- ( listImages.selectedItem as DragAndDropVo ).area = new AreaVo();
-
- ( listImages.selectedItem as DragAndDropVo ).area.value = Math.abs( ( area / 2 ) * Math.pow( ( listImages.selectedItem as DragAndDropVo ).scale.value, 2 ) );
- ( listImages.selectedItem as DragAndDropVo ).area.points = points;
-
- areaValue.text = formatNumber.format( ( listImages.selectedItem as DragAndDropVo ).area.value ) + " mm²";
- MAJArea();
-
- areaButton.selected = false;
- _moveEnabled = false;
- _drawEnabled = false;
-
- // add a dummy blankPaper to disable drawing
- _blankPaper = new BlankPaperWrapper();
- _blankPaper.name = "NIL";
- _blankPaper.multiple = false;
- imageZoom.addChild(_blankPaper);
- }
- /**
- * Création d'une aire pour le calcul de la surface
- */
- private function area2Created( event : PolygonEvent ) : void
- {
- var points : Array = event.points;
-
- var i : int;
- var j : int;
- var area : Number = 0;
-
- // Alert.show("area2Created");
- for( i = 0; i < points.length; i++ )
- {
- j = ( i + 1 ) % points.length;
- area += points[i].x * points[j].y;
- area -= points[i].y * points[j].x;
- }
-
- if (!( listImages.selectedItem as DragAndDropVo ).area2)
- ( listImages.selectedItem as DragAndDropVo ).area2 = new AreaVo();
-
- ( listImages.selectedItem as DragAndDropVo ).area2.value = Math.abs( ( area / 2 ) * Math.pow( ( listImages.selectedItem as DragAndDropVo ).scale.value, 2 ) );
- ( listImages.selectedItem as DragAndDropVo ).area2.points = points;
- areaValue2.text = formatNumber.format( ( listImages.selectedItem as DragAndDropVo ).area2.value ) + " mm²";
- MAJArea();
-
- areaButton.selected = false;
- _moveEnabled = false;
- _drawEnabled = false;
-
- // add a dummy blankPaper to disable drawing
- _blankPaper = new BlankPaperWrapper();
- _blankPaper.name = "NIL";
- _blankPaper.multiple = false;
- imageZoom.addChild(_blankPaper);
- }
- /**
- * Préparation du calcul de l'IMT
- */
- private function imtMeasure() : void
- {
- var scaleResizee:Number;
- distanceButton.selected = false;
- manualScale.selected = false;
- areaButton.selected = false;
- // Blocage si l'utilisateur n'as plus de crédits sur son compte
- if ((_model.connectedUser.cptCredits - _model.connectedUser.cptMesures) <= 0)
- {
- Alert.show(ResourceManager.getInstance().getString( 'labels', 'measures.nocredits' ));
- return;
- }
-
- // Pour LineTool on fourni l'échelle pour les 10 mm dans le domaine de l'image resizee
- scaleResizee = ( listImages.selectedItem as DragAndDropVo ).scale.value * calScaleResizee(( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimv);
- if( imtButton.selected )
- {
- deleteGraphicMeasures();
-
- _moveEnabled = false;
- _drawEnabled = true;
-
- _blankPaper = new BlankPaperWrapper();
-
- _blankPaper.name = "IMTLINE";
- _blankPaper.selectedTool = LineTool;
- _blankPaper.multiple = false;
- _blankPaper.scale = scaleResizee;
- // _blankPaper.scale = ( listImages.selectedItem as DragAndDropVo ).scale.value ;
-
- _blankPaper.addEventListener( MouseEvent.MOUSE_UP, imtCreated );
-
- imageZoom.addChild( _blankPaper );
-
- }
- else
- adjustGraphicMeasures();
- }
- /**
- * Création d'une ligne pour le calcul de l'IMT
- */
- private function imtCreated( event : MouseEvent ) : void
- {
- var imtLineObject : BlankPaperWrapper;
- var toastMessage : ImtToaster;
- var imt : String;
- var imtObject : BlankPaperWrapper;
- var pstartX:int;
- var pstartY:int;
- var pendX:int;
- var pendY:int;
-
- var x : Number = 0;
- var y : Number = 0;
- pstartX = pointxResizeToOriginal(event.target.startX,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh);
- pstartY = pointyResizeToOriginal(event.target.startY,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimv);
-
- pendX = pointxResizeToOriginal(event.target.endX,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width, ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh);
- pendY = pointyResizeToOriginal(event.target.endY,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width, ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimv);
-
- if( ObjectUtil.compare( event.target, event.currentTarget, 1 ) != 0 )
- {
- // x = ( event.target.endX - event.target.startX ) * ( listImages.selectedItem as DragAndDropVo ).scale.value;
- // y = ( event.target.endY - event.target.startY ) * ( listImages.selectedItem as DragAndDropVo ).scale.value;
- x = ( pendX - pstartX ) * ( listImages.selectedItem as DragAndDropVo ).scale.value;
- y = ( pendY - pstartY ) * ( listImages.selectedItem as DragAndDropVo ).scale.value;
- }
-
- if( Math.abs( x ) >= 10 && Math.abs( x ) <= 11 )
- {
- var byteArray : ByteArray = makeByteArray( ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData );
-
- var bitmapData : BitmapData = ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData;
-
- // La mesure de l'IMT s'effectue sur l'image originale à haute résolution
- imtResultVo = AlchemyCaller.imtCalculate( ( listImages.selectedItem as DragAndDropVo ).scale.value, bitmapData.width, bitmapData.height, pstartX, pstartY, pendX, pendY, byteArray );
-
- if (imtResultVo.numberOfPoints == 0)
- {
- toastMessage = new ImtToaster();
- toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'measures.error.imt.title');
- toastMessage.message = ResourceManager.getInstance().getString('labels', 'measures.error.imt.calculation');
- toastMessage.level = ImtToaster.WARNING;
- _model.toaster.toast( toastMessage );
-
- imtLineObject = imageZoom.getChildByName("IMTLINE") as BlankPaperWrapper;
- if (imtLineObject)
- imageZoom.removeChild(imtLineObject);
-
- imtMeasure();
- }
- else
- {
-
- var i : int;
-
- if( x > 0 )
- {
- for (i=0; i<imtResults.length; i++)
- {
- if (imtResults.getItemAt(i).name == ResourceManager.getInstance().getString( 'labels', 'measures.label.fw.imt' ))
- imtResults.removeItemAt(i);
- }
-
- fwImtResult = imtResultVo;
- fwImtResult.name = ResourceManager.getInstance().getString( 'labels', 'measures.label.fw.imt' );
- ( listImages.selectedItem as DragAndDropVo ).fwImtResult = fwImtResult;
- imtResults.addItem(fwImtResult);
-
- imt = "FWIMT";
-
- imtFarWallAverage.text = formatImtNumber.format(fwImtResult.mean);
- imtFarWallMaximum.text = formatImtNumber.format(fwImtResult.max);
- imtFarWallDistance.text = formatImtNumber.format(fwImtResult.distance);
- imtFarWallDeviation.text = formatImtNumber.format(fwImtResult.standardDeviation);
- imtFarWallQuality.text = formatNumber.format(fwImtResult.qualityIndex);
- imtFarWallPoints.text = formatInt.format(fwImtResult.numberOfPoints);
- }
- else
- {
- for (i=0; i<imtResults.length; i++)
- {
- if (imtResults.getItemAt(i).name == ResourceManager.getInstance().getString( 'labels', 'measures.label.nw.imt' ))
- imtResults.removeItemAt(i);
- }
- nwImtResult = imtResultVo;
- nwImtResult.name = ResourceManager.getInstance().getString( 'labels', 'measures.label.nw.imt' );
- ( listImages.selectedItem as DragAndDropVo ).nwImtResult = nwImtResult;
-
- imtResults.addItem(nwImtResult);
-
- imt = "NWIMT";
-
- imtNearWallAverage.text = formatImtNumber.format(nwImtResult.mean);
- imtNearWallMaximum.text = formatImtNumber.format(nwImtResult.max);
- imtNearWallDistance.text = formatImtNumber.format(nwImtResult.distance);
- imtNearWallDeviation.text = formatImtNumber.format(nwImtResult.standardDeviation);
- imtNearWallQuality.text = formatNumber.format(nwImtResult.qualityIndex);
- imtNearWallPoints.text = formatInt.format(nwImtResult.numberOfPoints);
- }
-
- imtLineObject = imageZoom.getChildByName("IMTLINE") as BlankPaperWrapper;
- if (imtLineObject)
- imageZoom.removeChild(imtLineObject);
-
- canvas = new Canvas();
- canvas.width = imageZoom.width;
- canvas.height = imageZoom.height;
- canvas.name = imt;
-
- imageZoom.addChild( canvas );
- // Alert.show("canvas.width = " + canvas.width.toString() + ", canvas.height =" + canvas.height.toString());
- // Alert.show("width = " + ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width.toString() + ", resize =" + m_imageResizee.dimh.toString());
- Measure.imtDraw(( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width, ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh, m_imageResizee.dimv, canvas.graphics, imtResultVo.intima, imtResultVo.adventitia, imtResultVo.numberOfPoints);
-
- imtButton.selected = false;
- _moveEnabled = false;
- _drawEnabled = false;
-
- var alert:Alert = Alert.show(ResourceManager.getInstance().getString('labels', 'measures.validate.store'), "", Alert.YES | Alert.NO, null, alertValidate, null, Alert.NO);
-
- var newX:Number = 300;
- var newY:Number = 170;
- alert.validateNow ();
- alert.move (newX, newY); }
- }
- else
- {
- _moveEnabled = false;
- _drawEnabled = true;
-
- if ( formatNumber.format( Math.abs(x) ) != "")
- {
- toastMessage = new ImtToaster();
- toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'measures.error.imt.title');
- toastMessage.message = ResourceManager.getInstance().getString('labels', 'measures.error.imt.message', [formatNumber.format( Math.abs(x) )] );
- toastMessage.level = ImtToaster.WARNING;
- _model.toaster.toast( toastMessage );
- }
-
- imtLineObject = imageZoom.getChildByName("IMTLINE") as BlankPaperWrapper;
- if (imtLineObject)
- imageZoom.removeChild(imtLineObject);
-
- imtMeasure();
- }
- }
- private function alertValidate(eventObj:CloseEvent):void
- {
- // Check to see if the OK button was pressed.
- if (eventObj.detail==Alert.YES)
- {
- validateMeasure();
-
- saveMeasures();
- }
- }
- public function deleteGraphicMeasures() : void
- {
- var imtObject : Canvas;
- // Alert.show("Etape 14");
- // Alert.show("deleteGraphicMeasures");
-
- imtObject = imageZoom.getChildByName("NWIMT") as Canvas;
- if (imtObject)
- imageZoom.removeChild(imtObject);
-
- imtObject = imageZoom.getChildByName("FWIMT") as Canvas;
- if (imtObject)
- imageZoom.removeChild(imtObject);
-
- var nilObject : BlankPaperWrapper = imageZoom.getChildByName("NIL") as BlankPaperWrapper;
- if (nilObject)
- imageZoom.removeChild(nilObject);
-
- var areaObject : BlankPaperWrapper = imageZoom.getChildByName("AREA") as BlankPaperWrapper;
- if (areaObject)
- imageZoom.removeChild(areaObject);
-
- var area2Object : BlankPaperWrapper = imageZoom.getChildByName("AREA2") as BlankPaperWrapper;
- if (area2Object)
- imageZoom.removeChild(area2Object);
- var distanceObject : BlankPaperWrapper = imageZoom.getChildByName("DISTANCE") as BlankPaperWrapper;
- if (distanceObject)
- imageZoom.removeChild(distanceObject);
- }
- public function adjustGraphicMeasures() : void
- {
- _moveEnabled = false;
- _drawEnabled = true;
- changeCursor();
- // Alert.show("Etape 15");
- // Alert.show("adjustGraphicMeasures");
-
- if (imageZoom.numChildren > 0)
- {
- var child : Object = imageZoom.getChildAt(imageZoom.numChildren - 1) as Object;
- if (child.name == "DISTANCE")
- {
- var distanceObject : BlankPaperWrapper = imageZoom.getChildByName("DISTANCE") as BlankPaperWrapper;
- if (distanceObject)
- imageZoom.removeChild(distanceObject);
- }
- else if (child.name == "AREA")
- {
- var areaObject : BlankPaperWrapper = imageZoom.getChildByName("AREA") as BlankPaperWrapper;
- if (areaObject)
- imageZoom.removeChild(areaObject);
- }
- else if (child.name == "AREA2")
- {
- var area2Object : BlankPaperWrapper = imageZoom.getChildByName("AREA2") as BlankPaperWrapper;
- if (area2Object)
- imageZoom.removeChild(area2Object);
- }
- else if (child.name == "NWIMT" || child.name == "FWIMT")
- {
- var imtObject : BlankPaperWrapper = imageZoom.getChildByName(child.name) as BlankPaperWrapper;
- if (imtObject)
- imageZoom.removeChild(imtObject);
- }
- else if (child.name == "IMTLINE")
- {
- var imtLineObject : BlankPaperWrapper = imageZoom.getChildByName("IMTLINE") as BlankPaperWrapper;
- if (imtLineObject)
- imageZoom.removeChild(imtLineObject);
- }
- else if (child.name == "NIL")
- {
- var nilObject : BlankPaperWrapper = imageZoom.getChildByName("NIL") as BlankPaperWrapper;
- if (nilObject)
- imageZoom.removeChild(nilObject);
- }
- }
-
- _moveEnabled = false;
- _drawEnabled = false;
- scaleMode = false;
- imtButton.selected = false;
- distanceButton.selected = false;
- areaButton.selected = false;
- changeCursor();
- }
- public function prepareScaleCursor() : void
- {
- _moveEnabled = true;
- _drawEnabled = false;
- }
- public function unPrepareScaleCursor() : void
- {
- _moveEnabled = false;
- _drawEnabled = false;
- }
- public function setScaleCursor() : void
- {
- _moveEnabled = true;
- _drawEnabled = false;
- CursorManager.removeAllCursors();
- CursorManager.setCursor(ScaleCursor);
- CursorManager.showCursor();
- Mouse.hide();
- }
- /**
- * Changement du curseur pour le déplacement
- */
- private function changeCursor() : void
- {
- if( _moveEnabled )
- {
- CursorManager.removeAllCursors();
- CursorManager.setCursor(ScaleCursor);
- CursorManager.showCursor();
- Mouse.hide();
- }
- else if (_drawEnabled)
- {
- CursorManager.removeAllCursors();
- CursorManager.setCursor(CustomCursor);
- CursorManager.showCursor();
- Mouse.hide();
- }
- else
- {
- CursorManager.removeAllCursors();
- Mouse.show();
- }
- }
- public function setDistanceType(type : String) : void
- {
- ( listImages.selectedItem as DragAndDropVo ).distance.type = type;
- distanceLabel.text = (listImages.selectedItem as DragAndDropVo).distance.getTypeText();
-
- distanceButton.selected = false;
- _moveEnabled = false;
- _drawEnabled = false;
- changeCursor();
-
- saveMeasures();
-
- distanceButton.selected = false;
- _moveEnabled = false;
- _drawEnabled = false;
-
- // add a dummy blankPaper to disable drawing
- _blankPaper = new BlankPaperWrapper();
- _blankPaper.name = "NIL";
- _blankPaper.multiple = false;
- imageZoom.addChild(_blankPaper);
- }
- /**
- * Sauvegarde des mesures
- */
- private function saveMeasures() : void
- {
- var collection : ArrayCollection = new ArrayCollection();
-
- for each( var dragAndDropVo : DragAndDropVo in listImages.dataProvider )
- {
- collection.addItem( dragAndDropVo );
- }
-
- new SaveMeasuresEvent( collection.source, this ).dispatch();
-
- _model.enabledReport = true;
- }
- public function clearPage() : void
- {
- // uncomment later ?
- //scaleValue.text = "-";
- distanceValue.text = "";
- areaValue.text = "";
- areaValue2.text = "";
-
- imtFarWallAverage.text = "";
- imtFarWallMaximum.text = ""
- imtFarWallDistance.text = "";
- imtFarWallDeviation.text = "";
- imtFarWallQuality.text = "";
- imtFarWallPoints.text = "";
-
- imtNearWallAverage.text = "";
- imtNearWallMaximum.text = ""
- imtNearWallDistance.text = "";
- imtNearWallDeviation.text = "";
- imtNearWallQuality.text = "";
- imtNearWallPoints.text = "";
-
- if (_model.measuresList)
- _model.measuresList.removeAll();
- if (listImages)
- listImages.selectedIndex = -1;
- if (imageZoom)
- imageZoom.removeAllChildren();
- if (miniature)
- miniature.removeAllChildren();
-
- _model.currentThumbnailIndex = -1;
-
- nwImtResult = null;
- fwImtResult = null;
- imtResults = new ArrayCollection();
-
- selectedZoneLabel.text = "";
- //scannerUsed.text = "";
-
- affCTPA = false;
-
- getCTPAValue();
- }
- /**
- * Effets sur l'échelle détectée
- */
- private function glowOnScale( event : TimerEvent ) : void
- {
- glowOn.play( [ canvas ] );
- }
- /**
- * Effets sur l'échelle détectée
- */
- private function glowOffScale( event : EffectEvent ) : void
- {
- glowOff.play( [ canvas ] );
- }
- /**
- * Affichage d'une fenêtre demandant la tailel de l'échelle
- */
- private function displayScaleQuestion( event : TimerEvent ) : void
- {
- timer.reset();
- timer.removeEventListener( TimerEvent.TIMER, glowOnScale );
- timer.removeEventListener( TimerEvent.TIMER_COMPLETE, displayScaleQuestion );
- }
- /**
- * Effets sur l'échelle détectée
- */
- private function glowOnManualScale( event : TimerEvent ) : void
- {
- glowOnManual.play( [ manualScale ] );
- }
- /**
- * Effets sur l'échelle détectée
- */
- private function glowOffManualScale( event : EffectEvent ) : void
- {
- glowOffManual.play( [ manualScale ] );
- }
- /**
- * Création d'un tableau d'octet propre à la bibliothèque d'IMT
- */
- private function makeByteArray( bitmapData : BitmapData ) : ByteArray
- {
- var byteArray : ByteArray = new ByteArray();
- byteArray.endian = "bigEndian";
-
- for ( var y : int = 0; y < bitmapData.height; y++ )
- {
- for ( var x : int = 0; x < bitmapData.width; x++ )
- {
- var col : int = bitmapData.getPixel32( x, y );
- var red : uint = col >> 16 & 0xFF;
- var green : uint = col >> 8 & 0xFF;
- var blue : uint = col & 0xFF;
-
- byteArray.writeByte( blue ^7 );
- byteArray.writeByte( red ^7 );
- byteArray.writeByte( green ^7 );
- }
- }
- return byteArray;
- }
- /**
- * Formatage du tableau d'EIM
- */
- private function formatValue( item : Object, col : DataGridColumn ) : String
- {
- var value : String = "";
-
- switch( col.dataField )
- {
- case "mean":
- value = formatImtNumber.format( item.mean );
- break;
- case "max":
- value = formatImtNumber.format( item.max );
- break;
- case "standardDeviation":
- value = formatImtNumber.format( item.standardDeviation );
- break;
- case "qualityIndex":
- value = formatNumber.format( item.qualityIndex );
- break;
- case "distance":
- value = formatImtNumber.format( item.distance );
- break;
- case "numberOfPoints":
- value = formatInt.format( item.numberOfPoints );
- break;
- }
-
- return value;
- }
- private function formatImtLabel( item : Object, col : DataGridColumn ) : String
- {
- if (item.name == ResourceManager.getInstance().getString( 'labels', 'measures.label.fw.imt' ))
- return ResourceManager.getInstance().getString( 'labels', 'measures.label.fw.imt' );
- // else
- return ResourceManager.getInstance().getString( 'labels', 'measures.label.nw.imt' );
- }
- /**
- * Réinitialisation des curseurs
- */
- public function resetCursor() : void
- {
- CursorManager.removeAllCursors();
- }
- public function resetScaleCursor() : void
- {
- _moveEnabled = false;
- CursorManager.removeAllCursors();
- Mouse.show();
- }
- /**
- * Affichage du tableau
- */
- private function displayDatagrid() : void
- {
- ( this.parentDocument as GeneralMeasureView ).selectZone('results');
- }
- /**
- * Redimensionnement des VDivider
- */
- private function resizeDivider( target : Box ) : void
- {
- if( target.width == 0 )
- target.width = 170;
- else
- target.width = 0;
- }
- /**
- * Redimensionnement des HDivider
- */
- private function resizeCenterDivider( target : Box ) : void
- {
- if( target.height == 0 )
- target.height = 150;
- else
- target.height = 0;
- }
- /**
- * Création d'une échelle manuelle (affichage de la zone de recherche)
- */
- private function checkManualScale() : void
- {
- _blankPaper = new BlankPaperWrapper();
-
- _blankPaper.name = "SCALE";
- _blankPaper.width = imageZoom.width;
- _blankPaper.height = imageZoom.height;
-
- _blankPaper.selectedTool = RectangleTool;
- _blankPaper.multiple = false;
-
- _blankPaper.addEventListener( MouseEvent.MOUSE_UP, zoneSelected );
-
- imageZoom.addChild( _blankPaper );
- }
- private function prepareMeasureView(dragAndDropVo:DragAndDropVo) : void
- {
- manualScale.selected = true;
- manualScale.enabled = true;
- imtButton.enabled = false;
- areaButton.enabled = false;
- distanceButton.enabled = false;
- imtButton.selected = false;
- areaButton.selected = false;
- distanceButton.selected = false;
- scaleMode = true;
- miniature.removeAllChildren();
- imtResults = new ArrayCollection();
- prepareScaleCursor();
- if (sprite.numChildren)
- sprite.removeChildAt(0);
-
- distanceLabel.text = ResourceManager.getInstance().getString('labels', 'measures.label.distance');
- distanceValue.text = "";
- areaValue.text = "";
- areaValue2.text = "";
- // J.Deppe : uncomment later if needed
- // if (dragAndDropVo != null )
- // scaleValue.text = dragAndDropVo.scale.toString();
-
- // J.Deppe : uncomment later if needed
- // var scanner : UltraSoundScannerVo = dragAndDropVo.ultrasoudscanner;
- // if (scanner.name)
- // scannerUsed.text = "(" + ResourceManager.getInstance().getString('labels', 'measures.scanner.used') + " : " + scanner.name + ")";
-
- var bitmapImage : Image = new Image();
- bitmapImage.maintainAspectRatio = true;
-
- // Modifications de passage en 4/3 et resize le 250216
- var ratio : Number;
- var imageCJ : ImageCJ = new ImageCJ();
- var bitmapData : BitmapData;
- imageCJ.m_isBlack = true;
- m_imageResizee = new ImageCJ();
-
- ratio = dragAndDropVo.imageHigh.bitmapData.width / dragAndDropVo.imageHigh.bitmapData.height;
- if (ratio != (4.0/3.0))
- {
- // L'image n'est pas 4/3 : Passage 4/3 et resize
- imageCJ.toQuatreTiers( dragAndDropVo.imageHigh.bitmapData.width, dragAndDropVo.imageHigh.bitmapData.height, dragAndDropVo.imageHigh.bitmapData );
-
- bitmapData = imageCJ.data.clone();
- bitmapImage.width = imageCJ.dimh;
- bitmapImage.height = imageCJ.dimv;
- }
- else
- {
- if( ( (dragAndDropVo.imageHigh.bitmapData.width != 768) && (dragAndDropVo.imageHigh.bitmapData.height != 576) ))
- {
- // Déja 4/3 mais pas la bonne taille
- imageCJ.resize2( dragAndDropVo.imageHigh.bitmapData.width, dragAndDropVo.imageHigh.bitmapData.height, 768, 576, dragAndDropVo.imageHigh.bitmapData);
-
- bitmapData = imageCJ.data.clone();
- bitmapImage.width = imageCJ.dimh;
- bitmapImage.height = imageCJ.dimv;
- }
- else
- {
- // L'image fait 768x576
- bitmapData = dragAndDropVo.imageHigh.bitmapData.clone();
- bitmapImage.width = dragAndDropVo.imageHigh.width;
- bitmapImage.height = dragAndDropVo.imageHigh.height;
- }
- }
- m_imageResizee.data = bitmapData.clone();
- m_imageResizee.dimh = bitmapImage.width;
- m_imageResizee.dimv = bitmapImage.height;
-
- // Alert.show("width = " + bitmapImage.width.toString() + "height = " + bitmapImage.height.toString());
-
- var bitmap : Bitmap = new Bitmap(bitmapData);
-
- bitmapImage.name = "IMAGE";
- bitmapImage.source = bitmap;
-
- imageZoom.removeAllChildren();
-
- _measureImage = imageZoom.addChild( bitmapImage ) as Image;
- _measureImage.setStyle("addedEffect", Fade);
-
- selectedZoneLabel.text = ResourceManager.getInstance().getString('type', dragAndDropVo.type);
-
- var incidenceText : String = dragAndDropVo.getIncidenceText();
- if (incidenceText != 'None')
- selectedZoneLabel.text += ' ' + incidenceText;
- }
- private function addSelectedSegmentToRightSideBox(dragAndDropVo:DragAndDropVo) : void
- {
- var zone : Image = new Image();
- zone.width = 160;
- zone.height = 300;
- zone.maintainAspectRatio = true;
- zone.setStyle("addedEffect", Fade);
-
- switch(dragAndDropVo.collection)
- {
- case "CR":
- if (_model.viewPatient)
- {
- FlashHelper.buildSegmentSelected(Application.application.menuPhysician.acquire.panzoomCarotidRight, "CR");
- FlashHelper.restoreSelectionForRightCarotid(dragAndDropVo.type);
- }
- _currentSide = RIGHT_SIDE;
- zone.source = _model.carotidRight;
- break;
- case "CL":
- if (_model.viewPatient)
- {
- FlashHelper.buildSegmentSelected(Application.application.menuPhysician.acquire.panzoomCarotidLeft, "CL");
- FlashHelper.restoreSelectionForLeftCarotid(dragAndDropVo.type);
- }
- _currentSide = LEFT_SIDE;
- zone.source = _model.carotidLeft;
- break;
- case "AR":
- if (_model.viewPatient)
- {
- FlashHelper.buildSegmentSelected(Application.application.menuPhysician.acquire.panzoomArmRight, "AR");
- FlashHelper.restoreSelectionForRightArm(dragAndDropVo.type);
- }
- _currentSide = RIGHT_SIDE;
- zone.source = _model.armRight;
- break;
- case "AL":
- if (_model.viewPatient)
- {
- FlashHelper.buildSegmentSelected(Application.application.menuPhysician.acquire.panzoomArmLeft, "AL");
- FlashHelper.restoreSelectionForLeftArm(dragAndDropVo.type);
- }
- _currentSide = LEFT_SIDE;
- zone.source = _model.armLeft;
- break;
- case "LR":
- if (_model.viewPatient)
- {
- FlashHelper.buildSegmentSelected(Application.application.menuPhysician.acquire.panzoomLegRight, "LR");
- FlashHelper.restoreSelectionForRightLeg(dragAndDropVo.type);
- }
- _currentSide = RIGHT_SIDE;
- zone.source = _model.legRight;
- break;
- case "LL":
- if (_model.viewPatient)
- {
- FlashHelper.buildSegmentSelected(Application.application.menuPhysician.acquire.panzoomLegLeft, "LL");
- FlashHelper.restoreSelectionForLeftLeg(dragAndDropVo.type);
- }
- _currentSide = LEFT_SIDE;
- zone.source = _model.legLeft;
- break;
- case "BO":
- if (_model.viewPatient)
- {
- FlashHelper.buildSegmentSelected(Application.application.menuPhysician.acquire.panzoomBody, "BO");
- FlashHelper.restoreSelectionForBody(dragAndDropVo.type);
- }
- zone.source = _model.body;
- break;
- }
-
- miniature.addChild( zone );
- }
- private function addMarkers() : void
- {
- // only in patient view mode
- if (!_model.viewPatient || _model.acquireViewLoaded)
- return;
-
- for each( var markerVo : MarkerVo in _model.listMarkers )
- {
- var marker : SWFLoader = new SWFLoader();
-
- if( markerVo.type == MarkerVo.PLAQUE )
- {
- marker.source = "swf/plaque.swf";
- marker.width = 9;
- marker.height = 11;
- }
- else if( markerVo.type == MarkerVo.STENOSE )
- {
- marker.source = "swf/stenose.swf";
- marker.width = 11;
- marker.height = 23;
- }
-
- else if( markerVo.type == MarkerVo.OCCLUSION )
- {
- marker.source = "swf/occlusion.swf";
- marker.width = 11;
- marker.height = 23;
- }
-
- if (markerVo.side == "RIGHT" && _currentSide == RIGHT_SIDE)
- miniature.addChild(marker);
- else if (markerVo.side == "LEFT" && _currentSide == LEFT_SIDE)
- miniature.addChild(marker);
-
- // ratio with panzoom:PanZoomComponent of AcquireView
- // contentWidth="205" contentHeight="465"
- // take 204 and 403 : empiric method
- // in MeasureView, selected zone block is about 137 and 300
- // find asap (if we have time) another method => take snapshot of panzoom of AcquireView plus resize
- marker.x = markerVo.xPosition * (137 / 204);
- marker.y = (markerVo.yPosition+8) * (300 / 463);
- }
- }
- private function drawExistingScale(dragAndDropVo:DragAndDropVo, scale:ScaleCJ, imgScale:Number, image:ImageCJ, graph:Graphics, sprite:Sprite) : void
- {
- // Alert.show("drawExistingScale");
- scale = new ScaleCJ();
- scale.setNbPoints(2);
- scale.setLength(20);
- scale.setPoints(50, 50, 50, 100 + (20 / imgScale));
- scale.setScaleFound(true);
-
- sprite = new Sprite();
- graph = sprite.graphics;
-
- image = new ImageCJ();
- image.setBitmapData(dragAndDropVo.imageHigh.bitmapData);
- // image.setBitmapData(m_imageResizee.data);
-
- scale.draw(( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width, ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh, m_imageResizee.dimv, graph, image, sprite);
- }
- private function drawExistingImt(dragAndDropVo:DragAndDropVo) : Boolean
- {
- imtFarWallAverage.text = "";
- imtFarWallMaximum.text = "";
- imtFarWallDistance.text = "";
- imtFarWallDeviation.text = "";
- imtFarWallQuality.text = "";
- imtFarWallPoints.text = "";
-
- imtNearWallAverage.text = "";
- imtNearWallMaximum.text = "";
- imtNearWallDistance.text = "";
- imtNearWallDeviation.text = "";
- imtNearWallQuality.text = "";
- imtNearWallPoints.text = "";
-
- if (dragAndDropVo.fwImtResult || dragAndDropVo.nwImtResult)
- {
- var intima : Array;
- var adventitia : Array;
- var numberOfPoints : int;
- var i : int;
-
- var canvas : Canvas = new Canvas();
- canvas.width = _measureImage.width;
- canvas.height = _measureImage.height;
-
- imageZoom.addChild( canvas );
-
- if (dragAndDropVo.fwImtResult)
- {
- canvas.name = "FWIMT";
-
- Measure.imtDraw(dragAndDropVo.imageHigh.bitmapData.width, dragAndDropVo.imageHigh.bitmapData.height, m_imageResizee.dimh, m_imageResizee.dimv,
- canvas.graphics,
- dragAndDropVo.fwImtResult.intima,
- dragAndDropVo.fwImtResult.adventitia,
- dragAndDropVo.fwImtResult.numberOfPoints);
-
- dragAndDropVo.fwImtResult.name = ResourceManager.getInstance().getString( 'labels', 'measures.label.fw.imt' );
- imtResults.addItem(dragAndDropVo.fwImtResult);
-
- imtFarWallAverage.text = formatImtNumber.format(dragAndDropVo.fwImtResult.mean);
- imtFarWallMaximum.text = formatImtNumber.format(dragAndDropVo.fwImtResult.max);
- imtFarWallDistance.text = formatImtNumber.format(dragAndDropVo.fwImtResult.distance);
- imtFarWallDeviation.text = formatImtNumber.format(dragAndDropVo.fwImtResult.standardDeviation);
- imtFarWallQuality.text = formatNumber.format(dragAndDropVo.fwImtResult.qualityIndex);
- imtFarWallPoints.text = formatInt.format(dragAndDropVo.fwImtResult.numberOfPoints);
- }
-
- if (dragAndDropVo.nwImtResult)
- {
- canvas.name = "NWIMT";
-
- Measure.imtDraw(dragAndDropVo.imageHigh.bitmapData.width, dragAndDropVo.imageHigh.bitmapData.height, m_imageResizee.dimh, m_imageResizee.dimv,
- canvas.graphics,
- dragAndDropVo.nwImtResult.intima,
- dragAndDropVo.nwImtResult.adventitia,
- dragAndDropVo.nwImtResult.numberOfPoints);
-
- dragAndDropVo.nwImtResult.name = ResourceManager.getInstance().getString( 'labels', 'measures.label.nw.imt' );
- imtResults.addItem(dragAndDropVo.nwImtResult);
-
- imtNearWallAverage.text = formatImtNumber.format(dragAndDropVo.nwImtResult.mean);
- imtNearWallMaximum.text = formatImtNumber.format(dragAndDropVo.nwImtResult.max);
- imtNearWallDistance.text = formatImtNumber.format(dragAndDropVo.nwImtResult.distance);
- imtNearWallDeviation.text = formatImtNumber.format(dragAndDropVo.nwImtResult.standardDeviation);
- imtNearWallQuality.text = formatNumber.format(dragAndDropVo.nwImtResult.qualityIndex);
- imtNearWallPoints.text = formatInt.format(dragAndDropVo.nwImtResult.numberOfPoints);
- }
-
- return true;
- }
-
- return false;
- }
- private function drawExistingDistance(dragAndDropVo:DragAndDropVo) : void
- {
- if (!dragAndDropVo.distance)
- return;
-
- var blankPaper : BlankPaperWrapper = new BlankPaperWrapper();
- blankPaper.name = "DISTANCE";
- imageZoom.addChild(blankPaper);
- Measure.distanceDraw(blankPaper.graphics,
- dragAndDropVo.distance.xFirstPoint,
- dragAndDropVo.distance.yFirstPoint,
- dragAndDropVo.distance.xLastPoint,
- dragAndDropVo.distance.yLastPoint
- );
-
- distanceValue.text = formatNumber.format(dragAndDropVo.distance.value) + " mm";
- distanceLabel.text = dragAndDropVo.distance.getTypeText();
- }
- private function drawExistingSurface(dragAndDropVo:DragAndDropVo) : void
- {
- if (!dragAndDropVo.area)
- return;
- var blankPaper : BlankPaperWrapper = new BlankPaperWrapper();
- blankPaper.name = "AREA";
-
- imageZoom.addChild( blankPaper );
- Measure.areaDraw(blankPaper.graphics, dragAndDropVo.area.points, dragAndDropVo.area.points.length);
-
- areaValue.text = formatNumber.format(dragAndDropVo.area.value ) + " mm²";
- if (dragAndDropVo.area2)
- {
- var blankPaper2 : BlankPaperWrapper = new BlankPaperWrapper();
- blankPaper2.name = "AREA2";
-
- imageZoom.addChild( blankPaper2 );
- Measure.areaDraw(blankPaper2.graphics, dragAndDropVo.area2.points, dragAndDropVo.area2.points.length);
-
- areaValue2.text = formatNumber.format(dragAndDropVo.area2.value ) + " mm²";
- }
- }
- private function processDicomImage(dragAndDropVo:DragAndDropVo) : void
- {
- var pstartX:int;
- var pstartY:int;
- var pendX:int;
- var pendY:int;
- unPrepareScaleCursor();
- manualScale.selected = false;
- manualScale.enabled = false;
- scaleMode = false;
- imtButton.enabled = true;
- areaButton.enabled = true;
- distanceButton.enabled = true;
- pstartX = pointxResizeToOriginal(70,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh);
- pstartY = pointyResizeToOriginal(100,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimv);
-
- pendX = pointxResizeToOriginal(70,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh);
- pendY = pointyResizeToOriginal(100,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width,( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimv);
-
- scale = new ScaleCJ();
- scale.setNbPoints(2);
- scale.setLength(20);
- scale.setPoints(pstartX, pstartY, pendX, pendY + (20 / dragAndDropVo.scale.value));
- scale.setScaleFound(true);
-
- sprite = new Sprite();
- graph = sprite.graphics;
-
- imageCJ = new ImageCJ();
- imageCJ.m_isBlack = true;
- imageCJ.setBitmapData(dragAndDropVo.imageHigh.bitmapData );
- // imageCJ.setBitmapData(m_imageResizee.data );
-
- scale.draw(( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width, ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh, m_imageResizee.dimv, graph, imageCJ, sprite);
-
- var existingImt : Boolean = drawExistingImt(dragAndDropVo);
-
- drawExistingDistance(dragAndDropVo);
- drawExistingSurface(dragAndDropVo);
-
- _measureImage.addChild(sprite) as Image;
- _measureImage.addEventListener( MouseEvent.MOUSE_MOVE, mouseMoveCursor );
-
- if (!_model.viewPatient && !existingImt)
- {
- var toastMessage : ImtToaster = new ImtToaster();
- toastMessage.titleMessage = ResourceManager.getInstance().getString('labels', 'measures.dicom.title');
- toastMessage.timeToLive = 7;
- toastMessage.message = ResourceManager.getInstance().getString('labels', 'measures.dicom.message');
- toastMessage.level = ImtToaster.INFORMATION;
- _model.toaster.toast( toastMessage );
- }
- }
- private function processImage(dragAndDropVo:DragAndDropVo) : void
- {
- _measureImage.addEventListener( MouseEvent.MOUSE_MOVE, mouseMoveCursor );
- _measureImage.addEventListener( MouseEvent.CLICK, saveClicks );
-
- if (dragAndDropVo.scale)
- {
- unPrepareScaleCursor();
- manualScale.selected = false;
- manualScale.enabled = true;
- scaleMode = false;
- imtButton.enabled = true;
- areaButton.enabled = true;
- distanceButton.enabled = true;
-
- scale = new ScaleCJ();
- scale.setNbPoints(2);
- scale.setLength(dragAndDropVo.scale.length);
- scale.setPoints(
- dragAndDropVo.scale.xFirstPoint,
- dragAndDropVo.scale.yFirstPoint,
- dragAndDropVo.scale.xLastPoint,
- dragAndDropVo.scale.yLastPoint);
- scale.setScaleFound(true);
-
- sprite = new Sprite();
- graph = sprite.graphics;
-
- imageCJ = new ImageCJ();
- imageCJ.m_isBlack = true;
- imageCJ.setBitmapData( dragAndDropVo.imageHigh.bitmapData );
- // imageCJ.setBitmapData( m_imageResizee.data );
-
- scale.draw(( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.width, ( listImages.selectedItem as DragAndDropVo ).imageHigh.bitmapData.height, m_imageResizee.dimh, m_imageResizee.dimv, graph, imageCJ, sprite);
-
- sprite.name = "SCALE";
-
- _measureImage.addChild(sprite) as Image;
- }
-
- drawExistingImt(dragAndDropVo);
- drawExistingDistance(dragAndDropVo);
- drawExistingSurface(dragAndDropVo);
- }
- public function updateSelectedZoneLabel() : void
- {
- if (_currentDragAndDropVo == null)
- return;
-
- selectedZoneLabel.text = ResourceManager.getInstance().getString('type', _currentDragAndDropVo.type);
-
- var incidenceText : String = _currentDragAndDropVo.getIncidenceText();
- if (incidenceText != 'None')
- selectedZoneLabel.text += ' ' + incidenceText;
- }
- public function imageSelection(dragAndDropVo:DragAndDropVo) : void
- {
- _model.currentThumbnailIndex = listImages.selectedIndex;
-
- prepareMeasureView(dragAndDropVo);
- addSelectedSegmentToRightSideBox(dragAndDropVo);
- addMarkers();
-
- _currentDragAndDropVo = dragAndDropVo;
-
- if (!dragAndDropVo.scale)
- {
- // put scale and measure on dragAndDropVo
- for each (var measuresVo : MeasuresVo in
- (this.parentDocument as GeneralMeasureView).getMeasuresArray())
- {
- if (dragAndDropVo.id == measuresVo.imageId)
- {
- if (measuresVo.scale)
- dragAndDropVo.scale = measuresVo.scale;
- if (measuresVo.distance)
- dragAndDropVo.distance = measuresVo.distance;
- if (measuresVo.area)
- dragAndDropVo.area = measuresVo.area;
- if (measuresVo.area2)
- dragAndDropVo.area2 = measuresVo.area2;
- if (measuresVo.fwImt)
- dragAndDropVo.fwImtResult = measuresVo.fwImt;
- if (measuresVo.nwImt)
- dragAndDropVo.nwImtResult = measuresVo.nwImt;
- }
- }
- }
-
- if (dragAndDropVo.isDicom)
- {
- processDicomImage(dragAndDropVo);
- }
- else
- {
- processImage(dragAndDropVo);
- }
-
- MAJNumArea();
- }
-
- // Calcul de la valeur de Total Plaque Area
- private function getCTPAValue() : void
- {
- if (!_model.viewPatient)
- {
- _model.CTPA = 0;
-
- for (var i:int = 0; i < listImages.dataProvider.length; i++)
- {
- if (((listImages.dataProvider[i] as DragAndDropVo).type == "COMD")
- || ((listImages.dataProvider[i] as DragAndDropVo).type == "COMG")
- || ((listImages.dataProvider[i] as DragAndDropVo).type == "BIFD")
- || ((listImages.dataProvider[i] as DragAndDropVo).type == "BIFG")
- || ((listImages.dataProvider[i] as DragAndDropVo).type == "INTD")
- || ((listImages.dataProvider[i] as DragAndDropVo).type == "INTG"))
- {
- if ((listImages.dataProvider[i] as DragAndDropVo ).area)
- {
- _model.CTPA += (listImages.dataProvider[i] as DragAndDropVo).area.value;
- }
- if ((listImages.dataProvider[i] as DragAndDropVo ).area2)
- {
- _model.CTPA += (listImages.dataProvider[i] as DragAndDropVo).area2.value;
- }
- }
- }
- }
-
- AfficheCTPA();
- ctpaValue.setFocus();
- }
- private function MAJNumArea(): void
- {
- if ((( listImages.selectedItem as DragAndDropVo ).type == "COMD")
- ||(( listImages.selectedItem as DragAndDropVo ).type == "COMG")
- ||(( listImages.selectedItem as DragAndDropVo ).type == "BIFD")
- ||(( listImages.selectedItem as DragAndDropVo ).type == "BIFG")
- ||(( listImages.selectedItem as DragAndDropVo ).type == "INTD")
- ||(( listImages.selectedItem as DragAndDropVo ).type == "INTG"))
- {
- if ((listImages.selectedItem as DragAndDropVo ).area)
- {
- areaValue.text = formatNumber.format(( listImages.selectedItem as DragAndDropVo ).area.value) + ' ' + ResourceManager.getInstance().getString( 'labels', 'label.unitmm2' );
- }
- else
- {
- areaValue.text = "";
- }
-
- if ((listImages.selectedItem as DragAndDropVo ).area2)
- {
- areaValue2.text = formatNumber.format(( listImages.selectedItem as DragAndDropVo ).area2.value) + ' ' + ResourceManager.getInstance().getString( 'labels', 'label.unitmm2' );
- }
- else
- {
- areaValue2.text = "";
- }
- }
-
- getCTPAValue();
- }
- // Détermine si on affiche ou pas la CTPA
- public function AfficheCTPA() : void
- {
- var ind :int;
- var i :int;
- affCTPA = false;
- ind = 0;
-
- if (_model.CTPA > 0)
- {
- if (listImages.dataProvider.length > 0)
- {
- // On recherche le dernier qui affiche une surface
- for (i = 0; i < listImages.dataProvider.length; i++)
- {
- if (((listImages.dataProvider[i] as DragAndDropVo).type == "COMD")
- || ((listImages.dataProvider[i] as DragAndDropVo).type == "COMG")
- || ((listImages.dataProvider[i] as DragAndDropVo).type == "BIFD")
- || ((listImages.dataProvider[i] as DragAndDropVo).type == "BIFG")
- || ((listImages.dataProvider[i] as DragAndDropVo).type == "INTD")
- || ((listImages.dataProvider[i] as DragAndDropVo).type == "INTG"))
- {
- if ((listImages.dataProvider[i] as DragAndDropVo).area)
- {
- ind = i;
- }
- }
- }
-
- if (((listImages.selectedItem as DragAndDropVo ).id == (listImages.dataProvider[ind] as DragAndDropVo ).id ))
- {
- affCTPA = true;
- }
- else
- {
- affCTPA = false;
- }
- }
- }
- }
- private function validateMeasure() : void
- {
- // Alert.show("cptMesuresVisite" + _model.cptMesuresVisite.toString());
-
- // On limite le nombre de crédits par visite à 5
- if (_model.cptMesuresVisite <= 5)
- {
- _model.cptMesuresVisite++;
- _model.connectedUser.cptMesures++;
-
- // Alert.show("validateMeasure" + ":login=" + _model.connectedUser.login + "; cptm = " + _model.connectedUser.cptMesures.toString());
-
- new majCptMesuresEvent( _model.connectedUser.login, _model.connectedUser.cptMesures, this).dispatch();
- if ((_model.connectedUser.cptCredits - _model.connectedUser.cptMesures) < 50)
- {
- _model.colorRemaining = 0xffa500;
- }
- else
- {
- _model.colorRemaining = 0xFFFFFF;
- }
- }
- }
- public function pointxResizeToOriginal(x:int, oridimh:int, oridimv:int, resizedimh:int):int
- {
- var result:int;
- var ratio : Number;
- var newdimh : int;
- var newdimv : int;
- var y : int ;
-
- ratio = Number(oridimh) / Number(oridimv);
-
- if (ratio <= (4.0 / 3.0))
- {
- newdimv = oridimv;
- newdimh = int((4.0 * oridimv) / 3.0);
- }
- else
- {
- newdimh = oridimh;
- newdimv = int ((3.0 * oridimh) / 4.0);
- }
-
- x = (x * newdimh) / resizedimh;
-
- if (newdimv >= oridimv)
- {
- // ------------
- //
- // ------------
- // xxxxxxxxxxxx
- // ------------
- //
- // ------------
- // x = x;
- x = x - ((newdimh - oridimh) / 2);
- y = y - ((newdimv - oridimv) / 2);
- }
- else if (newdimh >= oridimh)
- {
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // Alert.show("newdimh > dimh");
- x = x - ((newdimh - oridimh) / 2);
- y = y - ((newdimv - oridimv) / 2);
- // y = y;
- }
-
- return x;
- }
- public function pointyResizeToOriginal(y:int, oridimh:int, oridimv:int, resizedimv:int):int
- {
- var result:int;
- var ratio : Number;
- var newdimh : int;
- var newdimv : int;
- var x : int ;
-
- ratio = Number(oridimh) / Number(oridimv);
-
- if (ratio <= (4.0 / 3.0))
- {
- newdimv = oridimv;
- newdimh = int((4.0 * oridimv) / 3.0);
- }
- else
- {
- newdimh = oridimh;
- newdimv = int ((3.0 * oridimh) / 4.0);
- }
-
- y = (y * newdimv) / resizedimv;
- if (newdimv >= oridimv)
- {
- // ------------
- //
- // ------------
- // xxxxxxxxxxxx
- // ------------
- //
- // ------------
- // x = x;
- x = x - ((newdimh - oridimh) / 2);
- y = y - ((newdimv - oridimv) / 2);
- }
- else if (newdimh >= oridimh)
- {
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // Alert.show("newdimh > dimh");
- x = x - ((newdimh - oridimh) / 2);
- y = y - ((newdimv - oridimv) / 2);
- // y = y;
- }
- return y;
- }
- public static function pointxOriginalToResize(x:int, oridimh:int, oridimv:int, resizedimh:int):int
- {
- var result:int;
- var ratio : Number;
- var newdimh : int;
- var newdimv : int;
- var y : int ;
-
- ratio = Number(oridimh) / Number(oridimv);
-
- if (ratio <= (4.0 / 3.0))
- {
- newdimv = oridimv;
- newdimh = int((4.0 * oridimv) / 3.0);
- }
- else
- {
- newdimh = oridimh;
- newdimv = int ((3.0 * oridimh) / 4.0);
- }
-
- if (newdimv >= oridimv)
- {
- // ------------
- //
- // ------------
- // xxxxxxxxxxxx
- // ------------
- //
- // ------------
- // x = x;
- x = x + ((newdimh - oridimh) / 2);
- y = y + ((newdimv - oridimv) / 2);
- }
- else if (newdimh >= oridimh)
- {
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // Alert.show("newdimh > dimh");
- x = x + ((newdimh - oridimh) / 2);
- y = y + ((newdimv - oridimv) / 2);
- // y = y;
- }
-
- x = (x * resizedimh) / newdimh;
-
- return x;
- }
- public static function pointyOriginalToResize(y:int, oridimh:int, oridimv:int, resizedimv:int ):int
- {
- var result:int;
- var ratio : Number;
- var newdimh : int;
- var newdimv : int;
- var x : int ;
-
- ratio = Number(oridimh) / Number(oridimv);
-
- if (ratio <= (4.0 / 3.0))
- {
- newdimv = oridimv;
- newdimh = int((4.0 * oridimv) / 3.0);
- }
- else
- {
- newdimh = oridimh;
- newdimv = int ((3.0 * oridimh) / 4.0);
- }
-
- if (newdimv >= oridimv)
- {
- // ------------
- //
- // ------------
- // xxxxxxxxxxxx
- // ------------
- //
- // ------------
- // x = x;
- x = x + ((newdimh - oridimh) / 2);
- y = y + ((newdimv - oridimv) / 2);
- }
- else if (newdimh >= oridimh)
- {
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // | | x | |
- // Alert.show("newdimh > dimh");
-
- x = x + ((newdimh - oridimh) / 2);
- y = y + ((newdimv - oridimv) / 2);
- // y = y;
- }
-
- y = (y * resizedimv) / newdimv;
-
- return y;
- }
- public static function calScaleResizee(oridimh:int, oridimv:int, resizedimv:int ):Number
- {
- var result:Number;
- var ratio : Number;
- var newdimh : int;
- var newdimv : int;
- var x : int ;
- var y : int ;
-
- // Alert.show("oridimh:" + oridimh.toString() + "; oridimv: " + oridimv.toString()+ "; resizedimv: " + resizedimv.toString());
- ratio = Number(oridimh) / Number(oridimv);
-
- if (ratio <= (4.0 / 3.0))
- {
- newdimv = oridimv;
- newdimh = int((4.0 * oridimv) / 3.0);
- }
- else
- {
- newdimh = oridimh;
- newdimv = int ((3.0 * oridimh) / 4.0);
- }
- // Alert.show("ratio:" + ratio.toString() + "; newdimh: " + newdimh.toString()+ "; newdimv: " + newdimv.toString());
-
- result = newdimv / resizedimv;
- return result;
- }
|