BOOL CDRFilter::AddAttributesToArrowheadPath(NodePath *P, DocColour *Col, INT32 LineWidth, LineCapType Cap, JointType Join) { if(P->InkPath.IsFilled) { // it's a filled path, so it need to be filled with the colour and have no line // colour SetPathFilled(TRUE); if(!SetLineColour(DocColour(COLOUR_TRANS)) || !SetFillColour(*Col)) return FALSE; } else { // it's not a filled colour, so don't fill it and stroke it with the line width and colour if(!SetLineColour(*Col) || !SetLineWidth(LineWidth) || !SetLineCap(Cap) || !SetJoinType(Join)) return FALSE; } // apply the attributes to the object // If not filled, then set the ignore bit on the fill attribute. // if (P->InkPath.IsFilled == FALSE) // CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = TRUE; // else CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE; // Add attributes to the path, if they are different from the default... BOOL Result = AttributeManager::ApplyBasedOnDefaults(P, CurrentAttrs); // DeleteCurrentAttrs(); // SetUpCurrentAttrs(); // Enable the fill attribute again CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE; return Result; }
XFSpectrumDataSerie& XFSpectrumDataSerie::operator=(XFSpectrumDataSerie& Right) { if(this == &Right) return *this; m_pTCpxSpectrum = Right.m_pTCpxSpectrum; m_unSpectrumLength = Right.m_unSpectrumLength; m_nHandlerType = Right.m_nHandlerType; m_dbRate = Right.m_dbRate; m_pfcpxGll = Right.m_pfcpxGll; m_pfcpxGrr = Right.m_pfcpxGrr; m_pfcpxGlr = Right.m_pfcpxGlr; m_pfcpxC = Right.m_pfcpxC; SetLineColour(Right.GetLineColour()); SetFillColour(Right.GetFillColour()); Show(Right.IsShown()); return *this; }
BOOL CDRFilter::SetLineAttr(cdrfOffsetHeader *Object) { if(Version == CDRVERSION_3) { return SetLineAttr3(Object); } // find the reference... DWORD *pReference = (DWORD *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_LINE); // if the pointer to the reference is zero, then the reference is probably // within some random style definition if(pReference == 0) { // OK, try and find a style number within the style reference WORD *pStyleReference = (WORD *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_STYLE); if(pStyleReference != 0) { // OK, see if we can find a the style... cdrfStyle *pStyle; INT32 StyleSize; if((pStyle = (cdrfStyle *)Styles.Find(*pStyleReference, &StyleSize)) != 0) { // OK, got a style... now find a fill reference within it pReference = (DWORD *)FindDataInObject(&pStyle->Header, cdrfSTYLEOFFSETTYPE_OUTLINE); } } } cdrfOutline *Out; INT32 OutSize; if(pReference == 0 || (Out = (cdrfOutline *)Outlines.Find(*pReference, &OutSize)) == 0 || OutSize < sizeof(cdrfOutline)) { // if no outline data, or outline definitions couldn't be found, or outline // definition is too small, set up the default line attributes if(!SetLineWidth(cdrfOUTLINE_DEFAULT_WIDTH)) return FALSE; PColourCMYK cmyk; cmyk.Cyan = cmyk.Magenta = cmyk.Yellow = 0; cmyk.Key = 255; DocColour Col; Col.SetCMYKValue(&cmyk); if(!SetLineColour(Col)) return FALSE; return TRUE; } // check that this thingy should have an outline if((CDRDATA_WORD(Out->Flags) & cdrfOUTLINEFLAGS_NOOUTLINE) != 0) { if (!SetLineColour(DocColour(COLOUR_TRANS))) return FALSE; return TRUE; } // convert the line colour DocColour Col; ConvertColour(&Out->Colour, &Col); // find the line width INT32 LineWidth = CDRDATA_WORD(Out->LineThickness) * CDRCOORDS_TO_MILLIPOINTS; if(LineWidth > MAX_LINE_WIDTH) LineWidth = MAX_LINE_WIDTH; // find the join type JointType JType; switch(CDRDATA_WORD(Out->JoinStyle)) { case cdrfJOINSTYLE_SQUARE: JType = MitreJoin; break; case cdrfJOINSTYLE_ROUNDED: JType = RoundJoin; break; default: case cdrfJOINSTYLE_BEVEL: JType = BevelledJoin; break; } // set the cap style LineCapType CType; switch(CDRDATA_WORD(Out->EndStyle)) { case cdrfENDSTYLE_BUTT: CType = LineCapButt; break; case cdrfENDSTYLE_ROUNDED: CType = LineCapRound; break; default: case cdrfENDSTYLE_SQUARE: CType = LineCapSquare; break; } // set the dash pattern DashRec Dash; DashElement DashArray[cdrfMAX_DASH_ELEMENTS]; if(CDRDATA_WORD(Out->NDashSegments) > 0 && (CDRDATA_WORD(Out->Flags) & cdrfOUTLINEFLAGS_NODASH) == 0) { // set a dash pattern INT32 NSeg = CDRDATA_WORD(Out->NDashSegments); if(NSeg > cdrfMAX_DASH_ELEMENTS) NSeg = cdrfMAX_DASH_ELEMENTS; INT32 l; for(l = 0; l < NSeg; l++) { DashArray[l] = CDRDATA_WORD(Out->DashSegments[l]) * LineWidth; } Dash.Elements = NSeg; Dash.DashStart = 0; Dash.ElementData = DashArray; Dash.LineWidth = LineWidth; Dash.ScaleWithLineWidth = TRUE; Dash.DashID = -1; } else { // no dash pattern Dash = SD_SOLID; } // set the attributes if(!SetLineWidth(LineWidth) || !SetLineColour(Col) || !SetJoinType(JType) || !SetLineCap(CType) || !SetDashPattern(Dash)) return FALSE; // check for arrowheads if(CDRDATA_DWORD(Out->StartArrowReference) != 0 || CDRDATA_DWORD(Out->EndArrowReference) != 0) { // apply the attributes to the object // If not filled, then set the ignore bit on the fill attribute. if (ObjFilled == FALSE) CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = TRUE; // Add attributes to the path, if they are different from the default... AttributeManager::ApplyBasedOnDefaults(pMadeNode, CurrentAttrs); // DeleteCurrentAttrs(); // SetUpCurrentAttrs(); // Enable the fill attribute again CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE; // ensure that the attributes won't be applied again AttrsAlreadyApplied = TRUE; // apply arrow heads to the path AddArrowheadsToPath(CDRDATA_DWORD(Out->StartArrowReference), CDRDATA_DWORD(Out->EndArrowReference), &Col, LineWidth, CType, JType); } return TRUE; }
BOOL CDRFilter::SetLineAttr3(cdrfOffsetHeader *Object) { cdrfOutlineV3 *Out = (cdrfOutlineV3 *)FindDataInObject(Object, cdrfOBJOFFSETTYPE_LINE); if(Out == 0) { // if no outline data, or outline definitions couldn't be found, or outline // definition is too small, set up the default line attributes if(!SetLineWidth(cdrfOUTLINE_DEFAULT_WIDTH)) return FALSE; PColourCMYK cmyk; cmyk.Cyan = cmyk.Magenta = cmyk.Yellow = 0; cmyk.Key = 255; DocColour Col; Col.SetCMYKValue(&cmyk); if(!SetLineColour(Col)) return FALSE; return TRUE; } // check that this thingy should have an outline if((Out->Flags & cdrfOUTLINEFLAGSV3_STROKED) == 0) { if (!SetLineColour(DocColour(COLOUR_TRANS))) return FALSE; return TRUE; } // convert the line colour DocColour Col; ConvertColour((cdrfColour *)&Out->Colour, &Col); // find the line width INT32 LineWidth = CDRDATA_WORD(Out->LineThickness) * CDRCOORDS_TO_MILLIPOINTS; if(LineWidth > MAX_LINE_WIDTH) LineWidth = MAX_LINE_WIDTH; // find the join type JointType JType; switch(CDRDATA_WORD(Out->JoinStyle)) { case cdrfJOINSTYLE_SQUARE: JType = MitreJoin; break; case cdrfJOINSTYLE_ROUNDED: JType = RoundJoin; break; default: case cdrfJOINSTYLE_BEVEL: JType = BevelledJoin; break; } // set the cap style LineCapType CType; switch(Out->EndStyle) // byte { case cdrfENDSTYLE_BUTT: CType = LineCapButt; break; case cdrfENDSTYLE_ROUNDED: CType = LineCapRound; break; default: case cdrfENDSTYLE_SQUARE: CType = LineCapSquare; break; } // set the dash pattern /* DashRec Dash; DashElement DashArray[cdrfMAX_DASH_ELEMENTS]; if((ObjectFlagsV3 & cdrfOBJFLAGSV3_NODASH) == 0 && Out->NDashSegments > 0) // byte { // set a dash pattern INT32 NSeg = CDRDATA_WORD(Out->NDashSegments); if(NSeg > cdrfMAX_DASH_ELEMENTS) NSeg = cdrfMAX_DASH_ELEMENTS; INT32 l; for(l = 0; l < NSeg; l++) { DashArray[l] = Out->DashSegments[l] * LineWidth; // byte } Dash.Elements = NSeg; Dash.DashStart = 0; Dash.ElementData = DashArray; Dash.LineWidth = LineWidth; Dash.ScaleWithLineWidth = TRUE; Dash.DashID = -1; } else { // no dash pattern Dash = SD_SOLID; } */ // set the attributes if(!SetLineWidth(LineWidth) || !SetLineColour(Col) || !SetJoinType(JType) || !SetLineCap(CType)/* || !SetDashPattern(Dash)*/) return FALSE; // check for arrowheads if(CDRDATA_DWORD(Out->StartArrowReference) != 0 || CDRDATA_DWORD(Out->EndArrowReference) != 0) { // apply the attributes to the object // If not filled, then set the ignore bit on the fill attribute. if (ObjFilled == FALSE) CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = TRUE; // Add attributes to the path, if they are different from the default... AttributeManager::ApplyBasedOnDefaults(pMadeNode, CurrentAttrs); // Enable the fill attribute again CurrentAttrs[ATTR_FILLGEOMETRY].Ignore = FALSE; // ensure that the attributes won't be applied again AttrsAlreadyApplied = TRUE; // apply arrow heads to the path AddArrowheadsToPath(CDRDATA_DWORD(Out->StartArrowReference), CDRDATA_DWORD(Out->EndArrowReference), &Col, LineWidth, CType, JType); } return TRUE; }
BOOL FreeHandEPSFilter::ProcessToken() { // Decode the command, and execute it... switch (Token) { // state saving case EPSC_vms: if(!Import_gsave()) return FALSE; break; case EPSC_vmr: if(!Import_grestore()) return FALSE; break; case EPSC_vmrs: if(!Import_grestore()) return FALSE; if(!Import_gsave()) return FALSE; break; // tokens to ignore case EPSC_FREEHAND_IGNOREDTOKEN: break; // tokens which should be ignored and one entry discarded case EPSC_load: // the load part of a fill - discard the /clipper before it case EPSC_fhsetspreadallow: if(!Stack.Discard(1)) goto EPSError; break; case EPSC_concat: if(!Stack.DiscardArray()) goto EPSError; break; // complex paths... case EPSC_eomode: { INT32 ComplexStart; if(!Stack.Pop(&ComplexStart)) goto EPSError; // is this a start of a complex path? if(ComplexStart != TRUE) { ComplexPathMode = FALSE; } else { HadFirstOfComplexPath = FALSE; ComplexPathMode = TRUE; } } break; case EPSC_true: Stack.Push((INT32)TRUE); break; case EPSC_false: Stack.Push((INT32)FALSE); break; case EPSC_u: HadFirstOfComplexPath = FALSE; return EPSFilter::ProcessToken(); break; // colours case EPSC_Ka: case EPSC_ka: { DocColour Colour; if(PopColour(&Colour)) { // Remember this colour for future objects if (Token == EPSC_ka) { if (!SetFillColour(Colour)) goto NoMemory; } else { if (!SetLineColour(Colour)) goto NoMemory; } } else // Invalid colour operands goto EPSError; } break; case EPSC_Xa: case EPSC_xa: { DocColour Colour; if(PopNamedColour(&Colour)) { // Remember this colour for future objects if (Token == EPSC_xa) { if (!SetFillColour(Colour)) goto NoMemory; } else { if (!SetLineColour(Colour)) goto NoMemory; } } else // Invalid colour operands goto EPSError; } break; case EPSC_H: if(ComplexPathMode) { // in complex path mode - make this a filled one, not a discarded one Token = EPSC_S; } return EPSFilter::ProcessToken(); break; case EPSC_h: if(ComplexPathMode) { // in complex path mode - modify and process Token = EPSC_s; return EPSFilter::ProcessToken(); break; } // the hidden path closing operator - a grad fill thingy will follow shortly maybe... // this will prevent it being processed now, although it may get processed later on. HadhToken = TRUE; break; // for clipping masks, do some funky stuff case EPSC_q: // if there's a pending grad fill... if(DoingGradFill) { if(pPath != 0) { // right then, make a copy of the path... NodePath *pPathClone; if(!pPath->NodeCopy((Node **)&pPathClone)) { goto NoMemory; } // copy the flags EPSFlagsDefn EPSFlagsClone = EPSFlags; // send a token to finish and fill the path... Token = (pInkPath->IsFilled)?EPSC_f:EPSC_s; if(!EPSFilter::ProcessToken()) return FALSE; // restore the old fill if(!RestoreCurrentFill()) goto NoMemory; // restore the copy of the path pPath = pPathClone; pInkPath = &pPath->InkPath; // restore the flags EPSFlags = EPSFlagsClone; // definately want to send an h HadhToken = TRUE; } // done the grad fill DoingGradFill = FALSE; // restore the old token Token = EPSC_q; } // clipping started - have we got an h token to send? if(HadhToken) FHEF_SENDh // process this return EPSFilter::ProcessToken(); break; // for now, if there's no path, don't return a W case EPSC_W: if(pPath == 0) { // OK, now we want to get the last path we created, make a copy of it and then install it as the current one if(pLastPathSeen == 0) goto EPSError; // make a copy of it NodePath *pClone; if(!pLastPathSeen->NodeCopy((Node **)&pClone)) goto NoMemory; // delete it's attributes pClone->DeleteChildren(pClone->FindFirstChild()); // make it the current path pPath = pClone; pInkPath = &pPath->InkPath; ThePathType = PATH_NORMAL; EPSFlags.NoAttributes = TRUE; } if(pPath != 0) return EPSFilter::ProcessToken(); break; // we may need to modify path closing things if we're doing a grad fill case EPSC_s: case EPSC_S: if(Token == EPSC_S) { // if we've had an h token but no grad fill, send the h now if(HadhToken) FHEF_SENDh // if we've got a grad fill, modify the token we got if(DoingGradFill) Token = EPSC_b; } // process the possily modified token normally HadhToken = FALSE; return EPSFilter::ProcessToken(); break; // modify path closing for grad fills. case EPSC_n: if(DoingGradFill) { Token = EPSC_f; // we want to fill the thing HadhToken = FALSE; return EPSFilter::ProcessToken(); break; } HadhToken = FALSE; // ignore h's as this is another end path thingy... if(pPath != 0) return EPSFilter::ProcessToken(); break; // unset the had h token for other path closing things case EPSC_N: case EPSC_F: case EPSC_f: case EPSC_B: case EPSC_b: HadhToken = FALSE; return EPSFilter::ProcessToken(); break; // interested in path element things to switch off grad fills case EPSC_m: if(InText) { // if we're doing some text, discard the moveto command if(!Stack.Discard(2)) goto EPSError; break; } case EPSC_l: case EPSC_L: case EPSC_c: case EPSC_C: case EPSC_v: case EPSC_V: case EPSC_y: case EPSC_Y: // maybe we need an h token to be sent if(HadhToken) FHEF_SENDh // stop grad fill if(DoingGradFill) { // turn the grad fill state off DoingGradFill = FALSE; // restore the old fill type RestoreCurrentFill(); } return EPSFilter::ProcessToken(); break; case EPSC_recfill: { // get the colours DocColour StartColour, EndColour; if(!PopColour(&EndColour) || !PopColour(&StartColour)) goto EPSError; // discard the fill type thingy - we can only do colours if(!DiscardFillSubType()) goto EPSError; // OK, now a few coords DocCoord Centre; double Angle; DocRect BBox; if(!Stack.PopCoordPair(&BBox.hi) || !Stack.PopCoordPair(&BBox.lo) || !Stack.Pop(&Angle) || !Stack.PopCoordPair(&Centre)) goto EPSError; // munge the angle a little and get it into radians Angle += 225; Angle = (Angle * (2 * PI)) / 360; // see if we can get a more accurate BBox if(pPath != 0) { BBox = pPath->GetBoundingRect(); Centre.x = BBox.lo.x + (BBox.Width() / 2); Centre.y = BBox.lo.y + (BBox.Height() / 2); } // OK, we've got all the stuff we need to do some niceness on it BBox.Translate(0 - Centre.x, 0 - Centre.y); DocCoord StartPoint, EndPoint; StartPoint.x = Centre.x + (INT32)(((double)BBox.lo.x * cos(Angle)) - ((double)BBox.lo.y * sin(Angle))); StartPoint.y = Centre.y + (INT32)(((double)BBox.lo.x * sin(Angle)) + ((double)BBox.lo.y * cos(Angle))); EndPoint.x = Centre.x + (INT32)(((double)BBox.hi.x * cos(Angle)) - ((double)BBox.hi.y * sin(Angle))); EndPoint.y = Centre.y + (INT32)(((double)BBox.hi.x * sin(Angle)) + ((double)BBox.hi.y * cos(Angle))); // store current fill attribute SaveCurrentFill(); // set the fill if(!SetLinearFill(StartColour, EndColour, StartPoint, EndPoint)) goto NoMemory; // say we're doing a grad fill DoingGradFill = TRUE; HadhToken = FALSE; // absorb this } break; case EPSC_radfill: { // get the colours DocColour StartColour, EndColour; if(!PopColour(&StartColour) || !PopColour(&EndColour)) goto EPSError; // get the radius and centre coordinate DocCoord Centre; INT32 Radius; if(!Stack.PopCoord(&Radius) || !Stack.PopCoordPair(&Centre)) goto EPSError; // store current fill attribute SaveCurrentFill(); // set the fill DocCoord EndPoint(Centre.x + Radius, Centre.y); if(!SetRadialFill(StartColour, EndColour, Centre, EndPoint)) goto NoMemory; // say we're doing a grad fill DoingGradFill = TRUE; HadhToken = FALSE; } break; case EPSC_BeginSetup: // there's probably a colour list or something in that there setup thingy - search for the spots token { BOOL Found = FALSE; while(Found == FALSE) { if(!EPSFile->GetToken()) return FALSE; if(EPSFile->GetTokenType() == TOKEN_NORMAL) { if(camStrcmp(TokenBuf, _T("spots")) == 0) { // check to see if the array is about to start if(!EPSFile->GetToken()) return FALSE; if(TokenBuf[0] == '[') { TRACEUSER( "Ben", _T("Found spots\n")); Found = TRUE; } } } if(camStrncmp(TokenBuf, _T("%%EndSetup"), 10) == 0) { TRACEUSER( "Ben", _T("Met end of setup without finding spots\n")); break; } if(EPSFile->eof()) goto EPSError; } if(Found == TRUE) { InColours = TRUE; } } break; case EPSC_def: if(InColours) { // finished the colours... TRACEUSER( "Ben", _T("Finished spot colours\n")); // scan for the end of the setup section BOOL Found = FALSE; while(Found == FALSE) { if(!EPSFile->GetToken()) return FALSE; if(EPSFile->GetTokenType() == TOKEN_COMMENT) { if(camStrncmp(TokenBuf, _T("%%EndSetup"), 10) == 0) { TRACEUSER( "Ben", _T("Found end of setup\n")); Found = TRUE; } } if(EPSFile->eof()) goto EPSError; } // get the ] off the stack EPSCommand Ignored; Stack.PopCmd(&Ignored); // empty it... Stack.DeleteAll (); InColours = FALSE; } else { // probably a font type thingy - empty the stack including commands Stack.DeleteAll (); } break; case EPSC_newcmykcustomcolor: // OK, here's a named colour... add it to those known { // discard some random thingy if(!Stack.Discard()) goto EPSError; // get the name String_64 ColourName; if(!Stack.Pop(&ColourName)) goto EPSError; // get the components double C, M, Y, K; if(!Stack.Pop(&K) || !Stack.Pop(&Y) || !Stack.Pop(&M) || !Stack.Pop(&C)) goto EPSError; // make the new colour ColourCMYK Colour; Colour.Cyan = C; Colour.Magenta = M; Colour.Yellow = Y; Colour.Key = K; // add it if(!pNewColours->AddColour(&ColourName, &Colour)) goto NoMemory; // add it to the list of colours // this is a bit of a bodge, but never mind. Shouldn't be that bad. IndexedColour *TheNewColour = pNewColours->GetColour(ColourName); if(TheNewColour == 0) goto NoMemory; // add it to the list of colours // enough space? if((ColourArrayEntries + 1) >= ColourArraySize) { TRACEUSER( "Ben", _T("Extening colour array\n")); IndexedColour **NewPtr = (IndexedColour **)CCRealloc(ColourArray, (ColourArraySize + FHEF_COLOURARRAY_CHUNK) * sizeof(IndexedColour *)); if(NewPtr == 0) goto NoMemory; ColourArray = NewPtr; ColourArraySize += FHEF_COLOURARRAY_CHUNK; } // add ColourArray[ColourArrayEntries] = TheNewColour; ColourArrayEntries++; } break; // ignore text stuff case EPSC_makesetfont: if(!Stack.DiscardArray()) goto EPSError; if(!Stack.Discard(1)) goto EPSError; InText = TRUE; break; case EPSC_ts: if(!Stack.Discard(6)) goto EPSError; break; case EPSC_stob: case EPSC_sts: Stack.DeleteAll (); InText = FALSE; break; default: // Token not understood - pass on to base class return EPSFilter::ProcessToken(); } // No errors encountered while parsing this token and its operands. return TRUE; // Error handlers: EPSError: HandleEPSError(); return FALSE; NoMemory: HandleNoMemory(); return FALSE; }