Manipulator* LinkView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Coord x0, y0, x1, y1; Rubberband* rub = nil; Manipulator* m = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { m = CreateLinkCompManip(v, e, rel, tool); } else if (tool->IsA(MOVE_TOOL)) { GetEndpoints(x0, y0, x1, y1); rub = new SlidingLine(nil, nil, x0, y0, x1, y1, e.x, e.y); m = new DragManip(v, rub, rel, tool, Gravity); } else if (tool->IsA(SCALE_TOOL)) { GetEndpoints(x0, y0, x1, y1); rub = new ScalingLine(nil, nil, x0, y0, x1, y1, (x0+x1)/2, (y0+y1)/2); m = new DragManip(v, rub, rel, tool, Gravity); } else if (tool->IsA(ROTATE_TOOL)) { GetEndpoints(x0, y0, x1, y1); rub = new RotatingLine( nil, nil, x0, y0, x1, y1, (x0+x1)/2, (y0+y1)/2, e.x, e.y ); m = new DragManip(v, rub, rel, tool, Gravity); } return m; }
Manipulator* LineView::CreateManipulator ( Viewer* v, Event& e, Transformer* rel, Tool* tool ) { Coord x0, y0, x1, y1; Rubberband* rub = nil; Manipulator* m = nil; if (tool->IsA(GRAPHIC_COMP_TOOL)) { v->Constrain(e.x, e.y); rub = new RubberLine(nil, nil, e.x, e.y, e.x, e.y); m = new DragManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else if (tool->IsA(MOVE_TOOL)) { v->Constrain(e.x, e.y); GetEndpoints(x0, y0, x1, y1); rub = new SlidingLine(nil, nil, x0, y0, x1, y1, e.x, e.y); m = new DragManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else if (tool->IsA(SCALE_TOOL)) { v->Constrain(e.x, e.y); GetEndpoints(x0, y0, x1, y1); rub = new ScalingLine(nil, nil, x0, y0, x1, y1, (x0+x1)/2, (y0+y1)/2); m = new DragManip(v, rub, rel, tool, Gravity); } else if (tool->IsA(ROTATE_TOOL)) { v->Constrain(e.x, e.y); GetEndpoints(x0, y0, x1, y1); rub = new RotatingLine( nil, nil, x0, y0, x1, y1, (x0+x1)/2, (y0+y1)/2, e.x, e.y ); m = new DragManip(v, rub, rel, tool, Gravity); } else if (tool->IsA(RESHAPE_TOOL)) { v->Constrain(e.x, e.y); GetEndpoints(x0, y0, x1, y1); PointObj p1(x0, y0), p2(x1, y1), cp(e.x, e.y); if (p1.Distance(cp) < p2.Distance(cp)) { rub = new RubberLine(nil, nil, x1, y1, e.x, e.y); } else { rub = new RubberLine(nil, nil, x0, y0, e.x, e.y); } m = new DragManip( v, rub, rel, tool, DragConstraint(HorizOrVert | Gravity) ); } else { m = GraphicView::CreateManipulator(v, e, rel, tool); } return m; }
static void GetEndpointsAndCheck(const char* discoveryUrl, const char* filterTransportProfileUri, const UA_String expectedEndpointUrls[], size_t expectedEndpointUrlsSize) { UA_Client *client = UA_Client_new(); UA_ClientConfig_setDefault(UA_Client_getConfig(client)); ck_assert_uint_eq(UA_Client_connect(client, discoveryUrl), UA_STATUSCODE_GOOD); UA_EndpointDescription* endpointArray = NULL; size_t endpointArraySize = 0; UA_String discoveryUrlUA = UA_String_fromChars(discoveryUrl); UA_StatusCode retval = GetEndpoints(client, &discoveryUrlUA, &endpointArraySize, &endpointArray, filterTransportProfileUri); ck_assert_uint_eq(retval, UA_STATUSCODE_GOOD); UA_String_deleteMembers(&discoveryUrlUA); ck_assert_uint_eq(endpointArraySize , expectedEndpointUrlsSize); for(size_t j = 0; j < endpointArraySize && j < expectedEndpointUrlsSize; j++) { UA_EndpointDescription* endpoint = &endpointArray[j]; ck_assert(UA_String_equal(&endpoint->endpointUrl, &expectedEndpointUrls[j])); } UA_Array_delete(endpointArray, endpointArraySize, &UA_TYPES[UA_TYPES_ENDPOINTDESCRIPTION]); UA_Client_delete(client); }
void LineView::CreateHandles () { Coord x[2], y[2]; Viewer* v = GetViewer(); if (v != nil) { GetEndpoints(x[0], y[0], x[1], y[1]); _handles = new RubberHandles(nil, nil, x, y, 2, 0, HANDLE_SIZE); v->InitRubberband(_handles); } }
Command* ArrowLineView::InterpretManipulator (Manipulator* m) { DragManip* dm = (DragManip*) m; Editor* ed = dm->GetViewer()->GetEditor(); Tool* tool = dm->GetTool(); Transformer* rel = dm->GetTransformer(); Command* cmd = nil; ArrowVar* aVar = (ArrowVar*) ed->GetState("ArrowVar"); if (tool->IsA(GRAPHIC_COMP_TOOL)) { RubberLine* rl = (RubberLine*) dm->GetRubberband(); Coord x0, y0, x1, y1; rl->GetCurrent(x0, y0, x1, y1); if (x0 != x1 || y0 != y1) { BrushVar* brVar = (BrushVar*) ed->GetState("BrushVar"); ColorVar* colVar = (ColorVar*) ed->GetState("ColorVar"); PatternVar* patVar = (PatternVar*) ed->GetState("PatternVar"); if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } ArrowLine* aline = new ArrowLine( x0, y0, x1, y1, aVar->Head(), aVar->Tail(), dm->GetViewer()->GetMagnification(), stdgraphic ); if (brVar != nil) aline->SetBrush(brVar->GetBrush()); if (patVar != nil) { aline->SetPattern(patVar->GetPattern()); } if (colVar != nil) { aline->SetColors(colVar->GetFgColor(), colVar->GetBgColor()); } aline->SetTransformer(rel); Unref(rel); cmd = new PasteCmd(ed, new Clipboard(new ArrowLineComp(aline))); } } else if (tool->IsA(RESHAPE_TOOL)) { RubberLine* rl = (RubberLine*) dm->GetRubberband(); Coord epx0, epy0, epx1, epy1; GetEndpoints(epx0, epy0, epx1, epy1); Coord x0, y0, x1, y1; rl->GetCurrent(x0, y0, x1, y1); if (x0 == epx1 && y0 == epy1) { x0 = x1; y0 = y1; x1 = epx1; y1 = epy1; } if (rel != nil) { rel = new Transformer(rel); rel->Invert(); } ArrowLine* orig = GetArrowLineComp()->GetArrowLine(); ArrowLine* aline = new ArrowLine( x0, y0, x1, y1, orig->Head(), orig->Tail(), dm->GetViewer()->GetMagnification(), GetGraphic() ); aline->SetTransformer(rel); Unref(rel); cmd = new ReplaceCmd(ed, new ArrowLineComp(aline)); } else { cmd = LineView::InterpretManipulator(m); } return cmd; }