HeeksObj *VectorFont::Glyph::GlyphLine::Sketch( const gp_Pnt & location, const gp_Trsf & transformation_matrix, const float width, COrientationModifier *pOrientationModifier ) const { gp_Pnt start_point( location ); gp_Pnt end_point( location ); start_point.SetX( location.X() + m_x1 ); start_point.SetY( location.Y() + m_y1 ); end_point.SetX( location.X() + m_x2 ); end_point.SetY( location.Y() + m_y2 ); if (pOrientationModifier) { start_point = pOrientationModifier->Transform(transformation_matrix, location.Distance(gp_Pnt(0.0,0.0,0.0)), start_point, width ); end_point = pOrientationModifier->Transform(transformation_matrix, location.Distance(gp_Pnt(0.0,0.0,0.0)), end_point, width ); } start_point.Transform( transformation_matrix ); end_point.Transform( transformation_matrix ); double start[3]; double end[3]; start[0] = start_point.X(); start[1] = start_point.Y(); start[2] = start_point.Z(); end[0] = end_point.X(); end[1] = end_point.Y(); end[2] = end_point.Z(); HeeksObj *line = heekscad_interface.NewLine( start, end ); return(line); } // End Sketch() method
PST_Edge::~PST_Edge() { // Update list "head" pointers on points, if necessary. if( start_point() ) remove_start_point(); if( end_point() ) remove_end_point(); // Destroy parent facets for ( int i = 0; i < 2; i++ ) { PST_CoEdge* coedge = i ? reverse() : forward(); if ( coedge->face() ) { PST_Face* face = coedge->face(); face->coedge_ = 0; PST_CoEdge* first = coedge; do { assert(coedge->face() == face); coedge->face_ = 0; PST_CoEdge* next = coedge->next(); coedge->next_ = 0; coedge = next; } while( first != coedge ); delete face ; } } }
//Draw this line's 1st and 2nd coordinates in 2D space //using drawing function moveto( , ) and lineto( , ). //wind[] is the window of the screen to draw the line in. //Clipping will be performed about the wind[]. //(wind[0], wind[1]) is the center coordinates of the window. //wind[2] is width and wind[3] is hight of the window. When wind[2]<=0, //no clipping is performed. Even when wind[2]<=0, wind[3] is necessary //to input to specify the resolution of the line. In this case, //wind[0] and wind[1] are not referended. //ynum is the resolution of the line, is the number of //straight line segments for the curve length of wind[3](height of window). //***draw_2D does not perform box including judment, always performs clipping //operation and draws the line. Users must do obvious box inclusion test //if maximum drawing performance is necessary. void MGRLBRep::draw_all2D( int kfunc, //Kind of function move and line, //1:move(int,int), 2:move(float, float), otherwise:move(double,double). int (*moveto)(...), int (*lineto)(...), const double wind[4], //window box to draw the line in. size_t ynum)const//Resolution of the line. { unsigned n=bdim(), k=order(), wid=sdim(); const double* rcoef[3]={ rcoef[0]=m_line.m_line_bcoef.data(0,0), rcoef[1]=m_line.m_line_bcoef.data(0,1), rcoef[2]=m_line.m_line_bcoef.data(0,wid) }; const double* knotp=m_line.m_knot_vector.data(); double* work=new double[k*k+3*k]; std::vector<double> pvector; int nrw; if(wind[2]>0.){//If clipping is necessary. double xwin[2], ywin[2]; double xw=wind[2], yw=wind[3]; double error=MGTolerance::rc_zero(); double xerror=xw*error, yerror=yw*error; xw*=0.5; yw*=0.5; xwin[0]=wind[0]-xw+xerror; xwin[1]=wind[0]+xw-xerror; ywin[0]=wind[1]-yw+yerror; ywin[1]=wind[1]+yw-yerror; if(kfunc==1){ xwin[0]+=0.6; xwin[1]-=0.6; ywin[0]+=0.6; ywin[1]-=0.6;} //xwin[] , ywin[] are window coordinates. MGVector P=start_point(); if(xwin[0]<=P[0] && P[0]<=xwin[1] && ywin[0]<=P[1] && P[1]<=ywin[1]) pvector.push_back(param_s()); MGCParam_list plist=isect_1D(xwin[0],0); MGCParam_list::Citerator i, ie; ie=plist.end(); for(i=plist.begin(); i!=ie; i++) pvector.push_back(*i); plist=isect_1D(xwin[1],0); ie=plist.end(); for(i=plist.begin(); i!=ie; i++) pvector.push_back(*i); plist=isect_1D(ywin[0],1); ie=plist.end(); for(i=plist.begin(); i!=ie; i++) pvector.push_back(*i); plist=isect_1D(ywin[1],1); ie=plist.end(); for(i=plist.begin(); i!=ie; i++) pvector.push_back(*i); P=end_point(); if(xwin[0]<=P[0] && P[0]<=xwin[1] && ywin[0]<=P[1] && P[1]<=ywin[1]) pvector.push_back(param_e()); //*** sort the parameter value array. std::vector<double>::iterator vi=pvector.begin(), ve=pvector.end(); std::sort(vi,ve); nrw=pvector.size(); }else{ pvector=std::vector<double>(2); pvector[0]=param_s(); pvector[1]=param_e(); nrw=2; } double* isparam=&(pvector[0]); bldrwcr_(kfunc,(S_fp)moveto,(S_fp)lineto,ynum,wind,nrw,isparam,0, k,n,knotp,rcoef,work); delete[] work; }
HeeksObj *VectorFont::Glyph::GlyphArc::Sketch( const gp_Pnt & location, const gp_Trsf & transformation_matrix, const float width, COrientationModifier *pOrientationModifier ) const { double start[3]; double end[3]; double centre[3]; double up[3]; gp_Pnt centre_point( location.X() + m_xcentre, location.Y() + m_ycentre, location.Z() ); gp_Pnt start_point( centre_point.X() + m_radius, centre_point.Y(), centre_point.Z() ); gp_Pnt end_point( centre_point.X() + m_radius, centre_point.Y(), centre_point.Z() ); gp_Dir z_direction( 0, 0, 1 ); if (pOrientationModifier) centre_point = pOrientationModifier->Transform(transformation_matrix, location.Distance(gp_Pnt(0.0,0.0,0.0)), centre_point, width ); if (pOrientationModifier) start_point = pOrientationModifier->Transform(transformation_matrix, location.Distance(gp_Pnt(0.0,0.0,0.0)), start_point, width ); gp_Trsf start_rotation_matrix; start_rotation_matrix.SetRotation( gp_Ax1(centre_point, z_direction), m_start_angle ); start_point.Transform(start_rotation_matrix); // Rotate to start_angle start[0] = start_point.X(); start[1] = start_point.Y(); start[2] = start_point.Z(); if (pOrientationModifier) end_point = pOrientationModifier->Transform(transformation_matrix, location.Distance(gp_Pnt(0.0,0.0,0.0)), end_point, width ); gp_Trsf end_rotation_matrix; end_rotation_matrix.SetRotation( gp_Ax1(centre_point, z_direction), m_end_angle ); end_point.Transform(end_rotation_matrix); // Rotate to start_angle end[0] = end_point.X(); end[1] = end_point.Y(); end[2] = end_point.Z(); centre[0] = centre_point.X(); centre[1] = centre_point.Y(); centre[2] = centre_point.Z(); gp_Pnt up_point( 0.0, 0.0, 1.0 ); // For counter-clockwise (always in this font format) up[0] = up_point.X(); up[1] = up_point.Y(); up[2] = up_point.Z(); HeeksObj *arc = heekscad_interface.NewArc( start, end, centre, up ); double m[16]; extract(transformation_matrix,m); arc->ModifyByMatrix(m); return(arc); } // End Sketch() method
void CheckBox::PaintBox(Canvas& canvas, const Rect& box_rect) const { //Paint the box. canvas.SetBrushWithColor(GetBoxBackgroundColor()); canvas.DrawRectangle(box_rect); canvas.SetBrushWithColor(GetBoxBorderColor()); canvas.DrawRectangleFrame(box_rect, 1); //Paint the check state mark. auto check_state = GetCheckState(); if (check_state == CheckState::Indeterminate) { Rect mark_rect = box_rect; mark_rect.Inflate(-3); canvas.DrawRectangle(mark_rect); } else if (check_state == CheckState::Checked) { auto path = GetResourceFactory()->CreatePathGeometry(); if (path == nullptr) { return; } auto sink = path->Open(); if (sink == nullptr) { return; } Rect mark_rect = box_rect; mark_rect.Inflate(-2); Point start_point(mark_rect.position.x + mark_rect.size.width, mark_rect.position.y); Point middle_point(mark_rect.position.x + mark_rect.size.width * 0.4f, mark_rect.position.y + mark_rect.size.height - 1); Point end_point(mark_rect.position.x, mark_rect.position.y + mark_rect.size.height * 0.4f); sink->BeginFigure(start_point, GeometrySink::BeginFigureOption::Hollow); sink->AddLine(middle_point); sink->AddLine(end_point); sink->EndFigure(GeometrySink::EndFigureOption::Open); sink->Close(); canvas.DrawGeometryFrame(path, 1.5); } }
int main(int argc, char *argv[]) { int start_arr [] = {120,75}; Point2D start_point(start_arr, false); int end_arr [] = {180,75}; Point2D end_point(end_arr, false); std::cout << "hello world!" << std::endl; std::cout << "this point is "<< start_point.get_coordinate(0) << std::endl; Space2D * my_space = new Space2D(); // test to read pgm char *filename="../pic/circular_map.pgm"; my_space->initFromPgm(filename); my_space->printSpace(); /* code */ return 0; }
void QTrain::move() { QLineF line; if( move_duration >= 1 ) return; int railIndex = change->railNo - 1; QPointF wb_point( 0, 0 ), start_point( 0, 0 ), end_point( 0, 0 ); if( route->getSections()[index-1].getBlock().whatIsIt() == WorldBlock::STATION ) { wb_point.setX( route->getSections()[index-1].getBlock().getStation().getPosX() ); wb_point.setY( route->getSections()[index-1].getBlock().getStation().getPosY() ); } if( route->getSections()[index-1].getBlock().whatIsIt() == WorldBlock::JUNCT ) { wb_point.setX( route->getSections()[index-1].getBlock().getJunction().getPosX() ); wb_point.setY( route->getSections()[index-1].getBlock().getJunction().getPosY() ); } QLineF line1( wb_point, track->start_points[railIndex] ); QLineF line2( wb_point, track->end_points[railIndex] ); if( line1.length() < line2.length() ) { start_point = track->start_points[railIndex]; end_point = track->end_points[railIndex]; } else { start_point = track->end_points[railIndex]; end_point = track->start_points[railIndex]; } line.setLine( start_point.x(), start_point.y(), end_point.x(), end_point.y() ); qreal dx = end_point.x() - start_point.x(); qreal dy = end_point.y() - start_point.y(); move_duration += move_part; if( move_duration >= 1 ) return; else moveBy( dx * move_part, dy * move_part ); }
void PlaneRegistration::local_probing(){ fk_solver_->JntToCart( jnt_pos_, tip_frame_ ); Eigen::Vector3d start_point( startPoint(0), startPoint(1), startPoint(2) ); Eigen::Vector3d curr_point( tip_frame_.p[0], tip_frame_.p[1], tip_frame_.p[2] ); // cutter moving in the first straight line, estimate the first vector if ( ptsloc == 1 ){ plane_vec_1 = estimate_trj_unit_vector( start_point, curr_point, unit_vector_history_1 ); ptsloclast = 1; } // resetting start point when moving from direction 1 to direction 2 if ( ptsloc == -1 ){ reset_start_point = 1; } // cutter moving in another direction, estimate the second vector if ( ptsloc == 2 ){ plane_vec_2 = estimate_trj_unit_vector( start_point, curr_point, unit_vector_history_2 ); ptsloclast = 2; } // finished collecting two vectors on plane, calculate the normal if ( ptsloc == 3 ){ Eigen::Vector3d normal; normal = plane_vec_1.cross( plane_vec_2 ); // make sure the reported normal makes an angle < 90 degrees with the cutter z axis Eigen::Vector3d tipZ( tip_frame_.M.UnitZ()[0], tip_frame_.M.UnitZ()[1], tip_frame_.M.UnitZ()[2] ); if ( normal.dot( tipZ ) < 0 ){ normal = -normal; } Eigen::Vector3d unit_normal = normal / normal.norm(); std::cout << "est. Normal: "<< std::endl; std::cout << unit_normal <<std::endl; local_probing_est.x = unit_normal(0); local_probing_est.y = unit_normal(1); local_probing_est.z = unit_normal(2); pub_local_probing_normal_est_.publish( local_probing_est ); } }
t1_decoder_parse_charstrings( T1_Decoder decoder, FT_Byte* charstring_base, FT_UInt charstring_len ) { FT_Error error; T1_Decoder_Zone zone; FT_Byte* ip; FT_Byte* limit; T1_Builder builder = &decoder->builder; FT_Pos x, y, orig_x, orig_y; T1_Hints_Funcs hinter; /* we don't want to touch the source code -- use macro trick */ #define start_point t1_builder_start_point #define check_points t1_builder_check_points #define add_point t1_builder_add_point #define add_point1 t1_builder_add_point1 #define add_contour t1_builder_add_contour #define close_contour t1_builder_close_contour /* First of all, initialize the decoder */ decoder->top = decoder->stack; decoder->zone = decoder->zones; zone = decoder->zones; builder->parse_state = T1_Parse_Start; hinter = (T1_Hints_Funcs)builder->hints_funcs; zone->base = charstring_base; limit = zone->limit = charstring_base + charstring_len; ip = zone->cursor = zone->base; error = PSaux_Err_Ok; x = orig_x = builder->pos_x; y = orig_y = builder->pos_y; /* begin hints recording session, if any */ if ( hinter ) hinter->open( hinter->hints ); /* now, execute loop */ while ( ip < limit ) { FT_Long* top = decoder->top; T1_Operator op = op_none; FT_Long value = 0; /*********************************************************************/ /* */ /* Decode operator or operand */ /* */ /* */ /* first of all, decompress operator or value */ switch ( *ip++ ) { case 1: op = op_hstem; break; case 3: op = op_vstem; break; case 4: op = op_vmoveto; break; case 5: op = op_rlineto; break; case 6: op = op_hlineto; break; case 7: op = op_vlineto; break; case 8: op = op_rrcurveto; break; case 9: op = op_closepath; break; case 10: op = op_callsubr; break; case 11: op = op_return; break; case 13: op = op_hsbw; break; case 14: op = op_endchar; break; case 15: /* undocumented, obsolete operator */ op = op_none; break; case 21: op = op_rmoveto; break; case 22: op = op_hmoveto; break; case 30: op = op_vhcurveto; break; case 31: op = op_hvcurveto; break; case 12: if ( ip > limit ) { FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid escape (12+EOF)\n" )); goto Syntax_Error; } switch ( *ip++ ) { case 0: op = op_dotsection; break; case 1: op = op_vstem3; break; case 2: op = op_hstem3; break; case 6: op = op_seac; break; case 7: op = op_sbw; break; case 12: op = op_div; break; case 16: op = op_callothersubr; break; case 17: op = op_pop; break; case 33: op = op_setcurrentpoint; break; default: FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid escape (12+%d)\n", ip[-1] )); goto Syntax_Error; } break; case 255: /* four bytes integer */ if ( ip + 4 > limit ) { FT_ERROR(( "t1_decoder_parse_charstrings: " "unexpected EOF in integer\n" )); goto Syntax_Error; } value = (FT_Int32)( ((FT_Long)ip[0] << 24) | ((FT_Long)ip[1] << 16) | ((FT_Long)ip[2] << 8 ) | ip[3] ); ip += 4; break; default: if ( ip[-1] >= 32 ) { if ( ip[-1] < 247 ) value = (FT_Long)ip[-1] - 139; else { if ( ++ip > limit ) { FT_ERROR(( "t1_decoder_parse_charstrings: " )); FT_ERROR(( "unexpected EOF in integer\n" )); goto Syntax_Error; } if ( ip[-2] < 251 ) value = ( ( (FT_Long)ip[-2] - 247 ) << 8 ) + ip[-1] + 108; else value = -( ( ( (FT_Long)ip[-2] - 251 ) << 8 ) + ip[-1] + 108 ); } } else { FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid byte (%d)\n", ip[-1] )); goto Syntax_Error; } } /*********************************************************************/ /* */ /* Push value on stack, or process operator */ /* */ /* */ if ( op == op_none ) { if ( top - decoder->stack >= T1_MAX_CHARSTRINGS_OPERANDS ) { FT_ERROR(( "t1_decoder_parse_charstrings: stack overflow!\n" )); goto Syntax_Error; } FT_TRACE4(( " %ld", value )); *top++ = value; decoder->top = top; } else if ( op == op_callothersubr ) /* callothersubr */ { FT_TRACE4(( " callothersubr" )); if ( top - decoder->stack < 2 ) goto Stack_Underflow; top -= 2; switch ( (FT_Int)top[1] ) { case 1: /* start flex feature */ if ( top[0] != 0 ) goto Unexpected_OtherSubr; decoder->flex_state = 1; decoder->num_flex_vectors = 0; if ( start_point( builder, x, y ) || check_points( builder, 6 ) ) goto Fail; break; case 2: /* add flex vectors */ { FT_Int idx; if ( top[0] != 0 ) goto Unexpected_OtherSubr; /* note that we should not add a point for index 0; */ /* this will move our current position to the flex */ /* point without adding any point to the outline */ idx = decoder->num_flex_vectors++; if ( idx > 0 && idx < 7 ) add_point( builder, x, y, (FT_Byte)( idx == 3 || idx == 6 ) ); } break; case 0: /* end flex feature */ if ( top[0] != 3 ) goto Unexpected_OtherSubr; if ( decoder->flex_state == 0 || decoder->num_flex_vectors != 7 ) { FT_ERROR(( "t1_decoder_parse_charstrings: " "unexpected flex end\n" )); goto Syntax_Error; } /* now consume the remaining `pop pop setcurpoint' */ if ( ip + 6 > limit || ip[0] != 12 || ip[1] != 17 || /* pop */ ip[2] != 12 || ip[3] != 17 || /* pop */ ip[4] != 12 || ip[5] != 33 ) /* setcurpoint */ { FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid flex charstring\n" )); goto Syntax_Error; } ip += 6; decoder->flex_state = 0; break; case 3: /* change hints */ if ( top[0] != 1 ) goto Unexpected_OtherSubr; /* eat the following `pop' */ if ( ip + 2 > limit ) { FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid escape (12+%d)\n", ip[-1] )); goto Syntax_Error; } if ( ip[0] != 12 || ip[1] != 17 ) { FT_ERROR(( "t1_decoder_parse_charstrings: " )); FT_ERROR(( "`pop' expected, found (%d %d)\n", ip[0], ip[1] )); goto Syntax_Error; } ip += 2; if ( hinter ) hinter->reset( hinter->hints, builder->current->n_points ); break; case 12: case 13: /* counter control hints, clear stack */ top = decoder->stack; break; case 14: case 15: case 16: case 17: case 18: /* multiple masters */ { PS_Blend blend = decoder->blend; FT_UInt num_points, nn, mm; FT_Long* delta; FT_Long* values; if ( !blend ) { FT_ERROR(( "t1_decoder_parse_charstrings: " )); FT_ERROR(( "unexpected multiple masters operator!\n" )); goto Syntax_Error; } num_points = (FT_UInt)top[1] - 13 + ( top[1] == 18 ); if ( top[0] != (FT_Int)( num_points * blend->num_designs ) ) { FT_ERROR(( "t1_decoder_parse_charstrings: " )); FT_ERROR(( "incorrect number of mm arguments\n" )); goto Syntax_Error; } top -= blend->num_designs * num_points; if ( top < decoder->stack ) goto Stack_Underflow; /* we want to compute: */ /* */ /* a0*w0 + a1*w1 + ... + ak*wk */ /* */ /* but we only have the a0, a1-a0, a2-a0, .. ak-a0 */ /* however, given that w0 + w1 + ... + wk == 1, we can */ /* rewrite it easily as: */ /* */ /* a0 + (a1-a0)*w1 + (a2-a0)*w2 + .. + (ak-a0)*wk */ /* */ /* where k == num_designs-1 */ /* */ /* I guess that's why it's written in this `compact' */ /* form. */ /* */ delta = top + num_points; values = top; for ( nn = 0; nn < num_points; nn++ ) { FT_Long tmp = values[0]; for ( mm = 1; mm < blend->num_designs; mm++ ) tmp += FT_MulFix( *delta++, blend->weight_vector[mm] ); *values++ = tmp; } /* note that `top' will be incremented later by calls to `pop' */ break; } default: Unexpected_OtherSubr: FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid othersubr [%d %d]!\n", top[0], top[1] )); goto Syntax_Error; } decoder->top = top; } else /* general operator */ { FT_Int num_args = t1_args_count[op]; if ( top - decoder->stack < num_args ) goto Stack_Underflow; top -= num_args; switch ( op ) { case op_endchar: FT_TRACE4(( " endchar" )); close_contour( builder ); /* close hints recording session */ if ( hinter ) { if (hinter->close( hinter->hints, builder->current->n_points )) goto Syntax_Error; /* apply hints to the loaded glyph outline now */ hinter->apply( hinter->hints, builder->current, (PSH_Globals) builder->hints_globals, decoder->hint_mode ); } /* add current outline to the glyph slot */ FT_GlyphLoader_Add( builder->loader ); /* return now! */ FT_TRACE4(( "\n\n" )); return PSaux_Err_Ok; case op_hsbw: FT_TRACE4(( " hsbw" )); builder->parse_state = T1_Parse_Have_Width; builder->left_bearing.x += top[0]; builder->advance.x = top[1]; builder->advance.y = 0; orig_x = builder->last.x = x = builder->pos_x + top[0]; orig_y = builder->last.y = y = builder->pos_y; FT_UNUSED( orig_y ); /* the `metrics_only' indicates that we only want to compute */ /* the glyph's metrics (lsb + advance width), not load the */ /* rest of it; so exit immediately */ if ( builder->metrics_only ) return PSaux_Err_Ok; break; case op_seac: /* return immediately after the processing */ return t1operator_seac( decoder, top[0], top[1], top[2], (FT_Int)top[3], (FT_Int)top[4] ); case op_sbw: FT_TRACE4(( " sbw" )); builder->parse_state = T1_Parse_Have_Width; builder->left_bearing.x += top[0]; builder->left_bearing.y += top[1]; builder->advance.x = top[2]; builder->advance.y = top[3]; builder->last.x = x = builder->pos_x + top[0]; builder->last.y = y = builder->pos_y + top[1]; /* the `metrics_only' indicates that we only want to compute */ /* the glyph's metrics (lsb + advance width), not load the */ /* rest of it; so exit immediately */ if ( builder->metrics_only ) return PSaux_Err_Ok; break; case op_closepath: FT_TRACE4(( " closepath" )); close_contour( builder ); if ( !( builder->parse_state == T1_Parse_Have_Path || builder->parse_state == T1_Parse_Have_Moveto ) ) goto Syntax_Error; builder->parse_state = T1_Parse_Have_Width; break; case op_hlineto: FT_TRACE4(( " hlineto" )); if ( start_point( builder, x, y ) ) goto Fail; x += top[0]; goto Add_Line; case op_hmoveto: FT_TRACE4(( " hmoveto" )); x += top[0]; if ( !decoder->flex_state ) { if ( builder->parse_state == T1_Parse_Start ) goto Syntax_Error; builder->parse_state = T1_Parse_Have_Moveto; } break; case op_hvcurveto: FT_TRACE4(( " hvcurveto" )); if ( start_point( builder, x, y ) || check_points( builder, 3 ) ) goto Fail; x += top[0]; add_point( builder, x, y, 0 ); x += top[1]; y += top[2]; add_point( builder, x, y, 0 ); y += top[3]; add_point( builder, x, y, 1 ); break; case op_rlineto: FT_TRACE4(( " rlineto" )); if ( start_point( builder, x, y ) ) goto Fail; x += top[0]; y += top[1]; Add_Line: if ( add_point1( builder, x, y ) ) goto Fail; break; case op_rmoveto: FT_TRACE4(( " rmoveto" )); x += top[0]; y += top[1]; if ( !decoder->flex_state ) { if ( builder->parse_state == T1_Parse_Start ) goto Syntax_Error; builder->parse_state = T1_Parse_Have_Moveto; } break; case op_rrcurveto: FT_TRACE4(( " rcurveto" )); if ( start_point( builder, x, y ) || check_points( builder, 3 ) ) goto Fail; x += top[0]; y += top[1]; add_point( builder, x, y, 0 ); x += top[2]; y += top[3]; add_point( builder, x, y, 0 ); x += top[4]; y += top[5]; add_point( builder, x, y, 1 ); break; case op_vhcurveto: FT_TRACE4(( " vhcurveto" )); if ( start_point( builder, x, y ) || check_points( builder, 3 ) ) goto Fail; y += top[0]; add_point( builder, x, y, 0 ); x += top[1]; y += top[2]; add_point( builder, x, y, 0 ); x += top[3]; add_point( builder, x, y, 1 ); break; case op_vlineto: FT_TRACE4(( " vlineto" )); if ( start_point( builder, x, y ) ) goto Fail; y += top[0]; goto Add_Line; case op_vmoveto: FT_TRACE4(( " vmoveto" )); y += top[0]; if ( !decoder->flex_state ) { if ( builder->parse_state == T1_Parse_Start ) goto Syntax_Error; builder->parse_state = T1_Parse_Have_Moveto; } break; case op_div: FT_TRACE4(( " div" )); if ( top[1] ) { *top = top[0] / top[1]; ++top; } else { FT_ERROR(( "t1_decoder_parse_charstrings: division by 0\n" )); goto Syntax_Error; } break; case op_callsubr: { FT_Int idx; FT_TRACE4(( " callsubr" )); idx = (FT_Int)top[0]; if ( idx < 0 || idx >= (FT_Int)decoder->num_subrs ) { FT_ERROR(( "t1_decoder_parse_charstrings: " "invalid subrs index\n" )); goto Syntax_Error; } if ( zone - decoder->zones >= T1_MAX_SUBRS_CALLS ) { FT_ERROR(( "t1_decoder_parse_charstrings: " "too many nested subrs\n" )); goto Syntax_Error; } zone->cursor = ip; /* save current instruction pointer */ zone++; /* The Type 1 driver stores subroutines without the seed bytes. */ /* The CID driver stores subroutines with seed bytes. This */ /* case is taken care of when decoder->subrs_len == 0. */ zone->base = decoder->subrs[idx]; if ( decoder->subrs_len ) zone->limit = zone->base + decoder->subrs_len[idx]; else { /* We are using subroutines from a CID font. We must adjust */ /* for the seed bytes. */ zone->base += ( decoder->lenIV >= 0 ? decoder->lenIV : 0 ); zone->limit = decoder->subrs[idx + 1]; } zone->cursor = zone->base; if ( !zone->base ) { FT_ERROR(( "t1_decoder_parse_charstrings: " "invoking empty subrs!\n" )); goto Syntax_Error; } decoder->zone = zone; ip = zone->base; limit = zone->limit; break; } case op_pop: FT_TRACE4(( " pop" )); /* theoretically, the arguments are already on the stack */ top++; break; case op_return: FT_TRACE4(( " return" )); if ( zone <= decoder->zones ) { FT_ERROR(( "t1_decoder_parse_charstrings: unexpected return\n" )); goto Syntax_Error; } zone--; ip = zone->cursor; limit = zone->limit; decoder->zone = zone; break; case op_dotsection: FT_TRACE4(( " dotsection" )); break; case op_hstem: FT_TRACE4(( " hstem" )); /* record horizontal hint */ if ( hinter ) { /* top[0] += builder->left_bearing.y; */ hinter->stem( hinter->hints, 1, top ); } break; case op_hstem3: FT_TRACE4(( " hstem3" )); /* record horizontal counter-controlled hints */ if ( hinter ) hinter->stem3( hinter->hints, 1, top ); break; case op_vstem: FT_TRACE4(( " vstem" )); /* record vertical hint */ if ( hinter ) { top[0] += orig_x; hinter->stem( hinter->hints, 0, top ); } break; case op_vstem3: FT_TRACE4(( " vstem3" )); /* record vertical counter-controlled hints */ if ( hinter ) { FT_Pos dx = orig_x; top[0] += dx; top[2] += dx; top[4] += dx; hinter->stem3( hinter->hints, 0, top ); } break; case op_setcurrentpoint: FT_TRACE4(( " setcurrentpoint" )); FT_ERROR(( "t1_decoder_parse_charstrings: " )); FT_ERROR(( "unexpected `setcurrentpoint'\n" )); goto Syntax_Error; default: FT_ERROR(( "t1_decoder_parse_charstrings: " "unhandled opcode %d\n", op )); goto Syntax_Error; } decoder->top = top; } /* general operator processing */ } /* while ip < limit */ FT_TRACE4(( "..end..\n\n" )); Fail: return error; Syntax_Error: return PSaux_Err_Syntax_Error; Stack_Underflow: return PSaux_Err_Stack_Underflow; }
bool Parameters::DrawResults(QPainter &painter, QRect &free_rect ) const { QFont title_font = painter.font(); title_font.setFamily("Arial"); title_font.setPointSize(14); QFont text_font = title_font; text_font.setPointSize( 12 ); auto DrawRowCenter = [ &painter, &free_rect ]( QFont font, QColor color, QString text, double spase = 1 ) { painter.save(); QFontMetrics metrix( font ); QRect place; AllocatePlace( place, metrix.height()*spase ,free_rect ); QPoint start_point( place.center().x() - metrix.width( text ) / 2, place.center().y() +metrix.height()/2); painter.setFont( font ); painter.setPen( color ); painter.drawText( start_point, text ); painter.restore(); }; auto DrawRowCenter2 = [ &painter, &free_rect ]( QFont font, QColor color, QString text, QColor color2, QString text2, double spase = 1 ) { painter.save(); QFontMetrics metrix( font ); QRect place; AllocatePlace( place, metrix.height()*spase ,free_rect ); QPoint start_point( place.center().x() - ( metrix.width( text ) + metrix.width( text2 ) ) / 2, place.center().y() +metrix.height()/2); QPoint start_point2( start_point.x() + metrix.width(text), start_point.y() ); painter.setFont( font ); painter.setPen( color ); painter.drawText( start_point, text ); painter.setPen( color2 ); painter.drawText( start_point2, text2 ); painter.restore(); }; auto DrawRowLeft = [ &painter, &free_rect ]( QFont font, QColor color1, QString label, double spase = 1 ) { painter.save(); QFontMetrics metrix( font ); QRect place; AllocatePlace( place, metrix.height()*spase, free_rect ); QPoint start_point( place.left() , place.center().y()+metrix.height()/2 ); painter.setFont( font ); painter.setPen( color1 ); painter.drawText( start_point, label ); painter.restore(); }; auto DrawRowLeft3 = [ &painter, &free_rect ]( QFont const& font, QColor const& color1, QString const& label, QColor const& color2 = Qt::black, QString const& value = "", QColor const& color3 = Qt::black, QString const& value2 = "", double spase = 1) { painter.save(); QFontMetrics metrix( font ); QRect place; AllocatePlace( place, metrix.height()*spase, free_rect ); QPoint start_point( place.left() , place.center().y()+metrix.height()/2 ); QPoint start_point2( start_point.x() + metrix.width(label), place.center().y() +metrix.height()/2); QPoint start_point3( start_point2.x() + metrix.width(value), place.center().y() +metrix.height()/2); painter.setFont( font ); painter.setPen( color1 ); painter.drawText( start_point, label ); painter.setPen( color2 ); painter.drawText( start_point2, value ); painter.setPen( color3 ); painter.drawText( start_point3, value2 ); painter.restore(); }; DrawRowCenter( title_font, Qt::black, "", 7 ); DrawRowCenter( title_font, Qt::black, "Результаты испытаний", 1 ); DrawRowCenter2( title_font, Qt::black, "дискретного аппарата ", Qt::red, mGsType, 2 ); QString header = "<html>" "<head>" "<meta charset='utf-8'>" "<style type='text/css'>" "td { text-align: center;}" "th { font-weight: normal; padding: 2px;}" "table {border-collapse: collapse; border-style: solid; vertical-align:middle;}" "</style>" "</head>" "<body>" "<table width='100%' border='1.5' cellspacing='-0.5' cellpadding='-0.5'>" "<tr>" "<th> Номер </th>" "<th></th>" "<th> Работоспособность </th>" "</tr>"; QString footer = "</table>" "</body>" "</html>"; bool sucsess = true; QString row; for ( auto it = mTestCase.begin(), end = mTestCase.end(); it != end; ++it ) { Test* ptr = *it; row += "<tr>" "<td>"+test::ToString( ptr->Number() )+"</td>" "<td>"+ QString(ptr->Name()).replace("\n","<br>") +"</td>" "<td style='font-size:28pt; color: \"red\"; font-weight:bold;'>"+ (ptr->Success() ? QString("+"):QString("-")) +"</td>" "</tr>"; sucsess &= ptr->Success(); } QTextDocument doc; doc.setUndoRedoEnabled( false ); doc.setTextWidth( free_rect.width() ); doc.setUseDesignMetrics( true ); doc.setDefaultTextOption ( QTextOption (Qt::AlignHCenter ) ); doc.setHtml( header + row + footer ); auto h = doc.documentLayout()->documentSize().height(); QRect place; AllocatePlace( place, h ,free_rect ); QRectF r( 0, 0, place.width(), place.height() ); painter.save(); painter.translate( place.topLeft() ); doc.drawContents( &painter, r); painter.restore(); DrawRowLeft( text_font, Qt::black, "ИТОГ:", 3 ); DrawRowLeft3( text_font, Qt::black, "Гидроаппарат ", Qt::red, mGsType + (sucsess? " годен": " не годен"), Qt::black, " к эксплуатации", 1 ); return true; }
bool Parameters::Draw(QPainter &painter, QRect &free_rect, QString const& compare_width ) const { QFont title_font = painter.font(); title_font.setFamily("Arial"); title_font.setPointSize(18); QFont level_font = title_font; level_font.setPointSize( 14 ); QFont text_font = title_font; text_font.setPointSize( 12 ); auto DrawRowCenter = [ &painter, &free_rect ]( QFont font, QColor color, QString text, double spase = 1 ) { painter.save(); QFontMetrics metrix( font ); QRect place; AllocatePlace( place, metrix.height()*spase ,free_rect ); QPoint start_point( place.center().x() - metrix.width( text ) / 2, place.center().y() +metrix.height()/2); painter.setFont( font ); painter.setPen( color ); painter.drawText( start_point, text ); painter.restore(); }; auto DrawRowCenter2 = [ &painter, &free_rect ]( QFont font, QColor color, QString text, QColor color2, QString text2, double spase = 1 ) { painter.save(); QFontMetrics metrix( font ); QRect place; AllocatePlace( place, metrix.height()*spase ,free_rect ); QPoint start_point( place.center().x() - metrix.width( text + text2 ) / 2, place.center().y() +metrix.height()/2); painter.setFont( font ); painter.setPen( color ); painter.drawText( start_point, text ); QPoint start_point2( place.center().x() - metrix.width( text + text2 ) / 2 + metrix.width( text ) , place.center().y() +metrix.height()/2); painter.setPen( color2 ); painter.drawText( start_point2, text2 ); painter.restore(); }; auto DrawRowLeft = [ &painter, &free_rect ]( QFont font, QColor color1, QColor color2, QString label, QString value, QString value2 = "", double spase = 1 ) { painter.save(); QFontMetrics metrix( font ); QRect place; AllocatePlace( place, metrix.height()*spase, free_rect ); QPoint start_point( place.left() , place.center().y()+metrix.height()/2 ); QPoint start_point2( place.left() + metrix.width(label), place.center().y() +metrix.height()/2); QPoint start_point3( place.left() + metrix.width(label + value), place.center().y() +metrix.height()/2); painter.setFont( font ); painter.setPen( color1 ); painter.drawText( start_point, label ); painter.setPen( color2 ); painter.drawText( start_point2, value ); painter.setPen( Qt::gray ); painter.drawText( start_point3, value2 ); painter.restore(); }; auto DrawLastRow = [ &painter, &free_rect ]( QFont font, QColor color, QString text, double spase = 1 ) { painter.save(); QFontMetrics metrix( font ); QRect place; QRect draw_place; while ( AllocatePlace( place, metrix.height()*spase ,free_rect ) ) { draw_place = place; } QPoint start_point( place.left() , place.center().y()+metrix.height()/2 ); painter.setFont( font ); painter.setPen( color ); painter.drawText( start_point, text ); painter.restore(); }; QFontMetrics m(text_font); int width = m.width("12345678901234567890123456789012345678901234567890"); char symbol = '.'; auto FillToSize = [ width, &m, symbol ]( QString text ) { while( m.width( text + symbol ) < width ) text += symbol; return text + " "; }; double row_skale = 2; DrawRowCenter2( title_font, Qt::black, "ОТЧЕТ", Qt::red, " ( " + mReportType + " ) ", row_skale); DrawRowCenter( level_font, Qt::black, "Испытания дискретного аппарата", row_skale ); DrawRowCenter( level_font, Qt::red, mGsType, row_skale ); DrawRowLeft( text_font, Qt::black, Qt::red, "Идентификационный номер: ", mSerNo, "", row_skale); test::hydro::Parameters old; QJsonObject f = test::ReadFromFile( compare_width ).value("Params").toObject(); old.Deserialize( f ); QString str_e_wp = !compare_width.isEmpty() ? " (" +test::ToString(old.MaxWorkPressure()) + ")" : QString(); QString str_e_exp = !compare_width.isEmpty() ? " (" +test::ToString(old.MaxExpenditure()) + ")" : QString(); QString str_e_mxcp = !compare_width.isEmpty() ? ( old.ControlType() != CT_ELECTRIC ? " (" +test::ToString(old.MaxControlPressure()) + ")" : "( - )" ) : QString(); QString str_e_mncp = !compare_width.isEmpty() ? ( old.ControlType() != CT_ELECTRIC ? " (" +test::ToString(old.MinControlPressure()) + ")" : "( - )" ) : QString(); QString str_e_vt = !compare_width.isEmpty() ? " (" +test::ToString(old.Voltage()) + ")" : QString(); DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Максимальное давление, бар"), test::ToString( mMaxWorkPressure ),str_e_wp, row_skale ); DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Максимальный расход, л/мин"), test::ToString( mMaxExpenditure ), str_e_exp,row_skale ); if ( mControlType == CT_ELECTRIC ) { DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Максимальное давление управления*, бар"), "-", str_e_mxcp, row_skale ); DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Минимальное давление управления*, бар"), "-", str_e_mncp, row_skale ); } else { DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Максимальное давление управления*, бар"), test::ToString(mMaxControlPressure), str_e_mxcp, row_skale ); DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Минимальное давление управления*, бар"), test::ToString(mMinControlPressure), str_e_mncp, row_skale ); } DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Напряжение пинания, В"), "="+test::ToString( mVoltage )+" (~220)",str_e_vt, row_skale ); DrawRowLeft( text_font, Qt::black, Qt::black, FillToSize("Тонкость фильтрации рабочей жидкости, мкм"), "________", "", row_skale ); DrawRowLeft( text_font, Qt::black, Qt::black, FillToSize("Тип масла"), "Лукой Гейзер HLP32", "", row_skale ); DrawRowLeft( text_font, Qt::black, Qt::black, FillToSize("Вязкость масла (при 40˚С), сСт"), test::ToString(32), "", row_skale ); if ( !compare_width.isEmpty() ) { DrawRowLeft( text_font, Qt::black, Qt::red, "Аппарат для сравнения характеристик: ", "", "", row_skale ); DrawRowLeft( text_font, Qt::black, Qt::red, "", old.SerNo(), "", row_skale ); DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Дата испытания сравниваемого аппарата"), old.Date().toString("dd MMMM yyyy г. hh:mm"), "", row_skale ); DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Сравнение с эталоном"), old.ReportType().compare("Эталон", Qt::CaseInsensitive) == 0? "Да": "Нет", "", row_skale ); } else { DrawRowLeft( text_font, Qt::black, Qt::red, "Аппарат для сравнения характеристик: ", "-", "", row_skale ); DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Дата испытания сравниваемого аппарата"), "-", "", row_skale ); DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Сравнение с эталоном"), "-", "", row_skale ); } DrawRowLeft( text_font, Qt::black, Qt::red, FillToSize("Класс чистоты жидкости (по ISO 4406)"), "________", "", row_skale ); DrawRowCenter( text_font, Qt::black, "", row_skale ); DrawRowLeft( text_font, Qt::black, Qt::red, "Испытания проводил: ", mUser, "", row_skale ); DrawRowLeft( text_font, Qt::black, Qt::red, "Дата проведения испытаний: ", mDate.toString("dd MMMM yyyy г. hh:mm"), "", row_skale ); DrawLastRow( text_font, Qt::black, "*Для распределителей с электрогидравлическим управлением"); return true; }
bool FunctionalTest::Draw(QPainter& painter, QRect &free_rect , const QString &) const { test::hydro_cylinder::Parameters *params = static_cast< test::hydro_cylinder::Parameters * >( CURRENT_PARAMS ); if ( !params ) return true; QFont header_font = painter.font(); header_font.setFamily("Arial"); header_font.setPointSize( 14 ); QFont result_font = header_font; result_font.setUnderline(true); QFont text_font = header_font; text_font.setPointSize( 12 ); auto DrawRowCenter = [ &painter, &free_rect ](QRect const& place, QFont const& font, QColor const& color, QString const& text ) { painter.save(); QFontMetrics metrix( font ); QPoint start_point( place.center().x() - metrix.width( text ) / 2, place.center().y() +metrix.height()/2); painter.setFont( font ); painter.setPen( color ); painter.drawText( start_point, text ); painter.restore(); }; auto DrawRowLeft = [ &painter, &free_rect ]( QRect const& place, QFont const& font, QColor const& color1, QString const& label, QColor const& color2 = Qt::black, QString const& value = "", QColor const& color3 = Qt::black, QString const& value2 = "") { painter.save(); QFontMetrics metrix( font ); QPoint start_point( place.left() , place.center().y()+metrix.height()/2 ); QPoint start_point2( start_point.x() + metrix.width(label), place.center().y() +metrix.height()/2); QPoint start_point3( start_point2.x() + metrix.width(value), place.center().y() +metrix.height()/2); painter.setFont( font ); painter.setPen( color1 ); painter.drawText( start_point, label ); painter.setPen( color2 ); painter.drawText( start_point2, value ); painter.setPen( color3 ); painter.drawText( start_point3, value2 ); painter.restore(); }; QFontMetrics m(text_font); int width = m.width("123456789012345678901234567890123456789012345"); char symbol = '.'; auto FillToSize = [ width, &m, symbol ]( QString text ) { while( m.width( text + symbol ) < width ) text += symbol; return text + " "; }; uint32_t num = 0; bool res = DrawLine( num, free_rect, result_font, [ this, &painter, &DrawRowCenter, &result_font ]( QRect const& rect ) { DrawRowCenter( rect, result_font, Qt::black, "Результаты испытаний" ); }, 2 ); res = DrawLine( num, free_rect, text_font, [ this, &painter, &DrawRowLeft, &FillToSize, &text_font ]( QRect const& rect ) { DrawRowLeft( rect, text_font, Qt::black, FillToSize("Температура масла во время испытаний, ˚С"), Qt::red, test::ToString(OilTemp) ); }, 2 ); QString header = "<html>" "<head>" "<meta charset='utf-8'>" "<style type='text/css'>" "td { text-align: center;}" "th { font-weight: normal; padding: 2px;}" "table {border-collapse: collapse; border-style: solid; vertical-align:middle;}" "</style>" "</head>" "<body>" "<table width='100%' border='1.5' cellspacing='-0.5' cellpadding='-0.5'>" "<tr>" "<th> Номер </th>" "<th></th>" "<th> Работоспособность </th>" "</tr>"; QString footer = "</table>" "</body>" "</html>"; typedef std::pair<QString, bool> Item; std::vector< Item > tests; tests.push_back( Item( "Наружная герметичность ", HermResult ) ); tests.push_back( Item( "Максимальное давление", MaxPressureResult ) ); tests.push_back( Item( "Рабочее давление", WorkPressureResult ) ); tests.push_back( Item( "Номинальный расход", ExpenditureResult ) ); tests.push_back( Item( "Время перемещения в одну сторону", MoveTimeResult ) ); QString rows; for ( size_t i = 1, end = tests.size(); i <= end; ++i ) { Item& data = tests[i-1]; rows += "<tr>" "<td>"+test::ToString( static_cast<int>(i) )+"</td>" "<td>"+ data.first +"</td>" "<td style='font-size:28pt; color: \"red\"; font-weight:bold;'>"+ (data.second ? QString("+"):QString("-")) +"</td>" "</tr>"; } QString table = header + rows + footer; QTextDocument doc; doc.setUndoRedoEnabled( false ); doc.setTextWidth( free_rect.width() ); doc.setUseDesignMetrics( true ); doc.setDefaultTextOption ( QTextOption (Qt::AlignHCenter ) ); doc.setHtml( table ); auto h = doc.documentLayout()->documentSize().height(); res = DrawLine( num, free_rect, text_font, [ this, &painter, &doc, &text_font ]( QRect const& rect ) { painter.save(); QRectF r( 0, 0, rect.width(), rect.height() ); painter.translate( rect.topLeft() ); doc.drawContents( &painter, r); painter.restore(); }, 1, h ); res = DrawLine( num, free_rect, header_font, [ this, &painter, &DrawRowLeft, &header_font ]( QRect const& rect ) { DrawRowLeft( rect, header_font, Qt::black, "ИТОГ:" ); }, 1.5 ); res = DrawLine( num, free_rect, text_font, [ this, &painter, &DrawRowLeft, &text_font, params ]( QRect const& rect ) { DrawRowLeft( rect, text_font, Qt::black, "Гидроцилиндр ", Qt::red, params->SerNo() + (Success()? QString(" годен ") : QString(" не годен ")), Qt::black, " к эксплуатации"); }, 3 ); return res; }
//! Default constructor. RowsStages::RowsStages(const IMC::Rows* maneuver, Tasks::Task* task) { // Setup offsets (without bearing rotation) m_man = *maneuver; // Save a pointer to the task to call debug message m_task = task; double curve_sign = curveRight() ? 1 : -1; double alt_frac_up = 0.01 * (double)m_man.alternation; double alt_frac_down = 2 - 0.01 * (double)m_man.alternation; m_stages.clear(); Stage approach("approach", -m_man.coff, 0); m_stages.push_back(approach); Stage start_point("start", m_man.coff, 0); m_stages.push_back(start_point); Stage up("up", m_man.length + m_man.coff, 0); m_stages.push_back(up); Stage up_curve("begin curve (up)", 0, curve_sign * alt_frac_up * m_man.hstep); Stage up_curve_end("end curve (up)", -m_man.coff, 0); if (!squareCurve()) { Angles::rotate(m_man.cross_angle, curveLeft(), up_curve.x, up_curve.y); up_curve.x -= m_man.coff; m_stages.push_back(up_curve); } else { Angles::rotate(m_man.cross_angle, curveLeft(), up_curve.x, up_curve.y); m_stages.push_back(up_curve); m_stages.push_back(up_curve_end); } Stage down("down", -up.x, 0); m_stages.push_back(down); Stage down_curve("begin curve (down)", 0, curve_sign * alt_frac_down * m_man.hstep); Stage down_curve_end("end curve (down)", -up_curve_end.x, 0); if (!squareCurve()) { Angles::rotate(m_man.cross_angle, curveLeft(), down_curve.x, down_curve.y); down_curve.x += m_man.coff; m_stages.push_back(down_curve); } else { Angles::rotate(m_man.cross_angle, curveLeft(), down_curve.x, down_curve.y); m_stages.push_back(down_curve); m_stages.push_back(down_curve_end); } if (m_task != NULL) { m_task->debug("-- row stages and offsets -- "); for (uint8_t i = 0; i < m_stages.size(); ++i) { m_task->debug("%s | %0.2f %0.2f", m_stages[i].label, m_stages[i].x, m_stages[i].y); } } // Other init m_curves = (int)std::floor(m_man.width / m_man.hstep); m_curr = 0; m_sabs = Stage("undefined", 0, 0); m_index = 0; }
static int start_enter(void) { int w = config_get_d(CONFIG_WIDTH); int h = config_get_d(CONFIG_HEIGHT); int id, jd, kd, ld; if ((id = gui_vstack(0))) { if ((jd = gui_harray(id))) { gui_label(jd, "Level", GUI_SML, GUI_ALL, gui_yel, gui_red); gui_filler(jd); gui_filler(jd); gui_start(jd, "Back", GUI_SML, START_BACK, 0); } if ((jd = gui_harray(id))) { shot_id = gui_image(jd, "shot-rlk/easy.png", 7 * w / 16, 7 * h / 16); if ((kd = gui_varray(jd))) { if ((ld = gui_harray(kd))) { gui_level(ld, "05", 5); gui_level(ld, "04", 4); gui_level(ld, "03", 3); gui_level(ld, "02", 2); gui_level(ld, "01", 1); } if ((ld = gui_harray(kd))) { gui_level(ld, "10", 10); gui_level(ld, "09", 9); gui_level(ld, "08", 8); gui_level(ld, "07", 7); gui_level(ld, "06", 6); } if ((ld = gui_harray(kd))) { gui_level(ld, "15", 15); gui_level(ld, "14", 14); gui_level(ld, "13", 13); gui_level(ld, "12", 12); gui_level(ld, "11", 11); } if ((ld = gui_harray(kd))) { gui_level(ld, "20", 20); gui_level(ld, "19", 19); gui_level(ld, "18", 18); gui_level(ld, "17", 17); gui_level(ld, "16", 16); } if ((ld = gui_harray(kd))) { gui_level(ld, "25", 25); gui_level(ld, "24", 24); gui_level(ld, "23", 23); gui_level(ld, "22", 22); gui_level(ld, "21", 21); } } } gui_space(id); if ((jd = gui_harray(id))) { gui_most_coins(jd, 3, 4); gui_best_times(jd, 3, 4); } gui_layout(id, 0, 0); set_most_coins(0, 3); set_best_times(0, 3); } start_point(id,80,396,0,0); return id; }
void MGRLBRep::draw_all1D( int coordinate, //indicates coordinate kind to draw. bool t_is_x, //=true: t is x coordinate, and false:t is y. int kfunc, //Kind of function move and line, //1:move(int,int), 2:move(float, float), otherwise:move(double,double). int (*moveto)(...), int (*lineto)(...), const double wind[4], //window box to draw the line in. size_t ynum)const//Resolution of the line. { assert(size_t(coordinate)<sdim()); unsigned n=bdim(), k=order(), wid=sdim(); const double* rcoef[2]={ rcoef[0]=m_line.m_line_bcoef.data(0,coordinate), rcoef[1]=m_line.m_line_bcoef.data(0,wid) }; const double* knotp=m_line.m_knot_vector.data(); double* work=new double[k*k+3*k]; double ts,te,x,y; std::vector<double> pvector; int nrw; if(wind[2]>0.){//If clipping is necessary. double xwin[2], ywin[2]; double xw=wind[2], yw=wind[3]; double error=MGTolerance::rc_zero(); double xerror=xw*error, yerror=yw*error; xw*=0.5; yw*=0.5; xwin[0]=wind[0]-xw+xerror; xwin[1]=wind[0]+xw-xerror; ywin[0]=wind[1]-yw+yerror; ywin[1]=wind[1]+yw-yerror; if(kfunc==1){ xwin[0]+=0.6; xwin[1]-=0.6; ywin[0]+=0.6; ywin[1]-=0.6;} //xwin[] , ywin[] are window coordinates. MGVector P=start_point(); ts=param_s(); y=P[coordinate]; if(t_is_x) x=ts; else{x=y; y=ts;} if(xwin[0]<=x && x<=xwin[1] && ywin[0]<=y && y<=ywin[1]) pvector.push_back(ts); MGCParam_list plist; MGCParam_list::Citerator i, ie; if(t_is_x) plist=isect_1D(ywin[0],coordinate); else plist=isect_1D(xwin[0],coordinate); ie=plist.end(); for(i=plist.begin(); i!=ie; i++) pvector.push_back(*i); if(t_is_x) plist=isect_1D(ywin[1],coordinate); else plist=isect_1D(xwin[1],coordinate); ie=plist.end(); for(i=plist.begin(); i!=ie; i++) pvector.push_back(*i); te=param_e(); if(t_is_x){ if(ts<xwin[0] && xwin[0]<te) pvector.push_back(xwin[0]); if(ts<xwin[1] && xwin[1]<te) pvector.push_back(xwin[1]); }else{ if(ts<ywin[0] && ywin[0]<te) pvector.push_back(xwin[0]); if(ts<ywin[1] && ywin[1]<te) pvector.push_back(xwin[1]); } P=end_point(); y=P[coordinate]; if(t_is_x) x=te; else{x=y; y=te;} if(xwin[0]<=x && x<=xwin[1] && ywin[0]<=y && y<=ywin[1]) pvector.push_back(ts); //*** sort the parameter value array. std::vector<double>::iterator vi=pvector.begin(), ve=pvector.end(); std::sort(vi,ve); nrw=pvector.size(); }else{ pvector=std::vector<double>(2); pvector[0]=param_s(); pvector[1]=param_e(); nrw=2; } double* isparam=&(pvector[0]); int klin; if(t_is_x) klin=1; else klin=2; bldrwcr_(kfunc,(S_fp)moveto,(S_fp)lineto,ynum,wind,nrw,isparam,klin, k,n,knotp,rcoef,work); delete[] work; }