diff options
| author | Kris De Gussem <kris.degussem@gmail.com> | 2012-03-07 17:19:18 +0000 |
|---|---|---|
| committer | Kris <Kris.De.Gussem@hotmail.com> | 2012-03-07 17:19:18 +0000 |
| commit | 2eb76fb0bd4b8572866d3c2390eaa82747890292 (patch) | |
| tree | 673eb8fdedd2cc54fd48347fb59cc5e1e20f8508 /src | |
| parent | Translations. Greek translation update by Dimitris Spingos. (diff) | |
| download | inkscape-2eb76fb0bd4b8572866d3c2390eaa82747890292.tar.gz inkscape-2eb76fb0bd4b8572866d3c2390eaa82747890292.zip | |
cppcheck
(bzr r11052)
Diffstat (limited to 'src')
| -rw-r--r-- | src/bind/dobinding.cpp | 10 | ||||
| -rw-r--r-- | src/bind/javabind.cpp | 2 | ||||
| -rw-r--r-- | src/document.cpp | 8 | ||||
| -rw-r--r-- | src/extension/dxf2svg/entities.cpp | 1367 | ||||
| -rw-r--r-- | src/extension/dxf2svg/entities.h | 370 | ||||
| -rw-r--r-- | src/extension/internal/javafx-out.cpp | 13 | ||||
| -rw-r--r-- | src/extension/internal/javafx-out.h | 4 | ||||
| -rw-r--r-- | src/gradient-chemistry.cpp | 10 | ||||
| -rw-r--r-- | src/line-snapper.cpp | 4 | ||||
| -rw-r--r-- | src/pencil-context.cpp | 2 | ||||
| -rw-r--r-- | src/snap-candidate.h | 9 | ||||
| -rw-r--r-- | src/snapped-line.cpp | 4 | ||||
| -rw-r--r-- | src/sp-gradient.cpp | 4 | ||||
| -rw-r--r-- | src/svg-view-widget.cpp | 2 | ||||
| -rw-r--r-- | src/svg/svg-path.cpp | 2 | ||||
| -rw-r--r-- | src/trace/potrace/decompose.cpp | 7 | ||||
| -rw-r--r-- | src/trace/potrace/greymap.cpp | 4 | ||||
| -rw-r--r-- | src/trace/potrace/progress.h | 4 | ||||
| -rw-r--r-- | src/ui/dialog/icon-preview.cpp | 2 | ||||
| -rw-r--r-- | src/ui/dialog/object-attributes.cpp | 6 | ||||
| -rw-r--r-- | src/ui/dialog/svg-fonts-dialog.cpp | 24 | ||||
| -rw-r--r-- | src/ui/widget/selected-style.cpp | 2 | ||||
| -rw-r--r-- | src/widgets/gradient-selector.cpp | 2 |
23 files changed, 928 insertions, 934 deletions
diff --git a/src/bind/dobinding.cpp b/src/bind/dobinding.cpp index 5e783e59d..6da754716 100644 --- a/src/bind/dobinding.cpp +++ b/src/bind/dobinding.cpp @@ -110,16 +110,14 @@ static void setPointer(JNIEnv *env, jobject obj, jlong val) } -static void JNICALL BaseObject_construct - (JNIEnv *env, jobject obj) +static void JNICALL BaseObject_construct (JNIEnv *env, jobject obj) { setPointer(env, obj, 0L); } -static void JNICALL BaseObject_destruct - (JNIEnv *env, jobject obj) +static void JNICALL BaseObject_destruct (JNIEnv *env, jobject obj) { - BaseObject *ptr = (BaseObject *)getPointer(env, obj); + BaseObject *ptr = reinterpret_cast<BaseObject *>(getPointer(env, obj)); if (ptr) { delete ptr; @@ -154,7 +152,7 @@ static void JNICALL DOMBase_construct static void JNICALL DOMBase_destruct (JNIEnv *env, jobject obj) { - NodePtr *ptr = (NodePtr *)getPointer(env, obj); + NodePtr *ptr = reinterpret_cast<NodePtr *>(getPointer(env, obj)); if (ptr) { delete ptr; diff --git a/src/bind/javabind.cpp b/src/bind/javabind.cpp index d2091eb1b..0831ddf19 100644 --- a/src/bind/javabind.cpp +++ b/src/bind/javabind.cpp @@ -754,7 +754,7 @@ jboolean JNICALL documentSet(JNIEnv */*env*/, jobject /*obj*/, jlong /*ptr*/, js */ void JNICALL logWrite(JNIEnv */*env*/, jobject /*obj*/, jlong ptr, jint ch) { - JavaBinderyImpl *bind = (JavaBinderyImpl *)ptr; + JavaBinderyImpl *bind = reinterpret_cast<JavaBinderyImpl *>(ptr); bind->log(ch); } diff --git a/src/document.cpp b/src/document.cpp index 08563d761..6c6b41160 100644 --- a/src/document.cpp +++ b/src/document.cpp @@ -866,9 +866,13 @@ SPObject *SPDocument::getObjectById(gchar const *id) const GQuark idq = g_quark_from_string(id); gpointer rv = g_hash_table_lookup(priv->iddef, GINT_TO_POINTER(idq)); if(rv != NULL) - return (SPObject*)rv; + { + return static_cast<SPObject*>(rv); + } else + { return NULL; + } } sigc::connection SPDocument::connectIdChanged(gchar const *id, @@ -891,7 +895,7 @@ void SPDocument::bindObjectToRepr(Inkscape::XML::Node *repr, SPObject *object) SPObject *SPDocument::getObjectByRepr(Inkscape::XML::Node *repr) const { g_return_val_if_fail(repr != NULL, NULL); - return (SPObject*)g_hash_table_lookup(priv->reprdef, repr); + return static_cast<SPObject*>(g_hash_table_lookup(priv->reprdef, repr)); } Glib::ustring SPDocument::getLanguage() const diff --git a/src/extension/dxf2svg/entities.cpp b/src/extension/dxf2svg/entities.cpp index 0b18ab176..4e2f83ee7 100644 --- a/src/extension/dxf2svg/entities.cpp +++ b/src/extension/dxf2svg/entities.cpp @@ -15,155 +15,155 @@ #include<math.h> int detmine_entity(char* value){ - // Common Elements as far as I am concerend - if ( strncmp(value,"POLYLINE",8) == 0 ) return 0; - if ( strncmp(value,"ARC",3) == 0 ) return 1; - if ( strncmp(value,"CIRCLE",6) == 0 ) return 2; - if ( strncmp(value,"LINE",4) == 0 ) return 3; - if ( strncmp(value,"SPLINE",6) == 0 ) return 4; - if ( strncmp(value,"XLINE",5) == 0 ) return 5; - if ( strncmp(value,"RAY",3) == 0 ) return 6; - if ( strncmp(value,"DIMENSION",9) == 0 ) return 7; - if ( strncmp(value,"ELLIPSE",7) == 0 ) return 8; - if ( strncmp(value,"INSERT",6) == 0 ) return 9; - if ( strncmp(value,"VERTEX",6) == 0 ) return 10; - if ( strncmp(value,"TEXT",4) == 0 ) return 11; - - // Less Common eletities as far as I am concerend - if ( strncmp(value,"3DSOLID",7) == 0 ) return 12; - if ( strncmp(value,"ACAD_PROXY_ENTITY",17) == 0 ) return 13; - if ( strncmp(value,"ARCALIGNEDTEXT",14) == 0 ) return 14; - if ( strncmp(value,"ATTDEF",6) == 0 ) return 15; - if ( strncmp(value,"ATTRIB",6) == 0 ) return 16; - if ( strncmp(value,"BODY",4) == 0 ) return 17; - if ( strncmp(value,"HATCH",5) == 0 ) return 18; - if ( strncmp(value,"IMAGE",5) == 0 ) return 19; - if ( strncmp(value,"LEADER",6) == 0 ) return 20; - if ( strncmp(value,"LWPOLYLINE",10) == 0 ) return 21; - if ( strncmp(value,"MLINE",5) == 0 ) return 22; - if ( strncmp(value,"MTEXT",5) == 0 ) return 23; - if ( strncmp(value,"OLEFRAME",8) == 0 ) return 24; - if ( strncmp(value,"POINT",5) == 0 ) return 25; - if ( strncmp(value,"REGION",6) == 0 ) return 26; - if ( strncmp(value,"RTEXT",5) == 0 ) return 27; - if ( strncmp(value,"SEQEND",6) == 0 ) return 28; - if ( strncmp(value,"SHAPE",5) == 0 ) return 29; - if ( strncmp(value,"SOLID",5) == 0 ) return 30; - if ( strncmp(value,"3DFACE",6) == 0 ) return 31; - if ( strncmp(value,"TOLERANCE",9) == 0 ) return 32; - if ( strncmp(value,"TRACE",5) == 0 ) return 33; - if ( strncmp(value,"VIEWPORT",8) == 0 ) return 34; - if ( strncmp(value,"WIPEOUT",7) == 0 ) return 35; - else return -1; + // Common Elements as far as I am concerend + if ( strncmp(value,"POLYLINE",8) == 0 ) return 0; + if ( strncmp(value,"ARC",3) == 0 ) return 1; + if ( strncmp(value,"CIRCLE",6) == 0 ) return 2; + if ( strncmp(value,"LINE",4) == 0 ) return 3; + if ( strncmp(value,"SPLINE",6) == 0 ) return 4; + if ( strncmp(value,"XLINE",5) == 0 ) return 5; + if ( strncmp(value,"RAY",3) == 0 ) return 6; + if ( strncmp(value,"DIMENSION",9) == 0 ) return 7; + if ( strncmp(value,"ELLIPSE",7) == 0 ) return 8; + if ( strncmp(value,"INSERT",6) == 0 ) return 9; + if ( strncmp(value,"VERTEX",6) == 0 ) return 10; + if ( strncmp(value,"TEXT",4) == 0 ) return 11; + + // Less Common eletities as far as I am concerend + if ( strncmp(value,"3DSOLID",7) == 0 ) return 12; + if ( strncmp(value,"ACAD_PROXY_ENTITY",17) == 0 ) return 13; + if ( strncmp(value,"ARCALIGNEDTEXT",14) == 0 ) return 14; + if ( strncmp(value,"ATTDEF",6) == 0 ) return 15; + if ( strncmp(value,"ATTRIB",6) == 0 ) return 16; + if ( strncmp(value,"BODY",4) == 0 ) return 17; + if ( strncmp(value,"HATCH",5) == 0 ) return 18; + if ( strncmp(value,"IMAGE",5) == 0 ) return 19; + if ( strncmp(value,"LEADER",6) == 0 ) return 20; + if ( strncmp(value,"LWPOLYLINE",10) == 0 ) return 21; + if ( strncmp(value,"MLINE",5) == 0 ) return 22; + if ( strncmp(value,"MTEXT",5) == 0 ) return 23; + if ( strncmp(value,"OLEFRAME",8) == 0 ) return 24; + if ( strncmp(value,"POINT",5) == 0 ) return 25; + if ( strncmp(value,"REGION",6) == 0 ) return 26; + if ( strncmp(value,"RTEXT",5) == 0 ) return 27; + if ( strncmp(value,"SEQEND",6) == 0 ) return 28; + if ( strncmp(value,"SHAPE",5) == 0 ) return 29; + if ( strncmp(value,"SOLID",5) == 0 ) return 30; + if ( strncmp(value,"3DFACE",6) == 0 ) return 31; + if ( strncmp(value,"TOLERANCE",9) == 0 ) return 32; + if ( strncmp(value,"TRACE",5) == 0 ) return 33; + if ( strncmp(value,"VIEWPORT",8) == 0 ) return 34; + if ( strncmp(value,"WIPEOUT",7) == 0 ) return 35; + else return -1; } void entity::basic_entity( std::vector< dxfpair > info){ - // Extract all of the typical entity information (e.g. layer name, positions) - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 6: - strcpy( string," "); // Clear the string out - info[i].value_char(string); - strcpy(linetype,string); - break; - case 8: - strcpy( string," "); // Clear the string out - info[i].value_char(string); - strcpy(layer,string); - break; - case 10: - info[i].value_char(string); - x = atof(string); - if ( x < min_x ){ - min_x = x; - } - if ( x > max_x ){ - max_x = x; - } - break; - case 20: - info[i].value_char(string); - y = atof(string); - if ( y < min_y ){ - min_y = y; - } - if ( y > max_y ){ - max_y = y; - } - break; - case 30: - info[i].value_char(string); - z = atof(string); - break; - } - } - + // Extract all of the typical entity information (e.g. layer name, positions) + static char string[10000]; + for (int i = 0; i < info.size(); i++){ + switch( info[i].group_code ){ + case 6: + strcpy( string," "); // Clear the string out + info[i].value_char(string); + strcpy(linetype,string); + break; + case 8: + strcpy( string," "); // Clear the string out + info[i].value_char(string); + strcpy(layer,string); + break; + case 10: + info[i].value_char(string); + x = atof(string); + if ( x < min_x ){ + min_x = x; + } + if ( x > max_x ){ + max_x = x; + } + break; + case 20: + info[i].value_char(string); + y = atof(string); + if ( y < min_y ){ + min_y = y; + } + if ( y > max_y ){ + max_y = y; + } + break; + case 30: + info[i].value_char(string); + z = atof(string); + break; + } + } + } void entity::entity_display(){ - std::cout << "\tlayer = " << layer << "\n\tlinetype = " << linetype << "\n\tx = " << x << "\ty = " << y << "\tz = " << z << std::flush; + std::cout << "\tlayer = " << layer << "\n\tlinetype = " << linetype << "\n\tx = " << x << "\ty = " << y << "\tz = " << z << std::flush; } double entity::ret_x(){ - return x; + return x; } double entity::ret_y(){ - return y; + return y; } double entity::ret_z(){ - return z; + return z; } char* entity::ret_layer_name(char* string){ - return( strcpy(string,layer) ); + return( strcpy(string,layer) ); } char* entity::ret_ltype_name(char* string){ - return( strcpy(string,linetype) ); + return( strcpy(string,linetype) ); } double entity::ret_min_x(){ - return min_x; + return min_x; } double entity::ret_max_x(){ - return max_x; + return max_x; } double entity::ret_min_y(){ - return min_y; + return min_y; } double entity::ret_max_y(){ - return max_y; + return max_y; } void entity::test_coord(double x, double y){ - if ( x < min_x ){ - min_x = x; - } - if ( x > max_x ){ - max_x = x; - } - if ( y < min_y ){ - min_y = y; - } - if ( y > max_y ){ - max_y = y; - } + if ( x < min_x ){ + min_x = x; + } + if ( x > max_x ){ + max_x = x; + } + if ( y < min_y ){ + min_y = y; + } + if ( y > max_y ){ + max_y = y; + } } void entity::reset_extents(){ - min_x = -1e20; - max_x = 1e20; - min_y = -1e20; - max_y = 1e20; + min_x = -1e20; + max_x = 1e20; + min_y = -1e20; + max_y = 1e20; } @@ -173,27 +173,27 @@ void entity::reset_extents(){ vertex::vertex( std::vector< dxfpair > info){ - // Get the vertex information - - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 42: - info[i].value_char(string); - bulge = atof(string); - break; - } - } + // Get the vertex information + + basic_entity( info ); + static char string[10000]; + for (int i = 0; i < info.size(); i++){ + switch( info[i].group_code ){ + case 42: + info[i].value_char(string); + bulge = atof(string); + break; + } + } } double vertex::ret_bulge(){ - return bulge; + return bulge; } void vertex::display(){ - std::cout << "VERTEX\n"; - std::cout << "\tx = " << x << "\ty = " << y << "\tz = " << z << "\tbulge = " << bulge << std::flush; + std::cout << "VERTEX\n"; + std::cout << "\tx = " << x << "\ty = " << y << "\tz = " << z << "\tbulge = " << bulge << std::flush; } @@ -208,132 +208,125 @@ void vertex::display(){ // The polyline is handled a little differently compared to the other entities because a POLYLINE is built from a bunch of VERTEX entities polyline::polyline( std::vector< std::vector< dxfpair > > sections ){ - reset_extents(); - // get the polyline information - basic_entity( sections[0] ); - points.clear(); - static char string[10000]; - //char string[10000]; - pline_flag = 0; - curves_flag = 0; - for (int i = 0; i < sections[0].size(); i++){ - switch( sections[0][i].group_code ){ - case 70: - sections[0][i].value_char(string); - pline_flag = atoi(string); - break; - case 40: - sections[0][i].value_char(string); - start_width = atoi(string); - break; - case 41: - sections[0][i].value_char(string); - end_width = atoi(string); - break; - case 75: - sections[0][i].value_char(string); - curves_flag = atoi(string); - break; - } - } - // Now add the VERTEX entities to the POLYLINE - for (int i = 1; i < sections.size(); i++){ - points.push_back( vertex( sections[i] ) ); - } + buldge = 0; + pline_flag = 0; + reset_extents(); + // get the polyline information + basic_entity( sections[0] ); + points.clear(); + static char string[10000]; + for (int i = 0; i < sections[0].size(); i++){ + switch( sections[0][i].group_code ){ + case 70: + sections[0][i].value_char(string); + pline_flag = atoi(string); + break; + case 40: + sections[0][i].value_char(string); + start_width = atoi(string); + break; + case 41: + sections[0][i].value_char(string); + end_width = atoi(string); + break; + case 75: + sections[0][i].value_char(string); + curves_flag = atoi(string); + break; + } + } + curves_flag = 0; + + // Now add the VERTEX entities to the POLYLINE + for (int i = 1; i < sections.size(); i++){ + points.push_back( vertex( sections[i] ) ); + } } std::vector< vertex > polyline::ret_points(){ - return points; + return points; } double polyline::bulge(int point){ - return points[point].ret_bulge(); + return points[point].ret_bulge(); } double polyline::bulge_r(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - return r; + // Make sure we are not exceeding the bounds of the points vector + if (point >= (points.size()-1)) return 0; + + double dx = points[point+1].ret_x() - points[point].ret_x(); + double dy = points[point+1].ret_y() - points[point].ret_y(); + double bulge = points[point].ret_bulge(); + double l = sqrt(dx*dx + dy*dy); + double r = fabs(l*(bulge*bulge+1)/bulge/4); + + return r; } double polyline::bulge_start_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double xmid = dx/2 + points[point].ret_x(); - double ymid = dy/2 + points[point].ret_y(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - double a = fabs(bulge*l/2); - double sb = bulge/fabs(bulge); //sign of bulge - double theta_c; - dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number - if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - - // Now calculate the angle - double theta = asin(points[point].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; + // Make sure we are not exceeding the bounds of the points vector + if (point >= (points.size()-1)) + { + return 0; + } + + double dx = points[point+1].ret_x() - points[point].ret_x(); + double dy = points[point+1].ret_y() - points[point].ret_y(); + double bulge = points[point].ret_bulge(); + double l = sqrt(dx*dx + dy*dy); + double r = fabs(l*(bulge*bulge+1)/bulge/4); + + if (dx > 0) + { + sb *= -1; // Correct for different point ordering and bulge direction + } + + // Now calculate the angle + double theta = asin(points[point].ret_x()/r); + if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi + + return theta; } double polyline::bulge_end_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double xmid = dx/2 + points[point].ret_x(); - double ymid = dy/2 + points[point].ret_y(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - double a = fabs(bulge*l/2); - double sb = bulge/fabs(bulge); //sign of bulge - double theta_c; - dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number - if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - - // Now calculate the angle - double theta = asin(points[point+1].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; + // Make sure we are not exceeding the bounds of the points vector + if (point >= (points.size()-1)) + { + return 0; + } + + double dx = points[point+1].ret_x() - points[point].ret_x(); + double dy = points[point+1].ret_y() - points[point].ret_y(); + double bulge = points[point].ret_bulge(); + double l = sqrt(dx*dx + dy*dy); + double r = fabs(l*(bulge*bulge+1)/bulge/4); + + // Now calculate the angle + double theta = asin(points[point+1].ret_x()/r); + if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi + + return theta; } - bool polyline::is_closed(){ - // pline-flag holds info about closed pline in the 1 bit. The info is bit wise encoded so use bit wise operators - return bool(pline_flag&1); + // pline-flag holds info about closed pline in the 1 bit. The info is bit wise encoded so use bit wise operators + return bool(pline_flag&1); } void polyline::display(){ - std::cout << "POLYLINE\n"; - entity_display(); - std::cout << std::endl; - for (int i = 0; i < points.size(); i++){ - points[i].display(); - std::cout << std::endl; - } - std::cout << std::endl; + std::cout << "POLYLINE\n"; + entity_display(); + std::cout << std::endl; + for (int i = 0; i < points.size(); i++){ + points[i].display(); + std::cout << std::endl; + } + std::cout << std::endl; } - - ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // LWPOLYLINE ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -341,180 +334,164 @@ void polyline::display(){ // The lwpolyline is different than the polyline because there are no vertex entities. Use the same basic process as the polyline but parse it out differently lwpolyline::lwpolyline( std::vector< dxfpair > section ){ - - // First break up the data into the same format that is used by the polyline entity - std::vector< std::vector< dxfpair > > sections; - std::vector< dxfpair > first; - std::vector< dxfpair > others; - - sections.clear(); - first.clear(); - others.clear(); - - int gc; // make a shorter name for group_code; - - int vertex_part; - int already_found = 0; - - for (int i = 0; i < section.size(); i++){ - gc = section[i].group_code; - // Encode bitwise information to keep track of what has been found - vertex_part = 0; - if (gc == 10 ) vertex_part += 1; - if (gc == 20 ) vertex_part += 2; - if (gc == 30 ) vertex_part += 4; - if (gc == 40 ) vertex_part += 8; - if (gc == 41 ) vertex_part += 16; - if (gc == 42 ) vertex_part += 32; - //std::cout << "\n\nvertex_part = " << vertex_part << std::endl << "already_found = " << already_found << std::endl << "(vertex_part&already_found) = " << (vertex_part&already_found) << std::endl; - if ( vertex_part == 0 ){ - // If header stuff has been found save it under first. - // I.E. in a polyline the first set of information is linetype and layer, all of what should be in here - first.push_back( section[i] ); - } - else if ( (vertex_part&already_found) == 0 ){ - // Now work on what would be the vertex information - // New information is still being found so keep saving it - others.push_back( section[i] ); - //std::cout << "add to others" << std::endl; - already_found += vertex_part; // Keep track of what has been found - } - else{ - sections.push_back( others ); - //std::cout << "sections.size() = " << sections.size() << std::endl; - // Now clear the information out and start over - others.clear(); - others.push_back( section[i] ); - already_found = vertex_part; - } - } - - // Now put on the last data that was found - if (!others.empty()){ - sections.push_back(others); - } - - reset_extents(); - basic_entity( first ); - points.clear(); - static char string[10000]; - //char string[10000]; - pline_flag = 0; - curves_flag = 0; - for (int i = 0; i < first.size(); i++){ - switch( sections[0][i].group_code ){ - case 70: - first[i].value_char(string); - pline_flag = atoi(string); - break; - case 40: - first[i].value_char(string); - start_width = atoi(string); - break; - case 41: - first[i].value_char(string); - end_width = atoi(string); - break; - case 75: - first[i].value_char(string); - curves_flag = atoi(string); - break; - } - } - // Now add the VERTEX entities to the POLYLINE - for (int i = 0; i < sections.size(); i++){ - points.push_back( vertex( sections[i] ) ); - } + + // First break up the data into the same format that is used by the polyline entity + std::vector< std::vector< dxfpair > > sections; + std::vector< dxfpair > first; + std::vector< dxfpair > others; + + sections.clear(); + first.clear(); + others.clear(); + + int gc; // make a shorter name for group_code; + + int vertex_part; + int already_found = 0; + + for (int i = 0; i < section.size(); i++){ + gc = section[i].group_code; + // Encode bitwise information to keep track of what has been found + vertex_part = 0; + if (gc == 10 ) vertex_part += 1; + if (gc == 20 ) vertex_part += 2; + if (gc == 30 ) vertex_part += 4; + if (gc == 40 ) vertex_part += 8; + if (gc == 41 ) vertex_part += 16; + if (gc == 42 ) vertex_part += 32; + //std::cout << "\n\nvertex_part = " << vertex_part << std::endl << "already_found = " << already_found << std::endl << "(vertex_part&already_found) = " << (vertex_part&already_found) << std::endl; + if ( vertex_part == 0 ){ + // If header stuff has been found save it under first. + // I.E. in a polyline the first set of information is linetype and layer, all of what should be in here + first.push_back( section[i] ); + } + else if ( (vertex_part&already_found) == 0 ){ + // Now work on what would be the vertex information + // New information is still being found so keep saving it + others.push_back( section[i] ); + //std::cout << "add to others" << std::endl; + already_found += vertex_part; // Keep track of what has been found + } + else{ + sections.push_back( others ); + //std::cout << "sections.size() = " << sections.size() << std::endl; + // Now clear the information out and start over + others.clear(); + others.push_back( section[i] ); + already_found = vertex_part; + } + } + + // Now put on the last data that was found + if (!others.empty()){ + sections.push_back(others); + } + + reset_extents(); + basic_entity( first ); + points.clear(); + static char string[10000]; + buldge = 0; + pline_flag = 0; + curves_flag = 0; + for (int i = 0; i < first.size(); i++){ + switch( sections[0][i].group_code ){ + case 70: + first[i].value_char(string); + pline_flag = atoi(string); + break; + case 40: + first[i].value_char(string); + start_width = atoi(string); + break; + case 41: + first[i].value_char(string); + end_width = atoi(string); + break; + case 75: + first[i].value_char(string); + curves_flag = atoi(string); + break; + } + } + // Now add the VERTEX entities to the POLYLINE + for (int i = 0; i < sections.size(); i++){ + points.push_back( vertex( sections[i] ) ); + } } std::vector< vertex > lwpolyline::ret_points(){ - return points; + return points; } double lwpolyline::bulge(int point){ - return points[point].ret_bulge(); + return points[point].ret_bulge(); } double lwpolyline::bulge_r(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - return r; + // Make sure we are not exceeding the bounds of the points vector + if (point >= (points.size()-1)) return 0; + + double dx = points[point+1].ret_x() - points[point].ret_x(); + double dy = points[point+1].ret_y() - points[point].ret_y(); + double bulge = points[point].ret_bulge(); + double l = sqrt(dx*dx + dy*dy); + double r = fabs(l*(bulge*bulge+1)/bulge/4); + + return r; } double lwpolyline::bulge_start_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double xmid = dx/2 + points[point].ret_x(); - double ymid = dy/2 + points[point].ret_y(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - double a = fabs(bulge*l/2); - double sb = bulge/fabs(bulge); //sign of bulge - double theta_c; - dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number - if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - - // Now calculate the angle - double theta = asin(points[point].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; + // Make sure we are not exceeding the bounds of the points vector + if (point >= (points.size()-1)) return 0; + + double dx = points[point+1].ret_x() - points[point].ret_x(); + double dy = points[point+1].ret_y() - points[point].ret_y(); + double bulge = points[point].ret_bulge(); + double l = sqrt(dx*dx + dy*dy); + double r = fabs(l*(bulge*bulge+1)/bulge/4); + + // Now calculate the angle + double theta = asin(points[point].ret_x()/r); + if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi + + return theta; } double lwpolyline::bulge_end_angle(int point){ - // Make sure we are not exceeding the bounds of the points vector - if (point >= (points.size()-1)) return 0; - - double dx = points[point+1].ret_x() - points[point].ret_x(); - double dy = points[point+1].ret_y() - points[point].ret_y(); - double bulge = points[point].ret_bulge(); - double xmid = dx/2 + points[point].ret_x(); - double ymid = dy/2 + points[point].ret_y(); - double l = sqrt(dx*dx + dy*dy); - double r = fabs(l*(bulge*bulge+1)/bulge/4); - - double a = fabs(bulge*l/2); - double sb = bulge/fabs(bulge); //sign of bulge - double theta_c; - dx != 0 ? theta_c = atan(dy/dx) : theta_c = 1.57079632679489661923; // Check to make sure that dx is not zero and will give a negative number - if (dx > 0) sb *= -1; // Correct for different point ordering and bulge direction - - // Now calculate the angle - double theta = asin(points[point+1].ret_x()/r); - if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi - - return theta; + // Make sure we are not exceeding the bounds of the points vector + if (point >= (points.size()-1)) return 0; + + double dx = points[point+1].ret_x() - points[point].ret_x(); + double dy = points[point+1].ret_y() - points[point].ret_y(); + double bulge = points[point].ret_bulge(); + double l = sqrt(dx*dx + dy*dy); + double r = fabs(l*(bulge*bulge+1)/bulge/4); + + // Now calculate the angle + double theta = asin(points[point+1].ret_x()/r); + if (dy < 0) theta = 6.2831853 - theta; // The angle is greater than pi so fix this because max(asin) = pi + + return theta; } bool lwpolyline::is_closed(){ - // pline-flag holds info about closed pline in the 1 bit. The info is bit wise encoded so use bit wise operators - return bool(pline_flag&1); + // pline-flag holds info about closed pline in the 1 bit. The info is bit wise encoded so use bit wise operators + return bool(pline_flag&1); } void lwpolyline::display(){ - std::cout << "lwpolyline\n"; - entity_display(); - std::cout << std::endl; - for (int i = 0; i < points.size(); i++){ - points[i].display(); - std::cout << std::endl; - } - std::cout << std::endl; + std::cout << "lwpolyline\n"; + entity_display(); + std::cout << std::endl; + for (int i = 0; i < points.size(); i++){ + points[i].display(); + std::cout << std::endl; + } + std::cout << std::endl; } @@ -525,51 +502,51 @@ void lwpolyline::display(){ arc::arc( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 40: - info[i].value_char(string); - radius = atof(string); - test_coord(x+radius,y+radius); - test_coord(x-radius,y-radius); - break; - case 50: - info[i].value_char(string); - start_angle = atof(string); - break; - case 51: - info[i].value_char(string); - end_angle = atof(string); - break; - default: - break; - } - } + + reset_extents(); + basic_entity( info ); + static char string[10000]; + for (int i = 0; i < info.size(); i++){ + switch( info[i].group_code ){ + case 40: + info[i].value_char(string); + radius = atof(string); + test_coord(x+radius,y+radius); + test_coord(x-radius,y-radius); + break; + case 50: + info[i].value_char(string); + start_angle = atof(string); + break; + case 51: + info[i].value_char(string); + end_angle = atof(string); + break; + default: + break; + } + } } double arc::ret_radius(){ - return radius; + return radius; } double arc::ret_srt_ang(){ - return start_angle; + return start_angle; } double arc::ret_end_ang(){ - return end_angle; + return end_angle; } void arc::display(){ - std::cout << "ARC\n"; - entity_display(); - std::cout << "\n\tradius = " << radius << "\tstart_angle = " << start_angle << "end_angle = " << end_angle << std::flush; + std::cout << "ARC\n"; + entity_display(); + std::cout << "\n\tradius = " << radius << "\tstart_angle = " << start_angle << "end_angle = " << end_angle << std::flush; } @@ -580,31 +557,31 @@ void arc::display(){ circle::circle( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 40: - info[i].value_char(string); - radius = atof(string); - test_coord(x+radius,y+radius); - test_coord(x-radius,y-radius); - break; - } - } + + reset_extents(); + basic_entity( info ); + static char string[10000]; + for (int i = 0; i < info.size(); i++){ + switch( info[i].group_code ){ + case 40: + info[i].value_char(string); + radius = atof(string); + test_coord(x+radius,y+radius); + test_coord(x-radius,y-radius); + break; + } + } } void circle::display(){ - std::cout << "CIRCLE\n"; - entity_display(); - std::cout << "\n\tradius = " << radius << std::flush; + std::cout << "CIRCLE\n"; + entity_display(); + std::cout << "\n\tradius = " << radius << std::flush; } double circle::ret_radius(){ - return radius; + return radius; } @@ -614,47 +591,47 @@ double circle::ret_radius(){ line::line( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 11: - info[i].value_char(string); - xf = atof(string); - break; - case 21: - info[i].value_char(string); - yf = atof(string); - break; - case 31: - info[i].value_char(string); - zf = atof(string); - break; - } - } - test_coord(xf,yf); - + + reset_extents(); + basic_entity( info ); + static char string[10000]; + for (int i = 0; i < info.size(); i++){ + switch( info[i].group_code ){ + case 11: + info[i].value_char(string); + xf = atof(string); + break; + case 21: + info[i].value_char(string); + yf = atof(string); + break; + case 31: + info[i].value_char(string); + zf = atof(string); + break; + } + } + test_coord(xf,yf); + } void line::display(){ - std::cout << "LINE\n"; - entity_display(); - std::cout << "\n\txf = " << xf << "\tyf = " << yf << "\tzf = " << zf << std::flush; + std::cout << "LINE\n"; + entity_display(); + std::cout << "\n\txf = " << xf << "\tyf = " << yf << "\tzf = " << zf << std::flush; } double line::ret_xf(){ - return xf; + return xf; } double line::ret_yf(){ - return yf; + return yf; } double line::ret_zf(){ - return zf; + return zf; } @@ -665,44 +642,44 @@ double line::ret_zf(){ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// text::text( std::vector< dxfpair > info){ - - reset_extents(); - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 1: - info[i].value_char(dxf_text); // directly copy the text into a string - break; - case 40: - info[i].value_char(string); - text_height = atof(string); - break; - case 50: - info[i].value_char(string); - text_rotation = atof(string); - break; - } - } + + reset_extents(); + basic_entity( info ); + static char string[10000]; + for (int i = 0; i < info.size(); i++){ + switch( info[i].group_code ){ + case 1: + info[i].value_char(dxf_text); // directly copy the text into a string + break; + case 40: + info[i].value_char(string); + text_height = atof(string); + break; + case 50: + info[i].value_char(string); + text_rotation = atof(string); + break; + } + } } char * text::ret_text(char *string){ - return( strcpy(string,dxf_text) ); + return( strcpy(string,dxf_text) ); } double text::ret_txt_ht(){ - return text_height; + return text_height; } double text::ret_txt_rot(){ - return text_rotation; + return text_rotation; } void text::display(){ - char tmp[10000]; - std::cout << "TEXT\n"; - entity_display(); - std::cout << "\ndxf_text = " << ret_text(tmp) << std::flush; + char tmp[10000]; + std::cout << "TEXT\n"; + entity_display(); + std::cout << "\ndxf_text = " << ret_text(tmp) << std::flush; } ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// @@ -710,37 +687,41 @@ void text::display(){ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// insert::insert( std::vector< dxfpair > info){ - - basic_entity( info ); - static char string[10000]; - for (int i = 0; i < info.size(); i++){ - switch( info[i].group_code ){ - case 2: - info[i].value_char(block_name); // directly copy the text into a string - break; - case 41: - info[i].value_char(string); - x_scale_factor = atof(string); - break; - case 42: - info[i].value_char(string); - y_scale_factor = atof(string); - break; - case 43: - info[i].value_char(string); - z_scale_factor = atof(string); - break; - case 50: - info[i].value_char(string); - rotation = atof(string); - break; - } - } + ret_x_sf = 0; + ret_y_sf = 0; + ret_z_sf = 0; + ret_rotation = 0; + + basic_entity( info ); + static char string[10000]; + for (int i = 0; i < info.size(); i++){ + switch( info[i].group_code ){ + case 2: + info[i].value_char(block_name); // directly copy the text into a string + break; + case 41: + info[i].value_char(string); + x_scale_factor = atof(string); + break; + case 42: + info[i].value_char(string); + y_scale_factor = atof(string); + break; + case 43: + info[i].value_char(string); + z_scale_factor = atof(string); + break; + case 50: + info[i].value_char(string); + rotation = atof(string); + break; + } + } } char * insert::name(char *string){ - return( strcpy(string,block_name) ); + return( strcpy(string,block_name) ); } @@ -748,268 +729,268 @@ char * insert::name(char *string){ ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // entities ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// - + entities::entities(std::vector< std::vector< dxfpair > > sections){ - // Read the main information about the entities section and then put it in the enetites class - int value; - char string[10000]; - std::vector< dxfpair > single_line; - std::vector< std::vector< dxfpair > > pline; - pline.clear(); - single_line.clear(); - - for(int i = 0; i < sections.size(); i++){ - sections[i][0].value_char(string); - value = detmine_entity(string); - switch( value ){ - case 0: - // Get everything from the start of the polyline designation to an SEQEND value - pline.clear(); // First clear out the pline information - do{ - pline.push_back( sections[i] ); - sections[++i][0].value_char(string); - }while( strncmp(string,"SEQEND",6) != 0 ); - ents_polyline.push_back( polyline( pline ) ); - break; - - case 1: - // ARC - ents_arc.push_back( arc( sections[i] ) ); - break; - - case 2: - // CIRCLE - ents_circle.push_back( circle( sections[i] ) ); - break; - - case 3: - // LINE - ents_line.push_back( line( sections[i] ) ); - break; - case 11: - // TEXT - ents_text.push_back( text( sections[i] ) ); - break; - case 21: - // LWPOLYLINE - ents_lwpolyline.push_back( lwpolyline( sections[i] ) ); - case 9: - // INSERT - ents_insert.push_back( insert( sections[i] ) ); - - //default: - // Nothing here - } - - } - + // Read the main information about the entities section and then put it in the enetites class + int value; + char string[10000]; + std::vector< dxfpair > single_line; + std::vector< std::vector< dxfpair > > pline; + pline.clear(); + single_line.clear(); + + for(int i = 0; i < sections.size(); i++){ + sections[i][0].value_char(string); + value = detmine_entity(string); + switch( value ){ + case 0: + // Get everything from the start of the polyline designation to an SEQEND value + pline.clear(); // First clear out the pline information + do{ + pline.push_back( sections[i] ); + sections[++i][0].value_char(string); + }while( strncmp(string,"SEQEND",6) != 0 ); + ents_polyline.push_back( polyline( pline ) ); + break; + + case 1: + // ARC + ents_arc.push_back( arc( sections[i] ) ); + break; + + case 2: + // CIRCLE + ents_circle.push_back( circle( sections[i] ) ); + break; + + case 3: + // LINE + ents_line.push_back( line( sections[i] ) ); + break; + case 11: + // TEXT + ents_text.push_back( text( sections[i] ) ); + break; + case 21: + // LWPOLYLINE + ents_lwpolyline.push_back( lwpolyline( sections[i] ) ); + case 9: + // INSERT + ents_insert.push_back( insert( sections[i] ) ); + + //default: + // Nothing here + } + + } + } // Maybe all of this could be turned into fewer function by using templates, but no time right now. MBS std::vector< polyline > entities::ret_plines(){ - std::vector< polyline > pls; - pls.clear(); - for(int i = 0; i < ents_polyline.size();i++){ - pls.push_back( ents_polyline[i] ); - } - return pls; + std::vector< polyline > pls; + pls.clear(); + for(int i = 0; i < ents_polyline.size();i++){ + pls.push_back( ents_polyline[i] ); + } + return pls; } std::vector< lwpolyline > entities::ret_lwplines(){ - std::vector< lwpolyline > lwpls; - lwpls.clear(); - for(int i = 0; i < ents_lwpolyline.size();i++){ - lwpls.push_back( ents_lwpolyline[i] ); - } - return lwpls; + std::vector< lwpolyline > lwpls; + lwpls.clear(); + for(int i = 0; i < ents_lwpolyline.size();i++){ + lwpls.push_back( ents_lwpolyline[i] ); + } + return lwpls; } std::vector< arc > entities::ret_arcs(){ - std::vector< arc > a; - a.clear(); - for(int i = 0; i < ents_arc.size();i++){ - a.push_back( ents_arc[i] ); - } - return a; + std::vector< arc > a; + a.clear(); + for(int i = 0; i < ents_arc.size();i++){ + a.push_back( ents_arc[i] ); + } + return a; } std::vector< circle > entities::ret_circles(){ - std::vector< circle > circs; - circs.clear(); - for(int i = 0; i < ents_circle.size();i++){ - circs.push_back( ents_circle[i] ); - } - return circs; + std::vector< circle > circs; + circs.clear(); + for(int i = 0; i < ents_circle.size();i++){ + circs.push_back( ents_circle[i] ); + } + return circs; } std::vector< line > entities::ret_lines(){ - std::vector< line > lns; - lns.clear(); - for(int i = 0; i < ents_line.size();i++){ - lns.push_back( ents_line[i] ); - } - return lns; + std::vector< line > lns; + lns.clear(); + for(int i = 0; i < ents_line.size();i++){ + lns.push_back( ents_line[i] ); + } + return lns; } std::vector< text > entities::ret_texts(){ - std::vector< text > txts; - txts.clear(); - for(int i = 0; i < ents_text.size();i++){ - txts.push_back( ents_text[i] ); - } - return txts; + std::vector< text > txts; + txts.clear(); + for(int i = 0; i < ents_text.size();i++){ + txts.push_back( ents_text[i] ); + } + return txts; } std::vector< insert > entities::ret_inserts(){ - std::vector< insert > ins; - ins.clear(); - for(int i = 0; i < ents_insert.size();i++){ - ins.push_back( ents_insert[i] ); - } - return ins; + std::vector< insert > ins; + ins.clear(); + for(int i = 0; i < ents_insert.size();i++){ + ins.push_back( ents_insert[i] ); + } + return ins; } // Overload the return function to depend on the layer std::vector< polyline > entities::ret_plines(char * layer){ - char temp[10000]; - std::vector< polyline > pls; - pls.clear(); - - for(int i = 0; i < ents_polyline.size();i++){ - if ( strcmp( layer,ents_polyline[i].ret_layer_name(temp) ) == 0 ){ - pls.push_back( ents_polyline[i] ); - } - } - return pls; + char temp[10000]; + std::vector< polyline > pls; + pls.clear(); + + for(int i = 0; i < ents_polyline.size();i++){ + if ( strcmp( layer,ents_polyline[i].ret_layer_name(temp) ) == 0 ){ + pls.push_back( ents_polyline[i] ); + } + } + return pls; } std::vector< lwpolyline > entities::ret_lwplines(char * layer){ - char temp[10000]; - std::vector< lwpolyline > lwpls; - lwpls.clear(); - - for(int i = 0; i < ents_lwpolyline.size();i++){ - if ( strcmp( layer,ents_lwpolyline[i].ret_layer_name(temp) ) == 0 ){ - lwpls.push_back( ents_lwpolyline[i] ); - } - } - return lwpls; + char temp[10000]; + std::vector< lwpolyline > lwpls; + lwpls.clear(); + + for(int i = 0; i < ents_lwpolyline.size();i++){ + if ( strcmp( layer,ents_lwpolyline[i].ret_layer_name(temp) ) == 0 ){ + lwpls.push_back( ents_lwpolyline[i] ); + } + } + return lwpls; } std::vector< circle > entities::ret_circles(char * layer){ - char temp[10000]; - std::vector< circle > circs; - circs.clear(); - - for(int i = 0; i < ents_circle.size();i++){ - if ( strcmp( layer,ents_circle[i].ret_layer_name(temp) ) == 0 ){ - circs.push_back( ents_circle[i] ); - } - } - return circs; + char temp[10000]; + std::vector< circle > circs; + circs.clear(); + + for(int i = 0; i < ents_circle.size();i++){ + if ( strcmp( layer,ents_circle[i].ret_layer_name(temp) ) == 0 ){ + circs.push_back( ents_circle[i] ); + } + } + return circs; } std::vector< line > entities::ret_lines(char * layer){ - char temp[10000]; - std::vector< line > lns; - lns.clear(); - - for(int i = 0; i < ents_line.size();i++){ - if ( strcmp( layer,ents_line[i].ret_layer_name(temp) ) == 0 ){ - lns.push_back( ents_line[i] ); - } - } - return lns; + char temp[10000]; + std::vector< line > lns; + lns.clear(); + + for(int i = 0; i < ents_line.size();i++){ + if ( strcmp( layer,ents_line[i].ret_layer_name(temp) ) == 0 ){ + lns.push_back( ents_line[i] ); + } + } + return lns; } std::vector< text > entities::ret_texts(char * layer){ - char temp[10000]; - std::vector< text > txts; - txts.clear(); - - for(int i = 0; i < ents_text.size();i++){ - if ( strcmp( layer,ents_text[i].ret_layer_name(temp) ) == 0 ){ - txts.push_back( ents_text[i] ); - } - } - return txts; + char temp[10000]; + std::vector< text > txts; + txts.clear(); + + for(int i = 0; i < ents_text.size();i++){ + if ( strcmp( layer,ents_text[i].ret_layer_name(temp) ) == 0 ){ + txts.push_back( ents_text[i] ); + } + } + return txts; } /*std::vector< ellipse > entities::ret_ellipses(char * layer){ - char temp[10000]; - std::vector< polyline > pls; - pls.clear(); - - for(int i = 0; i < ents_polyline.size();i++){ - if ( strcmp( layer,ents_polyline[i].ret_layer_name(temp) ) == 0 ){ - pls.push_back( ents_polyline[i] ); - } - } - return pls; + char temp[10000]; + std::vector< polyline > pls; + pls.clear(); + + for(int i = 0; i < ents_polyline.size();i++){ + if ( strcmp( layer,ents_polyline[i].ret_layer_name(temp) ) == 0 ){ + pls.push_back( ents_polyline[i] ); + } + } + return pls; }*/ std::vector< arc > entities::ret_arcs(char * layer){ - char temp[10000]; - std::vector< arc > a; - a.clear(); - - for(int i = 0; i < ents_arc.size();i++){ - if ( strcmp( layer,ents_arc[i].ret_layer_name(temp) ) == 0 ){ - a.push_back( ents_arc[i] ); - } - } - return a; + char temp[10000]; + std::vector< arc > a; + a.clear(); + + for(int i = 0; i < ents_arc.size();i++){ + if ( strcmp( layer,ents_arc[i].ret_layer_name(temp) ) == 0 ){ + a.push_back( ents_arc[i] ); + } + } + return a; } std::vector< insert > entities::ret_inserts(char * layer){ - char temp[10000]; - std::vector< insert > ins; - ins.clear(); - - for(int i = 0; i < ents_insert.size();i++){ - if ( strcmp( layer,ents_insert[i].ret_layer_name(temp) ) == 0 ){ - ins.push_back( ents_insert[i] ); - } - } - return ins; + char temp[10000]; + std::vector< insert > ins; + ins.clear(); + + for(int i = 0; i < ents_insert.size();i++){ + if ( strcmp( layer,ents_insert[i].ret_layer_name(temp) ) == 0 ){ + ins.push_back( ents_insert[i] ); + } + } + return ins; } void entities::display_all(){ - for (int i = 0; i < ents_polyline.size(); i++){ - ents_polyline[i].display(); - } - std::cout << std::endl; - for (int i = 0; i < ents_lwpolyline.size(); i++){ - ents_lwpolyline[i].display(); - } - std::cout << std::endl; - for (int i = 0; i < ents_circle.size(); i++){ - ents_circle[i].display(); - } - std::cout << std::endl; - for (int i = 0; i < ents_text.size(); i++){ - ents_text[i].display(); - } + for (int i = 0; i < ents_polyline.size(); i++){ + ents_polyline[i].display(); + } + std::cout << std::endl; + for (int i = 0; i < ents_lwpolyline.size(); i++){ + ents_lwpolyline[i].display(); + } + std::cout << std::endl; + for (int i = 0; i < ents_circle.size(); i++){ + ents_circle[i].display(); + } + std::cout << std::endl; + for (int i = 0; i < ents_text.size(); i++){ + ents_text[i].display(); + } } diff --git a/src/extension/dxf2svg/entities.h b/src/extension/dxf2svg/entities.h index 96d863d94..3afd949b0 100644 --- a/src/extension/dxf2svg/entities.h +++ b/src/extension/dxf2svg/entities.h @@ -14,32 +14,32 @@ Google SOC class entity{ - public: - void basic_entity( std::vector< dxfpair > info); // Extract all of the typical entity information (e.g. layer name, positions) - void entity_display(); - double ret_x(); - double ret_y(); - double ret_z(); - char* ret_layer_name(char* string); - char* ret_ltype_name(char* string); - double ret_min_x(); - double ret_max_x(); - double ret_min_y(); - double ret_max_y(); - - - protected: - char layer[10000]; - char linetype[10000]; - double x; - double y; - double z; - double min_x; - double max_x; - double min_y; - double max_y; - void reset_extents(); - void test_coord(double x, double y); + public: + void basic_entity( std::vector< dxfpair > info); // Extract all of the typical entity information (e.g. layer name, positions) + void entity_display(); + double ret_x(); + double ret_y(); + double ret_z(); + char* ret_layer_name(char* string); + char* ret_ltype_name(char* string); + double ret_min_x(); + double ret_max_x(); + double ret_min_y(); + double ret_max_y(); + + + protected: + char layer[10000]; + char linetype[10000]; + double x; + double y; + double z; + double min_x; + double max_x; + double min_y; + double max_y; + void reset_extents(); + void test_coord(double x, double y); }; @@ -47,13 +47,13 @@ class entity{ class vertex : public entity { - public: - vertex( std::vector< dxfpair > info); - void display(); - double ret_bulge(); - - private: - double bulge; + public: + vertex( std::vector< dxfpair > info); + void display(); + double ret_bulge(); + + private: + double bulge; }; @@ -61,141 +61,141 @@ class vertex : public entity { class polyline : public entity { - public: - polyline( std::vector< std::vector< dxfpair > > sections ); - std::vector< vertex > ret_points(); - double bulge(int point); - double bulge_r(int point); - double bulge_start_angle(int point); - double bulge_end_angle(int point); - bool is_closed(); - void display(); - - private: - double buldge; - int pline_flag; // 70 - double start_width; // 40 - double end_width; // 41 - int curves_flag; - std::vector< vertex > points; + public: + polyline( std::vector< std::vector< dxfpair > > sections ); + std::vector< vertex > ret_points(); + double bulge(int point); + double bulge_r(int point); + double bulge_start_angle(int point); + double bulge_end_angle(int point); + bool is_closed(); + void display(); + + private: + double buldge; + int pline_flag; // 70 + double start_width; // 40 + double end_width; // 41 + int curves_flag; + std::vector< vertex > points; }; class lwpolyline : public entity { - public: - lwpolyline( std::vector< dxfpair > section ); - std::vector< vertex > ret_points(); - double bulge(int point); - double bulge_r(int point); - double bulge_start_angle(int point); - double bulge_end_angle(int point); - bool is_closed(); - void display(); - - private: - double buldge; - int pline_flag; // 70 - double start_width; // 40 - double end_width; // 41 - int curves_flag; - std::vector< vertex > points; + public: + lwpolyline( std::vector< dxfpair > section ); + std::vector< vertex > ret_points(); + double bulge(int point); + double bulge_r(int point); + double bulge_start_angle(int point); + double bulge_end_angle(int point); + bool is_closed(); + void display(); + + private: + double buldge; + int pline_flag; // 70 + double start_width; // 40 + double end_width; // 41 + int curves_flag; + std::vector< vertex > points; }; class arc : public entity { - public: - arc( std::vector< dxfpair > info); - double ret_radius(); - double ret_srt_ang(); - double ret_end_ang(); - void display(); - - private: - double radius; - double start_angle; - double end_angle; + public: + arc( std::vector< dxfpair > info); + double ret_radius(); + double ret_srt_ang(); + double ret_end_ang(); + void display(); + + private: + double radius; + double start_angle; + double end_angle; }; class circle : public entity { - public: - circle( std::vector< dxfpair > info); - void display(); - double ret_radius(); - - private: - double radius; + public: + circle( std::vector< dxfpair > info); + void display(); + double ret_radius(); + + private: + double radius; }; class line : public entity { - public: - line( std::vector< dxfpair > info); - void display(); - double ret_xf(); - double ret_yf(); - double ret_zf(); - - private: - double xf; - double yf; - double zf; + public: + line( std::vector< dxfpair > info); + void display(); + double ret_xf(); + double ret_yf(); + double ret_zf(); + + private: + double xf; + double yf; + double zf; }; class ellipse : public entity { - public: - ellipse( std::vector< dxfpair > info); - void display(); - double ret_x_ma; - double ret_y_ma; - double ret_z_ma; - double ret_ratio; - double ret_start_p; - double ret_end_p; - - - private: - double x_major_axis; - double y_major_axis; - double z_major_axis; - double ratio; - double start_param; - double end_param; + public: + ellipse( std::vector< dxfpair > info); + void display(); + double ret_x_ma; + double ret_y_ma; + double ret_z_ma; + double ret_ratio; + double ret_start_p; + double ret_end_p; + + + private: + double x_major_axis; + double y_major_axis; + double z_major_axis; + double ratio; + double start_param; + double end_param; }; class text : public entity { - public: - text( std::vector< dxfpair > info); - void display(); - char * ret_text(char *string); - double ret_txt_ht(); - double ret_txt_rot(); - - private: - char dxf_text[10000]; - double text_height; // dxf 40 - double text_rotation; //dxf 50 + public: + text( std::vector< dxfpair > info); + void display(); + char * ret_text(char *string); + double ret_txt_ht(); + double ret_txt_rot(); + + private: + char dxf_text[10000]; + double text_height; // dxf 40 + double text_rotation; //dxf 50 }; class insert : public entity { - public: - insert( std::vector< dxfpair > info); - void display(); - char* name(char* string); - double ret_x_sf; - double ret_y_sf; - double ret_z_sf; - double ret_rotation; - - private: - char block_name[10000]; - double x_scale_factor; - double y_scale_factor; - double z_scale_factor; - double rotation; + public: + insert( std::vector< dxfpair > info); + void display(); + char* name(char* string); + double ret_x_sf; + double ret_y_sf; + double ret_z_sf; + double ret_rotation; + + private: + char block_name[10000]; + double x_scale_factor; + double y_scale_factor; + double z_scale_factor; + double rotation; }; @@ -204,51 +204,51 @@ class insert : public entity { class entities{ - // Well I said that I would only use STL containers internally, but I would have to use a dynamically linked list, and I haven't done for a long time soo STL is my crutch. - // I also think that there are others in my same boat that prefer stl containers because they are much easier to use - public: - entities(std::vector< std::vector< dxfpair > > sections); // Put the various entities into their respective vectors - void display_all(); - std::vector< polyline > ret_plines(); - std::vector< circle > ret_circles(); - std::vector< line > ret_lines(); - std::vector< text > ret_texts(); - std::vector< ellipse > ret_ellipses(); - std::vector< arc > ret_arcs(); - std::vector< lwpolyline > ret_lwplines(); - std::vector< insert > ret_inserts(); - // Overload the return function to depend on the layer - std::vector< polyline > ret_plines(char * layer); - std::vector< circle > ret_circles(char * layer); - std::vector< line > ret_lines(char * layer); - std::vector< text > ret_texts(char * layer); - std::vector< ellipse > ret_ellipses(char * layer); - std::vector< arc > ret_arcs(char * layer); - std::vector< lwpolyline > ret_lwplines(char * layer); - std::vector< insert > ret_inserts(char * layer); - - int plines_size(); - int circles_size(); - int lines_size(); - int texts_size(); - - - - private: - void add_polyline(polyline pline); - void add_circle(circle circ); - void add_line(line ln); - - std::vector< polyline > ents_polyline; - std::vector< arc > ents_arc; - std::vector< circle > ents_circle; - std::vector< line > ents_line; - std::vector< ellipse > ents_ellipse; - std::vector< text > ents_text; - std::vector< lwpolyline > ents_lwpolyline; - std::vector< insert > ents_insert; - - + // Well I said that I would only use STL containers internally, but I would have to use a dynamically linked list, and I haven't done for a long time soo STL is my crutch. + // I also think that there are others in my same boat that prefer stl containers because they are much easier to use + public: + entities(std::vector< std::vector< dxfpair > > sections); // Put the various entities into their respective vectors + void display_all(); + std::vector< polyline > ret_plines(); + std::vector< circle > ret_circles(); + std::vector< line > ret_lines(); + std::vector< text > ret_texts(); + std::vector< ellipse > ret_ellipses(); + std::vector< arc > ret_arcs(); + std::vector< lwpolyline > ret_lwplines(); + std::vector< insert > ret_inserts(); + // Overload the return function to depend on the layer + std::vector< polyline > ret_plines(char * layer); + std::vector< circle > ret_circles(char * layer); + std::vector< line > ret_lines(char * layer); + std::vector< text > ret_texts(char * layer); + std::vector< ellipse > ret_ellipses(char * layer); + std::vector< arc > ret_arcs(char * layer); + std::vector< lwpolyline > ret_lwplines(char * layer); + std::vector< insert > ret_inserts(char * layer); + + int plines_size(); + int circles_size(); + int lines_size(); + int texts_size(); + + + + private: + void add_polyline(polyline pline); + void add_circle(circle circ); + void add_line(line ln); + + std::vector< polyline > ents_polyline; + std::vector< arc > ents_arc; + std::vector< circle > ents_circle; + std::vector< line > ents_line; + std::vector< ellipse > ents_ellipse; + std::vector< text > ents_text; + std::vector< lwpolyline > ents_lwpolyline; + std::vector< insert > ents_insert; + + }; diff --git a/src/extension/internal/javafx-out.cpp b/src/extension/internal/javafx-out.cpp index 4a3e3907e..4cf6f3c4f 100644 --- a/src/extension/internal/javafx-out.cpp +++ b/src/extension/internal/javafx-out.cpp @@ -99,6 +99,19 @@ static double effective_opacity(const SPStyle *style) //# OUTPUT FORMATTING //######################################################################## +JavaFXOutput::JavaFXOutput(void) : + name(), + outbuf(), + foutbuf(), + nrNodes(0), + nrShapes(0), + idindex(0), + minx(0), + miny(0), + maxx(0), + maxy(0) +{ +} /** * We want to control floating output format. diff --git a/src/extension/internal/javafx-out.h b/src/extension/internal/javafx-out.h index 9c1c8778b..2e0f5a124 100644 --- a/src/extension/internal/javafx-out.h +++ b/src/extension/internal/javafx-out.h @@ -38,9 +38,9 @@ namespace Internal class JavaFXOutput : public Inkscape::Extension::Implementation::Implementation { - public: - + JavaFXOutput (void); + /** * Our internal String definition */ diff --git a/src/gradient-chemistry.cpp b/src/gradient-chemistry.cpp index c14a94290..b56352c19 100644 --- a/src/gradient-chemistry.cpp +++ b/src/gradient-chemistry.cpp @@ -125,7 +125,7 @@ static SPGradient *sp_gradient_get_private_normalized(SPDocument *document, SPGr Inkscape::GC::release(repr); // get corresponding object - SPGradient *gr = (SPGradient *) document->getObjectByRepr(repr); + SPGradient *gr = static_cast<SPGradient *>(document->getObjectByRepr(repr)); g_assert(gr != NULL); g_assert(SP_IS_GRADIENT(gr)); @@ -257,7 +257,7 @@ SPGradient *sp_gradient_fork_vector_if_necessary(SPGradient *gr) Inkscape::XML::Node *repr = gr->getRepr()->duplicate(xml_doc); doc->getDefs()->getRepr()->addChild(repr, NULL); - SPGradient *gr_new = (SPGradient *) doc->getObjectByRepr(repr); + SPGradient *gr_new = static_cast<SPGradient *>(doc->getObjectByRepr(repr)); gr_new = sp_gradient_ensure_vector_normalized (gr_new); Inkscape::GC::release(repr); return gr_new; @@ -518,8 +518,10 @@ SPStop *sp_get_stop_i(SPGradient *gradient, guint stop_i) // inkscape has created a handle for the start of gradient anyway, // so when it asks for stop N that corresponds to stop element N-1 if (stop->offset != 0) + { stop_i --; - + } + for (guint i = 0; i < stop_i; i++) { if (!stop) { return NULL; @@ -766,7 +768,7 @@ void sp_item_gradient_reverse_vector(SPItem *item, bool fill_or_stroke) Inkscape::XML::Node *copy = (Inkscape::XML::Node *) i->data; vector->appendChildRepr(copy); sp_repr_set_svg_double (copy, "offset", 1 - *iter); - iter --; + --iter; Inkscape::GC::release(copy); } diff --git a/src/line-snapper.cpp b/src/line-snapper.cpp index c8f10fb29..d0c4c4583 100644 --- a/src/line-snapper.cpp +++ b/src/line-snapper.cpp @@ -58,7 +58,7 @@ void Inkscape::LineSnapper::freeSnap(IntermSnapResults &isr, // For this we need to know where the origin is located of the line that is currently being rotated, std::vector<std::pair<Geom::Point, bool> > const origins_and_vectors = p.getOriginsAndVectors(); // Now we will iterate over all the origins and vectors and see which of these will get use a tangential or perpendicular snap - for (std::vector<std::pair<Geom::Point, bool> >::const_iterator it_origin_or_vector = origins_and_vectors.begin(); it_origin_or_vector != origins_and_vectors.end(); it_origin_or_vector++) { + for (std::vector<std::pair<Geom::Point, bool> >::const_iterator it_origin_or_vector = origins_and_vectors.begin(); it_origin_or_vector != origins_and_vectors.end(); ++it_origin_or_vector) { if ((*it_origin_or_vector).second) { // if "second" is true then "first" is a vector, otherwise it's a point // When snapping a line with a constant vector (constant direction) to a guide or grid line, // then either all points will be perpendicular/tangential or none at all. This is not very useful @@ -137,7 +137,7 @@ void Inkscape::LineSnapper::constrainedSnap(IntermSnapResults &isr, { inters = Geom::intersection(constraint_line, gridguide_line); } - catch (Geom::InfiniteSolutions e) + catch (Geom::InfiniteSolutions &e) { // We're probably dealing with parallel lines, so snapping doesn't make any sense here continue; // jump to the next iterator in the for-loop diff --git a/src/pencil-context.cpp b/src/pencil-context.cpp index 5bc369099..e6bd8f297 100644 --- a/src/pencil-context.cpp +++ b/src/pencil-context.cpp @@ -847,8 +847,8 @@ sketch_interpolate(SPPencilContext *pc) } Geom::Piecewise<Geom::D2<Geom::SBasis> > fit_pwd2 = fit.toPwSb(); - double t =0.; if ( pc->sketch_n > 0 ) { + double t =0.; if (average_all_sketches) { // Average = (sum of all) / n // = (sum of all + new one) / n+1 diff --git a/src/snap-candidate.h b/src/snap-candidate.h index 1c84cdbae..db0c3fd67 100644 --- a/src/snap-candidate.h +++ b/src/snap-candidate.h @@ -30,14 +30,16 @@ public: _source_type(source), _target_type(target), _source_num(source_num), - _target_bbox(bbox) + _target_bbox(bbox), + _dist() { }; SnapCandidatePoint(Geom::Point const &point, Inkscape::SnapSourceType const source, Inkscape::SnapTargetType const target) : _point(point), _source_type(source), - _target_type(target) + _target_type(target), + _dist() { _source_num = -1; _target_bbox = Geom::OptRect(); @@ -47,7 +49,8 @@ public: : _point(point), _source_type(source), _target_type(Inkscape::SNAPTARGET_UNDEFINED), - _source_num(-1) + _source_num(-1), + _dist() { _target_bbox = Geom::OptRect(); } diff --git a/src/snapped-line.cpp b/src/snapped-line.cpp index 6c0c411d8..fa333d6f1 100644 --- a/src/snapped-line.cpp +++ b/src/snapped-line.cpp @@ -56,7 +56,7 @@ Inkscape::SnappedPoint Inkscape::SnappedLineSegment::intersect(SnappedLineSegmen { inters = Geom::intersection(getLineSegment(), line.getLineSegment()); } - catch (Geom::InfiniteSolutions e) + catch (Geom::InfiniteSolutions &e) { // We're probably dealing with parallel lines, so they don't really cross inters = Geom::OptCrossing(); @@ -138,7 +138,7 @@ Inkscape::SnappedPoint Inkscape::SnappedLine::intersect(SnappedLine const &line) { inters = Geom::intersection(getLine(), line.getLine()); } - catch (Geom::InfiniteSolutions e) + catch (Geom::InfiniteSolutions &e) { // We're probably dealing with parallel lines, so they don't really cross inters = Geom::OptCrossing(); diff --git a/src/sp-gradient.cpp b/src/sp-gradient.cpp index 0acdac76e..0934c0705 100644 --- a/src/sp-gradient.cpp +++ b/src/sp-gradient.cpp @@ -1035,7 +1035,7 @@ void SPGradient::rebuildVector() SPStop *stop = SP_STOP(child); SPGradientStop gstop; - if (vector.stops.size() > 0) { + if (!vector.stops.empty()) { // "Each gradient offset value is required to be equal to or greater than the // previous gradient stop's offset value. If a given gradient stop's offset // value is not equal to or greater than all previous offset values, then the @@ -1059,7 +1059,7 @@ void SPGradient::rebuildVector() } // Normalize per section 13.2.4 of SVG 1.1. - if (vector.stops.size() == 0) { + if (vector.stops.empty()) { /* "If no stops are defined, then painting shall occur as if 'none' were specified as the * paint style." */ diff --git a/src/svg-view-widget.cpp b/src/svg-view-widget.cpp index b71ef3f42..0e962a711 100644 --- a/src/svg-view-widget.cpp +++ b/src/svg-view-widget.cpp @@ -63,7 +63,7 @@ static void sp_svg_view_widget_class_init(SPSVGSPViewWidgetClass *klass) GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass); SPViewWidgetClass *vw_class = SP_VIEW_WIDGET_CLASS (klass); - widget_parent_class = (SPViewWidgetClass *)g_type_class_peek_parent (klass); + widget_parent_class = static_cast<SPViewWidgetClass *>(g_type_class_peek_parent (klass)); object_class->destroy = sp_svg_view_widget_destroy; diff --git a/src/svg/svg-path.cpp b/src/svg/svg-path.cpp index 3f3b944ff..135f9ff75 100644 --- a/src/svg/svg-path.cpp +++ b/src/svg/svg-path.cpp @@ -64,7 +64,7 @@ Geom::PathVector sp_svg_read_pathv(char const * str) try { Geom::parse_svg_path(str, generator); } - catch (Geom::SVGPathParseError e) { + catch (Geom::SVGPathParseError &e) { generator.finish(); // This warning is extremely annoying when testing //g_warning("Malformed SVG path, truncated path up to where error was found.\n Input path=\"%s\"\n Parsed path=\"%s\"", str, sp_svg_write_path(pathv)); diff --git a/src/trace/potrace/decompose.cpp b/src/trace/potrace/decompose.cpp index 708c17106..6c27a7ebf 100644 --- a/src/trace/potrace/decompose.cpp +++ b/src/trace/potrace/decompose.cpp @@ -21,12 +21,9 @@ /* set the excess padding to 0 */ static void bm_clearexcess(potrace_bitmap_t *bm) { - potrace_word mask; - int y; - if (bm->w % BM_WORDBITS != 0) { - mask = BM_ALLBITS << (BM_WORDBITS - (bm->w % BM_WORDBITS)); - for (y=0; y<bm->h; y++) { + potrace_word mask = BM_ALLBITS << (BM_WORDBITS - (bm->w % BM_WORDBITS)); + for (int y=0; y<bm->h; y++) { *bm_index(bm, bm->w, y) &= mask; } } diff --git a/src/trace/potrace/greymap.cpp b/src/trace/potrace/greymap.cpp index 2495575e8..e116021c1 100644 --- a/src/trace/potrace/greymap.cpp +++ b/src/trace/potrace/greymap.cpp @@ -61,12 +61,10 @@ greymap_t *gm_dup(greymap_t *gm) { /* clear the given greymap to color b. */ void gm_clear(greymap_t *gm, int b) { - int i; - if (b==0) { memset(gm->map, 0, gm->w*gm->h*sizeof(signed short int)); } else { - for (i=0; i<gm->w*gm->h; i++) { + for (int i=0; i<gm->w*gm->h; i++) { gm->map[i] = b; } } diff --git a/src/trace/potrace/progress.h b/src/trace/potrace/progress.h index 93a1fa3f0..3e1dfb34e 100644 --- a/src/trace/potrace/progress.h +++ b/src/trace/potrace/progress.h @@ -26,10 +26,8 @@ typedef struct progress_s progress_t; given in the 0.0-1.0 range, which will be scaled and translated to the progress object's range. */ static inline void progress_update(double d, progress_t *prog) { - double d_scaled; - if (prog != NULL && prog->callback != NULL) { - d_scaled = prog->min * (1-d) + prog->max * d; + double d_scaled = prog->min * (1-d) + prog->max * d; if (d == 1.0 || d_scaled >= prog->d_prev + prog->epsilon) { prog->callback(prog->min * (1-d) + prog->max * d, prog->data); prog->d_prev = d_scaled; diff --git a/src/ui/dialog/icon-preview.cpp b/src/ui/dialog/icon-preview.cpp index d102e5779..19cdea9bc 100644 --- a/src/ui/dialog/icon-preview.cpp +++ b/src/ui/dialog/icon-preview.cpp @@ -199,12 +199,12 @@ IconPreviewPanel::IconPreviewPanel() : Gtk::Alignment *align = Gtk::manage(new Gtk::Alignment(0.5, 0.5, 0, 0)); align->add(*buttons[i]); - int pad = 12; if ( !pack || ( (avail == 0) && (previous == 0) ) ) { verts->pack_end(*align, Gtk::PACK_SHRINK); previous = sizes[i]; avail = sizes[i]; } else { + int pad = 12; if ((avail < pad) || ((sizes[i] > avail) && (sizes[i] < previous))) { horiz = 0; } diff --git a/src/ui/dialog/object-attributes.cpp b/src/ui/dialog/object-attributes.cpp index a1c747ce8..74deffb06 100644 --- a/src/ui/dialog/object-attributes.cpp +++ b/src/ui/dialog/object-attributes.cpp @@ -79,8 +79,8 @@ ObjectAttributes::ObjectAttributes (void) : subselChangedConn(), selectModifiedConn() { - attrTable.show(); - widget_setup(); + attrTable.show(); + widget_setup(); desktopChangeConn = deskTrack.connectDesktopChanged( sigc::mem_fun(*this, &ObjectAttributes::setTargetDesktop) ); deskTrack.connect(GTK_WIDGET(gobj())); @@ -143,11 +143,11 @@ void ObjectAttributes::widget_setup (void) return; } - int len = 0; std::vector<Glib::ustring> labels; std::vector<Glib::ustring> attrs; if (CurrentItem != item) { + int len = 0; while (desc[len].label) { labels.push_back(desc[len].label); diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 56d209886..2127ef402 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -175,9 +175,9 @@ void GlyphComboBox::update(SPFont* spfont){ for(SPObject* node = spfont->children; node; node=node->next){ if (SP_IS_GLYPH(node)){ #if WITH_GTKMM_2_24 - this->append(((SPGlyph*)node)->unicode); + this->append((static_cast<SPGlyph*>(node))->unicode); #else - this->append_text(((SPGlyph*)node)->unicode); + this->append_text((static_cast<SPGlyph*>(node))->unicode); #endif } } @@ -423,9 +423,9 @@ SvgFontsDialog::populate_glyphs_box() for(SPObject* node = spfont->children; node; node=node->next){ if (SP_IS_GLYPH(node)){ Gtk::TreeModel::Row row = *(_GlyphsListStore->append()); - row[_GlyphsListColumns.glyph_node] = (SPGlyph*) node; - row[_GlyphsListColumns.glyph_name] = ((SPGlyph*) node)->glyph_name; - row[_GlyphsListColumns.unicode] = ((SPGlyph*) node)->unicode; + row[_GlyphsListColumns.glyph_node] = static_cast<SPGlyph*>(node); + row[_GlyphsListColumns.glyph_name] = (static_cast<SPGlyph*>(node))->glyph_name; + row[_GlyphsListColumns.unicode] = (static_cast<SPGlyph*>(node))->unicode; } } } @@ -441,10 +441,10 @@ SvgFontsDialog::populate_kerning_pairs_box() for(SPObject* node = spfont->children; node; node=node->next){ if (SP_IS_HKERN(node)){ Gtk::TreeModel::Row row = *(_KerningPairsListStore->append()); - row[_KerningPairsListColumns.first_glyph] = ((SPGlyphKerning*) node)->u1->attribute_string().c_str(); - row[_KerningPairsListColumns.second_glyph] = ((SPGlyphKerning*) node)->u2->attribute_string().c_str(); - row[_KerningPairsListColumns.kerning_value] = ((SPGlyphKerning*) node)->k; - row[_KerningPairsListColumns.spnode] = (SPGlyphKerning*) node; + row[_KerningPairsListColumns.first_glyph] = (static_cast<SPGlyphKerning*>(node))->u1->attribute_string().c_str(); + row[_KerningPairsListColumns.second_glyph] = (static_cast<SPGlyphKerning*>(node))->u2->attribute_string().c_str(); + row[_KerningPairsListColumns.kerning_value] = (static_cast<SPGlyphKerning*>(node))->k; + row[_KerningPairsListColumns.spnode] = static_cast<SPGlyphKerning*>(node); } } } @@ -743,9 +743,9 @@ void SvgFontsDialog::add_kerning_pair(){ for(SPObject* node = this->get_selected_spfont()->children; node; node=node->next){ //TODO: It is not really correct to get only the first byte of each string. //TODO: We should also support vertical kerning - if (SP_IS_HKERN(node) && ((SPGlyphKerning*)node)->u1->contains((gchar) first_glyph.get_active_text().c_str()[0]) - && ((SPGlyphKerning*)node)->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){ - this->kerning_pair = (SPGlyphKerning*)node; + if (SP_IS_HKERN(node) && (static_cast<SPGlyphKerning*>(node))->u1->contains((gchar) first_glyph.get_active_text().c_str()[0]) + && (static_cast<SPGlyphKerning*>(node))->u2->contains((gchar) second_glyph.get_active_text().c_str()[0]) ){ + this->kerning_pair = static_cast<SPGlyphKerning*>(node); continue; } } diff --git a/src/ui/widget/selected-style.cpp b/src/ui/widget/selected-style.cpp index 9ae853aaf..ab7b99237 100644 --- a/src/ui/widget/selected-style.cpp +++ b/src/ui/widget/selected-style.cpp @@ -1439,7 +1439,7 @@ Dialog::FillAndStroke *get_fill_and_stroke_panel(SPDesktop *desktop) Dialog::FillAndStroke &fill_and_stroke = dynamic_cast<Dialog::FillAndStroke &>(panel_dialog->getPanel()); return &fill_and_stroke; - } catch (std::exception e) { } + } catch (std::exception &e) { } } return 0; diff --git a/src/widgets/gradient-selector.cpp b/src/widgets/gradient-selector.cpp index 0d473bae2..e67d93388 100644 --- a/src/widgets/gradient-selector.cpp +++ b/src/widgets/gradient-selector.cpp @@ -360,7 +360,7 @@ sp_gradient_selector_add_vector_clicked (GtkWidget */*w*/, SPGradientSelector *s doc->getDefs()->getRepr()->addChild(repr, NULL); - gr = (SPGradient *) doc->getObjectByRepr(repr); + gr = static_cast<SPGradient *>(doc->getObjectByRepr(repr)); sp_gradient_vector_selector_set_gradient( SP_GRADIENT_VECTOR_SELECTOR (sel->vectors), doc, gr); |
